aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Mannehed <samuel@cendio.se>2021-09-23 16:31:19 +0200
committerSamuel Mannehed <samuel@cendio.se>2021-10-06 17:20:40 +0200
commit12978dff96492384de32059326cc0b64b681f26a (patch)
tree3bee0c7211c486f38bfdef44a6260d62da42efa7
parentd1c4c92679c945e9ce267f7983e551feb9bc3eb4 (diff)
downloadtigervnc-12978dff96492384de32059326cc0b64b681f26a.tar.gz
tigervnc-12978dff96492384de32059326cc0b64b681f26a.zip
Create helper function for grabKeyboard conditions
(cherry picked from commit d6f4edbbf3e27771d27d8691f7bf0984997bd2e3)
-rw-r--r--vncviewer/DesktopWindow.cxx30
-rw-r--r--vncviewer/DesktopWindow.h1
2 files changed, 13 insertions, 18 deletions
diff --git a/vncviewer/DesktopWindow.cxx b/vncviewer/DesktopWindow.cxx
index a8382fbf..31b5c4c6 100644
--- a/vncviewer/DesktopWindow.cxx
+++ b/vncviewer/DesktopWindow.cxx
@@ -652,8 +652,7 @@ void DesktopWindow::resize(int x, int y, int w, int h)
// Some systems require a grab after the window size has been changed.
// Otherwise they might hold on to displays, resulting in them being unusable.
- if (fullscreen_active() && fullscreenSystemKeys)
- grabKeyboard();
+ maybeGrabKeyboard();
}
@@ -800,11 +799,8 @@ int DesktopWindow::handle(int event)
// Update scroll bars
repositionWidgets();
- if (!fullscreenSystemKeys)
- break;
-
if (fullscreen_active())
- grabKeyboard();
+ maybeGrabKeyboard();
else
ungrabKeyboard();
@@ -870,10 +866,7 @@ int DesktopWindow::fltkDispatch(int event, Fl_Window *win)
// all monitors and the user clicked on another application.
// Make sure we update our grabs with the focus changes.
case FL_FOCUS:
- if (fullscreenSystemKeys) {
- if (dw->fullscreen_active())
- dw->grabKeyboard();
- }
+ dw->maybeGrabKeyboard();
break;
case FL_UNFOCUS:
if (fullscreenSystemKeys) {
@@ -1014,6 +1007,12 @@ Bool eventIsFocusWithSerial(Display *display, XEvent *event, XPointer arg)
}
#endif
+void DesktopWindow::maybeGrabKeyboard()
+{
+ if (fullscreenSystemKeys && fullscreen_active())
+ grabKeyboard();
+}
+
void DesktopWindow::grabKeyboard()
{
// Grabbing the keyboard is fairly safe as FLTK reroutes events to the
@@ -1144,12 +1143,7 @@ void DesktopWindow::handleGrab(void *data)
assert(self);
- if (!fullscreenSystemKeys)
- return;
- if (!self->fullscreen_active())
- return;
-
- self->grabKeyboard();
+ self->maybeGrabKeyboard();
}
@@ -1453,8 +1447,8 @@ void DesktopWindow::handleOptions(void *data)
{
DesktopWindow *self = (DesktopWindow*)data;
- if (self->fullscreen_active() && fullscreenSystemKeys)
- self->grabKeyboard();
+ if (fullscreenSystemKeys)
+ self->maybeGrabKeyboard();
else
self->ungrabKeyboard();
diff --git a/vncviewer/DesktopWindow.h b/vncviewer/DesktopWindow.h
index f25985cc..04539700 100644
--- a/vncviewer/DesktopWindow.h
+++ b/vncviewer/DesktopWindow.h
@@ -95,6 +95,7 @@ private:
static int fltkDispatch(int event, Fl_Window *win);
static int fltkHandle(int event);
+ void maybeGrabKeyboard();
void grabKeyboard();
void ungrabKeyboard();
void grabPointer();