[gnome-panel/wip/geiger/geometry: 8/8] panel-multiscreen: replace _x, _y, _height and _width



commit 93d1b7af41cbec6c10b64d6de69c9c6adf0692bb
Author: Sebastian Geiger <sbastig gmx net>
Date:   Sun Jan 7 20:47:23 2018 +0100

    panel-multiscreen: replace  _x, _y, _height and _width

 gnome-panel/panel-multiscreen.c |   52 ---------------------------------------
 gnome-panel/panel-multiscreen.h |    9 ------
 gnome-panel/panel-run-dialog.c  |    9 +++---
 gnome-panel/panel-toplevel.c    |   43 ++++++++++++++++++--------------
 4 files changed, 29 insertions(+), 84 deletions(-)
---
diff --git a/gnome-panel/panel-multiscreen.c b/gnome-panel/panel-multiscreen.c
index 0a5c88d..ddfbefe 100644
--- a/gnome-panel/panel-multiscreen.c
+++ b/gnome-panel/panel-multiscreen.c
@@ -78,58 +78,6 @@ panel_multiscreen_reinit (void)
        g_list_free (toplevels);
 }
 
-int
-panel_multiscreen_x (GdkScreen *screen,
-                    int        monitor)
-{
-  g_return_val_if_fail (monitor >= 0 && monitor < gdk_screen_get_n_monitors (screen), 0);
-
-  int x;
-
-  panel_multiscreen_get_monitor_geometry (monitor, &x, NULL, NULL, NULL);
-
-  return x;
-}
-
-int
-panel_multiscreen_y (GdkScreen *screen,
-                    int        monitor)
-{
-  g_return_val_if_fail (monitor >= 0 && monitor < gdk_screen_get_n_monitors (screen), 0);
-
-  int y;
-
-  panel_multiscreen_get_monitor_geometry (monitor, NULL, &y, NULL, NULL);
-
-  return y;
-}
-
-int
-panel_multiscreen_width (GdkScreen *screen,
-                        int        monitor)
-{
-  g_return_val_if_fail (monitor >= 0 && monitor < gdk_screen_get_n_monitors (screen), 0);
-
-  int width;
-
-  panel_multiscreen_get_monitor_geometry (monitor, NULL, NULL, NULL, &width);
-
-  return width;
-}
-
-int
-panel_multiscreen_height (GdkScreen *screen,
-                         int        monitor)
-{
-  g_return_val_if_fail (monitor >= 0 && monitor < gdk_screen_get_n_monitors (screen), 0);
-
-  int height;
-
-  panel_multiscreen_get_monitor_geometry (monitor, NULL, NULL, &height, NULL);
-
-  return height;
-}
-
 typedef struct {
        int x0;
        int y0;
diff --git a/gnome-panel/panel-multiscreen.h b/gnome-panel/panel-multiscreen.h
index 5453c76..f724366 100644
--- a/gnome-panel/panel-multiscreen.h
+++ b/gnome-panel/panel-multiscreen.h
@@ -36,15 +36,6 @@ void    panel_multiscreen_get_monitor_geometry  (int monitor_index,
                                                  int *height,
                                                  int *width);
 
-int    panel_multiscreen_x                     (GdkScreen *screen,
-                                                int        monitor);
-int    panel_multiscreen_y                     (GdkScreen *screen,
-                                                int        monitor);
-int    panel_multiscreen_width                 (GdkScreen *screen,
-                                                int        monitor);
-int    panel_multiscreen_height                (GdkScreen *screen,
-                                                int        monitor);
-
 void    panel_multiscreen_is_at_visible_extreme (int        monitor_index,
                                                  gboolean  *leftmost,
                                                  gboolean  *rightmost,
diff --git a/gnome-panel/panel-run-dialog.c b/gnome-panel/panel-run-dialog.c
index 490317c..4952919 100644
--- a/gnome-panel/panel-run-dialog.c
+++ b/gnome-panel/panel-run-dialog.c
@@ -1760,7 +1760,6 @@ static void
 panel_run_dialog_setup_entry (PanelRunDialog *dialog,
                              GtkBuilder     *gui)
 {
-       GdkScreen             *screen;
        int                    width_request;
        GtkWidget             *entry;
        
@@ -1774,10 +1773,12 @@ panel_run_dialog_setup_entry (PanelRunDialog *dialog,
        gtk_combo_box_set_entry_text_column
                (GTK_COMBO_BOX (dialog->combobox), 0);
 
-       screen = gtk_window_get_screen (GTK_WINDOW (dialog->run_dialog));
+       panel_multiscreen_get_monitor_geometry (0, NULL, NULL,
+                                               NULL, &width_request);
+
+       /* 1/4 the width of the first monitor should be a good value */
+       width_request /= 4;
 
-        /* 1/4 the width of the first monitor should be a good value */
-       width_request = panel_multiscreen_width (screen, 0) / 4;
        g_object_set (G_OBJECT (dialog->combobox),
                      "width_request", width_request,
                      NULL);
diff --git a/gnome-panel/panel-toplevel.c b/gnome-panel/panel-toplevel.c
index bc19d0a..35fc534 100644
--- a/gnome-panel/panel-toplevel.c
+++ b/gnome-panel/panel-toplevel.c
@@ -831,6 +831,7 @@ panel_toplevel_move_to (PanelToplevel *toplevel,
        PanelOrientation  new_orientation;
        gboolean          x_centered, y_centered;
        int               screen_width, screen_height;
+       int               new_monitor_x, new_monitor_y;
        int               monitor_width, monitor_height;
        int               width, height;
        int               new_monitor;
@@ -871,11 +872,15 @@ panel_toplevel_move_to (PanelToplevel *toplevel,
        panel_toplevel_get_monitor_geometry (
                        toplevel, NULL, NULL, &monitor_width, &monitor_height);
 
+       panel_multiscreen_get_monitor_geometry (new_monitor,
+                                               &new_monitor_x, &new_monitor_y,
+                                               NULL, NULL);
+
        x_centered = toplevel->priv->x_centered;
        y_centered = toplevel->priv->y_centered;
 
-       x = new_x - panel_multiscreen_x (screen, new_monitor);
-       y = new_y - panel_multiscreen_y (screen, new_monitor);
+       x = new_x - new_monitor_x;
+       y = new_y - new_monitor_y;
 
        if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK) {
                y_centered = FALSE;
@@ -1866,17 +1871,15 @@ get_delta (int       src,
 static void
 panel_toplevel_update_animating_position (PanelToplevel *toplevel)
 {
-       GdkScreen *screen;
        GTimeVal   time_val;
        int        deltax, deltay, deltaw = 0, deltah = 0;
        int        monitor_offset_x, monitor_offset_y;
 
        g_get_current_time (&time_val);
 
-       screen = gtk_window_get_screen (GTK_WINDOW (toplevel));
-
-       monitor_offset_x = panel_multiscreen_x (screen, toplevel->priv->monitor);
-       monitor_offset_y = panel_multiscreen_y (screen, toplevel->priv->monitor);
+       panel_toplevel_get_monitor_geometry (toplevel,
+                                            &monitor_offset_x, &monitor_offset_y,
+                                            NULL, NULL);
 
        if (toplevel->priv->animation_end_width != -1)
                deltaw = get_delta (toplevel->priv->geometry.width,
@@ -1984,8 +1987,8 @@ panel_toplevel_update_expanded_position (PanelToplevel *toplevel)
 
        panel_toplevel_set_monitor_internal (toplevel, monitor, TRUE);
 
-       x -= panel_multiscreen_x (screen, monitor);
-       y -= panel_multiscreen_y (screen, monitor);
+       x -= monitor_x;
+       y -= monitor_y;
 
        g_object_freeze_notify (G_OBJECT (toplevel));
 
@@ -2017,11 +2020,12 @@ panel_toplevel_update_position (PanelToplevel *toplevel)
 {
        int        x, y;
        int        w, h;
+       int        monitor_x, monitor_y;
        int        monitor_width, monitor_height;
-       GdkScreen *screen;
 
-       panel_toplevel_get_monitor_geometry (
-                       toplevel, NULL, NULL, &monitor_width, &monitor_height);
+       panel_toplevel_get_monitor_geometry (toplevel,
+                                            &monitor_x, &monitor_y,
+                                            &monitor_width, &monitor_height);
 
        if (toplevel->priv->animating) {
                panel_toplevel_update_animating_position (toplevel);
@@ -2105,9 +2109,8 @@ panel_toplevel_update_position (PanelToplevel *toplevel)
        if (h != -1)
                toplevel->priv->geometry.height = h;
 
-       screen = gtk_window_get_screen (GTK_WINDOW (toplevel));
-       x += panel_multiscreen_x (screen, toplevel->priv->monitor);
-       y += panel_multiscreen_y (screen, toplevel->priv->monitor);
+       x += monitor_x;
+       y += monitor_y;
 
        toplevel->priv->geometry.x = x;
        toplevel->priv->geometry.y = y;
@@ -2936,10 +2939,10 @@ panel_toplevel_calculate_animation_end_geometry (PanelToplevel *toplevel)
 static void
 panel_toplevel_start_animation (PanelToplevel *toplevel)
 {
-       GdkScreen      *screen;
        GtkRequisition  requisition;
        int             deltax, deltay, deltaw = 0, deltah = 0;
        int             cur_x = -1, cur_y = -1;
+       int             monitor_x, monitor_y;
        long            t;
 
        panel_toplevel_calculate_animation_end_geometry (toplevel);
@@ -2956,10 +2959,12 @@ panel_toplevel_start_animation (PanelToplevel *toplevel)
 
        gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (toplevel)), &cur_x, &cur_y);
 
-       screen = gtk_widget_get_screen (GTK_WIDGET (toplevel));
+       panel_toplevel_get_monitor_geometry (toplevel,
+                                            &monitor_x, &monitor_y,
+                                            NULL, NULL);
 
-       cur_x -= panel_multiscreen_x (screen, toplevel->priv->monitor);
-       cur_y -= panel_multiscreen_y (screen, toplevel->priv->monitor);
+       cur_x -= monitor_x;
+       cur_y -= monitor_y;
 
        deltax = toplevel->priv->animation_end_x - cur_x;
        deltay = toplevel->priv->animation_end_y - cur_y;


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