Apply our FLTK extensions
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4605 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/common/fltk/src/Fl_grab.cxx b/common/fltk/src/Fl_grab.cxx
index 76c9e9e..38724bd 100644
--- a/common/fltk/src/Fl_grab.cxx
+++ b/common/fltk/src/Fl_grab.cxx
@@ -38,6 +38,7 @@
// override_redirect, it does similar things on WIN32.
extern void fl_fix_focus(); // in Fl.cxx
+void fl_update_focus(void);
#ifdef WIN32
// We have to keep track of whether we have captured the mouse, since
@@ -50,7 +51,19 @@
extern void *fl_capture;
#endif
+#if !(defined(WIN32) || defined(__APPLE__))
+extern int ewmh_supported(); // from Fl_x.cxx
+#endif
+
void Fl::grab(Fl_Window* win) {
+ Fl_Window *fullscreen_win = NULL;
+ for (Fl_Window *W = Fl::first_window(); W; W = Fl::next_window(W)) {
+ if (W->fullscreen_active()) {
+ fullscreen_win = W;
+ break;
+ }
+ }
+
if (win) {
if (!grab_) {
#ifdef WIN32
@@ -60,8 +73,9 @@
fl_capture = Fl_X::i(first_window())->xid;
Fl_X::i(first_window())->set_key_window();
#else
+ Window xid = fullscreen_win ? fl_xid(fullscreen_win) : fl_xid(first_window());
XGrabPointer(fl_display,
- fl_xid(first_window()),
+ xid,
1,
ButtonPressMask|ButtonReleaseMask|
ButtonMotionMask|PointerMotionMask,
@@ -71,7 +85,7 @@
0,
fl_event_time);
XGrabKeyboard(fl_display,
- fl_xid(first_window()),
+ xid,
1,
GrabModeAsync,
GrabModeAsync,
@@ -79,6 +93,7 @@
#endif
}
grab_ = win;
+ fl_update_focus();
} else {
if (grab_) {
#ifdef WIN32
@@ -87,13 +102,17 @@
#elif defined(__APPLE__)
fl_capture = 0;
#else
+ // We must keep the grab in the non-EWMH fullscreen case
+ if (!fullscreen_win || ewmh_supported()) {
XUngrabKeyboard(fl_display, fl_event_time);
+ }
XUngrabPointer(fl_display, fl_event_time);
// this flush is done in case the picked menu item goes into
// an infinite loop, so we don't leave the X server locked up:
XFlush(fl_display);
#endif
grab_ = 0;
+ fl_update_focus();
fl_fix_focus();
}
}