[shotwell/wip/gtk4: 75/88] Add focus handling to page




commit e495019f5e9f75e5913e7376717f10df92069664
Author: Jens Georg <mail jensge org>
Date:   Wed Apr 20 14:41:14 2022 +0200

    Add focus handling to page

 src/CheckerboardLayout.vala |  2 +-
 src/Page.vala               | 10 +---------
 src/PageWindow.vala         | 22 +++++++---------------
 3 files changed, 9 insertions(+), 25 deletions(-)
---
diff --git a/src/CheckerboardLayout.vala b/src/CheckerboardLayout.vala
index 4dc3b141..a2231174 100644
--- a/src/CheckerboardLayout.vala
+++ b/src/CheckerboardLayout.vala
@@ -147,7 +147,7 @@ public class CheckerboardLayout : Gtk.DrawingArea {
         page_name = name;
     }
     
-    private void on_viewport_resized() {
+    public void on_viewport_resized() {
         Gtk.Requisition req;
         get_preferred_size(null, out req);
         
diff --git a/src/Page.vala b/src/Page.vala
index cf496c21..863bd5b9 100644
--- a/src/Page.vala
+++ b/src/Page.vala
@@ -901,17 +901,9 @@ public abstract class Page : Gtk.Box {
         return on_app_key_released(event, keycode, keyval, modifiers);
     }
 
-    #if 0
-    public bool notify_app_focus_in(Gdk.EventFocus event) {
+    public void notify_app_focus_in() {
         update_modifiers();
-        
-        return false;
     }
-
-    public bool notify_app_focus_out(Gdk.EventFocus event) {
-        return false;
-    }
-    #endif
     
     protected virtual void on_resize(Gdk.Rectangle rect) {
     }
diff --git a/src/PageWindow.vala b/src/PageWindow.vala
index 9c8f52e0..fd4a7ea0 100644
--- a/src/PageWindow.vala
+++ b/src/PageWindow.vala
@@ -28,6 +28,10 @@ public abstract class PageWindow : Gtk.ApplicationWindow {
         key_controller.key_pressed.connect(key_press_event);
         key_controller.key_released.connect(key_release_event);
         ((Gtk.Widget)this).add_controller(key_controller);
+
+        var focus_controller = new Gtk.EventControllerFocus();
+        focus_controller.enter.connect(focus_in_event);
+        ((Gtk.Widget)this).add_controller(focus_controller);
     }
 
     private void synthesize_configure_event() {
@@ -97,23 +101,11 @@ public abstract class PageWindow : Gtk.ApplicationWindow {
             current_page.notify_app_key_released(event, keyval, keycode, modifiers);
     }
 
-    #if 0
-    public override bool focus_in_event(Gdk.EventFocus event) {
-        if (current_page != null && current_page.notify_app_focus_in(event))
-            return true;
-
-        return (base.focus_in_event != null) ? base.focus_in_event(event) : false;
-    }
-
-    public override bool focus_out_event(Gdk.EventFocus event) {
-        if (current_page != null && current_page.notify_app_focus_out(event))
-            return true;
-
-        return (base.focus_out_event != null) ? base.focus_out_event(event) : false;
+    public void focus_in_event(Gtk.EventControllerFocus event) {
+        if (current_page != null)
+            current_page.notify_app_focus_in();
     }
 
-    #endif
-
     public void set_busy_cursor() {
         if (busy_counter++ > 0)
             return;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]