[gnome-panel/wip/geiger/geometry: 3/6] panel-toplevel: replace deprecated gdk_screen functions



commit 2f4c3f063f7bc0ec81e91cf72addb358a12907f9
Author: Sebastian Geiger <sbastig gmx net>
Date:   Sat Jan 6 16:31:52 2018 +0100

    panel-toplevel: replace deprecated gdk_screen functions

 gnome-panel/panel-toplevel.c |   31 ++++++++++++++++++++++---------
 1 files changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/gnome-panel/panel-toplevel.c b/gnome-panel/panel-toplevel.c
index 0dce96a..eb4120b 100644
--- a/gnome-panel/panel-toplevel.c
+++ b/gnome-panel/panel-toplevel.c
@@ -693,25 +693,26 @@ panel_toplevel_calc_new_orientation (PanelToplevel *toplevel,
                                     int            pointer_y)
 {
        PanelOrientation  new_orientation;
-       GdkScreen        *screen;
+       GdkRectangle      geometry;
+
        int               hborder, vborder;
-       int               monitor;
        int               monitor_width, monitor_height;
        int               new_x, new_y;
 
-       screen = gtk_window_get_screen (GTK_WINDOW (toplevel));
+       GdkMonitor *monitor = gdk_display_get_monitor_at_point(gdk_display_get_default(),
+                                                              pointer_x, pointer_y);
 
-       monitor = gdk_screen_get_monitor_at_point (screen, pointer_x, pointer_y);
+       gdk_monitor_get_geometry(monitor, &geometry);
 
        if (toplevel->priv->geometry.height < toplevel->priv->geometry.width)
                vborder = hborder = (3 * toplevel->priv->geometry.height) >> 1;
        else
                vborder = hborder = (3 * toplevel->priv->geometry.width)  >> 1;
 
-       new_x = pointer_x - panel_multiscreen_x (screen, monitor);
-       new_y = pointer_y - panel_multiscreen_y (screen, monitor);
-       monitor_width = panel_multiscreen_width (screen, monitor);
-       monitor_height = panel_multiscreen_height (screen, monitor);
+       new_x = pointer_x - geometry.x;
+       new_y = pointer_y - geometry.y;
+       monitor_width = geometry.width;
+       monitor_height = geometry.height;
 
        new_orientation = toplevel->priv->orientation;
 
@@ -765,7 +766,19 @@ panel_toplevel_calc_new_orientation (PanelToplevel *toplevel,
                break;
        }
 
-       panel_toplevel_set_monitor (toplevel, monitor);
+       // this is a temporary hack until we can port all panel_toplevel_* functions
+       // to make use of GdkMonitor instead of the monitor index.
+       int monitor_index = 0;
+
+       for (int i=0; i < gdk_display_get_n_monitors (gdk_display_get_default ()); i++)
+         {
+            if (monitor == gdk_display_get_monitor (gdk_display_get_default (), i))
+              {
+               monitor_index = i;
+             }
+         }
+
+       panel_toplevel_set_monitor (toplevel, monitor_index);
        panel_toplevel_set_orientation (toplevel, new_orientation);
 }
 


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