/[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 101 by astrand, Mon Aug 26 17:12:43 2002 UTC revision 119 by astrand, Thu Sep 12 09:38:31 2002 UTC
# Line 248  close_inputmethod(void) Line 248  close_inputmethod(void)
248  }  }
249    
250  BOOL  BOOL
251    get_key_state(int keysym)
252    {
253            int keysymMask = 0, modifierpos, key;
254            Window wDummy1, wDummy2;
255            int iDummy3, iDummy4, iDummy5, iDummy6;
256            unsigned int current_state;
257            int offset;
258    
259            XModifierKeymap *map = XGetModifierMapping(display);
260            KeyCode keycode = XKeysymToKeycode(display, keysym);
261    
262            if (keycode == NoSymbol)
263                    return False;
264    
265            for (modifierpos = 0; modifierpos < 8; modifierpos++)
266            {
267                    offset = map->max_keypermod * modifierpos;
268    
269                    for (key = 0; key < map->max_keypermod; key++)
270                    {
271                            if (map->modifiermap[offset + key] == keycode)
272                                    keysymMask = 1 << modifierpos;
273                    }
274            }
275    
276            XQueryPointer(display, DefaultRootWindow(display), &wDummy1,
277                          &wDummy2, &iDummy3, &iDummy4, &iDummy5, &iDummy6, &current_state);
278    
279            XFreeModifiermap(map);
280    
281            return (current_state & keysymMask) ? True : False;
282    }
283    
284    
285    BOOL
286  ui_init()  ui_init()
287  {  {
288          Screen *screen;          Screen *screen;
# Line 266  ui_init() Line 301  ui_init()
301          return True;          return True;
302  }  }
303    
304  BOOL  void
305  ui_create_window_obj(int xpos, int ypos, int width, int height, int valuemask)  ui_create_window_obj(int xpos, int ypos, int width, int height, int valuemask)
306  {  {
307          XClassHint *classhints;          XClassHint *classhints;
# Line 394  ui_create_window() Line 429  ui_create_window()
429                  attribs.override_redirect = False;                  attribs.override_redirect = False;
430          }          }
431    
         width = (width + 3) & ~3;       /* make width a multiple of 32 bits */  
   
   
432          input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |          input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
433                  VisibilityChangeMask | FocusChangeMask;                  VisibilityChangeMask | FocusChangeMask;
434    
# Line 485  toggle_fullscreen() Line 517  toggle_fullscreen()
517          XFreePixmap(display, pixmap);          XFreePixmap(display, pixmap);
518  }  }
519    
520    /* Process all events in Xlib queue */
521  static void  static void
522  xwin_process_events()  xwin_process_events()
523  {  {
# Line 498  xwin_process_events() Line 531  xwin_process_events()
531          char str[256];          char str[256];
532          Status status;          Status status;
533    
         /* Refresh keyboard mapping if it has changed. This is important for  
            Xvnc, since it allocates keycodes dynamically */  
         if (XCheckTypedEvent(display, MappingNotify, &xevent))  
         {  
                 if (xevent.xmapping.request == MappingKeyboard  
                     || xevent.xmapping.request == MappingModifier)  
                         XRefreshKeyboardMapping(&xevent.xmapping);  
         }  
   
534          while (XCheckMaskEvent(display, ~0, &xevent))          while (XCheckMaskEvent(display, ~0, &xevent))
535          {          {
536                  if (enable_compose && (XFilterEvent(&xevent, None) == True))                  if (enable_compose && (XFilterEvent(&xevent, None) == True))
# Line 542  xwin_process_events() Line 566  xwin_process_events()
566                                                        str, sizeof(str), &keysym, NULL);                                                        str, sizeof(str), &keysym, NULL);
567                                  }                                  }
568    
                                 /* FIXME needs alt modifier */  
                                 if (keysym == XK_Break) /* toggle full screen */  
                                 {  
                                         toggle_fullscreen();  
                                         break;  
                                 }  
