[gnome-panel/wip/geiger/geometry: 2/7] Add panel-multi-monitor



commit 661efe22e6a5dbe0bdb9e73f38c0d90317d7572e
Author: Sebastian Geiger <sbastig gmx net>
Date:   Fri Feb 16 23:22:52 2018 +0100

    Add panel-multi-monitor

 gnome-panel/Makefile.am           |    2 +
 gnome-panel/panel-multi-monitor.c |   39 +++++++++++++++++++++++++++++++++++++
 gnome-panel/panel-multi-monitor.h |   27 +++++++++++++++++++++++++
 gnome-panel/panel-struts.c        |   38 ++++++++++-------------------------
 4 files changed, 79 insertions(+), 27 deletions(-)
---
diff --git a/gnome-panel/Makefile.am b/gnome-panel/Makefile.am
index 1df0258..07620cf 100644
--- a/gnome-panel/Makefile.am
+++ b/gnome-panel/Makefile.am
@@ -46,6 +46,7 @@ panel_sources =                       \
        panel-toplevel.c        \
        panel-struts.c          \
        panel-xutils.c          \
+       panel-multi-monitor.c \
        panel-multiscreen.c     \
        panel-a11y.c            \
        panel-bindings.c        \
@@ -84,6 +85,7 @@ panel_headers =                       \
        panel-toplevel.h        \
        panel-struts.h          \
        panel-xutils.h          \
+       panel-multi-monitor.h \
        panel-multiscreen.h     \
        panel-a11y.h            \
        panel-bindings.h        \
diff --git a/gnome-panel/panel-multi-monitor.c b/gnome-panel/panel-multi-monitor.c
new file mode 100644
index 0000000..625196f
--- /dev/null
+++ b/gnome-panel/panel-multi-monitor.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2018 Sebastian Geiger
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "panel-multi-monitor.h"
+
+#include <gtk/gtk.h>
+
+void
+panel_multi_monitor_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-multi-monitor.h b/gnome-panel/panel-multi-monitor.h
new file mode 100644
index 0000000..9cd88ce
--- /dev/null
+++ b/gnome-panel/panel-multi-monitor.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2018 Sebastian Geiger
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PANEL_MULTI_MONITOR_H
+#define PANEL_MULTI_MONITOR_H
+
+void panel_multi_monitor_get_monitor_geometry  (int monitor_index,
+                                                int *x,
+                                                int *y,
+                                                int *height,
+                                                int *width);
+
+#endif //PANEL_MULTI_MONITOR_H
diff --git a/gnome-panel/panel-struts.c b/gnome-panel/panel-struts.c
index 2bc4bda..c14bfb8 100644
--- a/gnome-panel/panel-struts.c
+++ b/gnome-panel/panel-struts.c
@@ -25,6 +25,7 @@
 
 #include "panel-multiscreen.h"
 #include "panel-xutils.h"
+#include "panel-multi-monitor.h"
 
 
 typedef struct {
@@ -64,20 +65,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 +185,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_multi_monitor_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 +256,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_multi_monitor_get_monitor_geometry (strut->monitor,
+                                                 &monitor_x, &monitor_y,
+                                                 &monitor_height, &monitor_width);
 
         panel_multiscreen_is_at_visible_extreme (strut->screen,
                                                  strut->monitor,
@@ -407,10 +391,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_multi_monitor_get_monitor_geometry (monitor,
+                                                 &monitor_x, &monitor_y,
+                                                 &monitor_height, &monitor_width);
 
        switch (strut->orientation) {
        case PANEL_ORIENTATION_TOP:


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