/[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 643 by jsorg71, Wed Mar 24 18:16:58 2004 UTC revision 679 by jsorg71, Mon Apr 26 23:00:25 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;  extern 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 57  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 65  static int g_red_shift_r, g_blue_shift_r Line 66  static int g_red_shift_r, g_blue_shift_r
66  static int g_red_shift_l, g_blue_shift_l, g_green_shift_l;  static int g_red_shift_l, g_blue_shift_l, g_green_shift_l;
67    
68  /* software backing store */  /* software backing store */
69  BOOL g_ownbackstore = True;     /* We can't rely on external BackingStore */  extern BOOL g_ownbackstore;
70  static Pixmap g_backstore = 0;  static Pixmap g_backstore = 0;
71    
72  /* Moving in single app mode */  /* Moving in single app mode */
# Line 114  PixelColour; Line 115  PixelColour;
115  }  }
116    
117  /* colour maps */  /* colour maps */
118  BOOL g_owncolmap = False;  extern BOOL g_owncolmap;
119  static Colormap g_xcolmap;  static Colormap g_xcolmap;
120  static uint32 *g_colmap = NULL;  static uint32 *g_colmap = NULL;
121    
# Line 228  translate_colour(uint32 colour) Line 229  translate_colour(uint32 colour)
229          return make_colour(pc);          return make_colour(pc);
230  }  }
231    
232    #define UNROLL8(stm) { stm stm stm stm stm stm stm stm }
233    #define REPEAT(stm) \
234    { \
235            while (out <= end - 8 * 4) \
236                    UNROLL8(stm) \
237            while (out < end) \
238                    { stm } \
239    }
240    
241  static void  static void
242  translate8to8(uint8 * data, uint8 * out, uint8 * end)  translate8to8(uint8 * data, uint8 * out, uint8 * end)
243  {  {
# Line 240  translate8to16(uint8 * data, uint8 * out Line 250  translate8to16(uint8 * data, uint8 * out
250  {  {
251          uint16 value;          uint16 value;
252    
253          if (g_xserver_be)          if (g_arch_match)
254                    REPEAT(*(((uint16*)out)++) = g_colmap[*(data++)];)
255            else if (g_xserver_be)
256          {          {
257                  while (out < end)                  while (out < end)
258                  {                  {
# Line 293  translate8to32(uint8 * data, uint8 * out Line 305  translate8to32(uint8 * data, uint8 * out
305  {  {
306          uint32 value;          uint32 value;
307    
308          if (g_xserver_be)          if (g_arch_match)
309                    REPEAT(*(((uint32*)out)++) = g_colmap[*(data++)];)
310            else if (g_xserver_be)
311          {          {
312                  while (out < end)                  while (out < end)
313                  {                  {
# Line 597  translate24to32(uint8 * data, uint8 * ou Line 611  translate24to32(uint8 * data, uint8 * ou
611  static uint8 *  static uint8 *
612  translate_image(int width, int height, uint8 * data)  translate_image(int width, int height, uint8 * data)
613  {  {
614          int size = width * height * g_bpp / 8;          int size;
615          uint8 *out = (uint8 *) xmalloc(size);          uint8 *out;
616          uint8 *end = out + size;          uint8 *end;
617    
618            /* if server and xserver bpp match, */
619            /* and arch(endian) matches, no need to translate */
620            /* just return data */
621            if (g_arch_match)
622            {
623                    if (g_depth == 15 && g_server_bpp == 15)
624                            return data;
625                    if (g_depth == 16 && g_server_bpp == 16)
626                            return data;
627            }
628    
629            size = width * height * (g_bpp / 8);
630            out = (uint8 *) xmalloc(size);
631            end = out + size;
632    
633          switch (g_server_bpp)          switch (g_server_bpp)
634          {          {
# Line 737  ui_init(void) Line 766  ui_init(void)
766                  TrueColorVisual = True;                  TrueColorVisual = True;
767          }          }
768    
769            test = 1;
770            g_host_be = !(BOOL) (*(uint8 *) (&test));
771            g_xserver_be = (ImageByteOrder(g_display) == MSBFirst);
772    
773          if ((g_server_bpp == 8) && ((!TrueColorVisual) || (g_depth <= 8)))          if ((g_server_bpp == 8) && ((!TrueColorVisual) || (g_depth <= 8)))
774          {          {
775                  /* we use a colourmap, so the default visual should do */                  /* we use a colourmap, so the default visual should do */
# Line 763  ui_init(void) Line 796  ui_init(void)
796                  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);
797                  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);
798                  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);
799    
800                    /* if RGB video and averything is little endian */
801                    if (vi.red_mask > vi.green_mask && vi.green_mask > vi.blue_mask)
802                            if (!g_xserver_be && !g_host_be)
803                                    g_arch_match = True;
804          }          }
805    
806          pfm = XListPixmapFormats(g_display, &i);          pfm = XListPixmapFormats(g_display, &i);
# Line 802  ui_init(void) Line 840  ui_init(void)
840                  g_ownbackstore = True;                  g_ownbackstore = True;
841          }          }
842    
         test = 1;  
         g_host_be = !(BOOL) (*(uint8 *) (&test));  
         g_xserver_be = (ImageByteOrder(g_display) == MSBFirst);  
   
843          /*          /*
844           * Determine desktop size           * Determine desktop size
845           */           */
# Line 935  ui_create_window(void) Line 969  ui_create_window(void)
969                  XFree(sizehints);                  XFree(sizehints);
970          }          }
971    
972          if ( g_embed_wnd )          if (g_embed_wnd)
973          {          {
974                  XReparentWindow(g_display, g_wnd, (Window)g_embed_wnd, 0, 0);                  XReparentWindow(g_display, g_wnd, (Window) g_embed_wnd, 0, 0);
975          }          }
976    
977          input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |          input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
978                  VisibilityChangeMask | FocusChangeMask;                  VisibilityChangeMask | FocusChangeMask;
# Line 988  ui_create_window(void) Line 1022  ui_create_window(void)
1022  }  }
1023    
1024  void  void
1025    ui_resize_window()
1026    {
1027            XSizeHints *sizehints;
1028    
1029            sizehints = XAllocSizeHints();
1030            if (sizehints)
1031            {
1032                    sizehints->flags = PMinSize | PMaxSize;
1033                    sizehints->min_width = sizehints->max_width = g_width;
1034                    sizehints->min_height = sizehints->max_height = g_height;
1035                    XSetWMNormalHints(g_display, g_wnd, sizehints);
1036                    XFree(sizehints);
1037            }
1038    
1039            if (!(g_fullscreen || g_embed_wnd))
1040            {
1041                    XResizeWindow(g_display, g_wnd, g_width, g_height);
1042            }
1043    }
1044    
1045    void
1046  ui_destroy_window(void)  ui_destroy_window(void)
1047  {  {
1048          if (g_IC != NULL)          if (g_IC != NULL)
# Line 1381  ui_create_bitmap(int width, int height, Line 1436  ui_create_bitmap(int width, int height,
1436          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);
1437    
1438          XFree(image);          XFree(image);
1439          if (!g_owncolmap)          if (tdata != data)
1440                  xfree(tdata);                  xfree(tdata);
1441          return (HBITMAP) bitmap;          return (HBITMAP) bitmap;
1442  }  }
# Line 1420  ui_paint_bitmap(int x, int y, int cx, in Line 1475  ui_paint_bitmap(int x, int y, int cx, in
1475          }          }
1476    
1477          XFree(image);          XFree(image);
1478          if (!g_owncolmap)          if (tdata != data)
1479                  xfree(tdata);                  xfree(tdata);
1480  }  }
1481    

Legend:
Removed from v.643  
changed lines
  Added in v.679

  ViewVC Help
Powered by ViewVC 1.1.26