[Xfce4-commits] [xfce/xfwm4] 10/32: Handle GDK display/screen/monitor deprecations

noreply at xfce.org noreply at xfce.org
Tue Dec 5 09:21:56 CET 2017


This is an automated email from the git hooks/post-receive script.

o   l   i   v   i   e   r       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/xfwm4.

commit 050a52ed2d44b1b5c16af4b85c518c16dd3c51d9
Author: Viktor Odintsev <zakhams at gmail.com>
Date:   Sun Jul 2 17:03:27 2017 +0300

    Handle GDK display/screen/monitor deprecations
---
 common/xfwm-common.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
 common/xfwm-common.h |  9 +++++++++
 src/client.c         |  4 +++-
 src/events.c         |  6 ++++--
 src/menu.c           | 33 +++++++++++++++++++++++++--------
 src/placement.c      |  6 +++---
 src/screen.c         | 18 ++++++++++--------
 src/tabwin.c         | 18 +++++++++---------
 src/workspaces.c     |  4 +++-
 9 files changed, 117 insertions(+), 32 deletions(-)

diff --git a/common/xfwm-common.c b/common/xfwm-common.c
index b6c9ae2..a89fc93 100644
--- a/common/xfwm-common.c
+++ b/common/xfwm-common.c
@@ -72,3 +72,54 @@ xfwm_get_screen_dimensions (gint *width, gint *height)
     *height = gdk_screen_height ();
 #endif
 }
