/[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 34 by matty, Sat Sep 15 13:03:35 2001 UTC revision 44 by matthewc, Wed Apr 10 14:07:56 2002 UTC
# Line 1  Line 1 
1  /*  /*
2     rdesktop: A Remote Desktop Protocol client.     rdesktop: A Remote Desktop Protocol client.
3     User interface services - X-Windows     User interface services - X Window System
4     Copyright (C) Matthew Chapman 1999-2001     Copyright (C) Matthew Chapman 1999-2001
5        
6     This program is free software; you can redistribute it and/or modify     This program is free software; you can redistribute it and/or modify
# Line 24  Line 24 
24  #include <errno.h>  #include <errno.h>
25  #include "rdesktop.h"  #include "rdesktop.h"
26    
27    extern char keymapname[16];
28    extern int keylayout;
29  extern int width;  extern int width;
30  extern int height;  extern int height;
31  extern BOOL sendmotion;  extern BOOL sendmotion;
# Line 149  translate_image(int width, int height, u Line 151  translate_image(int width, int height, u
151          return out;          return out;
152  }  }
153    
154  #define BSWAP16(x) x = (((x & 0xff) << 8) | (x >> 8));  #define BSWAP16(x) { x = (((x & 0xff) << 8) | (x >> 8)); }
155  #define BSWAP24(x) x = (((x & 0xff) << 16) | (x >> 16) | ((x >> 8) & 0xff00));  #define BSWAP24(x) { x = (((x & 0xff) << 16) | (x >> 16) | ((x >> 8) & 0xff00)); }
156  #define BSWAP32(x) x = (((x & 0xff00ff) << 8) | ((x >> 8) & 0xff00ff)); \  #define BSWAP32(x) { x = (((x & 0xff00ff) << 8) | ((x >> 8) & 0xff00ff)); \
157                     x = (x << 16) | (x >> 16);                          x = (x << 16) | (x >> 16); }
158    
159  static uint32  static uint32
160  translate_colour(uint32 colour)  translate_colour(uint32 colour)
# Line 280  ui_create_window(char *title) Line 282  ui_create_window(char *title)
282                  XFree(sizehints);                  XFree(sizehints);
283          }          }
284    
285            xkeymap_init(display);
286    
287          input_mask = KeyPressMask | KeyReleaseMask          input_mask = KeyPressMask | KeyReleaseMask
288                          | ButtonPressMask | ButtonReleaseMask                          | ButtonPressMask | ButtonReleaseMask
289                          | EnterWindowMask | LeaveWindowMask;                          | EnterWindowMask | LeaveWindowMask;
# Line 312  ui_destroy_window() Line 316  ui_destroy_window()
316          display = NULL;          display = NULL;
317  }  }
318    
 static uint8  
 xwin_translate_key(unsigned long key)  
 {  
         DEBUG(("KEY(code=0x%lx)\n", key));  
   
         if ((key > 8) && (key <= 0x60))  
                 return (key - 8);  
   
         switch (key)  
         {  
                 case 0x61:      /* home */  
                         return 0x47 | 0x80;  
                 case 0x62:      /* up arrow */  
                         return 0x48 | 0x80;  
                 case 0x63:      /* page up */  
                         return 0x49 | 0x80;  
                 case 0x64:      /* left arrow */  
                         return 0x4b | 0x80;  
                 case 0x66:      /* right arrow */  
                         return 0x4d | 0x80;  
                 case 0x67:      /* end */  
                         return 0x4f | 0x80;  
                 case 0x68:      /* down arrow */  
                         return 0x50 | 0x80;  
                 case 0x69:      /* page down */  
                         return 0x51 | 0x80;  
                 case 0x6a:      /* insert */  
                         return 0x52 | 0x80;  
                 case 0x6b:      /* delete */  
                         return 0x53 | 0x80;  
                 case 0x6c:      /* keypad enter */  
                         return 0x1c | 0x80;  
                 case 0x6d:      /* right ctrl */  
                         return 0x1d | 0x80;  
                 case 0x6f:      /* ctrl - print screen */  
                         return 0x37 | 0x80;  
                 case 0x70:      /* keypad '/' */  
                         return 0x35 | 0x80;  
                 case 0x71:      /* right alt */  
                         return 0x38 | 0x80;  
                 case 0x72:      /* ctrl break */  
                         return 0x46 | 0x80;  
                 case 0x73:      /* left window key */  
                         return 0xff;    /* real scancode is 5b */  
                 case 0x74:      /* right window key */  
                         return 0xff;    /* real scancode is 5c */  
                 case 0x75:      /* menu key */  
                         return 0x5d | 0x80;  
         }  
   
         return 0;  
 }  
   
 static uint16  
 xwin_translate_mouse(unsigned long button)  
 {  
         switch (button)  
         {  
                 case Button1:   /* left */  
                         return MOUSE_FLAG_BUTTON1;  
                 case Button2:   /* middle */  
                         return MOUSE_FLAG_BUTTON3;  
                 case Button3:   /* right */  
                         return MOUSE_FLAG_BUTTON2;  
         }  
   
         return 0;  
 }  
   
