/[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 1029 by astrand, Fri Nov 18 22:46:38 2005 UTC revision 1049 by astrand, Wed Mar 1 13:54:19 2006 UTC
# Line 38  extern BOOL g_fullscreen; Line 38  extern BOOL g_fullscreen;
38  extern BOOL g_grab_keyboard;  extern BOOL g_grab_keyboard;
39  extern BOOL g_hide_decorations;  extern BOOL g_hide_decorations;
40  extern char g_title[];  extern char g_title[];
41  extern int g_server_bpp;  /* Color depth of the RDP session.
42       As of RDP 5.1, it may be 8, 15, 16 or 24. */
43    extern int g_server_depth;
44  extern int g_win_button_size;  extern int g_win_button_size;
45    
46  Display *g_display;  Display *g_display;
# Line 53  static GC g_gc = NULL; Line 55  static GC g_gc = NULL;
55  static GC g_create_bitmap_gc = NULL;  static GC g_create_bitmap_gc = NULL;
56  static GC g_create_glyph_gc = NULL;  static GC g_create_glyph_gc = NULL;
57  static Visual *g_visual;  static Visual *g_visual;
58    /* Color depth of the X11 visual of our window (e.g. 24 for True Color R8G8B visual).
59       This may be 32 for R8G8B8 visuals, and then the rest of the bits are undefined
60       as far as we're concerned. */
61  static int g_depth;  static int g_depth;
62    /* Bits-per-Pixel of the pixmaps we'll be using to draw on our window.
63       This may be larger than g_depth, in which case some of the bits would
64       be kept solely for alignment (e.g. 32bpp pixmaps on a 24bpp visual). */
65  static int g_bpp;  static int g_bpp;
66  static XIM g_IM;  static XIM g_IM;
67  static XIC g_IC;  static XIC g_IC;
# Line 63  static HCURSOR g_null_cursor = NULL; Line 71  static HCURSOR g_null_cursor = NULL;
71  static Atom g_protocol_atom, g_kill_atom;  static Atom g_protocol_atom, g_kill_atom;
72  static BOOL g_focused;  static BOOL g_focused;
73  static BOOL g_mouse_in_wnd;  static BOOL g_mouse_in_wnd;
74  static BOOL g_arch_match = False;       /* set to True if RGB XServer and little endian */  /* Indicates that:
75       1) visual has 15, 16 or 24 depth and the same color channel masks
76          as its RDP equivalent (implies X server is LE),
77       2) host is LE
78       This will trigger an optimization whose real value is questionable.
79    */
80    static BOOL g_compatible_arch;
81    /* Indicates whether RDP's bitmaps and our XImages have the same
82       binary format. If so, we can avoid an expensive translation.
83       Note that this can be true when g_compatible_arch is false,
84       e.g.:
85      
86         RDP(LE) <-> host(BE) <-> X-Server(LE)
87        
88       ('host' is the machine running rdesktop; the host simply memcpy's
89        so its endianess doesn't matter)
90     */
91    static BOOL g_no_translate_image = False;
92    
93  /* endianness */  /* endianness */
94  static BOOL g_host_be;  static BOOL g_host_be;
# Line 92  extern BOOL g_rdpsnd; Line 117  extern BOOL g_rdpsnd;
117  #define PROP_MOTIF_WM_HINTS_ELEMENTS    5  #define PROP_MOTIF_WM_HINTS_ELEMENTS    5
118  typedef struct  typedef struct
119  {  {
120          uint32 flags;          unsigned long flags;
121          uint32 functions;          unsigned long functions;
122          uint32 decorations;          unsigned long decorations;
123          sint32 inputMode;          long inputMode;
124          uint32 status;          unsigned long status;
125  }  }
126  PropMotifWmHints;  PropMotifWmHints;
127    
# Line 150  extern BOOL g_owncolmap; Line 175  extern BOOL g_owncolmap;
175  static Colormap g_xcolmap;  static Colormap g_xcolmap;
176  static uint32 *g_colmap = NULL;  static uint32 *g_colmap = NULL;
177    
178  #define TRANSLATE(col)          ( g_server_bpp != 8 ? translate_colour(col) : g_owncolmap ? col : g_colmap[col] )  #define TRANSLATE(col)          ( g_server_depth != 8 ? translate_colour(col) : g_owncolmap ? col : g_colmap[col] )
179  #define SET_FOREGROUND(col)     XSetForeground(g_display, g_gc, TRANSLATE(col));  #define SET_FOREGROUND(col)     XSetForeground(g_display, g_gc, TRANSLATE(col));
180  #define SET_BACKGROUND(col)     XSetBackground(g_display, g_gc, TRANSLATE(col));  #define SET_BACKGROUND(col)     XSetBackground(g_display, g_gc, TRANSLATE(col));
181    
# Line 229  mwm_hide_decorations(void) Line 254  mwm_hide_decorations(void)
254  #define BSWAP32(x) { x = (((x & 0xff00ff) << 8) | ((x >> 8) & 0xff00ff)); \  #define BSWAP32(x) { x = (((x & 0xff00ff) << 8) | ((x >> 8) & 0xff00ff)); \
255                          x = (x << 16) | (x >> 16); }                          x = (x << 16) | (x >> 16); }
256    
257    /* The following macros output the same octet sequences
258       on both BE and LE hosts: */
259    
260  #define BOUT16(o, x) { *(o++) = x >> 8; *(o++) = x; }  #define BOUT16(o, x) { *(o++) = x >> 8; *(o++) = x; }
261  #define BOUT24(o, x) { *(o++) = x >> 16; *(o++) = x >> 8; *(o++) = x; }  #define BOUT24(o, x) { *(o++) = x >> 16; *(o++) = x >> 8; *(o++) = x; }
262  #define BOUT32(o, x) { *(o++) = x >> 24; *(o++) = x >> 16; *(o++) = x >> 8; *(o++) = x; }  #define BOUT32(o, x) { *(o++) = x >> 24; *(o++) = x >> 16; *(o++) = x >> 8; *(o++) = x; }
# Line 240  static uint32 Line 268  static uint32
268  translate_colour(uint32 colour)  translate_colour(uint32 colour)
269  {  {
270          PixelColour pc;          PixelColour pc;
271          switch (g_server_bpp)          switch (g_server_depth)
272          {          {
273                  case 15:                  case 15:
274                          SPLITCOLOUR15(colour, pc);                          SPLITCOLOUR15(colour, pc);
# Line 251  translate_colour(uint32 colour) Line 279  translate_colour(uint32 colour)
279                  case 24:                  case 24:
280                          SPLITCOLOUR24(colour, pc);                          SPLITCOLOUR24(colour, pc);
281                          break;                          break;
282                    default:
283                            /* Avoid warning */
284                            pc.red = 0;
285                            pc.green = 0;
286                            pc.blue = 0;
287                            break;
288          }          }
289          return MAKECOLOUR(pc);          return MAKECOLOUR(pc);
290  }  }
# Line 302  translate8to16(const uint8 * data, uint8 Line 336  translate8to16(const uint8 * data, uint8
336  {  {
337          uint16 value;          uint16 value;
338    
339          if (g_arch_match)          if (g_compatible_arch)
340          {          {
341                  /* *INDENT-OFF* */                  /* *INDENT-OFF* */
342                  REPEAT2                  REPEAT2
# Line 336  translate8to24(const uint8 * data, uint8 Line 370  translate8to24(const uint8 * data, uint8
370  {  {
371          uint32 value;          uint32 value;
372    
373          if (g_xserver_be)          if (g_compatible_arch)
374          {          {
375                  while (out < end)                  while (out < end)
376                  {                  {
# Line 359  translate8to32(const uint8 * data, uint8 Line 393  translate8to32(const uint8 * data, uint8
393  {  {
394          uint32 value;          uint32 value;
395    
396          if (g_arch_match)          if (g_compatible_arch)
397          {          {
398                  /* *INDENT-OFF* */                  /* *INDENT-OFF* */
399                  REPEAT4                  REPEAT4
# Line 431  translate15to24(const uint16 * data, uin Line 465  translate15to24(const uint16 * data, uin
465          uint16 pixel;          uint16 pixel;
466          PixelColour pc;          PixelColour pc;
467    
468          if (g_arch_match)          if (g_compatible_arch)
469          {          {
470                  /* *INDENT-OFF* */                  /* *INDENT-OFF* */
471                  REPEAT3                  REPEAT3
# Line 481  translate15to32(const uint16 * data, uin Line 515  translate15to32(const uint16 * data, uin
515          uint32 value;          uint32 value;
516          PixelColour pc;          PixelColour pc;
517    
518          if (g_arch_match)          if (g_compatible_arch)
519          {          {
520                  /* *INDENT-OFF* */                  /* *INDENT-OFF* */
521                  REPEAT4                  REPEAT4
# Line 589  translate16to24(const uint16 * data, uin Line 623  translate16to24(const uint16 * data, uin
623          uint16 pixel;          uint16 pixel;
624          PixelColour pc;          PixelColour pc;
625    
626          if (g_arch_match)          if (g_compatible_arch)
627          {          {
628                  /* *INDENT-OFF* */                  /* *INDENT-OFF* */
629                  REPEAT3                  REPEAT3
# Line 659  translate16to32(const uint16 * data, uin Line 693  translate16to32(const uint16 * data, uin
693          uint32 value;          uint32 value;
694          PixelColour pc;          PixelColour pc;
695    
696          if (g_arch_match)          if (g_compatible_arch)
697          {          {
698                  /* *INDENT-OFF* */                  /* *INDENT-OFF* */
699                  REPEAT4                  REPEAT4
# Line 788  translate24to32(const uint8 * data, uint Line 822  translate24to32(const uint8 * data, uint
822          uint32 value;          uint32 value;
823          PixelColour pc;          PixelColour pc;
824    
825          if (g_arch_match)          if (g_compatible_arch)
826          {          {
827                  /* *INDENT-OFF* */                  /* *INDENT-OFF* */
828  #ifdef NEED_ALIGN  #ifdef NEED_ALIGN
# Line 802  translate24to32(const uint8 * data, uint Line 836  translate24to32(const uint8 * data, uint
836  #else  #else
837                  REPEAT4                  REPEAT4
838                  (                  (
839                          *((uint32 *) out) = *((uint32 *) data);                   /* Only read 3 bytes. Reading 4 bytes means reading beyond buffer. */
840                          out += 4;                   *((uint32 *) out) = *((uint16 *) data) + (*((uint8 *) data + 2) << 16);
841                          data += 3;                   out += 4;
842                     data += 3;
843                  )                  )
844  #endif  #endif
845                  /* *INDENT-ON* */                  /* *INDENT-ON* */
# Line 842  translate_image(int width, int height, u Line 877  translate_image(int width, int height, u
877          uint8 *out;          uint8 *out;
878          uint8 *end;          uint8 *end;
879    
880          /* if server and xserver bpp match, */          /*
881          /* and arch(endian) matches, no need to translate */             If RDP depth and X Visual depths match,
882          /* just return data */             and arch(endian) matches, no need to translate:
883          if (g_arch_match)             just return data.
884               Note: select_visual should've already ensured g_no_translate
885               is only set for compatible depths, but the RDP depth might've
886               changed during connection negotiations.
887             */
888            if (g_no_translate_image)
889          {          {
890                  if (g_depth == 15 && g_server_bpp == 15)                  if ((g_depth == 15 && g_server_depth == 15) ||
891                          return data;                      (g_depth == 16 && g_server_depth == 16) ||
892                  if (g_depth == 16 && g_server_bpp == 16)                      (g_depth == 24 && g_server_depth == 24))
                         return data;  
                 if (g_depth == 24 && g_bpp == 24 && g_server_bpp == 24)  
893                          return data;                          return data;
894          }          }
895    
# Line 859  translate_image(int width, int height, u Line 897  translate_image(int width, int height, u
897          out = (uint8 *) xmalloc(size);          out = (uint8 *) xmalloc(size);
898          end = out + size;          end = out + size;
899    
900          switch (g_server_bpp)          switch (g_server_depth)
901          {          {
902                  case 24:                  case 24:
903                          switch (g_bpp)                          switch (g_bpp)
# Line 957  calculate_shifts(uint32 mask, int *shift Line 995  calculate_shifts(uint32 mask, int *shift
995          *shift_r = 8 - ffs(mask & ~(mask >> 1));          *shift_r = 8 - ffs(mask & ~(mask >> 1));
996  }  }
997    
998  BOOL  /* Given a mask of a colour channel (e.g. XVisualInfo.red_mask),
999  ui_init(void)     calculates the bits-per-pixel of this channel (a.k.a. colour weight).
1000     */
1001    static unsigned
1002    calculate_mask_weight(uint32 mask)
1003    {
1004            unsigned weight = 0;
1005            do
1006            {
1007                    weight += (mask & 1);
1008            }
1009            while (mask >>= 1);
1010            return weight;
1011    }
1012    
1013    static BOOL
1014    select_visual()
1015  {  {
         XVisualInfo vi;  
1016          XPixmapFormatValues *pfm;          XPixmapFormatValues *pfm;
1017          uint16 test;          int pixmap_formats_count, visuals_count;
         int i, screen_num, nvisuals;  
1018          XVisualInfo *vmatches = NULL;          XVisualInfo *vmatches = NULL;
1019          XVisualInfo template;          XVisualInfo template;
1020          Bool TrueColorVisual = False;          int i;
1021            unsigned red_weight, blue_weight, green_weight;
1022    
1023          g_display = XOpenDisplay(NULL);          red_weight = blue_weight = green_weight = 0;
1024          if (g_display == NULL)  
1025            pfm = XListPixmapFormats(g_display, &pixmap_formats_count);
1026            if (pfm == NULL)
1027          {          {
1028                  error("Failed to open display: %s\n", XDisplayName(NULL));                  error("Unable to get list of pixmap formats from display.\n");
1029                    XCloseDisplay(g_display);
1030                  return False;                  return False;
1031          }          }
1032    
1033          screen_num = DefaultScreen(g_display);          /* Search for best TrueColor visual */
         g_x_socket = ConnectionNumber(g_display);  
         g_screen = ScreenOfDisplay(g_display, screen_num);  
         g_depth = DefaultDepthOfScreen(g_screen);  
   
         /* Search for best TrueColor depth */  
1034          template.class = TrueColor;          template.class = TrueColor;
1035          vmatches = XGetVisualInfo(g_display, VisualClassMask, &template, &nvisuals);          vmatches = XGetVisualInfo(g_display, VisualClassMask, &template, &visuals_count);
1036            g_visual = NULL;
1037            g_no_translate_image = False;
1038            g_compatible_arch = False;
1039            if (vmatches != NULL)
1040            {
1041                    for (i = 0; i < visuals_count; ++i)
1042                    {
1043                            XVisualInfo *visual_info = &vmatches[i];
1044    
1045                            /* Try to find a no-translation visual that'll
1046                               allow us to use RDP bitmaps directly as ZPixmaps. */
1047                            if (!g_xserver_be && (((visual_info->depth == 15) &&
1048                                                   /* R5G5B5 */
1049                                                   (visual_info->red_mask == 0x7c00) &&
1050                                                   (visual_info->green_mask == 0x3e0) &&
1051                                                   (visual_info->blue_mask == 0x1f)) ||
1052                                                  ((visual_info->depth == 16) &&
1053                                                   /* R5G6B5 */
1054                                                   (visual_info->red_mask == 0xf800) &&
1055                                                   (visual_info->green_mask == 0x7e0) &&
1056                                                   (visual_info->blue_mask == 0x1f)) ||
1057                                                  ((visual_info->depth == 24) &&
1058                                                   /* R8G8B8 */
1059                                                   (visual_info->red_mask == 0xff0000) &&
1060                                                   (visual_info->green_mask == 0xff00) &&
1061                                                   (visual_info->blue_mask == 0xff))))
1062                            {
1063                                    g_visual = visual_info->visual;
1064                                    g_depth = visual_info->depth;
1065                                    g_compatible_arch = !g_host_be;
1066                                    g_no_translate_image = (visual_info->depth == g_server_depth);
1067                                    if (g_no_translate_image)
1068                                            /* We found the best visual */
1069                                            break;
1070                            }
1071                            else
1072                            {
1073                                    g_compatible_arch = False;
1074                            }
1075    
1076                            if (visual_info->depth > 24)
1077                            {
1078                                    /* Avoid 32-bit visuals and likes like the plague.
1079                                       They're either untested or proven to work bad
1080                                       (e.g. nvidia's Composite 32-bit visual).
1081                                       Most implementation offer a 24-bit visual anyway. */
1082                                    continue;
1083                            }
1084    
1085          nvisuals--;                          /* Only care for visuals, for whose BPPs (not depths!)
1086          while (nvisuals >= 0)                             we have a translateXtoY function. */
1087          {                          BOOL can_translate_to_bpp = False;
1088                  if ((vmatches + nvisuals)->depth > g_depth)                          int j;
1089                  {                          for (j = 0; j < pixmap_formats_count; ++j)
1090                          g_depth = (vmatches + nvisuals)->depth;                          {
1091                                    if (pfm[j].depth == visual_info->depth)
1092                                    {
1093                                            if ((pfm[j].bits_per_pixel == 16) ||
1094                                                (pfm[j].bits_per_pixel == 24) ||
1095                                                (pfm[j].bits_per_pixel == 32))
1096                                            {
1097                                                    can_translate_to_bpp = True;
1098                                            }
1099                                            break;
1100                                    }
1101                            }
1102    
1103                            /* Prefer formats which have the most colour depth.
1104                               We're being truly aristocratic here, minding each
1105                               weight on its own. */
1106                            if (can_translate_to_bpp)
1107                            {
1108                                    unsigned vis_red_weight =
1109                                            calculate_mask_weight(visual_info->red_mask);
1110                                    unsigned vis_green_weight =
1111                                            calculate_mask_weight(visual_info->green_mask);
1112                                    unsigned vis_blue_weight =
1113                                            calculate_mask_weight(visual_info->blue_mask);
1114                                    if ((vis_red_weight >= red_weight)
1115                                        && (vis_green_weight >= green_weight)
1116                                        && (vis_blue_weight >= blue_weight))
1117                                    {
1118                                            red_weight = vis_red_weight;
1119                                            green_weight = vis_green_weight;
1120                                            blue_weight = vis_blue_weight;
1121                                            g_visual = visual_info->visual;
1122                                            g_depth = visual_info->depth;
1123                                    }
1124                            }
1125                  }                  }
1126                  nvisuals--;                  XFree(vmatches);
                 TrueColorVisual = True;  
1127          }          }
1128    
1129          test = 1;          if (g_visual != NULL)
         g_host_be = !(BOOL) (*(uint8 *) (&test));  
         g_xserver_be = (ImageByteOrder(g_display) == MSBFirst);  
   
         if ((g_server_bpp == 8) && ((!TrueColorVisual) || (g_depth <= 8)))  
1130          {          {
1131                  /* we use a colourmap, so the default visual should do */                  g_owncolmap = False;
1132                  g_visual = DefaultVisualOfScreen(g_screen);                  calculate_shifts(g_visual->red_mask, &g_red_shift_r, &g_red_shift_l);
1133                  g_depth = DefaultDepthOfScreen(g_screen);                  calculate_shifts(g_visual->green_mask, &g_green_shift_r, &g_green_shift_l);
1134                    calculate_shifts(g_visual->blue_mask, &g_blue_shift_r, &g_blue_shift_l);
                 /* Do not allocate colours on a TrueColor visual */  
                 if (g_visual->class == TrueColor)  
                 {  
                         g_owncolmap = False;  
                 }  
1135          }          }
1136          else          else
1137          {          {
1138                  /* need a truecolour visual */                  template.class = PseudoColor;
1139                  if (!XMatchVisualInfo(g_display, screen_num, g_depth, TrueColor, &vi))                  template.depth = 8;
1140                  {                  template.colormap_size = 256;
1141                          error("The display does not support true colour - high colour support unavailable.\n");                  vmatches =
1142                            XGetVisualInfo(g_display,
1143                                           VisualClassMask | VisualDepthMask | VisualColormapSizeMask,
1144                                           &template, &visuals_count);
1145                    if (vmatches == NULL)
1146                    {
1147                            error("No usable TrueColor or PseudoColor visuals on this display.\n");
1148                            XCloseDisplay(g_display);
1149                            XFree(pfm);
1150                          return False;                          return False;
1151                  }                  }
1152    
1153                  g_visual = vi.visual;                  /* we use a colourmap, so the default visual should do */
1154                  g_owncolmap = False;                  g_owncolmap = True;
1155                  calculate_shifts(vi.red_mask, &g_red_shift_r, &g_red_shift_l);                  g_visual = vmatches[0].visual;
1156                  calculate_shifts(vi.blue_mask, &g_blue_shift_r, &g_blue_shift_l);                  g_depth = vmatches[0].depth;
1157                  calculate_shifts(vi.green_mask, &g_green_shift_r, &g_green_shift_l);          }
1158    
1159                  /* if RGB video and everything is little endian */          g_bpp = 0;
1160                  if ((vi.red_mask > vi.green_mask && vi.green_mask > vi.blue_mask) &&          for (i = 0; i < pixmap_formats_count; ++i)
1161                      !g_xserver_be && !g_host_be)          {
1162                    XPixmapFormatValues *pf = &pfm[i];
1163                    if (pf->depth == g_depth)
1164                  {                  {
1165                          if (g_depth <= 16 || (g_red_shift_l == 16 && g_green_shift_l == 8 &&                          g_bpp = pf->bits_per_pixel;
1166                                                g_blue_shift_l == 0))  
1167                            if (g_no_translate_image)
1168                          {                          {
1169                                  g_arch_match = True;                                  switch (g_server_depth)
1170                                    {
1171                                            case 15:
1172                                            case 16:
1173                                                    if (g_bpp != 16)
1174                                                            g_no_translate_image = False;
1175                                                    break;
1176                                            case 24:
1177                                                    /* Yes, this will force image translation
1178                                                       on most modern servers which use 32 bits
1179                                                       for R8G8B8. */
1180                                                    if (g_bpp != 24)
1181                                                            g_no_translate_image = False;
1182                                                    break;
1183                                            default:
1184                                                    g_no_translate_image = False;
1185                                                    break;
1186                                    }
1187                          }                          }
                 }  
1188    
1189                  if (g_arch_match)                          /* Pixmap formats list is a depth-to-bpp mapping --
1190                  {                             there's just a single entry for every depth,
1191                          DEBUG(("Architectures match, enabling little endian optimisations.\n"));                             so we can safely break here */
1192                            break;
1193                  }                  }
1194          }          }
1195            XFree(pfm);
1196            pfm = NULL;
1197            return True;
1198    }
1199    
1200    BOOL
1201    ui_init(void)
1202    {
1203            int screen_num;
1204    
1205          pfm = XListPixmapFormats(g_display, &i);          g_display = XOpenDisplay(NULL);
1206          if (pfm != NULL)          if (g_display == NULL)
1207          {          {
1208                  /* Use maximum bpp for this depth - this is generally                  error("Failed to open display: %s\n", XDisplayName(NULL));
1209                     desirable, e.g. 24 bits->32 bits. */                  return False;
                 while (i--)  
                 {  
                         if ((pfm[i].depth == g_depth) && (pfm[i].bits_per_pixel > g_bpp))  
                         {  
                                 g_bpp = pfm[i].bits_per_pixel;  
                         }  
                 }  
                 XFree(pfm);  
1210          }          }
1211    
         if (g_bpp < 8)  
1212          {          {
1213                  error("Less than 8 bpp not currently supported.\n");                  uint16 endianess_test = 1;
1214                  XCloseDisplay(g_display);                  g_host_be = !(BOOL) (*(uint8 *) (&endianess_test));
1215            }
1216    
1217            g_xserver_be = (ImageByteOrder(g_display) == MSBFirst);
1218            screen_num = DefaultScreen(g_display);
1219            g_x_socket = ConnectionNumber(g_display);
1220            g_screen = ScreenOfDisplay(g_display, screen_num);
1221            g_depth = DefaultDepthOfScreen(g_screen);
1222    
1223            if (!select_visual())
1224                  return False;                  return False;
1225    
1226            if (g_no_translate_image)
1227            {
1228                    DEBUG(("Performance optimization possible: avoiding image translation (colour depth conversion).\n"));
1229          }          }
1230    
1231            if (g_server_depth > g_bpp)
1232            {
1233                    warning("Remote desktop colour depth %d higher than display colour depth %d.\n",
1234                            g_server_depth, g_bpp);
1235            }
1236    
1237            DEBUG(("RDP depth: %d, display depth: %d, display bpp: %d, X server BE: %d, host BE: %d\n",
1238                   g_server_depth, g_depth, g_bpp, g_xserver_be, g_host_be));
1239    
1240          if (!g_owncolmap)          if (!g_owncolmap)
1241          {          {
1242                  g_xcolmap =                  g_xcolmap =
1243                          XCreateColormap(g_display, RootWindowOfScreen(g_screen), g_visual,                          XCreateColormap(g_display, RootWindowOfScreen(g_screen), g_visual,
1244                                          AllocNone);                                          AllocNone);
1245                  if (g_depth <= 8)                  if (g_depth <= 8)
1246                          warning("Screen depth is 8 bits or lower: you may want to use -C for a private colourmap\n");                          warning("Display colour depth is %d bit: you may want to use -C for a private colourmap.\n", g_depth);
1247          }          }
1248    
1249          if ((!g_ownbackstore) && (DoesBackingStore(g_screen) != Always))          if ((!g_ownbackstore) && (DoesBackingStore(g_screen) != Always))
1250          {          {
1251                  warning("External BackingStore not available, using internal\n");                  warning("External BackingStore not available. Using internal.\n");
1252                  g_ownbackstore = True;                  g_ownbackstore = True;
1253          }          }
1254    
# Line 1127  ui_init(void) Line 1299  ui_init(void)
1299    
1300          xclip_init();          xclip_init();
1301    
1302          DEBUG_RDP5(("server bpp %d client bpp %d depth %d\n", g_server_bpp, g_bpp, g_depth));          DEBUG_RDP5(("server bpp %d client bpp %d depth %d\n", g_server_depth, g_bpp, g_depth));
1303    
1304          return True;          return True;
1305  }  }
# Line 1688  ui_create_bitmap(int width, int height, Line 1860  ui_create_bitmap(int width, int height,
1860          uint8 *tdata;          uint8 *tdata;
1861          int bitmap_pad;          int bitmap_pad;
1862    
1863          if (g_server_bpp == 8)          if (g_server_depth == 8)
1864          {          {
1865                  bitmap_pad = 8;                  bitmap_pad = 8;
1866          }          }
# Line 1720  ui_paint_bitmap(int x, int y, int cx, in Line 1892  ui_paint_bitmap(int x, int y, int cx, in
1892          uint8 *tdata;          uint8 *tdata;
1893          int bitmap_pad;          int bitmap_pad;
1894    
1895          if (g_server_bpp == 8)          if (g_server_depth == 8)
1896          {          {
1897                  bitmap_pad = 8;                  bitmap_pad = 8;
1898          }          }
# Line 2445  ui_draw_text(uint8 font, uint8 flags, ui Line 2617  ui_draw_text(uint8 font, uint8 flags, ui
2617                  switch (text[i])                  switch (text[i])
2618                  {                  {
2619                          case 0xff:                          case 0xff:
2620                                    /* At least two bytes needs to follow */
2621                                  if (i + 3 > length)                                  if (i + 3 > length)
2622                                  {                                  {
2623                                          /* short command, skip */                                          warning("Skipping short 0xff command:");
2624                                            for (j = 0; j < length; j++)
2625                                                    fprintf(stderr, "%02x ", text[j]);
2626                                            fprintf(stderr, "\n");
2627                                          i = length = 0;                                          i = length = 0;
2628                                          break;                                          break;
2629                                  }                                  }
# Line 2460  ui_draw_text(uint8 font, uint8 flags, ui Line 2636  ui_draw_text(uint8 font, uint8 flags, ui
2636                                  break;                                  break;
2637    
2638                          case 0xfe:                          case 0xfe:
2639                                  if (i + 3 > length)                                  /* At least one byte needs to follow */
2640                                    if (i + 2 > length)
2641                                  {                                  {
2642                                          /* short command, skip */                                          warning("Skipping short 0xfe command:");
2643                                            for (j = 0; j < length; j++)
2644                                                    fprintf(stderr, "%02x ", text[j]);
2645                                            fprintf(stderr, "\n");
2646                                          i = length = 0;                                          i = length = 0;
2647                                          break;                                          break;
2648                                  }                                  }
2649                                  entry = cache_get_text(text[i + 1]);                                  entry = cache_get_text(text[i + 1]);
2650                                  if (entry != NULL)                                  if (entry->data != NULL)
2651                                  {                                  {
2652                                          if ((((uint8 *) (entry->data))[1] ==                                          if ((((uint8 *) (entry->data))[1] == 0)
2653                                               0) && (!(flags & TEXT2_IMPLICIT_X)))                                              && (!(flags & TEXT2_IMPLICIT_X)) && (i + 2 < length))
2654                                          {                                          {
2655                                                  if (flags & TEXT2_VERTICAL)                                                  if (flags & TEXT2_VERTICAL)
2656                                                          y += text[i + 2];                                                          y += text[i + 2];
# Line 2480  ui_draw_text(uint8 font, uint8 flags, ui Line 2660  ui_draw_text(uint8 font, uint8 flags, ui
2660                                          for (j = 0; j < entry->size; j++)                                          for (j = 0; j < entry->size; j++)
2661                                                  DO_GLYPH(((uint8 *) (entry->data)), j);                                                  DO_GLYPH(((uint8 *) (entry->data)), j);
2662                                  }                                  }
2663                                  i += 3;                                  if (i + 2 < length)
2664                                            i += 3;
2665                                    else
2666                                            i += 2;
2667                                  length -= i;                                  length -= i;
2668                                  /* this will move pointer from start to first character after FE command */                                  /* this will move pointer from start to first character after FE command */
2669                                  text = &(text[i]);                                  text = &(text[i]);

Legend:
Removed from v.1029  
changed lines
  Added in v.1049

  ViewVC Help
Powered by ViewVC 1.1.26