[gnome-panel/wip/geiger/geometry: 7/8] panel-multiscreen: remove global geometries variable



commit e66740848d76b28556e4c511b727749fe8a3257a
Author: Sebastian Geiger <sbastig gmx net>
Date:   Sat Jan 6 22:38:52 2018 +0100

    panel-multiscreen: remove global geometries variable

 gnome-panel/panel-multiscreen.c |   69 ++++++++++++++++-----------------------
 1 files changed, 28 insertions(+), 41 deletions(-)
---
diff --git a/gnome-panel/panel-multiscreen.c b/gnome-panel/panel-multiscreen.c
index b8d8060..0a5c88d 100644
--- a/gnome-panel/panel-multiscreen.c
+++ b/gnome-panel/panel-multiscreen.c
@@ -26,35 +26,10 @@
 #include "config.h"
 #include "panel-multiscreen.h"
 
-static GdkRectangle *geometries  = NULL;
 static guint         reinit_id   = 0;
 
 static void panel_multiscreen_reinit (void);
 
-static void
-get_monitors (GdkScreen *screen)
-{
-
-  gint n_monitors;
-  gint primary;
-  gint i;
-
-  n_monitors = gdk_screen_get_n_monitors (screen);
-  primary = gdk_screen_get_primary_monitor (screen);
-
-  g_free (geometries);
-  geometries = g_new (GdkRectangle, n_monitors);
-
-  gdk_screen_get_monitor_geometry (screen, primary, &(geometries[0]));
-
-  for (i = 1; i < n_monitors; i++)
-    {
-      if (i == primary)
-        continue;
-      gdk_screen_get_monitor_geometry (screen, i, &(geometries[i]));
-    }
-}
-
 static gboolean
 panel_multiscreen_reinit_idle (gpointer data)
 {
@@ -88,21 +63,13 @@ panel_multiscreen_init (void)
                     G_CALLBACK(panel_multiscreen_queue_reinit), NULL);
   g_signal_connect (screen, "monitors-changed",
                     G_CALLBACK(panel_multiscreen_queue_reinit), NULL);
-
-  get_monitors(screen);
 }
 
 static void
 panel_multiscreen_reinit (void)
 {
-       GdkScreen *screen;
        GList     *toplevels, *l;
 
-       screen = gdk_screen_get_default ();
-       g_signal_handlers_disconnect_by_func (screen, panel_multiscreen_queue_reinit, NULL);
-
-       panel_multiscreen_init ();
-
        toplevels = gtk_window_list_toplevels ();
 
        for (l = toplevels; l; l = l->next)
@@ -117,7 +84,11 @@ panel_multiscreen_x (GdkScreen *screen,
 {
   g_return_val_if_fail (monitor >= 0 && monitor < gdk_screen_get_n_monitors (screen), 0);
 
-  return geometries [monitor].x;
+  int x;
+
+  panel_multiscreen_get_monitor_geometry (monitor, &x, NULL, NULL, NULL);
+
+  return x;
 }
 
 int
@@ -126,7 +97,11 @@ panel_multiscreen_y (GdkScreen *screen,
 {
   g_return_val_if_fail (monitor >= 0 && monitor < gdk_screen_get_n_monitors (screen), 0);
 
-  return geometries [monitor].y;
+  int y;
+
+  panel_multiscreen_get_monitor_geometry (monitor, NULL, &y, NULL, NULL);
+
+  return y;
 }
 
 int
@@ -135,7 +110,11 @@ panel_multiscreen_width (GdkScreen *screen,
 {
   g_return_val_if_fail (monitor >= 0 && monitor < gdk_screen_get_n_monitors (screen), 0);
 
-       return geometries [monitor].width;
+  int width;
+
+  panel_multiscreen_get_monitor_geometry (monitor, NULL, NULL, NULL, &width);
+
+  return width;
 }
 
 int
@@ -144,7 +123,11 @@ panel_multiscreen_height (GdkScreen *screen,
 {
   g_return_val_if_fail (monitor >= 0 && monitor < gdk_screen_get_n_monitors (screen), 0);
 
-  return geometries [monitor].height;
+  int height;
+
+  panel_multiscreen_get_monitor_geometry (monitor, NULL, NULL, &height, NULL);
+
+  return height;
 }
 
 typedef struct {
@@ -160,10 +143,14 @@ get_monitor_bounds (int            n_monitor,
 {
        g_assert (bounds != NULL);
 
-       bounds->x0 = geometries [n_monitor].x;
-       bounds->y0 = geometries [n_monitor].y;
-       bounds->x1 = bounds->x0 + geometries [n_monitor].width;
-       bounds->y1 = bounds->y0 + geometries [n_monitor].height;
+       int x, y, height, width;
+
+       panel_multiscreen_get_monitor_geometry (n_monitor, &x, &y, &height, &width);
+
+       bounds->x0 = x;
+       bounds->y0 = y;
+       bounds->x1 = bounds->x0 + width;
+       bounds->y1 = bounds->y0 + height;
 }
 
 /* determines whether a given monitor is along the visible


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