569                                  ksname = get_ksname(keysym);                                  ksname = get_ksname(keysym);
570                                  DEBUG_KBD(("\nKeyPress for (keysym 0x%lx, %s)\n", keysym, ksname));                                  DEBUG_KBD(("\nKeyPress for (keysym 0x%lx, %s)\n", keysym, ksname));
571    
572                                  if (inhibit_key(keysym))                                  if (handle_special_keys(keysym, ev_time, True))
                                 {  
                                         DEBUG_KBD(("Inhibiting key\n"));  
573                                          break;                                          break;
                                 }  
574    
575                                  tr = xkeymap_translate_key(keysym,                                  tr = xkeymap_translate_key(keysym,
576                                                             xevent.xkey.keycode, xevent.xkey.state);                                                             xevent.xkey.keycode, xevent.xkey.state);
577    
                                 ensure_remote_modifiers(ev_time, tr);  
   
578                                  if (tr.scancode == 0)                                  if (tr.scancode == 0)
579                                          break;                                          break;
580    
581                                    ensure_remote_modifiers(ev_time, tr);
582    
583                                  rdp_send_scancode(ev_time, RDP_KEYPRESS, tr.scancode);                                  rdp_send_scancode(ev_time, RDP_KEYPRESS, tr.scancode);
584                                  break;                                  break;
585                          case KeyRelease:                          case KeyRelease:
# Line 575  xwin_process_events() Line 590  xwin_process_events()
590                                  DEBUG_KBD(("\nKeyRelease for (keysym 0x%lx, %s)\n", keysym,                                  DEBUG_KBD(("\nKeyRelease for (keysym 0x%lx, %s)\n", keysym,
591                                             ksname));                                             ksname));
592    
593                                  if (inhibit_key(keysym))                                  if (handle_special_keys(keysym, ev_time, False))
594                                          break;                                          break;
595    
596                                  tr = xkeymap_translate_key(keysym,                                  tr = xkeymap_translate_key(keysym,
# Line 628  xwin_process_events() Line 643  xwin_process_events()
643                                            xevent.xexpose.height,                                            xevent.xexpose.height,
644                                            xevent.xexpose.x, xevent.xexpose.y);                                            xevent.xexpose.x, xevent.xexpose.y);
645                                  break;                                  break;
646    
647                            case MappingNotify:
648                                    /* Refresh keyboard mapping if it has changed. This is important for
649                                       Xvnc, since it allocates keycodes dynamically */
650                                    if (xevent.xmapping.request == MappingKeyboard
651                                        || xevent.xmapping.request == MappingModifier)
652                                            XRefreshKeyboardMapping(&xevent.xmapping);
653                                    break;
654    
655                  }                  }
656          }          }
657  }  }
# Line 637  ui_select(int rdp_socket) Line 661  ui_select(int rdp_socket)
661  {  {
662          int n = (rdp_socket > x_socket) ? rdp_socket + 1 : x_socket + 1;          int n = (rdp_socket > x_socket) ? rdp_socket + 1 : x_socket + 1;
663          fd_set rfds;          fd_set rfds;
664            XEvent xevent;
665    
666          FD_ZERO(&rfds);          FD_ZERO(&rfds);
667    
668          while (True)          while (True)
669          {          {
670                    /* Process any events already in queue */
671                    xwin_process_events();
672    
673                  FD_ZERO(&rfds);                  FD_ZERO(&rfds);
674                  FD_SET(rdp_socket, &rfds);                  FD_SET(rdp_socket, &rfds);
675                  if (display != NULL)                  if (display != NULL)
# Line 660  ui_select(int rdp_socket) Line 688  ui_select(int rdp_socket)
688                  }                  }
689    
690                  if (FD_ISSET(x_socket, &rfds))                  if (FD_ISSET(x_socket, &rfds))
691                          xwin_process_events();                  {
692                            /* Move new events from socket to queue */
693                            XPeekEvent(display, &xevent);
694                            continue;
695                    }
696    
697                  if (FD_ISSET(rdp_socket, &rfds))                  if (FD_ISSET(rdp_socket, &rfds))
698                          return;                          return;

Legend:
Removed from v.101  
changed lines
  Added in v.119

  ViewVC Help
Powered by ViewVC 1.1.26