/[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 478 by matthewc, Sun Oct 5 12:07:56 2003 UTC revision 500 by astrand, Wed Oct 15 14:32:43 2003 UTC
# Line 34  extern BOOL g_hide_decorations; Line 34  extern BOOL g_hide_decorations;
34  extern char g_title[];  extern char g_title[];
35  extern int g_server_bpp;  extern int g_server_bpp;
36  extern int g_win_button_size;  extern int g_win_button_size;
 BOOL g_enable_compose = False;  
 BOOL g_focused;  
 BOOL g_mouse_in_wnd;  
37    
38  Display *g_display;  Display *g_display;
39  Time g_last_gesturetime;  Time g_last_gesturetime;
40  static int g_x_socket;  static int g_x_socket;
41  static Screen *g_screen;  static Screen *g_screen;
42  Window g_wnd;  Window g_wnd;
43    BOOL g_enable_compose = False;
44  static GC g_gc;  static GC g_gc;
45  static Visual *g_visual;  static Visual *g_visual;
46  static int g_depth;  static int g_depth;
# Line 52  static XIC g_IC; Line 50  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 Atom g_protocol_atom, g_kill_atom;  static Atom g_protocol_atom, g_kill_atom;
53    static BOOL g_focused;
54    static BOOL g_mouse_in_wnd;
55    
56  /* endianness */  /* endianness */
57  static BOOL g_host_be;  static BOOL g_host_be;
# Line 280  translate_colour(uint32 colour) Line 280  translate_colour(uint32 colour)
280                          }                          }
281                          break;                          break;
282          }          }
         switch (g_bpp)  
         {  
                 case 16:  
                         if (g_host_be != g_xserver_be)  
                                 BSWAP16(colour);  
                         break;  
   
                 case 24:  
                         if (g_xserver_be)  
                                 BSWAP24(colour);  
                         break;  
   
                 case 32:  
                         if (g_host_be != g_xserver_be)  
                                 BSWAP32(colour);  
                         break;  
         }  
   
