[gtk/wip/matthiasc/popup2: 106/108] gtk: Stop using gdk_surface_get_device_position



commit a6d74118c57ceaf24813744b6cd01357c9fdc0a1
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Mar 25 08:32:50 2019 -0400

    gtk: Stop using gdk_surface_get_device_position
    
    Use the double version directly.

 gtk/gtkdnd.c      | 13 +++++++------
 gtk/gtkmenu.c     |  7 ++++++-
 gtk/gtktooltip.c  | 14 ++++++++++----
 gtk/gtktreeview.c | 51 ---------------------------------------------------
 4 files changed, 23 insertions(+), 62 deletions(-)
---
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index fd7543bb52..23f6bd619a 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -882,6 +882,7 @@ gtk_drag_begin_internal (GtkWidget          *widget,
   GtkDragSourceInfo *info;
   GtkRoot *root;
   GdkDrag *drag;
+  double px, py;
   int dx, dy;
   GtkDragContent *content;
 
@@ -890,12 +891,12 @@ gtk_drag_begin_internal (GtkWidget          *widget,
 
   root = gtk_widget_get_root (widget);
   gtk_widget_translate_coordinates (widget, GTK_WIDGET (root), x, y, &x, &y);
-  gdk_surface_get_device_position (gtk_widget_get_surface (GTK_WIDGET (root)),
-                                   device,
-                                   &dx, &dy,
-                                   NULL);
-  dx -= x;
-  dy -= y;
+  gdk_surface_get_device_position_double (gtk_widget_get_surface (GTK_WIDGET (root)),
+                                          device,
+                                          &px, &py,
+                                          NULL);
+  dx = round (px) - x;
+  dy = round (py) - y;
 
   content = g_object_new (GTK_TYPE_DRAG_CONTENT, NULL);
   content->widget = g_object_ref (widget);
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index ad0209367f..c75ff03eb8 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -1823,7 +1823,12 @@ gtk_menu_popup_at_pointer (GtkMenu        *menu,
             device = gdk_device_get_associated_device (device);
 
           if (device)
-            gdk_surface_get_device_position (rect_surface, device, &rect.x, &rect.y, NULL);
+            {
+              double px, py;
+              gdk_surface_get_device_position_double (rect_surface, device, &px, &py, NULL);
+              rect.x = round (px);
+              rect.y = round (py);
+            }
         }
     }
   else
diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c
index c366957536..6b19b9b5d7 100644
--- a/gtk/gtktooltip.c
+++ b/gtk/gtktooltip.c
@@ -618,6 +618,7 @@ gtk_tooltip_position (GtkTooltip *tooltip,
       const int max_x_distance = 32;
       /* Max 48x48 icon + default padding */
       const int max_anchor_rect_height = 48 + 8;
+      double px, py;
       int pointer_x, pointer_y;
 
       /*
@@ -633,9 +634,11 @@ gtk_tooltip_position (GtkTooltip *tooltip,
        * far away from the pointer position.
        */
       effective_toplevel = _gtk_widget_get_surface (toplevel);
-      gdk_surface_get_device_position (effective_toplevel,
-                                       device,
-                                       &pointer_x, &pointer_y, NULL);
+      gdk_surface_get_device_position_double (effective_toplevel,
+                                              device,
+                                              &px, &py, NULL);
+      pointer_x = round (px);
+      pointer_y = round (py);
 
       if (anchor_rect.height > max_anchor_rect_height)
         {
@@ -674,6 +677,7 @@ gtk_tooltip_position (GtkTooltip *tooltip,
 static void
 gtk_tooltip_show_tooltip (GdkDisplay *display)
 {
+  double px, py;
   gint x, y;
   GdkSurface *surface;
   GtkWidget *tooltip_widget;
@@ -691,7 +695,9 @@ gtk_tooltip_show_tooltip (GdkDisplay *display)
 
     device = gdk_seat_get_pointer (gdk_display_get_default_seat (display));
 
-    gdk_surface_get_device_position (surface, device, &x, &y, NULL);
+    gdk_surface_get_device_position_double (surface, device, &px, &py, NULL);
+    x = round (px);
+    y = round (py);
 
     tooltip_widget = _gtk_widget_find_at_coords (surface, x, y, &x, &y);
   }
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 3e38cb86ec..4bf4858eeb 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -6717,57 +6717,6 @@ remove_info (GtkTreeView *tree_view)
   g_object_set_data (G_OBJECT (tree_view), I_("gtk-tree-view-drag-info"), NULL);
 }
 
-#if 0
-static gint
-drag_scan_timeout (gpointer data)
-{
-  GtkTreeView *tree_view;
-  gint x, y;
-  GdkModifierType state;
-  GtkTreePath *path = NULL;
-  GtkTreeViewColumn *column = NULL;
-  GdkRectangle visible_rect;
-  GdkSeat *seat;
-
-  tree_view = GTK_TREE_VIEW (data);
-
-  seat = gdk_display_get_default_seat (gtk_widget_get_display (GTK_WIDGET (tree_view)));
-  gdk_surface_get_device_position (tree_view->priv->bin_window,
-                                  gdk_seat_get_pointer (seat),
-                                  &x, &y, &state);
-
-  gtk_tree_view_get_visible_rect (tree_view, &visible_rect);
-
-  /* See if we are near the edge. */
-  if ((x - visible_rect.x) < SCROLL_EDGE_SIZE ||
-      (visible_rect.x + visible_rect.width - x) < SCROLL_EDGE_SIZE ||
-      (y - visible_rect.y) < SCROLL_EDGE_SIZE ||
-      (visible_rect.y + visible_rect.height - y) < SCROLL_EDGE_SIZE)
-    {
-      gtk_tree_view_get_path_at_pos (tree_view,
-                                     tree_view->priv->bin_window,
-                                     x, y,
-                                     &path,
-                                     &column,
-                                     NULL,
-                                     NULL);
-
-      if (path != NULL)
-        {
-          gtk_tree_view_scroll_to_cell (tree_view,
-                                        path,
-                                        column,
-                                       TRUE,
-                                        0.5, 0.5);
-
-          gtk_tree_path_free (path);
-        }
-    }
-
-  return TRUE;
-}
-#endif /* 0 */
-
 static void
 add_scroll_timeout (GtkTreeView *tree_view)
 {


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