diff options
author | Pierre Ossman <ossman@cendio.se> | 2018-03-26 14:16:43 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2018-03-26 14:16:43 +0200 |
commit | 9a74732b5cbb1a11b950cd09ff5e764ddffc3897 (patch) | |
tree | 07cb1b90563cc0c9573925caeb6485e35dc8a039 /vncviewer | |
parent | 7823629930d3bd76caafecb99cacce4bc3aac59c (diff) | |
download | tigervnc-9a74732b5cbb1a11b950cd09ff5e764ddffc3897.tar.gz tigervnc-9a74732b5cbb1a11b950cd09ff5e764ddffc3897.zip |
Add focus test helper for Viewport
Diffstat (limited to 'vncviewer')
-rw-r--r-- | vncviewer/Viewport.cxx | 30 | ||||
-rw-r--r-- | vncviewer/Viewport.h | 1 |
2 files changed, 14 insertions, 17 deletions
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx index be38b929..3b56fce5 100644 --- a/vncviewer/Viewport.cxx +++ b/vncviewer/Viewport.cxx @@ -309,17 +309,9 @@ void Viewport::setCursor(int width, int height, const Point& hotspot, void Viewport::setLEDState(unsigned int state) { - Fl_Widget *focus; - vlog.debug("Got server LED state: 0x%08x", state); - focus = Fl::grab(); - if (!focus) - focus = Fl::focus(); - if (!focus) - return; - - if (focus != this) + if (!hasFocus()) return; #if defined(WIN32) @@ -635,6 +627,17 @@ int Viewport::handle(int event) } +bool Viewport::hasFocus() +{ + Fl_Widget* focus; + + focus = Fl::grab(); + if (!focus) + focus = Fl::focus(); + + return focus == this; +} + #if ! (defined(WIN32) || defined(__APPLE__)) unsigned int Viewport::getModifierMask(unsigned int keysym) { @@ -845,17 +848,10 @@ void Viewport::handleKeyRelease(int keyCode) int Viewport::handleSystemEvent(void *event, void *data) { Viewport *self = (Viewport *)data; - Fl_Widget *focus; assert(self); - focus = Fl::grab(); - if (!focus) - focus = Fl::focus(); - if (!focus) - return 0; - - if (focus != self) + if (!self->hasFocus()) return 0; assert(event); diff --git a/vncviewer/Viewport.h b/vncviewer/Viewport.h index 14ef4ab1..170be0d7 100644 --- a/vncviewer/Viewport.h +++ b/vncviewer/Viewport.h @@ -64,6 +64,7 @@ public: int handle(int event); private: + bool hasFocus(); unsigned int getModifierMask(unsigned int keysym); |