/[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 501 by stargo, Fri Oct 17 08:23:47 2003 UTC revision 521 by stargo, Tue Oct 28 09:02:46 2003 UTC
# Line 49  static XIM g_IM; Line 49  static XIM g_IM;
49  static XIC g_IC;  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 HCURSOR g_null_cursor;
53  static Atom g_protocol_atom, g_kill_atom;  static Atom g_protocol_atom, g_kill_atom;
54  static BOOL g_focused;  static BOOL g_focused;
55  static BOOL g_mouse_in_wnd;  static BOOL g_mouse_in_wnd;
# Line 274  translate_colour(uint32 colour) Line 275  translate_colour(uint32 colour)
275                                          colour = make_colour16(split_colour24(colour));                                          colour = make_colour16(split_colour24(colour));
276                                          break;                                          break;
277                                  case 24:                                  case 24:
278                                            colour = make_colour24(split_colour24(colour));
279                                          break;                                          break;
280                                  case 32:                                  case 32:
281                                          colour = make_colour32(split_colour24(colour));                                          colour = make_colour32(split_colour24(colour));
# Line 292  translate8to8(uint8 * data, uint8 * out, Line 294  translate8to8(uint8 * data, uint8 * out,
294  }  }
295    
296  static void  static void
297  translate8to16(uint8 * data, uint16 * out, uint16 * end)  translate8to16(uint8 * data, uint8 * out, uint8 * end)
298  {  {
299            uint16 value;
300    
301          while (out < end)          while (out < end)
302                  *(out++) = (uint16) g_colmap[*(data++)];          {
303                    value = (uint16) g_colmap[*(data++)];
304                    
305                    if (g_xserver_be)
306                    {
307                            *(out++) = value >> 8;
308                            *(out++) = value;
309                    }
310                    else
311                    {
312                            *(out++) = value;
313                            *(out++) = value >> 8;
314                    }
315            }
316  }  }
317    
318  /* little endian - conversion happens when colourmap is built */  /* little endian - conversion happens when colourmap is built */
# Line 307  translate8to24(uint8 * data, uint8 * out Line 324  translate8to24(uint8 * data, uint8 * out
324          while (out < end)          while (out < end)
325          {          {
326                  value = g_colmap[*(data++)];                  value = g_colmap[*(data++)];
327                  *(out++) = value;                  
328                  *(out++) = value >> 8;                  if (g_xserver_be)
329                  *(out++) = value >> 16;                  {
330                            *(out++) = value >> 16;
331                            *(out++) = value >> 8;
332                            *(out++) = value;
333                    }
334                    else
335                    {
336                            *(out++) = value;
337                            *(out++) = value >> 8;
338                            *(out++) = value >> 16;
339                    }
340          }          }
341  }  }
342    
343  static void  static void
344  translate8to32(uint8 * data, uint32 * out, uint32 * end)  translate8to32(uint8 * data, uint8 * out, uint8 * end)
345  {  {
346            uint32 value;
347    
348          while (out < end)          while (out < end)
349                  *(out++) = g_colmap[*(data++)];          {
350                    value = g_colmap[*(data++)];
351    
352                    if (g_xserver_be)
353                    {
354                            *(out++) = value >> 24;
355                            *(out++) = value >> 16;
356                            *(out++) = value >> 8;
357                            *(out++) = value;
358                    }
359                    else
360                    {
361                            *(out++) = value;
362                            *(out++) = value >> 8;
363                            *(out++) = value >> 16;
364                            *(out++) = value >> 24;
365                    }
366            }
367  }  }
368    
369  /* todo the remaining translate function might need some big endian check ?? */  /* todo the remaining translate function might need some big endian check ?? */
# Line 334  translate15to16(uint16 * data, uint8 * o Line 380  translate15to16(uint16 * data, uint8 * o
380    
381                  if (g_host_be)                  if (g_host_be)
382                  {                  {
383                  BSWAP16(pixel)}                          BSWAP16(pixel);
384                    }
385    
386                  value = make_colour16(split_colour15(pixel));                  value = make_colour16(split_colour15(pixel));
387    
# Line 363  translate15to24(uint16 * data, uint8 * o Line 410  translate15to24(uint16 * data, uint8 * o
410    
411                  if (g_host_be)                  if (g_host_be)
412                  {                  {
413                  BSWAP16(pixel)}                          BSWAP16(pixel);
414                    }
415    
416                  value = make_colour24(split_colour15(pixel));                  value = make_colour24(split_colour15(pixel));
417                  if (g_xserver_be)                  if (g_xserver_be)
# Line 456  translate16to24(uint16 * data, uint8 * o Line 504  translate16to24(uint16 * data, uint8 * o
504    
505                  if (g_host_be)                  if (g_host_be)
506                  {                  {
507                  BSWAP16(pixel)}                          BSWAP16(pixel);
508                    }
509    
510                  value = make_colour24(split_colour16(pixel));                  value = make_colour24(split_colour16(pixel));
511    
# Line 624  translate_image(int width, int height, u Line 673  translate_image(int width, int height, u
673                                          translate8to8(data, out, end);                                          translate8to8(data, out, end);
674                                          break;                                          break;
675                                  case 16:                                  case 16:
676                                          translate8to16(data, (uint16 *) out, (uint16 *) end);                                          translate8to16(data, out, end);
677                                          break;                                          break;
678                                  case 24:                                  case 24:
679                                          translate8to24(data, out, end);                                          translate8to24(data, out, end);
680                                          break;                                          break;
681                                  case 32:                                  case 32:
682                                          translate8to32(data, (uint32 *) out, (uint32 *) end);                                          translate8to32(data, out, end);
683                                          break;                                          break;
684                          }                          }
685                          break;                          break;
# Line 704  ui_init(void) Line 753  ui_init(void)
753                  return False;                  return False;
754          }          }
755    
756          if (g_owncolmap != True)          /* private colour map code only works for 8 bpp */
757            if (g_owncolmap && (g_bpp > 8))
758                    g_owncolmap = False;
759    
760            if (!g_owncolmap)
761          {          {
762                  g_xcolmap = DefaultColormapOfScreen(g_screen);                  g_xcolmap = DefaultColormapOfScreen(g_screen);
763                  if (g_depth <= 8)                  if (g_depth <= 8)
# Line 775  ui_init(void) Line 828  ui_init(void)
828    
829          xclip_init();          xclip_init();
830    
831          /* todo take this out when high colour is done */          DEBUG_RDP5(("server bpp %d client bpp %d depth %d\n", g_server_bpp, g_bpp, g_depth));
         printf("server bpp %d client bpp %d depth %d\n", g_server_bpp, g_bpp, g_depth);  
832    
833          return True;          return True;
834  }  }
# Line 797  ui_deinit(void) Line 849  ui_deinit(void)
849          g_display = NULL;          g_display = NULL;
850  }  }
851    
852    #define NULL_POINTER_MASK       "\x80"
853    #define NULL_POINTER_DATA       "\x0\x0\x0"
854            
855  BOOL  BOOL
856  ui_create_window(void)  ui_create_window(void)
857  {  {
# Line 881  ui_create_window(void) Line 936  ui_create_window(void)
936          g_kill_atom = XInternAtom(g_display, "WM_DELETE_WINDOW", True);          g_kill_atom = XInternAtom(g_display, "WM_DELETE_WINDOW", True);
937          XSetWMProtocols(g_display, g_wnd, &g_kill_atom, 1);          XSetWMProtocols(g_display, g_wnd, &g_kill_atom, 1);
938    
939            /* create invisible 1x1 cursor to be used as null cursor */
940            g_null_cursor = ui_create_cursor(0, 0, 1, 1, NULL_POINTER_MASK, NULL_POINTER_DATA);
941    
942          return True;          return True;
943  }  }
944    
945  void  void
946  ui_destroy_window(void)  ui_destroy_window(void)
947  {  {
948            ui_destroy_cursor(g_null_cursor);
949            
950          if (g_IC != NULL)          if (g_IC != NULL)
951                  XDestroyIC(g_IC);                  XDestroyIC(g_IC);
952    
# Line 1204  ui_select(int rdp_socket) Line 1264  ui_select(int rdp_socket)
1264    
1265  #ifdef WITH_RDPSND  #ifdef WITH_RDPSND
1266                  /* FIXME: there should be an API for registering fds */                  /* FIXME: there should be an API for registering fds */
1267                  if (g_rdpsnd && g_dsp_busy)                  if (g_dsp_busy)
1268                  {                  {
1269                          FD_SET(g_dsp_fd, &wfds);                          FD_SET(g_dsp_fd, &wfds);
1270                          n = (g_dsp_fd + 1 > n) ? g_dsp_fd + 1 : n;                          n = (g_dsp_fd + 1 > n) ? g_dsp_fd + 1 : n;
# Line 1224  ui_select(int rdp_socket) Line 1284  ui_select(int rdp_socket)
1284                          return 1;                          return 1;
1285    
1286  #ifdef WITH_RDPSND  #ifdef WITH_RDPSND
1287                  if (g_rdpsnd && g_dsp_busy && FD_ISSET(g_dsp_fd, &wfds))                  if (g_dsp_busy && FD_ISSET(g_dsp_fd, &wfds))
1288                          wave_out_play();                          wave_out_play();
1289  #endif  #endif
1290          }          }
# Line 1242  ui_create_bitmap(int width, int height, Line 1302  ui_create_bitmap(int width, int height,
1302          XImage *image;          XImage *image;
1303          Pixmap bitmap;          Pixmap bitmap;
1304          uint8 *tdata;          uint8 *tdata;
1305            int bitmap_pad;
1306    
1307            if (g_server_bpp == 8)
1308            {
1309                    bitmap_pad = 8;
1310            }
1311            else
1312            {
1313                    bitmap_pad = g_bpp;
1314    
1315                    if (g_bpp == 24)
1316                            bitmap_pad = 32;
1317            }
1318    
1319          tdata = (g_owncolmap ? data : translate_image(width, height, data));          tdata = (g_owncolmap ? data : translate_image(width, height, data));
1320          bitmap = XCreatePixmap(g_display, g_wnd, width, height, g_depth);          bitmap = XCreatePixmap(g_display, g_wnd, width, height, g_depth);
1321          image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0,          image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0,
1322                               (char *) tdata, width, height, g_server_bpp == 8 ? 8 : g_bpp, 0);                               (char *) tdata, width, height, bitmap_pad, 0);
1323    
1324          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);
1325    
# Line 1261  ui_paint_bitmap(int x, int y, int cx, in Line 1334  ui_paint_bitmap(int x, int y, int cx, in
1334  {  {
1335          XImage *image;          XImage *image;
1336          uint8 *tdata;          uint8 *tdata;
1337            int bitmap_pad;
1338    
1339            if (g_server_bpp == 8)
1340            {
1341                    bitmap_pad = 8;
1342            }
1343            else
1344            {
1345                    bitmap_pad = g_bpp;
1346    
1347                    if (g_bpp == 24)
1348                            bitmap_pad = 32;
1349            }
1350    
1351          tdata = (g_owncolmap ? data : translate_image(width, height, data));          tdata = (g_owncolmap ? data : translate_image(width, height, data));
1352          image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0,          image = XCreateImage(g_display, g_visual, g_depth, ZPixmap, 0,
1353                               (char *) tdata, width, height, g_server_bpp == 8 ? 8 : g_bpp, 0);                               (char *) tdata, width, height, bitmap_pad, 0);
1354    
1355          if (g_ownbackstore)          if (g_ownbackstore)
1356          {          {
# Line 1402  ui_destroy_cursor(HCURSOR cursor) Line 1489  ui_destroy_cursor(HCURSOR cursor)
1489          XFreeCursor(g_display, (Cursor) cursor);          XFreeCursor(g_display, (Cursor) cursor);
1490  }  }
1491    
1492    void
1493    ui_set_null_cursor(void)
1494    {
1495            ui_set_cursor(g_null_cursor);
1496    }
1497    
1498  #define MAKE_XCOLOR(xc,c) \  #define MAKE_XCOLOR(xc,c) \
1499                  (xc)->red   = ((c)->red   << 8) | (c)->red; \                  (xc)->red   = ((c)->red   << 8) | (c)->red; \
1500                  (xc)->green = ((c)->green << 8) | (c)->green; \                  (xc)->green = ((c)->green << 8) | (c)->green; \

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

  ViewVC Help
Powered by ViewVC 1.1.26