[Xfce4-commits] [xfce/xfwm4] 02/02: Use ximerama indices for _NET_WM_FULLSCREEN_MONITORS

noreply at xfce.org noreply at xfce.org
Mon May 15 09:10:17 CEST 2017


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

olivier pushed a commit to branch xfce-4.12
in repository xfce/xfwm4.

commit c3673a138bf8c3512a1d7382e7883a9f33af77ad
Author: Olivier Fourdan <fourdan at xfce.org>
Date:   Mon May 1 22:15:49 2017 +0200

    Use ximerama indices for _NET_WM_FULLSCREEN_MONITORS
    
    Bug: 9351
    
    _NET_WM_FULLSCREEN_MONITORS uses Xinerama indices for multi-monitor
    fullscreen, but xfwm4 uses gdk indices which may differ.
    
    As a result, depending on the actual layout and which monitor is marked
    as primary, a fullscreen window could be placed on the wrong outputs.
    
    Fetch the Xinerama list and use the monitor size from there instead of
    relying on gdk monitor indices for _NET_WM_FULLSCREEN_MONITORS
    
    (cherry picked from commit 29e813a4fe7ad1dbe77a96dd841627fc567a6bd6)
---
 configure.ac.in |  1 +
 src/Makefile.am |  2 ++
 src/client.c    |  5 +++--
 src/screen.c    | 27 +++++++++++++++++++++++++++
 src/screen.h    |  4 +++-
 5 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/configure.ac.in b/configure.ac.in
index 5a55fbf..21b3772 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -95,6 +95,7 @@ XDT_CHECK_PACKAGE([LIBXFCONF], libxfconf-0, [xfconf_minimum_version])
 XDT_CHECK_PACKAGE([LIBWNCK], [libwnck-1.0], [wnck_minimum_version])
 XDT_CHECK_PACKAGE([DBUS], [dbus-1], [1.0.0])
 XDT_CHECK_PACKAGE([DBUS_GLIB], [dbus-glib-1], [0.72])
+XDT_CHECK_PACKAGE([XINERAMA], [xinerama], [0])
 
 AS_IF([test "x$USE_MAINTAINER_MODE" = "xyes"],
 [
diff --git a/src/Makefile.am b/src/Makefile.am
index ee2fff6..4052094 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -83,6 +83,7 @@ xfwm4_CFLAGS =								\
 	$(LIBDRM_CFLAGS)						\
 	$(LIBSTARTUP_NOTIFICATION_CFLAGS)				\
 	$(COMPOSITOR_CFLAGS)						\
+	$(XINERAMA_CFLAGS)						\
 	-DPACKAGE_LOCALE_DIR=\"$(localedir)\"				\
 	-DDATADIR=\"$(datadir)\"					\
 	-DHELPERDIR=\"$(HELPER_PATH_PREFIX)\"				\
@@ -102,6 +103,7 @@ xfwm4_LDADD =								\
 	$(RENDER_LIBS)							\
 	$(COMPOSITOR_LIBS)						\
 	$(RANDR_LIBS) 							\
+	$(XINERAMA_LIBS) 						\
 	$(MATH_LIBS)
 
 EXTRA_DIST = 								\
diff --git a/src/client.c b/src/client.c
index 0d946de..b8301b3 100644
--- a/src/client.c
+++ b/src/client.c
@@ -2974,10 +2974,11 @@ clientUpdateFullscreenSize (Client *c)
     {
         if (FLAG_TEST (c->flags, CLIENT_FLAG_FULLSCREN_MONITORS))
         {
-            gdk_screen_get_monitor_geometry (screen_info->gscr, c->fullscreen_monitors[0], &rect);
+            /* Monitor numbering is from Xinerama */
+            myScreenGetXineramaMonitorGeometry (screen_info, c->fullscreen_monitors[0], &rect);
             for (i = 1; i < 4; i++)
             {
-                gdk_screen_get_monitor_geometry (screen_info->gscr, c->fullscreen_monitors[i], &monitor);
+                myScreenGetXineramaMonitorGeometry (screen_info, c->fullscreen_monitors[i], &monitor);
                 gdk_rectangle_union (&rect, &monitor, &rect);
             }
         }
diff --git a/src/screen.c b/src/screen.c
index ffc4f87..34e3d76 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -27,6 +27,7 @@
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 #include <X11/extensions/shape.h>
+#include <X11/extensions/Xinerama.h>
 #include <glib.h>
 #include <gdk/gdk.h>
 #include <gdk/gdkx.h>
@@ -820,6 +821,31 @@ myScreenFindMonitorAtPoint (ScreenInfo *screen_info, gint x, gint y, GdkRectangl
     *rect = screen_info->cache_monitor;
 }
 
+void
+myScreenGetXineramaMonitorGeometry (ScreenInfo *screen_info, gint monitor_num, GdkRectangle *rect)
+{
+    XineramaScreenInfo *infos;
+    int n;
+
+    g_return_if_fail (screen_info != NULL);
+    g_return_if_fail (rect != NULL);
+    g_return_if_fail (XineramaIsActive (myScreenGetXDisplay (screen_info)));
+
+    infos = XineramaQueryScreens (myScreenGetXDisplay (screen_info), &n);
+    if (infos == NULL || n <= 0 || monitor_num < n || monitor_num > n)
+    {
+        XFree (infos);
+        return;
+    }
+
+    rect->x = infos[monitor_num].x_org;
+    rect->y = infos[monitor_num].y_org;
+    rect->width = infos[monitor_num].width;
+    rect->height = infos[monitor_num].height;
+
+    XFree (infos);
+}
+
 gboolean
 myScreenUpdateFontHeight (ScreenInfo *screen_info)
 {
@@ -848,3 +874,4 @@ myScreenUpdateFontHeight (ScreenInfo *screen_info)
 
     return FALSE;
 }
+
diff --git a/src/screen.h b/src/screen.h
index 9aeffc4..00f5fd0 100644
--- a/src/screen.h
+++ b/src/screen.h
@@ -247,5 +247,7 @@ void                     myScreenFindMonitorAtPoint             (ScreenInfo *,
                                                                  gint,
                                                                  GdkRectangle *);
 gboolean                 myScreenUpdateFontHeight               (ScreenInfo *);
-
+void                     myScreenGetXineramaMonitorGeometry     (ScreenInfo *,
+                                                                 gint,
+                                                                 GdkRectangle *);
 #endif /* INC_SCREEN_H */

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


More information about the Xfce4-commits mailing list