[gnome-panel/wip/geiger/geometry: 5/8] panel-multiscreen: replace deprecated geometry code



commit 851bd0644274e2f90c3b894320911e87b9251175
Author: Sebastian Geiger <sbastig gmx net>
Date:   Sat Jan 6 16:29:39 2018 +0100

    panel-multiscreen: replace deprecated geometry code

 gnome-panel/panel-multiscreen.c |   19 +++++++++++++++++
 gnome-panel/panel-multiscreen.h |    6 +++++
 gnome-panel/panel-struts.c      |   37 +++++++++-------------------------
 gnome-panel/panel-toplevel.c    |   42 +++++++++++++-------------------------
 4 files changed, 50 insertions(+), 54 deletions(-)
---
diff --git a/gnome-panel/panel-multiscreen.c b/gnome-panel/panel-multiscreen.c
index 3c59564..b8d8060 100644
--- a/gnome-panel/panel-multiscreen.c
+++ b/gnome-panel/panel-multiscreen.c
@@ -218,3 +218,22 @@ panel_multiscreen_is_at_visible_extreme (int        monitor_index,
                }
        }
 }
+
+void
+panel_multiscreen_get_monitor_geometry(int monitor_index,
+                                       int *x,
+                                       int *y,
+                                       int *height,
+                                       int *width)
+{
+  GdkMonitor *monitor = gdk_display_get_monitor (gdk_display_get_default (), monitor_index);
+
+  GdkRectangle geometry;
+
+  gdk_monitor_get_geometry (monitor, &geometry);
+
+  if (x) *x = geometry.x;
+  if (y) *y = geometry.y;
+  if (height) *height = geometry.height;
+  if (width) *width = geometry.width;
+}
diff --git a/gnome-panel/panel-multiscreen.h b/gnome-panel/panel-multiscreen.h
index 71c767f..5453c76 100644
--- a/gnome-panel/panel-multiscreen.h
+++ b/gnome-panel/panel-multiscreen.h
@@ -30,6 +30,12 @@
 
 void   panel_multiscreen_init                  (void);
 
+void    panel_multiscreen_get_monitor_geometry  (int monitor_index,
+                                                 int *x,
+                                                 int *y,
+                                                 int *height,
+                                                 int *width);
+
 int    panel_multiscreen_x                     (GdkScreen *screen,
                                                 int        monitor);
 int    panel_multiscreen_y                     (GdkScreen *screen,
diff --git a/gnome-panel/panel-struts.c b/gnome-panel/panel-struts.c
index 3fd92bf..2887083 100644
--- a/gnome-panel/panel-struts.c
+++ b/gnome-panel/panel-struts.c
@@ -64,20 +64,6 @@ panel_struts_find_strut (PanelToplevel *toplevel)
        return l ? l->data : NULL;
 }
 
