FLTK logo

[master] f01216f - Weston support: handle click on titlebar.

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] f01216f - Weston support: handle click on titlebar. "ManoloFLTK" May 17, 2022  
 
commit f01216f167bad1ad2efff1c351c9d310ef1104a2
Author:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
AuthorDate: Tue May 17 10:40:09 2022 +0200
Commit:     ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>
CommitDate: Tue May 17 10:40:09 2022 +0200

    Weston support: handle click on titlebar.

 src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx | 10 ++++++----
 src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx | 11 +++++++----
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
index 7b4b341..27512a4 100644
--- src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
+++ src/drivers/Wayland/Fl_Wayland_Screen_Driver.cxx
@@ -227,10 +227,12 @@ struct wl_display *Fl_Wayland_Screen_Driver::wl_display = NULL;
 
 
 Fl_Window *Fl_Wayland_Screen_Driver::surface_to_window(struct wl_surface *surface) {
-  Fl_X *xp = Fl_X::first;
-  while (xp) {
-    if (xp->xid->wl_surface == surface) return xp->w;
-    xp = xp->next;
+  if (surface) {
+    Fl_X *xp = Fl_X::first;
+    while (xp) {
+      if (xp->xid->wl_surface == surface) return xp->w;
+      xp = xp->next;
+    }
   }
   return NULL;
 }
diff --git src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
index 587b156..934cb4d 100644
--- src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
+++ src/drivers/Wayland/Fl_Wayland_Window_Driver.cxx
@@ -790,10 +790,12 @@ static void handle_configure(struct libdecor_frame *frame,
  "There is no way to know if the surface is currently minimized, nor is there any way to
  unset minimization on this surface. If you are looking to throttle redrawing when minimized,
  please instead use the wl_surface.frame event" */
-  if (window_state == LIBDECOR_WINDOW_STATE_NONE) {
-    Fl::handle(FL_UNFOCUS, window->fl_win);
-  }
-  else if (window_state & LIBDECOR_WINDOW_STATE_ACTIVE) {
+  if (window_state & LIBDECOR_WINDOW_STATE_ACTIVE) {
+    if (Fl_Wayland_Screen_Driver::compositor == Fl_Wayland_Screen_Driver::WESTON) {
+      // After click on titlebar, weston calls wl_keyboard_enter() for a
+      // titlebar-related surface that FLTK can't identify, so we send FL_FOCUS here.
+      Fl::handle(FL_FOCUS, window->fl_win);
+    }
     if (!window->fl_win->border()) libdecor_frame_set_visibility(window->frame, false);
     else if (!libdecor_frame_is_visible(window->frame)) libdecor_frame_set_visibility(window->frame, true);
   }
@@ -833,6 +835,7 @@ void Fl_Wayland_Window_Driver::wait_for_expose()
       wl_display_roundtrip(Fl_Wayland_Screen_Driver::wl_display);
     }
   } else if (xid->kind == DECORATED) {
+    // necessary for the windowfocus demo program with recent Wayland versions
     if (!(xid->state & LIBDECOR_WINDOW_STATE_ACTIVE)) {
       wl_display_dispatch(Fl_Wayland_Screen_Driver::wl_display);
     }
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'.