/[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 528 by matthewc, Wed Oct 29 08:37:20 2003 UTC revision 545 by stargo, Mon Nov 3 20:19:01 2003 UTC
# Line 20  Line 20 
20    
21  #include <X11/Xlib.h>  #include <X11/Xlib.h>
22  #include <X11/Xutil.h>  #include <X11/Xutil.h>
23    #include <unistd.h>
24  #include <time.h>  #include <time.h>
25  #include <errno.h>  #include <errno.h>
26  #include "rdesktop.h"  #include "rdesktop.h"
# Line 207  make_colour(PixelColour pc) Line 208  make_colour(PixelColour pc)
208  }  }
209    
210  #define BSWAP16(x) { x = (((x & 0xff) << 8) | (x >> 8)); }  #define BSWAP16(x) { x = (((x & 0xff) << 8) | (x >> 8)); }
211  #define BSWAP24(x) { x = (((x & 0xff) << 16) | (x >> 16) | ((x >> 8) & 0xff00)); }  #define BSWAP24(x) { x = (((x & 0xff) << 16) | (x >> 16) | (x & 0xff00)); }
212  #define BSWAP32(x) { x = (((x & 0xff00ff) << 8) | ((x >> 8) & 0xff00ff)); \  #define BSWAP32(x) { x = (((x & 0xff00ff) << 8) | ((x >> 8) & 0xff00ff)); \
213                          x = (x << 16) | (x >> 16); }                          x = (x << 16) | (x >> 16); }
214    
# Line 245  translate8to16(uint8 * data, uint8 * out Line 246  translate8to16(uint8 * data, uint8 * out
246          while (out < end)          while (out < end)
247          {          {
248                  value = (uint16) g_colmap[*(data++)];                  value = (uint16) g_colmap[*(data++)];
249                    
250                  if (g_xserver_be)                  if (g_xserver_be)
251                  {                  {
252                          *(out++) = value >> 8;                          *(out++) = value >> 8;
# Line 268  translate8to24(uint8 * data, uint8 * out Line 269  translate8to24(uint8 * data, uint8 * out
269          while (out < end)          while (out < end)
270          {          {
271                  value = g_colmap[*(data++)];                  value = g_colmap[*(data++)];
272                    
273                  if (g_xserver_be)                  if (g_xserver_be)
274                  {                  {
275                          *(out++) = value >> 16;                          *(out++) = value >> 16;
# Line 310  translate8to32(uint8 * data, uint8 * out Line 311  translate8to32(uint8 * data, uint8 * out
311          }          }
312  }  }
313    
 /* todo the remaining translate function might need some big endian check ?? */  
   
314  static void  static void
315  translate15to16(uint16 * data, uint8 * out, uint8 * end)  translate15to16(uint16 * data, uint8 * out, uint8 * end)
316  {  {
# Line 481  translate16to32(uint16 * data, uint8 * o Line 480  translate16to32(uint16 * data, uint8 * o
480    
481                  if (g_host_be)                  if (g_host_be)
482                  {                  {
483                  BSWAP16(pixel)}                          BSWAP16(pixel);
484                    }
485    
486                  value = make_colour(split_colour16(pixel));                  value = make_colour(split_colour16(pixel));
487    
# Line 531  translate24to16(uint8 * data, uint8 * ou Line 531  translate24to16(uint8 * data, uint8 * ou
531  static void  static void
532  translate24to24(uint8 * data, uint8 * out, uint8 * end)  translate24to24(uint8 * data, uint8 * out, uint8 * end)
533  {  {
534            uint32 pixel;
535            uint32 value;
536    
537          while (out < end)          while (out < end)
538          {          {
539                  *(out++) = (*(data++));                  pixel = *(data++) << 16;
540                    pixel |= *(data++) << 8;
541                    pixel |= *(data++);
542    
543                    value = make_colour(split_colour24(pixel));
544    
545                    if (g_xserver_be)
546                    {
547                            *(out++) = value >> 16;
548                            *(out++) = value >> 8;
549                            *(out++) = value;
550                    }
551                    else
552                    {
553                            *(out++) = value;
554                            *(out++) = value >> 8;
555                            *(out++) = value >> 16;
556                    }
557          }          }
558  }  }
559    
560  static void  static void
561  translate24to32(uint8 * data, uint8 * out, uint8 * end)  translate24to32(uint8 * data, uint8 * out, uint8 * end)
562  {  {
563            uint32 pixel;
564            uint32 value;
565    
566          while (out < end)          while (out < end)
567          {          {
568                    pixel = *(data++) << 16;
569                    pixel |= *(data++) << 8;
570                    pixel |= *(data++);
571    
572                    value = make_colour(split_colour24(pixel));
573    
574                  if (g_xserver_be)                  if (g_xserver_be)
575                  {                  {
576                          *(out++) = 0x00;                          *(out++) = value >> 24;
577                          *(out++) = *(data++);                          *(out++) = value >> 16;
578                          *(out++) = *(data++);                          *(out++) = value >> 8;
579                          *(out++) = *(data++);                          *(out++) = value;
580                  }                  }
581                  else                  else
582                  {                  {
583                          *(out++) = *(data++);                          *(out++) = value;
584                          *(out++) = *(data++);                          *(out++) = value >> 8;
585                          *(out++) = *(data++);                          *(out++) = value >> 16;
586                          *(out++) = 0x00;                          *(out++) = value >> 24;
587                  }                  }
588          }          }
589  }  }
# Line 700  ui_init(void) Line 729  ui_init(void)
729    
730                  g_visual = vi.visual;                  g_visual = vi.visual;
731                  g_owncolmap = False;                  g_owncolmap = False;
732                  calculate_shifts(vi.red_mask,   &g_red_shift_r,   &g_red_shift_l);                  calculate_shifts(vi.red_mask, &g_red_shift_r, &g_red_shift_l);
733                  calculate_shifts(vi.blue_mask,  &g_blue_shift_r,  &g_blue_shift_l);                  calculate_shifts(vi.blue_mask, &g_blue_shift_r, &g_blue_shift_l);
734                  calculate_shifts(vi.green_mask, &g_green_shift_r, &g_green_shift_l);                  calculate_shifts(vi.green_mask, &g_green_shift_r, &g_green_shift_l);
735          }          }
736    
# Line 819  ui_deinit(void) Line 848  ui_deinit(void)
848          g_display = NULL;          g_display = NULL;
849  }  }
850    
 #define NULL_POINTER_MASK       "\x80"  
 #define NULL_POINTER_DATA       "\x0\x0\x0"  
           
851  BOOL  BOOL
852  ui_create_window(void)  ui_create_window(void)
853  {  {
854            uint8 null_pointer_mask[1] = { 0x80 };
855            uint8 null_pointer_data[4] = { 0x00, 0x00, 0x00, 0x00 };
856          XSetWindowAttributes attribs;          XSetWindowAttributes attribs;
857          XClassHint *classhints;          XClassHint *classhints;
858          XSizeHints *sizehints;          XSizeHints *sizehints;
# Line 907  ui_create_window(void) Line 935  ui_create_window(void)
935          XSetWMProtocols(g_display, g_wnd, &g_kill_atom, 1);          XSetWMProtocols(g_display, g_wnd, &g_kill_atom, 1);
936    
937          /* create invisible 1x1 cursor to be used as null cursor */          /* create invisible 1x1 cursor to be used as null cursor */
938          g_null_cursor = ui_create_cursor(0, 0, 1, 1, NULL_POINTER_MASK, NULL_POINTER_DATA);          g_null_cursor = ui_create_cursor(0, 0, 1, 1, null_pointer_mask, null_pointer_data);
939    
940          return True;          return True;
941  }  }
# Line 915  ui_create_window(void) Line 943  ui_create_window(void)
943  void  void
944  ui_destroy_window(void)  ui_destroy_window(void)
945  {  {
         ui_destroy_cursor(g_null_cursor);  
           
946          if (g_IC != NULL)          if (g_IC != NULL)
947                  XDestroyIC(g_IC);                  XDestroyIC(g_IC);
948    
# Line 960  xwin_process_events(void) Line 986  xwin_process_events(void)
986          key_translation tr;          key_translation tr;
987          char str[256];          char str[256];
988          Status status;          Status status;
         unsigned int state;  
         Window wdummy;  
         int dummy;  
989    
990          while (XPending(g_display) > 0)          while (XPending(g_display) > 0)
991          {          {
# Line 1135  xwin_process_events(void) Line 1158  xwin_process_events(void)
1158                                  if (xevent.xfocus.mode == NotifyGrab)                                  if (xevent.xfocus.mode == NotifyGrab)
1159                                          break;                                          break;
1160                                  g_focused = True;                                  g_focused = True;
1161                                  XQueryPointer(g_display, g_wnd, &wdummy, &wdummy, &dummy, &dummy,                                  reset_modifier_keys();
                                               &dummy, &dummy, &state);  
                                 reset_modifier_keys(state);  
1162                                  if (g_grab_keyboard && g_mouse_in_wnd)                                  if (g_grab_keyboard && g_mouse_in_wnd)
1163                                          XGrabKeyboard(g_display, g_wnd, True,                                          XGrabKeyboard(g_display, g_wnd, True,
1164                                                        GrabModeAsync, GrabModeAsync, CurrentTime);                                                        GrabModeAsync, GrabModeAsync, CurrentTime);

Legend:
Removed from v.528  
changed lines
  Added in v.545

  ViewVC Help
Powered by ViewVC 1.1.26