-static void
-panel_struts_get_monitor_geometry (GdkScreen *screen,
-                                  int        monitor,
-                                  int       *x,
-                                  int       *y,
-                                  int       *width,
-                                  int       *height)
-{
-        *x      = panel_multiscreen_x      (screen, monitor);
-        *y      = panel_multiscreen_y      (screen, monitor);
-        *width  = panel_multiscreen_width  (screen, monitor);
-        *height = panel_multiscreen_height (screen, monitor);
-}
-
 static PanelStrut *
 panel_struts_intersect (GSList       *struts,
                        GdkRectangle *geometry,
@@ -198,9 +184,9 @@ panel_struts_allocate_struts (PanelToplevel *toplevel,
                if (strut->screen != screen || strut->monitor != monitor)
                        continue;
 
-               panel_struts_get_monitor_geometry (strut->screen, strut->monitor,
-                                                  &monitor_x, &monitor_y,
-                                                  &monitor_width, &monitor_height);
+               panel_multiscreen_get_monitor_geometry(strut->monitor,
+                                                      &monitor_x, &monitor_y,
+                                                      &monitor_height, &monitor_width);
 
                strut->allocated_strut_size  = strut->strut_size;
                strut->allocated_strut_start = strut->strut_start;
@@ -269,12 +255,9 @@ panel_struts_set_window_hint (PanelToplevel *toplevel)
        screen_width  = gdk_screen_get_width  (strut->screen);
        screen_height = gdk_screen_get_height (strut->screen);
 
-       panel_struts_get_monitor_geometry (strut->screen,
-                                          strut->monitor,
-                                          &monitor_x,
-                                          &monitor_y,
-                                          &monitor_width,
-                                          &monitor_height);
+       panel_multiscreen_get_monitor_geometry(strut->monitor,
+                                              &monitor_x, &monitor_y,
+                                              &monitor_height, &monitor_width);
 
        panel_multiscreen_is_at_visible_extreme (strut->monitor,
                                                 &leftmost,
@@ -406,10 +389,10 @@ panel_struts_register_strut (PanelToplevel    *toplevel,
        strut->strut_size  = strut_size;
        strut->strut_start = strut_start;
        strut->strut_end   = strut_end;
-       
-       panel_struts_get_monitor_geometry (screen, monitor,
-                                          &monitor_x, &monitor_y,
-                                          &monitor_width, &monitor_height);
+
+       panel_multiscreen_get_monitor_geometry(monitor,
+                                              &monitor_x, &monitor_y,
+                                              &monitor_height, &monitor_width);
 
        switch (strut->orientation) {
        case PANEL_ORIENTATION_TOP:
diff --git a/gnome-panel/panel-toplevel.c b/gnome-panel/panel-toplevel.c
index db10e44..7689981 100644
--- a/gnome-panel/panel-toplevel.c
+++ b/gnome-panel/panel-toplevel.c
@@ -409,27 +409,16 @@ panel_toplevel_get_screen_geometry (PanelToplevel *toplevel,
        return screen;
 }
 
-static GdkScreen *
+static void
 panel_toplevel_get_monitor_geometry (PanelToplevel *toplevel,
-                                    int           *x,
-                                    int           *y,
-                                    int           *width,
-                                    int           *height)
+                                     int           *x,
+                                     int           *y,
+                                     int           *width,
+                                     int           *height)
 {
-       GdkScreen *screen;
-
-       g_return_val_if_fail (PANEL_IS_TOPLEVEL (toplevel), NULL);
-       g_return_val_if_fail (width != NULL && height != NULL, NULL);
+  int monitor_index = toplevel->priv->monitor;
 
-       screen = gtk_window_get_screen (GTK_WINDOW (toplevel));
-
-       if (x) *x = panel_multiscreen_x (screen, toplevel->priv->monitor);
-       if (y) *y = panel_multiscreen_y (screen, toplevel->priv->monitor);
-
-       if (width)  *width  = panel_multiscreen_width  (screen, toplevel->priv->monitor);
-       if (height) *height = panel_multiscreen_height (screen, toplevel->priv->monitor);
-
-       return screen;
+  panel_multiscreen_get_monitor_geometry(monitor_index, x, y, height, width);
 }
 
 static GdkCursorType
@@ -1437,7 +1426,6 @@ static gboolean
 panel_toplevel_update_struts (PanelToplevel *toplevel, gboolean end_of_animation)
 {
        PanelOrientation  orientation;
-       GdkScreen        *screen;
        gboolean          geometry_changed = FALSE;
        int               strut, strut_start, strut_end;
        int               x, y, width, height;
@@ -1461,17 +1449,17 @@ panel_toplevel_update_struts (PanelToplevel *toplevel, gboolean end_of_animation
                        panel_toplevel_calculate_animation_end_geometry (toplevel);
        }
 
-       screen = panel_toplevel_get_monitor_geometry (toplevel,
-                                                     &monitor_x,
-                                                     &monitor_y,
-                                                     &monitor_width,
-                                                     &monitor_height);
+       panel_toplevel_get_monitor_geometry (toplevel,
+                                            &monitor_x,
+                                            &monitor_y,
+                                            &monitor_width,
+                                            &monitor_height);
 
        if (end_of_animation) {
                x = toplevel->priv->animation_end_x;
                y = toplevel->priv->animation_end_y;
-               x += panel_multiscreen_x (screen, toplevel->priv->monitor);
-               y += panel_multiscreen_y (screen, toplevel->priv->monitor);
+               x += monitor_x;
+               y += monitor_y;
                if (toplevel->priv->animation_end_width != -1)
                        width = toplevel->priv->animation_end_width;
                else
@@ -1529,7 +1517,7 @@ panel_toplevel_update_struts (PanelToplevel *toplevel, gboolean end_of_animation
 
        if (strut > 0)
                geometry_changed = panel_struts_register_strut (toplevel,
-                                                               screen,
+                                                               gdk_screen_get_default(),
                                                                toplevel->priv->monitor,
                                                                orientation,
                                                                strut,


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