summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
index 4dddcd146..e3353298c 100644
--- a/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
+++ b/src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
@@ -144,6 +144,9 @@ void Fl_Wayland_Window_Driver::take_focus()
{
Window w = fl_xid(pWindow);
if (w) {
+ Fl_Widget *old_focus = Fl::focus();
+ // necessary for recent Wayland versions; may change focus
+ wl_display_dispatch(Fl_Wayland_Screen_Driver::wl_display);
Fl_Window *old_first = Fl::first_window();
Window first_xid = (old_first ? fl_xid(old_first->top_window()) : NULL);
if (first_xid && first_xid != w && xdg_toplevel()) {
@@ -156,6 +159,11 @@ void Fl_Wayland_Window_Driver::take_focus()
}
// this sets the first window
fl_find(w);
+ if (old_focus && Fl::focus() != old_focus) { // reset focus as at function entry
+ extern Fl_Window *fl_xfocus;
+ fl_xfocus = old_focus->top_window();
+ Fl::focus(old_focus);
+ }
}
}