/[rdesktop]/sourceforge.net/trunk/rdesktop/xwin.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/xwin.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 474 by matthewc, Tue Sep 30 09:11:08 2003 UTC revision 501 by stargo, Fri Oct 17 08:23:47 2003 UTC
# Line 34  extern BOOL g_hide_decorations; Line 34  extern BOOL g_hide_decorations;
34  extern char g_title[];  extern char g_title[];
35  extern int g_server_bpp;  extern int g_server_bpp;
36  extern int g_win_button_size;  extern int g_win_button_size;
 BOOL g_enable_compose = False;  
 BOOL g_focused;  
 BOOL g_mouse_in_wnd;  
37    
38  Display *g_display;  Display *g_display;
39  Time g_last_gesturetime;  Time g_last_gesturetime;
40  static int g_x_socket;  static int g_x_socket;
41  static Screen *g_screen;  static Screen *g_screen;
42  Window g_wnd;  Window g_wnd;
43    BOOL g_enable_compose = False;
44  static GC g_gc;  static GC g_gc;
45  static Visual *g_visual;  static Visual *g_visual;
46  static int g_depth;  static int g_depth;
# Line 52  static XIC g_IC; Line 50  static XIC g_IC;
50  static XModifierKeymap *g_mod_map;  static XModifierKeymap *g_mod_map;
51  static Cursor g_current_cursor;  static Cursor g_current_cursor;
52  static Atom g_protocol_atom, g_kill_atom;  static Atom g_protocol_atom, g_kill_atom;
53    static BOOL g_focused;
54    static BOOL g_mouse_in_wnd;
55    
56  /* endianness */  /* endianness */
57  static BOOL g_host_be;  static BOOL g_host_be;
# Line 69  static int g_move_y_offset = 0; Line 69  static int g_move_y_offset = 0;
69  #ifdef WITH_RDPSND  #ifdef WITH_RDPSND
70  extern int g_dsp_fd;  extern int g_dsp_fd;
71  extern BOOL g_dsp_busy;  extern BOOL g_dsp_busy;
72    extern BOOL g_rdpsnd;
73  #endif  #endif
74    
75  /* MWM decorations */  /* MWM decorations */
# Line 280  translate_colour(uint32 colour) Line 281  translate_colour(uint32 colour)
281                          }                          }
282                          break;                          break;
283          }          }
         switch (g_bpp)  
         {  
                 case 16:  
                         if (g_host_be != g_xserver_be)  
                                 BSWAP16(colour);  
                         break;  
   
                 case 24:  
                         if (g_xserver_be)  
                                 BSWAP24(colour);  
                         break;  
   
                 case 32:  
                         if (g_host_be != g_xserver_be)  
                                 BSWAP32(colour);  
                         break;  
         }  
   