283          return colour;          return colour;
284  }  }
285    
# Line 340  translate8to32(uint8 * data, uint32 * ou Line 322  translate8to32(uint8 * data, uint32 * ou
322  /* todo the remaining translate function might need some big endian check ?? */  /* todo the remaining translate function might need some big endian check ?? */
323    
324  static void  static void
325  translate15to16(uint16 * data, uint16 * out, uint16 * end)  translate15to16(uint16 * data, uint8 * out, uint8 * end)
326  {  {
327            uint16 pixel;
328            uint16 value;
329    
330          while (out < end)          while (out < end)
331                  *(out++) = (uint16) make_colour16(split_colour15(*(data++)));          {
332                    pixel = *(data++);
333    
334                    if (g_host_be)
335                    {
336                    BSWAP16(pixel)}
337    
338                    value = make_colour16(split_colour15(pixel));
339    
340                    if (g_xserver_be)
341                    {
342                            *(out++) = value >> 8;
343                            *(out++) = value;
344                    }
345                    else
346                    {
347                            *(out++) = value;
348                            *(out++) = value >> 8;
349                    }
350            }
351  }  }
352    
353  static void  static void
354  translate15to24(uint16 * data, uint8 * out, uint8 * end)  translate15to24(uint16 * data, uint8 * out, uint8 * end)
355  {  {
356          uint32 value;          uint32 value;
357            uint16 pixel;
358    
359          while (out < end)          while (out < end)
360          {          {
361                  value = make_colour24(split_colour15(*(data++)));                  pixel = *(data++);
362                  *(out++) = value;  
363                  *(out++) = value >> 8;                  if (g_host_be)
364                  *(out++) = value >> 16;                  {
365                    BSWAP16(pixel)}
366    
367                    value = make_colour24(split_colour15(pixel));
368                    if (g_xserver_be)
369                    {
370                            *(out++) = value >> 16;
371                            *(out++) = value >> 8;
372                            *(out++) = value;
373                    }
374                    else
375                    {
376                            *(out++) = value;
377                            *(out++) = value >> 8;
378                            *(out++) = value >> 16;
379                    }
380          }          }
381  }  }
382    
383  static void  static void
384  translate15to32(uint16 * data, uint32 * out, uint32 * end)  translate15to32(uint16 * data, uint8 * out, uint8 * end)
385  {  {
386          uint16 pixel;          uint16 pixel;
387            uint32 value;
388    
389          while (out < end)          while (out < end)
390          {          {
391                    pixel = *(data++);
392    
393                  if (g_host_be)                  if (g_host_be)
394                  {                  {
395                          pixel = *(data++);                          BSWAP16(pixel);
396                          pixel = (pixel & 0xff) << 8 | (pixel & 0xff00) >> 8;                  }
397                          *(out++) = make_colour32(split_colour15(pixel));  
398                    value = make_colour32(split_colour15(pixel));
399    
400                    if (g_xserver_be)
401                    {
402                            *(out++) = value >> 24;
403                            *(out++) = value >> 16;
404                            *(out++) = value >> 8;
405                            *(out++) = value;
406                  }                  }
407                  else                  else
408                  {                  {
409                          *(out++) = make_colour32(split_colour15(*(data++)));                          *(out++) = value;
410                            *(out++) = value >> 8;
411                            *(out++) = value >> 16;
412                            *(out++) = value >> 24;
413                  }                  }
414          }          }
415  }  }
# Line 383  translate15to32(uint16 * data, uint32 * Line 417  translate15to32(uint16 * data, uint32 *
417  static void  static void
418  translate16to16(uint16 * data, uint16 * out, uint16 * end)  translate16to16(uint16 * data, uint16 * out, uint16 * end)
419  {  {
420          while (out < end)          uint16 value;
421                  *(out++) = (uint16) (*(data++));  
422            if (g_xserver_be)
423            {
424                    while (out < end)
425                    {
426                            value = *data;
427                            BSWAP16(value);
428                            *out = value;
429                            data++;
430                            out++;
431                    }
432    
433            }
434            else
435            {
436                    while (out < end)
437                    {
438                            *out = *data;
439                            out++;
440                            data++;
441                    }
442            }
443  }  }
444    
445    
# Line 392  static void Line 447  static void
447  translate16to24(uint16 * data, uint8 * out, uint8 * end)  translate16to24(uint16 * data, uint8 * out, uint8 * end)
448  {  {
449          uint32 value;          uint32 value;
450            uint16 pixel;
451    
452          while (out < end)          while (out < end)
453          {          {
454                  value = make_colour24(split_colour16(*(data++)));                  pixel = *(data++);
455                  *(out++) = value;  
456                  *(out++) = value >> 8;                  if (g_host_be)
457                  *(out++) = value >> 16;                  {
458                    BSWAP16(pixel)}
459    
460                    value = make_colour24(split_colour16(pixel));
461    
462                    if (g_xserver_be)
463                    {
464                            *(out++) = value >> 16;
465                            *(out++) = value >> 8;
466                            *(out++) = value;
467                    }
468                    else
469                    {
470                            *(out++) = value;
471                            *(out++) = value >> 8;
472                            *(out++) = value >> 16;
473                    }
474          }          }
475  }  }
476    
477  static void  static void
478  translate16to32(uint16 * data, uint32 * out, uint32 * end)  translate16to32(uint16 * data, uint8 * out, uint8 * end)
479  {  {
480          uint16 pixel;          uint16 pixel;
481            uint32 value;
482    
483          while (out < end)          while (out < end)
484          {          {
485                    pixel = *(data++);
486    
487                  if (g_host_be)                  if (g_host_be)
488                  {                  {
489                          pixel = *(data++);                  BSWAP16(pixel)}
490                          pixel = (pixel & 0xff) << 8 | (pixel & 0xff00) >> 8;  
491                          *(out++) = make_colour32(split_colour16(pixel));                  value = make_colour32(split_colour16(pixel));
492    
493                    if (g_xserver_be)
494                    {
495                            *(out++) = value >> 24;
496                            *(out++) = value >> 16;
497                            *(out++) = value >> 8;
498                            *(out++) = value;
499                  }                  }
500                  else                  else
501                  {                  {
502                          *(out++) = make_colour32(split_colour16(*(data++)));                          *(out++) = value;
503                            *(out++) = value >> 8;
504                            *(out++) = value >> 16;
505                            *(out++) = value >> 24;
506                  }                  }
507          }          }
508  }  }
509    
510  static void  static void
511  translate24to16(uint8 * data, uint16 * out, uint16 * end)  translate24to16(uint8 * data, uint8 * out, uint8 * end)
512  {  {
513          uint32 pixel = 0;          uint32 pixel = 0;
514            uint16 value;
515          while (out < end)          while (out < end)
516          {          {
517                  pixel = *(data++) << 16;                  pixel = *(data++) << 16;
518                  pixel |= *(data++) << 8;                  pixel |= *(data++) << 8;
519                  pixel |= *(data++);                  pixel |= *(data++);
520                  *(out++) = (uint16) make_colour16(split_colour24(pixel));  
521                    value = (uint16) make_colour16(split_colour24(pixel));
522    
523                    if (g_xserver_be)
524                    {
525                            *(out++) = value >> 8;
526                            *(out++) = value;
527                    }
528                    else
529                    {
530                            *(out++) = value;
531                            *(out++) = value >> 8;
532                    }
533          }          }
534  }  }
535    
# Line 445  translate24to24(uint8 * data, uint8 * ou Line 543  translate24to24(uint8 * data, uint8 * ou
543  }  }
544    
545  static void  static void
546  translate24to32(uint8 * data, uint32 * out, uint32 * end)  translate24to32(uint8 * data, uint8 * out, uint8 * end)
547  {  {
         uint32 pixel = 0;  
548          while (out < end)          while (out < end)
549          {          {
550                  if (g_host_be)                  if (g_xserver_be)
551                  {                  {
552                          pixel = *(data++) << 16;                          *(out++) = 0x00;
553                          pixel |= *(data++) << 8;                          *(out++) = *(data++);
554                          pixel |= *(data++);                          *(out++) = *(data++);
555                            *(out++) = *(data++);
556                  }                  }
557                  else                  else
558                  {                  {
559                          pixel = *(data++);                          *(out++) = *(data++);
560                          pixel |= *(data++) << 8;                          *(out++) = *(data++);
561                          pixel |= *(data++) << 16;                          *(out++) = *(data++);
562                            *(out++) = 0x00;
563                  }                  }
                 *(out++) = pixel;  
564          }          }
565  }  }
566    
# Line 479  translate_image(int width, int height, u Line 577  translate_image(int width, int height, u
577                          switch (g_bpp)                          switch (g_bpp)
578                          {                          {
579                                  case 32:                                  case 32:
580                                          translate24to32(data, (uint32 *) out, (uint32 *) end);                                          translate24to32(data, out, end);
581                                          break;                                          break;
582                                  case 24:                                  case 24:
583                                          translate24to24(data, out, end);                                          translate24to24(data, out, end);
584                                          break;                                          break;
585                                  case 16:                                  case 16:
586                                          translate24to16(data, (uint16 *) out, (uint16 *) end);                                          translate24to16(data, out, end);
587                                          break;                                          break;
588                          }                          }
589                          break;                          break;
# Line 493  translate_image(int width, int height, u Line 591  translate_image(int width, int height, u
591                          switch (g_bpp)                          switch (g_bpp)
592                          {                          {
593                                  case 32:                                  case 32:
594                                          translate16to32((uint16 *) data, (uint32 *) out,                                          translate16to32((uint16 *) data, out, end);
                                                         (uint32 *) end);  
595                                          break;                                          break;
596                                  case 24:                                  case 24:
597                                          translate16to24((uint16 *) data, out, end);                                          translate16to24((uint16 *) data, out, end);
# Line 509  translate_image(int width, int height, u Line 606  translate_image(int width, int height, u
606                          switch (g_bpp)                          switch (g_bpp)
607                          {                          {
608                                  case 32:                                  case 32:
609                                          translate15to32((uint16 *) data, (uint32 *) out,                                          translate15to32((uint16 *) data, out, end);
                                                         (uint32 *) end);  
610                                          break;                                          break;
611                                  case 24:                                  case 24:
612                                          translate15to24((uint16 *) data, out, end);                                          translate15to24((uint16 *) data, out, end);
613                                          break;                                          break;
614                                  case 16:                                  case 16:
615                                          translate15to16((uint16 *) data, (uint16 *) out,                                          translate15to16((uint16 *) data, out, end);
                                                         (uint16 *) end);  
616                                          break;                                          break;
617                          }                          }
618                          break;                          break;
# Line 624  ui_init(void) Line 719  ui_init(void)
719          g_host_be = !(BOOL) (*(uint8 *) (&test));          g_host_be = !(BOOL) (*(uint8 *) (&test));
720          g_xserver_be = (ImageByteOrder(g_display) == MSBFirst);          g_xserver_be = (ImageByteOrder(g_display) == MSBFirst);
721    
722          if ((g_width == 0) || (g_height == 0))          /*
723             * Determine desktop size
724             */
725            if (g_width < 0)
726            {
727                    /* Percent of screen */
728                    g_height = HeightOfScreen(g_screen) * (-g_width) / 100;
729                    g_width = WidthOfScreen(g_screen) * (-g_width) / 100;
730            }
731            else if (g_width == 0)
732          {          {
733                  /* Fetch geometry from _NET_WORKAREA */                  /* Fetch geometry from _NET_WORKAREA */
734                  uint32 x, y, cx, cy;                  uint32 x, y, cx, cy;
# Line 641  ui_init(void) Line 745  ui_init(void)
745                          g_height = 600;                          g_height = 600;
746                  }                  }
747          }          }
748            else if (g_fullscreen)
         if (g_fullscreen)  
