/[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 203 by matthewc, Thu Sep 26 14:04:30 2002 UTC revision 257 by jsorg71, Mon Nov 11 23:15:27 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 Window System     User interface services - X Window System
4     Copyright (C) Matthew Chapman 1999-2001     Copyright (C) Matthew Chapman 1999-2002
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
7     it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
# Line 31  extern BOOL fullscreen; Line 31  extern BOOL fullscreen;
31  extern BOOL grab_keyboard;  extern BOOL grab_keyboard;
32  extern char title[];  extern char title[];
33  BOOL enable_compose = False;  BOOL enable_compose = False;
34    BOOL focused;
35    BOOL mouse_in_wnd;
36    
37  Display *display;  Display *display;
38  static int x_socket;  static int x_socket;
# Line 184  translate_colour(uint32 colour) Line 186  translate_colour(uint32 colour)
186  }  }
187    
188  BOOL  BOOL
189  get_key_state(uint32 keysym, unsigned int state)  get_key_state(unsigned int state, uint32 keysym)
190  {  {
191          int modifierpos, key, keysymMask = 0;          int modifierpos, key, keysymMask = 0;
192          int offset;          int offset;
# Line 218  ui_init(void) Line 220  ui_init(void)
220          display = XOpenDisplay(NULL);          display = XOpenDisplay(NULL);
221          if (display == NULL)          if (display == NULL)
222          {          {
223                  error("Failed to open display\n");                  error("Failed to open display: %s\n", XDisplayName(NULL));
224                  return False;                  return False;
225          }          }
226    
# Line 293  ui_deinit(void) Line 295  ui_deinit(void)
295          if (IM != NULL)          if (IM != NULL)
296                  XCloseIM(IM);                  XCloseIM(IM);
297    
298          XFreeModifierMap(mod_map);          XFreeModifiermap(mod_map);
299    
300          if (ownbackstore)          if (ownbackstore)
301                  XFreePixmap(display, backstore);                  XFreePixmap(display, backstore);
# Line 345  ui_create_window(void) Line 347  ui_create_window(void)
347          }          }
348    
349          input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |          input_mask = KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
350                  StructureNotifyMask | FocusChangeMask;                  VisibilityChangeMask | FocusChangeMask;
351    
352          if (sendmotion)          if (sendmotion)
353                  input_mask |= PointerMotionMask;                  input_mask |= PointerMotionMask;
354          if (ownbackstore)          if (ownbackstore)
355                  input_mask |= ExposureMask;                  input_mask |= ExposureMask;
356            if (fullscreen || grab_keyboard)
357                    input_mask |= EnterWindowMask;
358            if (grab_keyboard)
359                    input_mask |= LeaveWindowMask;
360    
361          if (IM != NULL)          if (IM != NULL)
362          {          {
# Line 365  ui_create_window(void) Line 371  ui_create_window(void)
371          XSelectInput(display, wnd, input_mask);          XSelectInput(display, wnd, input_mask);
372          XMapWindow(display, wnd);          XMapWindow(display, wnd);
373    
374          /* wait for MapNotify */          /* wait for VisibilityNotify */
375          do          do
376          {          {
377                  XMaskEvent(display, StructureNotifyMask, &xevent);                  XMaskEvent(display, VisibilityChangeMask, &xevent);
378          }          }
379          while (xevent.type != MapNotify);          while (xevent.type != VisibilityNotify);
380    
381          if (fullscreen)          focused = False;
382                  XSetInputFocus(display, wnd, RevertToPointerRoot, CurrentTime);          mouse_in_wnd = False;
383    
384          return True;          return True;
385  }  }
# Line 519  xwin_process_events(void) Line 525  xwin_process_events(void)
525                                  break;                                  break;
526    
527                          case FocusIn:                          case FocusIn:
528                                    if (xevent.xfocus.mode == NotifyGrab)
529                                            break;
530                                    focused = True;
531                                  XQueryPointer(display, wnd, &wdummy, &wdummy, &dummy, &dummy, &dummy, &dummy, &state);                                  XQueryPointer(display, wnd, &wdummy, &wdummy, &dummy, &dummy, &dummy, &dummy, &state);
532                                  reset_modifier_keys(state);                                  reset_modifier_keys(state);
533                                  if (grab_keyboard)                                  if (grab_keyboard && mouse_in_wnd)
534                                          XGrabKeyboard(display, wnd, True,                                          XGrabKeyboard(display, wnd, True,
535                                                        GrabModeAsync, GrabModeAsync, CurrentTime);                                                        GrabModeAsync, GrabModeAsync, CurrentTime);
536                                  break;                                  break;
537    
538                          case FocusOut:                          case FocusOut:
539                                    if (xevent.xfocus.mode == NotifyUngrab)
540                                            break;
541                                    focused = False;
542                                  if (xevent.xfocus.mode == NotifyWhileGrabbed)                                  if (xevent.xfocus.mode == NotifyWhileGrabbed)
543                                          XUngrabKeyboard(display, CurrentTime);                                          XUngrabKeyboard(display, CurrentTime);
544                                  break;                                  break;
545    
546                            case EnterNotify:
547                                    /* we only register for this event when in fullscreen mode */
548                                    /* or grab_keyboard */
549                                    mouse_in_wnd = True;
550                                    if (fullscreen)
551                                    {
552                                            XSetInputFocus(display, wnd, RevertToPointerRoot, CurrentTime);
553                                            break;
554                                    }
555                                    if (focused)
556                                            XGrabKeyboard(display, wnd, True,
557                                                          GrabModeAsync, GrabModeAsync, CurrentTime);
558                                    break;
559    
560                            case LeaveNotify:
561                                    /* we only register for this event when grab_keyboard */
562                                    mouse_in_wnd = False;
563                                    XUngrabKeyboard(display, CurrentTime);
564                                    break;
565    
566                          case Expose:                          case Expose:
567                                  XCopyArea(display, backstore, wnd, gc,                                  XCopyArea(display, backstore, wnd, gc,
568                                            xevent.xexpose.x, xevent.xexpose.y,                                            xevent.xexpose.x, xevent.xexpose.y,
# Line 548  xwin_process_events(void) Line 580  xwin_process_events(void)
580    
581                                  if (xevent.xmapping.request == MappingModifier)                                  if (xevent.xmapping.request == MappingModifier)
582                                  {                                  {
583                                          XFreeModifierMap(mod_map);                                          XFreeModifiermap(mod_map);
584                                          mod_map = XGetModifierMapping(display);                                          mod_map = XGetModifierMapping(display);
585                                  }                                  }
586                                  break;                                  break;

Legend:
Removed from v.203  
changed lines
  Added in v.257

  ViewVC Help
Powered by ViewVC 1.1.26