/[rdesktop]/sourceforge.net/branches/seamlessrdp-branch/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/branches/seamlessrdp-branch/rdesktop/xwin.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 35 by matty, Sat Sep 15 14:01:45 2001 UTC revision 49 by mmihalik, Fri Apr 19 12:06:08 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 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 925  ui_draw_glyph(int mixmode, Line 863  ui_draw_glyph(int mixmode,
863          XSetFillStyle(display, gc, FillSolid);          XSetFillStyle(display, gc, FillSolid);
864  }  }
865    
866    #define DO_GLYPH(ttext,idx) \
867    {\
868      glyph = cache_get_font (font, ttext[idx]);\
869      if (!(flags & TEXT2_IMPLICIT_X))\
870        {\
871          xyoffset = ttext[++idx];\
872          if ((xyoffset & 0x80))\
873            {\
874              if (flags & TEXT2_VERTICAL) \
875                y += ttext[++idx] | (ttext[++idx] << 8);\
876              else\
877                x += ttext[++idx] | (ttext[++idx] << 8);\
878            }\
879          else\
880            {\
881              if (flags & TEXT2_VERTICAL) \
882                y += xyoffset;\
883              else\
884                x += xyoffset;\
885            }\
886        }\
887      if (glyph != NULL)\
888        {\
889          ui_draw_glyph (mixmode, x + (short) glyph->offset,\
890                         y + (short) glyph->baseline,\
891                         glyph->width, glyph->height,\
892                         glyph->pixmap, 0, 0, bgcolour, fgcolour);\
893          if (flags & TEXT2_IMPLICIT_X)\
894            x += glyph->width;\
895        }\
896    }
897    
898  void  void
899  ui_draw_text(uint8 font, uint8 flags, int mixmode, int x, int y,  ui_draw_text(uint8 font, uint8 flags, int mixmode, int x, int y,
900               int clipx, int clipy, int clipcx, int clipcy,               int clipx, int clipy, int clipcx, int clipcy, int boxx,
901               int boxx, int boxy, int boxcx, int boxcy,               int boxy, int boxcx, int boxcy, int bgcolour,
902               int bgcolour, int fgcolour, uint8 *text, uint8 length)               int fgcolour, uint8 * text, uint8 length)
903  {  {
904          FONTGLYPH *glyph;          FONTGLYPH *glyph;
905          int i, offset;          int i, j, xyoffset;
906            DATABLOB *entry;
907    
908          SET_FOREGROUND(bgcolour);          SET_FOREGROUND(bgcolour);
909    
# Line 946  ui_draw_text(uint8 font, uint8 flags, in Line 917  ui_draw_text(uint8 font, uint8 flags, in
917          }          }
918    
919          /* Paint text, character by character */          /* Paint text, character by character */
920          for (i = 0; i < length; i++)          for (i = 0; i < length;) {
921          {                  switch (text[i]) {
922                  glyph = cache_get_font(font, text[i]);                  case 0xff:
923                            if (i + 2 < length)
924                                    cache_put_text(text[i + 1], text, text[i + 2]);
925                            else {
926                                    error("this shouldn't be happening\n");
927                                    break;
928                            }
929                            /* this will move pointer from start to first character after FF command */
930                            length -= i + 3;
931                            text = &(text[i + 3]);
932                            i = 0;
933                            break;
934    
935                  if (!(flags & TEXT2_IMPLICIT_X))                  case 0xfe:
936                  {                          entry = cache_get_text(text[i + 1]);
937                          offset = text[++i];                          if (entry != NULL) {
938                          if (offset & 0x80)                                  if ((((uint8 *) (entry->data))[1] == 0)
939                                  offset = ((offset & 0x7f) << 8) | text[++i];                                      && (!(flags & TEXT2_IMPLICIT_X))) {
940                                            if (flags & TEXT2_VERTICAL)      
941                                                    y += text[i + 2];
942                                            else
943                                                    x += text[i + 2];
944                                    }
945                                    if (i + 2 < length)
946                                            i += 3;
947                                    else
948                                            i += 2;
949                                    length -= i;  
950                                    /* this will move pointer from start to first character after FE command */
951                                    text = &(text[i]);
952                                    i = 0;
953                                    for (j = 0; j < entry->size; j++)
954                                            DO_GLYPH(((uint8 *) (entry->data)), j);
955                            }
956                            break;
957    
958                          if (flags & TEXT2_VERTICAL)                  default:
959                                  y += offset;                          DO_GLYPH(text, i);
960                          else                          i++;
961                                  x += offset;                          break;
962                  }                  }
963            }
964    
                 if (glyph != NULL)  
                 {  
                         ui_draw_glyph(mixmode, x + (short) glyph->offset,  
                                       y + (short) glyph->baseline,  
                                       glyph->width, glyph->height,  
                                       glyph->pixmap, 0, 0,  
                                       bgcolour, fgcolour);  
965    
                         if (flags & TEXT2_IMPLICIT_X)  
                                 x += glyph->width;  
                 }  
         }  
966  }  }
967    
968  void  void
# Line 998  ui_desktop_save(uint32 offset, int x, in Line 987  ui_desktop_save(uint32 offset, int x, in
987    
988          offset *= bpp/8;          offset *= bpp/8;
989          cache_put_desktop(offset, cx, cy, image->bytes_per_line,          cache_put_desktop(offset, cx, cy, image->bytes_per_line,
990                            bpp/8, image->data);                            bpp/8, (uint8 *)image->data);
991    
992          XDestroyImage(image);          XDestroyImage(image);
993  }  }

Legend:
Removed from v.35  
changed lines
  Added in v.49

  ViewVC Help
Powered by ViewVC 1.1.26