749          {          {
750                  g_width = WidthOfScreen(g_screen);                  g_width = WidthOfScreen(g_screen);
751                  g_height = HeightOfScreen(g_screen);                  g_height = HeightOfScreen(g_screen);
# Line 664  ui_init(void) Line 767  ui_init(void)
767    
768          g_mod_map = XGetModifierMapping(g_display);          g_mod_map = XGetModifierMapping(g_display);
769    
770            xkeymap_init();
771    
772          if (g_enable_compose)          if (g_enable_compose)
773                  g_IM = XOpenIM(g_display, NULL, NULL, NULL);                  g_IM = XOpenIM(g_display, NULL, NULL, NULL);
774    
         xkeymap_init();  
775          xclip_init();          xclip_init();
776    
777          /* todo take this out when high colour is done */          /* todo take this out when high colour is done */
# Line 1103  ui_select(int rdp_socket) Line 1207  ui_select(int rdp_socket)
1207                  {                  {
1208                          FD_SET(g_dsp_fd, &wfds);                          FD_SET(g_dsp_fd, &wfds);
1209                          n = (g_dsp_fd + 1 > n) ? g_dsp_fd + 1 : n;                          n = (g_dsp_fd + 1 > n) ? g_dsp_fd + 1 : n;
1210                  }                  }
1211  #endif  #endif
1212    
1213                  switch (select(n, &rfds, &wfds, NULL, NULL))                  switch (select(n, &rfds, &wfds, NULL, NULL))
# Line 1497  ui_patblt(uint8 opcode, Line 1601  ui_patblt(uint8 opcode,
1601                  case 2: /* Hatch */                  case 2: /* Hatch */
1602                          fill = (Pixmap) ui_create_glyph(8, 8,                          fill = (Pixmap) ui_create_glyph(8, 8,
1603                                                          hatch_patterns + brush->pattern[0] * 8);                                                          hatch_patterns + brush->pattern[0] * 8);
1604                          SET_FOREGROUND(bgcolour);                          SET_FOREGROUND(fgcolour);
1605                          SET_BACKGROUND(fgcolour);                          SET_BACKGROUND(bgcolour);
1606                          XSetFillStyle(g_display, g_gc, FillOpaqueStippled);                          XSetFillStyle(g_display, g_gc, FillOpaqueStippled);
1607                          XSetStipple(g_display, g_gc, fill);                          XSetStipple(g_display, g_gc, fill);
1608                          XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);                          XSetTSOrigin(g_display, g_gc, brush->xorigin, brush->yorigin);

Legend:
Removed from v.478  
changed lines
  Added in v.500

  ViewVC Help
Powered by ViewVC 1.1.26