/[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 620 by astrand, Wed Mar 3 10:46:35 2004 UTC revision 644 by jsorg71, Thu Mar 25 22:58:45 2004 UTC
# Line 43  Time g_last_gesturetime; Line 43  Time g_last_gesturetime;
43  static int g_x_socket;  static int g_x_socket;
44  static Screen *g_screen;  static Screen *g_screen;
45  Window g_wnd;  Window g_wnd;
46    uint32 g_embed_wnd;
47  BOOL g_enable_compose = False;  BOOL g_enable_compose = False;
48  static GC g_gc = NULL;  static GC g_gc = NULL;
49  static Visual *g_visual;  static Visual *g_visual;
# Line 56  static HCURSOR g_null_cursor = NULL; Line 57  static HCURSOR g_null_cursor = NULL;
57  static Atom g_protocol_atom, g_kill_atom;  static Atom g_protocol_atom, g_kill_atom;
58  static BOOL g_focused;  static BOOL g_focused;
59  static BOOL g_mouse_in_wnd;  static BOOL g_mouse_in_wnd;
60    static BOOL g_arch_match = False; /* set to True if RGB XServer and little endian */
61    
62  /* endianness */  /* endianness */
63  static BOOL g_host_be;  static BOOL g_host_be;
# Line 239  translate8to16(uint8 * data, uint8 * out Line 241  translate8to16(uint8 * data, uint8 * out
241  {  {
242          uint16 value;          uint16 value;
243    
244          while (out < end)          if (g_xserver_be)
245          {          {
246                  value = (uint16) g_colmap[*(data++)];                  while (out < end)
   
                 if (g_xserver_be)  
247                  {                  {
248                            value = (uint16) g_colmap[*(data++)];
249                          *(out++) = value >> 8;                          *(out++) = value >> 8;
250                          *(out++) = value;                          *(out++) = value;
251                  }                  }
252                  else          }
253            else
254            {
255                    while (out < end)
256                  {                  {
257                            value = (uint16) g_colmap[*(data++)];
258                          *(out++) = value;                          *(out++) = value;
259                          *(out++) = value >> 8;                          *(out++) = value >> 8;
260                  }                  }
# Line 262  translate8to24(uint8 * data, uint8 * out Line 267  translate8to24(uint8 * data, uint8 * out
267  {  {
268          uint32 value;          uint32 value;
269    
270          while (out < end)          if (g_xserver_be)
271          {          {
272                  value = g_colmap[*(data++)];                  while (out < end)
   
                 if (g_xserver_be)  
273                  {                  {
274                            value = g_colmap[*(data++)];
275                          *(out++) = value >> 16;                          *(out++) = value >> 16;
276                          *(out++) = value >> 8;                          *(out++) = value >> 8;
277                          *(out++) = value;                          *(out++) = value;
278                  }                  }
279                  else          }
280            else
281            {
282                    while (out < end)
283                  {                  {
284                            value = g_colmap[*(data++)];
285                          *(out++) = value;                          *(out++) = value;
286                          *(out++) = value >> 8;                          *(out++) = value >> 8;
287                          *(out++) = value >> 16;                          *(out++) = value >> 16;
# Line 286  translate8to32(uint8 * data, uint8 * out Line 294  translate8to32(uint8 * data, uint8 * out
294  {  {
295          uint32 value;          uint32 value;
296    
297          while (out < end)          if (g_xserver_be)
298          {          {
299                  value = g_colmap[*(data++)];                  while (out < end)
   
                 if (g_xserver_be)  
300                  {                  {
301                            value = g_colmap[*(data++)];
302                          *(out++) = value >> 24;                          *(out++) = value >> 24;
303                          *(out++) = value >> 16;                          *(out++) = value >> 16;
304                          *(out++) = value >> 8;                          *(out++) = value >> 8;
305                          *(out++) = value;                          *(out++) = value;
306                  }                  }
307                  else          }
308            else
309            {
310                    while (out < end)
311                  {                  {
312                            value = g_colmap[*(data++)];
313                          *(out++) = value;                          *(out++) = value;
314                          *(out++) = value >> 8;                          *(out++) = value >> 8;
315                          *(out++) = value >> 16;                          *(out++) = value >> 16;
# Line 587  translate24to32(uint8 * data, uint8 * ou Line 598  translate24to32(uint8 * data, uint8 * ou
598  static uint8 *  static uint8 *
599  translate_image(int width, int height, uint8 * data)  translate_image(int width, int height, uint8 * data)
600  {  {
601          int size = width * height * g_bpp / 8;          int size;
602          uint8 *out = (uint8 *) xmalloc(size);          uint8 *out;
603          uint8 *end = out + size;          uint8 *end;
604    
605            /* if server and xserver bpp match, */
606            /* and arch(endian) matches, no need to translate */
607            /* just return data */
608            if (g_depth > 8)
609                    if (g_arch_match)
610                            if (g_depth == g_server_bpp)
611                                    return data;
612    
613            size = width * height * (g_bpp / 8);
614            out = (uint8 *) xmalloc(size);
615            end = out + size;
616    
617          switch (g_server_bpp)          switch (g_server_bpp)
618          {          {
# Line 727  ui_init(void) Line 750  ui_init(void)
750                  TrueColorVisual = True;                  TrueColorVisual = True;
751          }          }
752    
753            test = 1;
754            g_host_be = !(BOOL) (*(uint8 *) (&test));
755            g_xserver_be = (ImageByteOrder(g_display) == MSBFirst);
756    
757          if ((g_server_bpp == 8) && ((!TrueColorVisual) || (g_depth <= 8)))          if ((g_server_bpp == 8) && ((!TrueColorVisual) || (g_depth <= 8)))
758          {          {
759                  /* we use a colourmap, so the default visual should do */                  /* we use a colourmap, so the default visual should do */
# Line 753  ui_init(void) Line 780  ui_init(void)
780                  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);
781                  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);
782                  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);
783    
784                    /* if RGB video and averything is little endian */
785                    if (vi.red_mask > vi.green_mask && vi.green_mask > vi.blue_mask)
786                            if (!g_xserver_be && !g_host_be)
787                                    g_arch_match = True;
788          }          }
789    
790          pfm = XListPixmapFormats(g_display, &i);          pfm = XListPixmapFormats(g_display, &i);
# Line 792  ui_init(void) Line 824  ui_init(void)
824                  g_ownbackstore = True;                  g_ownbackstore = True;
825          }          }
826    
         test = 1;  
         g_host_be = !(BOOL) (*(uint8 *) (&test));  
         g_xserver_be = (ImageByteOrder(g_display) == MSBFirst);  
   
827          /*          /*
828           * Determine desktop size           * Determine desktop size
829           */           */
# Line 925  ui_create_window(void) Line 953  ui_create_window(void)
953                  XFree(sizehints);                  XFree(sizehints);
954          }          }
955    
956            if ( g_embed_wnd )
957            {
958                    XReparentWindow(g_display, g_wnd, (Window)g_embed_wnd, 0, 0);
959            }
960    
961          input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |          input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
962                  VisibilityChangeMask | FocusChangeMask;                  VisibilityChangeMask | FocusChangeMask;
963    
# Line 1366  ui_create_bitmap(int width, int height, Line 1399  ui_create_bitmap(int width, int height,
1399          XPutImage(g_display, bitmap, g_gc, image, 0, 0, 0, 0, width, height);          XPutImage(g_display, bitmap, g_gc, image, 0, 0, 0, 0, width, height);
1400    
1401          XFree(image);          XFree(image);
1402          if (!g_owncolmap)          if (tdata != data)
1403                  xfree(tdata);                  xfree(tdata);
1404          return (HBITMAP) bitmap;          return (HBITMAP) bitmap;
1405  }  }
# Line 1405  ui_paint_bitmap(int x, int y, int cx, in Line 1438  ui_paint_bitmap(int x, int y, int cx, in
1438          }          }
1439    
1440          XFree(image);          XFree(image);
1441          if (!g_owncolmap)          if (tdata != data)
1442                  xfree(tdata);                  xfree(tdata);
1443  }  }
1444    

Legend:
Removed from v.620  
changed lines
  Added in v.644

  ViewVC Help
Powered by ViewVC 1.1.26