diff options
-rw-r--r-- | vncviewer/DesktopWindow.cxx | 16 | ||||
-rw-r--r-- | vncviewer/DesktopWindow.h | 2 |
2 files changed, 17 insertions, 1 deletions
diff --git a/vncviewer/DesktopWindow.cxx b/vncviewer/DesktopWindow.cxx index 31b5c4c6..d379a712 100644 --- a/vncviewer/DesktopWindow.cxx +++ b/vncviewer/DesktopWindow.cxx @@ -1007,9 +1007,23 @@ Bool eventIsFocusWithSerial(Display *display, XEvent *event, XPointer arg) } #endif +bool DesktopWindow::hasFocus() +{ + Fl_Widget* focus; + + focus = Fl::grab(); + if (!focus) + focus = Fl::focus(); + + if (!focus) + return false; + + return focus->window() == this; +} + void DesktopWindow::maybeGrabKeyboard() { - if (fullscreenSystemKeys && fullscreen_active()) + if (fullscreenSystemKeys && fullscreen_active() && hasFocus()) grabKeyboard(); } diff --git a/vncviewer/DesktopWindow.h b/vncviewer/DesktopWindow.h index 04539700..a654b126 100644 --- a/vncviewer/DesktopWindow.h +++ b/vncviewer/DesktopWindow.h @@ -95,6 +95,8 @@ private: static int fltkDispatch(int event, Fl_Window *win); static int fltkHandle(int event); + bool hasFocus(); + void maybeGrabKeyboard(); void grabKeyboard(); void ungrabKeyboard(); |