+
+
+
+void
+xfwm_get_monitor_geometry (GdkScreen    *screen,
+                           gint          monitor_num,
+                           GdkRectangle *geometry)
+{
+#if GTK_CHECK_VERSION(3, 22, 0)
+  GdkDisplay *display;
+  GdkMonitor *monitor;
+
+  display = gdk_screen_get_display (screen);
+  monitor = gdk_display_get_monitor (display, monitor_num);
+  gdk_monitor_get_geometry (monitor, geometry);
+#else
+  gdk_screen_get_monitor_geometry (screen, monitor_num, geometry);
+#endif
+}
+
+
+
+void
+xfwm_get_primary_monitor_geometry (GdkScreen    *screen,
+                                   GdkRectangle *geometry)
+{
+#if GTK_CHECK_VERSION(3, 22, 0)
+  GdkDisplay *display;
+  GdkMonitor *monitor;
+
+  display = gdk_screen_get_display (screen);
+  monitor = gdk_display_get_primary_monitor (display);
+  gdk_monitor_get_geometry (monitor, geometry);
+#else
+  gdk_screen_get_monitor_geometry (screen,
+                                   gdk_screen_get_primary_monitor (screen),
+                                   geometry);
+#endif
+}
+
+
+
+gint
+xfwm_get_n_monitors (GdkScreen *screen)
+{
+#if GTK_CHECK_VERSION(3, 22, 0)
+  return gdk_display_get_n_monitors (gdk_screen_get_display (screen));
+#else
+  return gdk_screen_get_n_monitors (screen);
+#endif
+}
diff --git a/common/xfwm-common.h b/common/xfwm-common.h
index eb2ed41..742767f 100644
--- a/common/xfwm-common.h
+++ b/common/xfwm-common.h
@@ -29,4 +29,13 @@ void              xfwm_widget_reparent                  (GtkWidget    *widget,
 void              xfwm_get_screen_dimensions            (gint         *width,
                                                          gint         *height);
 
+void              xfwm_get_monitor_geometry             (GdkScreen    *screen,
+                                                         gint          monitor_num,
+                                                         GdkRectangle *geometry);
+
+void              xfwm_get_primary_monitor_geometry     (GdkScreen    *screen,
+                                                         GdkRectangle *geometry);
+
+gint              xfwm_get_n_monitors                   (GdkScreen    *screen);
+
 #endif /* !__COMMON_H__ */
diff --git a/src/client.c b/src/client.c
index 4085e75..e4f58cf 100644
--- a/src/client.c
+++ b/src/client.c
@@ -42,6 +42,8 @@
 #include <gtk/gtk.h>
 #include <libxfce4util/libxfce4util.h>
 
+#include <common/xfwm-common.h>
+
 #include "client.h"
 #include "compositor.h"
 #include "focus.h"
@@ -3079,7 +3081,7 @@ void clientSetFullscreenMonitor (Client *c, gint top, gint bottom, gint left, gi
     screen_info = c->screen_info;
     display_info = screen_info->display_info;
 
-    num_monitors = gdk_screen_get_n_monitors (screen_info->gscr);
+    num_monitors = xfwm_get_n_monitors (screen_info->gscr);
     if ((top >= 0)    && (top < num_monitors)    &&
         (bottom >= 0) && (bottom < num_monitors) &&
         (left >= 0)   && (left < num_monitors)   &&
diff --git a/src/events.c b/src/events.c
index e8b6b34..0c7e3ae 100644
--- a/src/events.c
+++ b/src/events.c
@@ -43,6 +43,8 @@
 #include <libxfce4util/libxfce4util.h>
 #include <libxfce4ui/libxfce4ui.h>
 
+#include <common/xfwm-common.h>
+
 #include "misc.h"
 #include "workspaces.h"
 #include "settings.h"
@@ -2765,7 +2767,7 @@ size_changed_cb(GdkScreen *gscreen, gpointer data)
     g_return_if_fail (screen_info);
     display_info = screen_info->display_info;
 
-    if (gdk_screen_get_n_monitors (screen_info->gscr) == 0)
+    if (xfwm_get_n_monitors (screen_info->gscr) == 0)
     {
         /*
          * Recent Xorg drivers disable the output when the lid
@@ -2811,7 +2813,7 @@ monitors_changed_cb(GdkScreen *gscreen, gpointer data)
     g_return_if_fail (screen_info);
     display_info = screen_info->display_info;
 
-    if (gdk_screen_get_n_monitors (screen_info->gscr) == 0)
+    if (xfwm_get_n_monitors (screen_info->gscr) == 0)
     {
         /*
          * Recent Xorg drivers disable the output when the lid
diff --git a/src/menu.c b/src/menu.c
index 9dcab0c..e8869ee 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -34,6 +34,8 @@
 #include <string.h>
 #include <libxfce4util/libxfce4util.h>
 
+#include <common/xfwm-common.h>
+
 #include "event_filter.h"
 #include "menu.h"
 #include "misc.h"
@@ -98,35 +100,50 @@ popup_position_func (GtkMenu * menu, gint * x, gint * y, gboolean * push_in,
 {
     GtkRequisition req;
     GdkPoint *pos;
-    gint monitor;
+#if GTK_CHECK_VERSION(3, 22, 0)
+    GdkDisplay *display;
+    GdkMonitor *monitor;
+#else
     GdkScreen *screen;
+    gint monitor_num;
+#endif
+    gint width;
+    gint height;
 
     pos = user_data;
 
     gtk_widget_size_request (GTK_WIDGET (menu), &req);
 
+    xfwm_get_screen_dimensions (&width, &height);
+
     if (pos->x >= 0)
     {
         *x = pos->x;
-        *x = CLAMP (*x, 0, MAX (0, gdk_screen_width () - req.width));
+        *x = CLAMP (*x, 0, MAX (0, width - req.width));
     }
     else
     {
-        *x = (gdk_screen_width () - req.width) / 2;
+        *x = (width - req.width) / 2;
     }
     if (pos->x >= 0)
     {
         *y = pos->y;
-        *y = CLAMP (*y, 0, MAX (0, gdk_screen_height () - req.height));
+        *y = CLAMP (*y, 0, MAX (0, height - req.height));
     }
     else
     {
-        *y = (gdk_screen_height () - req.height) / 2;
+        *y = (height - req.height) / 2;
     }
 
-    screen = gtk_widget_get_screen (GTK_WIDGET(menu));
-    monitor = gdk_screen_get_monitor_at_point (screen, *x, *y);
-    gtk_menu_set_monitor (GTK_MENU (menu), monitor);
+#if GTK_CHECK_VERSION(3, 22, 0)
+    display = gtk_widget_get_display (GTK_WIDGET (menu));
+    monitor = gdk_display_get_monitor_at_point (display, *x, *y);
+    gtk_menu_place_on_monitor (GTK_MENU (menu), monitor);
+#else
+    screen = gtk_widget_get_screen (GTK_WIDGET (menu));
+    monitor_num = gdk_screen_get_monitor_at_point (screen, *x, *y);
+    gtk_menu_set_monitor (GTK_MENU (menu), monitor_num);
+#endif
 
     g_free (user_data);
 }
diff --git a/src/placement.c b/src/placement.c
index 9090a3f..d679bf8 100644
--- a/src/placement.c
+++ b/src/placement.c
@@ -29,6 +29,8 @@
 #include <glib.h>
 #include <libxfce4util/libxfce4util.h>
 
+#include <common/xfwm-common.h>
+
 #include "screen.h"
 #include "misc.h"
 #include "client.h"
@@ -771,9 +773,7 @@ clientInitPosition (Client * c)
     position = (c->size->flags & (PPosition | USPosition));
 
     n_monitors = myScreenGetNumMonitors (c->screen_info);
-    gdk_screen_get_monitor_geometry (screen_info->gscr,
-                                     gdk_screen_get_primary_monitor (screen_info->gscr),
-                                     &rect);
+    xfwm_get_primary_monitor_geometry (screen_info->gscr, &rect);
     is_transient = clientIsTransient (c);
 
     if (position || is_transient || (c->type & (WINDOW_TYPE_DONT_PLACE | WINDOW_TYPE_DIALOG)))
diff --git a/src/screen.c b/src/screen.c
index cfb3884..0d80916 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -44,6 +44,8 @@
 #include <libsn/sn.h>
 #endif
 
+#include <common/xfwm-common.h>
+
 #include "display.h"
 #include "screen.h"
 #include "misc.h"
@@ -632,7 +634,7 @@ myScreenComputeSize (ScreenInfo *screen_info)
 
     width = 0;
     height = 0;
-    num_monitors = gdk_screen_get_n_monitors (screen_info->gscr);
+    num_monitors = xfwm_get_n_monitors (screen_info->gscr);
 
     if (num_monitors == 0)
     {
@@ -641,13 +643,13 @@ myScreenComputeSize (ScreenInfo *screen_info)
 
     for (i = 0; i < num_monitors; i++)
     {
-        gdk_screen_get_monitor_geometry (screen_info->gscr, i, &monitor);
+        xfwm_get_monitor_geometry (screen_info->gscr, i, &monitor);
         width = MAX (monitor.x + monitor.width, width);
         height = MAX (monitor.y + monitor.height, height);
     }
 
-    screen_info->logical_width = gdk_screen_get_width (screen_info->gscr);
-    screen_info->logical_height = gdk_screen_get_height (screen_info->gscr);
+    screen_info->logical_width = WidthOfScreen (screen_info->xscreen);
+    screen_info->logical_height = HeightOfScreen (screen_info->xscreen);
     if ((width != screen_info->logical_width) || (height != screen_info->logical_height))
     {
         g_warning ("output size (%dx%d) and logical screen size (%dx%d) do not match",
@@ -718,14 +720,14 @@ myScreenRebuildMonitorIndex (ScreenInfo *screen_info)
      * the bigger ones first (giving preference to taller monitors
      * over wider monitors)
      */
-    num_monitors = gdk_screen_get_n_monitors (screen_info->gscr);
+    num_monitors = xfwm_get_n_monitors (screen_info->gscr);
     for (i = 0; i < num_monitors; i++)
     {
-        gdk_screen_get_monitor_geometry (screen_info->gscr, i, &monitor);
+        xfwm_get_monitor_geometry (screen_info->gscr, i, &monitor);
         cloned = FALSE;
         for (j = 0; j < (gint) screen_info->monitors_index->len; j++)
         {
-            gdk_screen_get_monitor_geometry (screen_info->gscr, j, &previous);
+            xfwm_get_monitor_geometry (screen_info->gscr, j, &previous);
             if ((previous.x == monitor.x) && (previous.y == monitor.y))
             {
                 cloned = TRUE;
@@ -788,7 +790,7 @@ myScreenFindMonitorAtPoint (ScreenInfo *screen_info, gint x, gint y, GdkRectangl
         gint monitor_index;
 
         monitor_index = myScreenGetMonitorIndex (screen_info, i);
-        gdk_screen_get_monitor_geometry (screen_info->gscr, monitor_index, &monitor);
+        xfwm_get_monitor_geometry (screen_info->gscr, monitor_index, &monitor);
 
         if ((x >= monitor.x) && (x < (monitor.x + monitor.width)) &&
             (y >= monitor.y) && (y < (monitor.y + monitor.height)))
diff --git a/src/tabwin.c b/src/tabwin.c
index def337f..83c3b8b 100644
--- a/src/tabwin.c
+++ b/src/tabwin.c
@@ -65,6 +65,9 @@
 #include <gdk/gdk.h>
 #include <gtk/gtk.h>
 #include <libxfce4util/libxfce4util.h>
+
+#include <common/xfwm-common.h>
+
 #include "icons.h"
 #include "focus.h"
 #include "tabwin.h"
@@ -383,7 +386,7 @@ getMinMonitorWidth (ScreenInfo *screen_info)
     for (min_width = i = 0; i < num_monitors; i++)
     {
         GdkRectangle monitor;
-        gdk_screen_get_monitor_geometry (screen_info->gscr, i, &monitor);
+        xfwm_get_monitor_geometry (screen_info->gscr, i, &monitor);
         if (min_width == 0 || monitor.width < min_width)
             min_width = monitor.width;
     }
@@ -397,7 +400,7 @@ getMinMonitorHeight (ScreenInfo *screen_info)
     for (min_height = i = 0; i < num_monitors; i++)
     {
         GdkRectangle monitor;
-        gdk_screen_get_monitor_geometry (screen_info->gscr, i, &monitor);
+        xfwm_get_monitor_geometry (screen_info->gscr, i, &monitor);
         if (min_height == 0 || monitor.height < min_height)
         {
             min_height = monitor.height;
@@ -609,9 +612,7 @@ createWindowlist (ScreenInfo *screen_info, TabwinWidget *tabwin_widget)
 static gboolean
 tabwinConfigure (TabwinWidget *tabwin_widget, GdkEventConfigure *event)
 {
-    GtkWindow *window;
     GdkRectangle monitor;
-    GdkScreen *screen;
     gint x, y;
 
     g_return_val_if_fail (tabwin_widget != NULL, FALSE);
@@ -622,12 +623,11 @@ tabwinConfigure (TabwinWidget *tabwin_widget, GdkEventConfigure *event)
         return FALSE;
     }
 
-    window = GTK_WINDOW(tabwin_widget);
-    screen = gtk_window_get_screen(window);
-    gdk_screen_get_monitor_geometry (screen, tabwin_widget->monitor_num, &monitor);
+    xfwm_get_monitor_geometry (gtk_widget_get_screen (GTK_WIDGET (tabwin_widget)),
+                               tabwin_widget->monitor_num, &monitor);
     x = monitor.x + (monitor.width - event->width) / 2;
     y = monitor.y + (monitor.height - event->height) / 2;
-    gtk_window_move (window, x, y);
+    gtk_window_move (GTK_WINDOW (tabwin_widget), x, y);
 
     tabwin_widget->width = event->width;
     tabwin_widget->height = event->height;
@@ -848,7 +848,7 @@ tabwinCreateWidget (Tabwin *tabwin, ScreenInfo *screen_info, gint monitor_num)
     gtk_widget_style_get (GTK_WIDGET(tabwin_widget), "border-radius", &border_radius, NULL);
     gtk_container_set_border_width (GTK_CONTAINER (tabwin_widget), border_radius + 4);
     gtk_window_set_position (GTK_WINDOW (tabwin_widget), GTK_WIN_POS_NONE);
-    gdk_screen_get_monitor_geometry (screen_info->gscr, tabwin_widget->monitor_num, &monitor);
+    xfwm_get_monitor_geometry (screen_info->gscr, tabwin_widget->monitor_num, &monitor);
     gtk_window_move (GTK_WINDOW (tabwin_widget), monitor.x + monitor.width / 2,
                                       monitor.y + monitor.height / 2);
 
diff --git a/src/workspaces.c b/src/workspaces.c
index 1006d6e..62c3702 100644
--- a/src/workspaces.c
+++ b/src/workspaces.c
@@ -35,6 +35,8 @@
 #include <gtk/gtk.h>
 #include <libxfce4util/libxfce4util.h>
 
+#include <common/xfwm-common.h>
+
 #include "display.h"
 #include "screen.h"
 #include "misc.h"
@@ -546,7 +548,7 @@ workspaceUpdateArea (ScreenInfo *screen_info)
         screen_info->margins[i] = screen_info->gnome_margins[i];
     }
 
-    gdk_screen_get_monitor_geometry (screen_info->gscr, gdk_screen_get_primary_monitor(screen_info->gscr), &workarea);
+    xfwm_get_primary_monitor_geometry (screen_info->gscr, &workarea);
 
     for (c = screen_info->clients, i = 0; i < screen_info->client_count; c = c->next, i++)
     {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list