Przeglądaj źródła

Ignore fake focus events from XGrabKeyboard()

Grabbing (and ungrabbing) the keyboard generates fake focus events
with modern versions of Xorg. This causes an infinite loop since we
update the grab status on focus events.

Work around this by ignoring these fake events.
tags/v1.8.90
Pierre Ossman 6 lat temu
rodzic
commit
1d94124f68
1 zmienionych plików z 44 dodań i 0 usunięć
  1. 44
    0
      vncviewer/DesktopWindow.cxx

+ 44
- 0
vncviewer/DesktopWindow.cxx Wyświetl plik

fullscreen(); fullscreen();
} }


#if !defined(WIN32) && !defined(__APPLE__)
Bool eventIsFocusWithSerial(Display *display, XEvent *event, XPointer arg)
{
unsigned long serial;

serial = *(unsigned long*)arg;

if (event->xany.serial != serial)
return False;

if ((event->type != FocusIn) && (event->type != FocusOut))
return False;

return True;
}
#endif

void DesktopWindow::grabKeyboard() void DesktopWindow::grabKeyboard()
{ {
// Grabbing the keyboard is fairly safe as FLTK reroutes events to the // Grabbing the keyboard is fairly safe as FLTK reroutes events to the
#else #else
int ret; int ret;


XEvent xev;
unsigned long serial;

serial = XNextRequest(fl_display);

ret = XGrabKeyboard(fl_display, fl_xid(this), True, ret = XGrabKeyboard(fl_display, fl_xid(this), True,
GrabModeAsync, GrabModeAsync, CurrentTime); GrabModeAsync, GrabModeAsync, CurrentTime);
if (ret) { if (ret) {
} }
return; return;
} }

// Xorg 1.20+ generates FocusIn/FocusOut even when there is no actual
// change of focus. This causes us to get stuck in an endless loop
// grabbing and ungrabbing the keyboard. Avoid this by filtering out
// any focus events generated by XGrabKeyboard().
XSync(fl_display, False);
while (XCheckIfEvent(fl_display, &xev, &eventIsFocusWithSerial,
(XPointer)&serial) == True) {
vlog.debug("Ignored synthetic focus event cause by grab change");
}
#endif #endif


keyboardGrabbed = true; keyboardGrabbed = true;
if (Fl::grab()) if (Fl::grab())
return; return;


XEvent xev;
unsigned long serial;

serial = XNextRequest(fl_display);

XUngrabKeyboard(fl_display, CurrentTime); XUngrabKeyboard(fl_display, CurrentTime);

// See grabKeyboard()
XSync(fl_display, False);
while (XCheckIfEvent(fl_display, &xev, &eventIsFocusWithSerial,
(XPointer)&serial) == True) {
vlog.debug("Ignored synthetic focus event cause by grab change");
}
#endif #endif
} }



Ładowanie…
Anuluj
Zapisz