/[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 208 by matthewc, Fri Sep 27 01:04:34 2002 UTC revision 261 by astrand, Mon Nov 18 15:35:41 2002 UTC
# 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 351  ui_create_window(void) Line 353  ui_create_window(void)
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 372  ui_create_window(void) Line 378  ui_create_window(void)
378          }          }
379          while (xevent.type != VisibilityNotify);          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 463  xwin_process_events(void) Line 469  xwin_process_events(void)
469                                                        str, sizeof(str), &keysym, NULL);                                                        str, sizeof(str), &keysym, NULL);
470                                  }                                  }
471    
472                                  DEBUG_KBD(("KeyPress for (keysym 0x%lx, %s)\n", keysym, get_ksname(keysym)));                                  DEBUG_KBD(("KeyPress for (keysym 0x%lx, %s)\n", keysym,
473                                               get_ksname(keysym)));
474    
475                                  ev_time = time(NULL);                                  ev_time = time(NULL);
476                                  if (handle_special_keys(keysym, xevent.xkey.state, ev_time, True))                                  if (handle_special_keys(keysym, xevent.xkey.state, ev_time, True))
# Line 519  xwin_process_events(void) Line 526  xwin_process_events(void)
526                                  break;                                  break;
527    
528                          case FocusIn:                          case FocusIn:
529                                  XQueryPointer(display, wnd, &wdummy, &wdummy, &dummy, &dummy, &dummy, &dummy, &state);                                  if (xevent.xfocus.mode == NotifyGrab)
530                                            break;
531                                    focused = True;
532                                    XQueryPointer(display, wnd, &wdummy, &wdummy, &dummy, &dummy,
533                                                  &dummy, &dummy, &state);
534                                  reset_modifier_keys(state);                                  reset_modifier_keys(state);
535                                  if (grab_keyboard)                                  if (grab_keyboard && mouse_in_wnd)
536                                          XGrabKeyboard(display, wnd, True,                                          XGrabKeyboard(display, wnd, True,
537                                                        GrabModeAsync, GrabModeAsync, CurrentTime);                                                        GrabModeAsync, GrabModeAsync, CurrentTime);
538                                  break;                                  break;
539    
540                          case FocusOut:                          case FocusOut:
541                                    if (xevent.xfocus.mode == NotifyUngrab)
542                                            break;
543                                    focused = False;
544                                  if (xevent.xfocus.mode == NotifyWhileGrabbed)                                  if (xevent.xfocus.mode == NotifyWhileGrabbed)
545                                          XUngrabKeyboard(display, CurrentTime);                                          XUngrabKeyboard(display, CurrentTime);
546                                  break;                                  break;
547    
548                            case EnterNotify:
549                                    /* we only register for this event when in fullscreen mode */
550                                    /* or grab_keyboard */
551                                    mouse_in_wnd = True;
552                                    if (fullscreen)
553                                    {
554                                            XSetInputFocus(display, wnd, RevertToPointerRoot,
555                                                           CurrentTime);
556                                            break;
557                                    }
558                                    if (focused)
559                                            XGrabKeyboard(display, wnd, True,
560                                                          GrabModeAsync, GrabModeAsync, CurrentTime);
561                                    break;
562    
563                            case LeaveNotify:
564                                    /* we only register for this event when grab_keyboard */
565                                    mouse_in_wnd = False;
566                                    XUngrabKeyboard(display, CurrentTime);
567                                    break;
568    
569                          case Expose:                          case Expose:
570                                  XCopyArea(display, backstore, wnd, gc,                                  XCopyArea(display, backstore, wnd, gc,
571                                            xevent.xexpose.x, xevent.xexpose.y,                                            xevent.xexpose.x, xevent.xexpose.y,

Legend:
Removed from v.208  
changed lines
  Added in v.261

  ViewVC Help
Powered by ViewVC 1.1.26