[shotwell/wip/gtk4] Fix autoscroll when selecting



commit 0fcd6294b7ca6075263f968caa34f836252941b1
Author: Jens Georg <mail jensge org>
Date:   Fri Apr 22 08:47:22 2022 +0200

    Fix autoscroll when selecting

 src/CheckerboardLayout.vala | 6 +++---
 src/CheckerboardPage.vala   | 2 +-
 src/Page.vala               | 6 ++++--
 src/util/ui.vala            | 6 +++---
 4 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/src/CheckerboardLayout.vala b/src/CheckerboardLayout.vala
index a2231174..015e6e7d 100644
--- a/src/CheckerboardLayout.vala
+++ b/src/CheckerboardLayout.vala
@@ -606,12 +606,12 @@ public class CheckerboardLayout : Gtk.DrawingArea {
         drag_origin.y = y.clamp(0, allocation.height);
     }
     
-    public void set_drag_select_endpoint(int x, int y) {
+    public void set_drag_select_endpoint(double x, double y) {
         Gtk.Allocation allocation;
         get_allocation(out allocation);
         
-        drag_endpoint.x = x.clamp(0, allocation.width);
-        drag_endpoint.y = y.clamp(0, allocation.height);
+        drag_endpoint.x = (int) x.clamp(0, allocation.width);
+        drag_endpoint.y = (int) y.clamp(0, allocation.height);
         
         // drag_origin and drag_endpoint are maintained only to generate selection_band; all reporting
         // and drawing functions refer to it, not drag_origin and drag_endpoint
diff --git a/src/CheckerboardPage.vala b/src/CheckerboardPage.vala
index 66bcd86b..46fdd3a6 100644
--- a/src/CheckerboardPage.vala
+++ b/src/CheckerboardPage.vala
@@ -615,7 +615,7 @@ public abstract class CheckerboardPage : Page {
         // as the viewport never scrolls horizontally, only interested in vertical
         Gtk.Adjustment vadj = scrolled.get_vadjustment();
 
-        int x, y;
+        double x, y;
         Gdk.ModifierType mask;
         get_event_source_pointer(out x, out y, out mask);
 
diff --git a/src/Page.vala b/src/Page.vala
index e4c1a065..e3afcb70 100644
--- a/src/Page.vala
+++ b/src/Page.vala
@@ -687,7 +687,7 @@ public abstract class Page : Gtk.Box {
     // button-down mouse drag (i.e. a window grab).
     //
     // For more information, see: https://bugzilla.gnome.org/show_bug.cgi?id=599937
-    public bool get_event_source_pointer(out int x, out int y, out Gdk.ModifierType mask) {
+    public bool get_event_source_pointer(out double x, out double y, out Gdk.ModifierType mask) {
         if (event_source == null) {
             x = 0;
             y = 0;
@@ -697,7 +697,9 @@ public abstract class Page : Gtk.Box {
         }
         
         var seat = Gdk.Display.get_default().get_default_seat();
-        //event_source.get_window().get_device_position(seat.get_pointer(), out x, out y, out mask);
+        double win_x, win_y;
+        event_source.get_native().get_surface().get_device_position(seat.get_pointer(), out win_x, out 
win_y, out mask);
+        event_source.get_native().translate_coordinates(event_source, win_x, win_y, out x, out y);
         
         if (last_down.x < 0 || last_down.y < 0)
             return true;
diff --git a/src/util/ui.vala b/src/util/ui.vala
index fc96b36d..b663d35a 100644
--- a/src/util/ui.vala
+++ b/src/util/ui.vala
@@ -40,10 +40,10 @@ public void spin_event_loop() {
         MainContext.default().iteration(true);
 }
 
-public AdjustmentRelation get_adjustment_relation(Gtk.Adjustment adjustment, int value) {
-    if (value < (int) adjustment.get_value())
+public AdjustmentRelation get_adjustment_relation(Gtk.Adjustment adjustment, double value) {
+    if (value < adjustment.get_value())
         return AdjustmentRelation.BELOW;
-    else if (value > (int) (adjustment.get_value() + adjustment.get_page_size()))
+    else if (value > (adjustment.get_value() + adjustment.get_page_size()))
         return AdjustmentRelation.ABOVE;
     else
         return AdjustmentRelation.IN_RANGE;


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