FLTK logo

[master] 5747c3e - Fix Fl_Wayland_Window_Driver::take_focus() required for recent Wayland versions.

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 5747c3e - Fix Fl_Wayland_Window_Driver::take_focus() required for recent Wayland versions. "ManoloFLTK" May 16, 2022  
 
commit 5747c3eed929f00717c65a0e23986e9a22d42541
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Mon May 16 11:25:28 2022 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Mon May 16 11:25:28 2022 +0200

    Fix Fl_Wayland_Window_Driver::take_focus() required for recent Wayland versions.

 src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
index 4dddcd1..e335329 100644
--- src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
+++ 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);
+    }
   }
 }
 
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.