319  static void  static void
320  xwin_process_events()  xwin_process_events()
321  {  {
322          XEvent event;          XEvent event;
323            KeySym keysym;
324          uint8 scancode;          uint8 scancode;
325          uint16 button;          uint16 button;
326          uint32 ev_time;          uint32 ev_time;
# Line 392  xwin_process_events() Line 328  xwin_process_events()
328          if (display == NULL)          if (display == NULL)
329                  return;                  return;
330    
331          while (XCheckWindowEvent(display, wnd, ~0, &event))          while (XCheckMaskEvent(display, ~0, &event))
332          {          {
333                  ev_time = time(NULL);                  ev_time = time(NULL);
334    
335                  switch (event.type)                  switch (event.type)
336                  {                  {
337                          case KeyPress:                          case KeyPress:
338                                  scancode = xwin_translate_key(event.xkey.keycode);                                  keysym = XKeycodeToKeysym(display, event.xkey.keycode, 0);
339                                    scancode = xkeymap_translate_key(keysym, event.xkey.keycode);
340                                  if (scancode == 0)                                  if (scancode == 0)
341                                          break;                                          break;
342    
# Line 408  xwin_process_events() Line 345  xwin_process_events()
345                                  break;                                  break;
346    
347                          case KeyRelease:                          case KeyRelease:
348                                  scancode = xwin_translate_key(event.xkey.keycode);                                  keysym = XKeycodeToKeysym(display, event.xkey.keycode, 0);
349                                    scancode = xkeymap_translate_key(keysym, event.xkey.keycode);
350                                  if (scancode == 0)                                  if (scancode == 0)
351                                          break;                                          break;
352    
# Line 418  xwin_process_events() Line 356  xwin_process_events()
356                                  break;                                  break;
357    
358                          case ButtonPress:                          case ButtonPress:
359                                  button = xwin_translate_mouse(event.xbutton.button);                                  button = xkeymap_translate_button(event.xbutton.button);
360                                  if (button == 0)                                  if (button == 0)
361                                          break;                                          break;
362    
# Line 429  xwin_process_events() Line 367  xwin_process_events()
367                                  break;                                  break;
368    
369                          case ButtonRelease:                          case ButtonRelease:
370                                  button = xwin_translate_mouse(event.xbutton.button);                                  button = xkeymap_translate_button(event.xbutton.button);
371                                  if (button == 0)                                  if (button == 0)
372                                          break;                                          break;
373    
# Line 932  ui_draw_text(uint8 font, uint8 flags, in Line 870  ui_draw_text(uint8 font, uint8 flags, in
870               int bgcolour, int fgcolour, uint8 *text, uint8 length)               int bgcolour, int fgcolour, uint8 *text, uint8 length)
871  {  {
872          FONTGLYPH *glyph;          FONTGLYPH *glyph;
873          int i, offset;          short offset;
874            int i;
875    
876          SET_FOREGROUND(bgcolour);          SET_FOREGROUND(bgcolour);
877    
# Line 954  ui_draw_text(uint8 font, uint8 flags, in Line 893  ui_draw_text(uint8 font, uint8 flags, in
893                  {                  {
894                          offset = text[++i];                          offset = text[++i];
895                          if (offset & 0x80)                          if (offset & 0x80)
896                                  offset = ((offset & 0x7f) << 8) | text[++i];                          {
897                                    if (offset == 0x80)
898                                    {
899                                            /* next two bytes, little-endian */
900                                            offset = text[++i];
901                                            offset |= text[++i] << 8;
902                                    }
903                                    else
904                                    {
905                                            offset = (offset & 0x7f) << 8;
906                                            offset |= text[++i];
907                                    }
908                            }
909    
910                          if (flags & TEXT2_VERTICAL)                          if (flags & TEXT2_VERTICAL)
911                                  y += offset;                                  y += offset;
# Line 998  ui_desktop_save(uint32 offset, int x, in Line 949  ui_desktop_save(uint32 offset, int x, in
949    
950          offset *= bpp/8;          offset *= bpp/8;
951          cache_put_desktop(offset, cx, cy, image->bytes_per_line,          cache_put_desktop(offset, cx, cy, image->bytes_per_line,
952                            bpp/8, image->data);                            bpp/8, (uint8 *)image->data);
953    
954          XDestroyImage(image);          XDestroyImage(image);
955  }  }

Legend:
Removed from v.34  
changed lines
  Added in v.44

  ViewVC Help
Powered by ViewVC 1.1.26