284          return colour;          return colour;
285  }  }
286    
# Line 340  translate8to32(uint8 * data, uint32 * ou Line 323  translate8to32(uint8 * data, uint32 * ou
323  /* todo the remaining translate function might need some big endian check ?? */  /* todo the remaining translate function might need some big endian check ?? */
324    
325  static void  static void
326  translate15to16(uint16 * data, uint16 * out, uint16 * end)  translate15to16(uint16 * data, uint8 * out, uint8 * end)
327  {  {
328            uint16 pixel;
329            uint16 value;
330    
331          while (out < end)          while (out < end)
332                  *(out++) = (uint16) make_colour16(split_colour15(*(data++)));          {
333                    pixel = *(data++);
334    
335                    if (g_host_be)
336                    {
337                    BSWAP16(pixel)}
338    
339                    value = make_colour16(split_colour15(pixel));
340    
341                    if (g_xserver_be)
342                    {
343                            *(out++) = value >> 8;
344                            *(out++) = value;
345                    }
346                    else
347                    {
348                            *(out++) = value;
349                            *(out++) = value >> 8;
350                    }
351            }
352  }  }
353    
354  static void  static void
355  translate15to24(uint16 * data, uint8 * out, uint8 * end)  translate15to24(uint16 * data, uint8 * out, uint8 * end)
356  {  {
357          uint32 value;          uint32 value;
358            uint16 pixel;
359    
360          while (out < end)          while (out < end)
361          {          {
362                  value = make_colour24(split_colour15(*(data++)));                  pixel = *(data++);
363                  *(out++) = value;  
364                  *(out++) = value >> 8;                  if (g_host_be)
365                  *(out++) = value >> 16;                  {
366                    BSWAP16(pixel)}
367    
368                    value = make_colour24(split_colour15(pixel));
369                    if (g_xserver_be)
370                    {
371                            *(out++) = value >> 16;
372                            *(out++) = value >> 8;
373                            *(out++) = value;
374                    }
375                    else
376                    {
377                            *(out++) = value;
378                            *(out++) = value >> 8;
379                            *(out++) = value >> 16;
380                    }
381          }          }
382  }  }
383    
384  static void  static void
385  translate15to32(uint16 * data, uint32 * out, uint32 * end)  translate15to32(uint16 * data, uint8 * out, uint8 * end)
386  {  {
387          uint16 pixel;          uint16 pixel;
388            uint32 value;
389    
390          while (out < end)          while (out < end)
391          {          {
392                    pixel = *(data++);
393    
394                  if (g_host_be)                  if (g_host_be)
395                  {                  {
396                          pixel = *(data++);                          BSWAP16(pixel);
397                          pixel = (pixel & 0xff) << 8 | (pixel & 0xff00) >> 8;                  }
398                          *(out++) = make_colour32(split_colour15(pixel));  
399                    value = make_colour32(split_colour15(pixel));
400    
401                    if (g_xserver_be)
402                    {
403                            *(out++) = value >> 24;
404                            *(out++) = value >> 16;
405                            *(out++) = value >> 8;
406                            *(out++) = value;
407                  }                  }
408                  else                  else
409                  {                  {
410                          *(out++) = make_colour32(split_colour15(*(data++)));                          *(out++) = value;
411                            *(out++) = value >> 8;
412                            *(out++) = value >> 16;
413                            *(out++) = value >> 24;
414                  }                  }
415          }          }
416  }  }
# Line 383  translate15to32(uint16 * data, uint32 * Line 418  translate15to32(uint16 * data, uint32 *
418  static void  static void
419  translate16to16(uint16 * data, uint16 * out, uint16 * end)  translate16to16(uint16 * data, uint16 * out, uint16 * end)
420  {  {
421          while (out < end)          uint16 value;
422                  *(out++) = (uint16) (*(data++));  
423            if (g_xserver_be)
424            {
425                    while (out < end)
426                    {
427                            value = *data;
428                            BSWAP16(value);
429                            *out = value;
430                            data++;
431                            out++;
432                    }
433    
434            }
435            else
436            {
437                    while (out < end)
438                    {
439                            *out = *data;
440                            out++;
441                            data++;
442                    }
443            }
444  }  }
445    
446    
# Line 392  static void Line 448  static void
448  translate16to24(uint16 * data, uint8 * out, uint8 * end)  translate16to24(uint16 * data, uint8 * out, uint8 * end)
449  {  {
450          uint32 value;          uint32 value;
451            uint16 pixel;
452    
453          while (out < end)          while (out < end)
454          {          {
455                  value = make_colour24(split_colour16(*(data++)));                  pixel = *(data++);
456                  *(out++) = value;  
457                  *(out++) = value >> 8;                  if (g_host_be)
458                  *(out++) = value >> 16;                  {
459                    BSWAP16(pixel)}
460    
461                    value = make_colour24(split_colour16(pixel));
462    
463                    if (g_xserver_be)
464                    {
465                            *(out++) = value >> 16;
466                            *(out++) = value >> 8;
467                            *(out++) = value;
468                    }
469                    else
470                    {
471                            *(out++) = value;
472                            *(out++) = value >> 8;
473                            *(out++) = value >> 16;
474                    }
475          }          }
476  }  }
477    
478  static void  static void
479  translate16to32(uint16 * data, uint32 * out, uint32 * end)  translate16to32(uint16 * data, uint8 * out, uint8 * end)
480  {  {
481          uint16 pixel;          uint16 pixel;
482            uint32 value;
483    
484          while (out < end)          while (out < end)
485          {          {
486                    pixel = *(data++);
487    
488                  if (g_host_be)                  if (g_host_be)
489                  {                  {
490                          pixel = *(data++);                  BSWAP16(pixel)}
491                          pixel = (pixel & 0xff) << 8 | (pixel & 0xff00) >> 8;  
492                          *(out++) = make_colour32(split_colour16(pixel));                  value = make_colour32(split_colour16(pixel));
493    
494                    if (g_xserver_be)
495                    {
496                            *(out++) = value >> 24;
497                            *(out++) = value >> 16;
498                            *(out++) = value >> 8;
499                            *(out++) = value;
500                  }                  }
501                  else                  else
502                  {                  {
503                          *(out++) = make_colour32(split_colour16(*(data++)));                          *(out++) = value;
504                            *(out++) = value >> 8;
505                            *(out++) = value >> 16;
506                            *(out++) = value >> 24;
507                  }                  }
508          }          }
509  }  }
510    
511  static void  static void
512  translate24to16(uint8 * data, uint16 * out, uint16 * end)  translate24to16(uint8 * data, uint8 * out, uint8 * end)
513  {  {
514          uint32 pixel = 0;          uint32 pixel = 0;
515            uint16 value;
516          while (out < end)          while (out < end)
517          {          {
518                  pixel = *(data++) << 16;                  pixel = *(data++) << 16;
519                  pixel |= *(data++) << 8;                  pixel |= *(data++) << 8;
520                  pixel |= *(data++);                  pixel |= *(data++);
521                  *(out++) = (uint16) make_colour16(split_colour24(pixel));  
522                    value = (uint16) make_colour16(split_colour24(pixel));
523    
524                    if (g_xserver_be)
525                    {
526                            *(out++) = value >> 8;
527                            *(out++) = value;
528                    }
529                    else
530                    {
531                            *(out++) = value;
532                            *(out++) = value >> 8;
533                    }
534          }          }
535  }  }
536    
# Line 445  translate24to24(uint8 * data, uint8 * ou Line 544  translate24to24(uint8 * data, uint8 * ou
544  }  }
545    
546  static void  static void
547  translate24to32(uint8 * data, uint32 * out, uint32 * end)  translate24to32(uint8 * data, uint8 * out, uint8 * end)
548  {  {
         uint32 pixel = 0;  
549          while (out < end)          while (out < end)
550          {          {
551                  if (g_host_be)                  if (g_xserver_be)
552                  {                  {
553                          pixel = *(data++) << 16;                          *(out++) = 0x00;
554                          pixel |= *(data++) << 8;                          *(out++) = *(data++);
555                          pixel |= *(data++);                          *(out++) = *(data++);
556                            *(out++) = *(data++);
557                  }                  }
558                  else                  else
559                  {                  {
560                          pixel = *(data++);                          *(out++) = *(data++);
561                          pixel |= *(data++) << 8;                          *(out++) = *(data++);
562                          pixel |= *(data++) << 16;                          *(out++) = *(data++);
563                            *(out++) = 0x00;
564                  }                  }
                 *(out++) = pixel;  
565          }          }
566  }  }
567    
# Line 479  translate_image(int width, int height, u Line 578  translate_image(int width, int height, u
578                          switch (g_bpp)                          switch (g_bpp)
579                          {                          {
580                                  case 32:                                  case 32:
581                                          translate24to32(data, (uint32 *) out, (uint32 *) end);                                          translate24to32(data, out, end);
582                                          break;                                          break;
583                                  case 24:                                  case 24:
584                                          translate24to24(data, out, end);                                          translate24to24(data, out, end);
585                                          break;                                          break;
586                                  case 16:                                  case 16:
587                                          translate24to16(data, (uint16 *) out, (uint16 *) end);                                          translate24to16(data, out, end);
588                                          break;                                          break;
589                          }                          }
590                          break;                          break;
# Line 493  translate_image(int width, int height, u Line 592  translate_image(int width, int height, u
592                          switch (g_bpp)                          switch (g_bpp)
593                          {                          {
594                                  case 32:                                  case 32:
595                                          translate16to32((uint16 *) data, (uint32 *) out,                                          translate16to32((uint16 *) data, out, end);
                                                         (uint32 *) end);  
596                                          break;                                          break;
597                                  case 24:                                  case 24:
598                                          translate16to24((uint16 *) data, out, end);                                          translate16to24((uint16 *) data, out, end);
# Line 509  translate_image(int width, int height, u Line 607  translate_image(int width, int height, u
607                          switch (g_bpp)                          switch (g_bpp)
608                          {                          {
609                                  case 32:                                  case 32:
610                                          translate15to32((uint16 *) data, (uint32 *) out,                                          translate15to32((uint16 *) data, out, end);
                                                         (uint32 *) end);  
611                                          break;                                          break;
612                                  case 24:                                  case 24:
613                                          translate15to24((uint16 *) data, out, end);                                          translate15to24((uint16 *) data, out, end);
614                                          break;                                          break;
615                                  case 16:                                  case 16:
616                                          translate15to16((uint16 *) data, (uint16 *) out,                                          translate15to16((uint16 *) data, out, end);
                                                         (uint16 *) end);  
617                                          break;                                          break;
618                          }                          }
619                          break;                          break;
# Line 624  ui_init(void) Line 720  ui_init(void)
720          g_host_be = !(BOOL) (*(uint8 *) (&test));          g_host_be = !(BOOL) (*(uint8 *) (&test));
721          g_xserver_be = (ImageByteOrder(g_display) == MSBFirst);          g_xserver_be = (ImageByteOrder(g_display) == MSBFirst);
722    
723          if ((g_width == 0) || (g_height == 0))          /*
724             * Determine desktop size
725             */
726            if (g_width < 0)
727            {
728                    /* Percent of screen */
729                    g_height = HeightOfScreen(g_screen) * (-g_width) / 100;
730                    g_width = WidthOfScreen(g_screen) * (-g_width) / 100;
731            }
732            else if (g_width == 0)
733          {          {
734                  /* Fetch geometry from _NET_WORKAREA */                  /* Fetch geometry from _NET_WORKAREA */
735                  uint32 x, y, cx, cy;                  uint32 x, y, cx, cy;
# Line 641  ui_init(void) Line 746  ui_init(void)
746                          g_height = 600;                          g_height = 600;
747                  }                  }
748          }          }
749            else if (g_fullscreen)
         if (g_fullscreen)  
750          {          {
751                  g_width = WidthOfScreen(g_screen);                  g_width = WidthOfScreen(g_screen);
752                  g_height = HeightOfScreen(g_screen);                  g_height = HeightOfScreen(g_screen);
# Line 664  ui_init(void) Line 768  ui_init(void)
768    
769          g_mod_map = XGetModifierMapping(g_display);          g_mod_map = XGetModifierMapping(g_display);
770    
771            xkeymap_init();
772    
773          if (g_enable_compose)          if (g_enable_compose)
774                  g_IM = XOpenIM(g_display, NULL, NULL, NULL);                  g_IM = XOpenIM(g_display, NULL, NULL, NULL);
775    
         xkeymap_init();  
776          xclip_init();          xclip_init();
777    
778          /* todo take this out when high colour is done */          /* todo take this out when high colour is done */
# Line 1085  ui_select(int rdp_socket) Line 1190  ui_select(int rdp_socket)
1190          int n = (rdp_socket > g_x_socket) ? rdp_socket + 1 : g_x_socket + 1;          int n = (rdp_socket > g_x_socket) ? rdp_socket + 1 : g_x_socket + 1;
1191          fd_set rfds, wfds;          fd_set rfds, wfds;
1192    
         FD_ZERO(&rfds);  
   
1193          while (True)          while (True)
1194          {          {
1195                  /* Process any events already waiting */                  /* Process any events already waiting */
# Line 1101  ui_select(int rdp_socket) Line 1204  ui_select(int rdp_socket)
1204    
1205  #ifdef WITH_RDPSND  #ifdef WITH_RDPSND
1206                  /* FIXME: there should be an API for registering fds */                  /* FIXME: there should be an API for registering fds */
1207                  if (g_dsp_busy)                  if (g_rdpsnd && g_dsp_busy)
1208                  {                  {
1209                          FD_SET(g_dsp_fd, &wfds);                          FD_SET(g_dsp_fd, &wfds);
1210                          n = (g_dsp_fd + 1 > n) ? g_dsp_fd + 1 : n;                          n = (g_dsp_fd + 1 > n) ? g_dsp_fd + 1 : n;
1211                  }                  }
1212  #endif  #endif
1213    
1214                  switch (select(n, &rfds, &wfds, NULL, NULL))                  switch (select(n, &rfds, &wfds, NULL, NULL))
# Line 1121  ui_select(int rdp_socket) Line 1224  ui_select(int rdp_socket)
1224                          return 1;                          return 1;
1225    
1226  #ifdef WITH_RDPSND  #ifdef WITH_RDPSND
1227                  if (FD_ISSET(g_dsp_fd, &wfds))                  if (g_rdpsnd && g_dsp_busy && FD_ISSET(g_dsp_fd, &wfds))
1228                          wave_out_play();                          wave_out_play();
1229  #endif  #endif
1230          }          }
# Line 1499  ui_patblt(uint8 opcode, Line 1602  ui_patblt(uint8 opcode,
1602                  case 2: /* Hatch */                  case 2: /* Hatch */
1603                          fill = (Pixmap) ui_create_glyph(8, 8,                          fill = (Pixmap) ui_create_glyph(8, 8,
1604                                                          hatch_patterns + brush->pattern[0] * 8);                                                          hatch_patterns + brush->pattern[0] * 8);
1605                          SET_FOREGROUND(bgcolour);                          SET_FOREGROUND(fgcolour);
1606                          SET_BACKGROUND(fgcolour);                          SET_BACKGROUND(bgcolour);
1607                          XSetFillStyle(g_display, g_gc, FillOpaqueStippled);                          XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
1608                          XSetStipple(g_display, g_gc, fill);                          XSetStipple(g_display, g_gc, fill);
1609                          XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);                          XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);

Legend:
Removed from v.474  
changed lines
  Added in v.501

  ViewVC Help
Powered by ViewVC 1.1.26