[mutter/gnome-3-10] window: don't set _NET_WM_FULLSCREEN_MONITORS to bogus values



commit b39ef6a9611f5dbd33ec5ba625222efab402c45b
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Sat Dec 14 14:24:27 2013 +0100

    window: don't set _NET_WM_FULLSCREEN_MONITORS to bogus values
    
    Prior to the DisplayConfig merge, we would set _NET_WM_FULLSCREEN_MONITORS
    to (unsigned)-1 when unset. After that, we would have invalid
    reads inside meta_screen_monitor_index_to_xinerama_index() (called
    with -1).
    The way I read the specification, the proper way to indicate
    that the window is back to fullscreen on all monitors is to
    remove the property, so do that.
    
    Also, add an assertion that meta_screne_monitor_index_to_xinerama_index()
    is doing the right thing.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=724258

 src/core/screen.c |    2 ++
 src/core/window.c |   46 +++++++++++++++++++++++++++++-----------------
 2 files changed, 31 insertions(+), 17 deletions(-)
---
diff --git a/src/core/screen.c b/src/core/screen.c
index 6ba2e68..737c605 100644
--- a/src/core/screen.c
+++ b/src/core/screen.c
@@ -392,6 +392,8 @@ int
 meta_screen_monitor_index_to_xinerama_index (MetaScreen *screen,
                                              int         index)
 {
+  g_return_val_if_fail (index >= 0 && index < screen->n_monitor_infos, -1);
+
   meta_screen_ensure_xinerama_indices (screen);
 
   return screen->monitor_infos[index].xinerama_index;
diff --git a/src/core/window.c b/src/core/window.c
index fdbd3b4..7a02c01 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -2059,23 +2059,35 @@ set_net_wm_state (MetaWindow *window)
 
   if (window->fullscreen)
     {
-      data[0] = meta_screen_monitor_index_to_xinerama_index (window->screen,
-                                                             window->fullscreen_monitors[0]);
-      data[1] = meta_screen_monitor_index_to_xinerama_index (window->screen,
-                                                             window->fullscreen_monitors[1]);
-      data[2] = meta_screen_monitor_index_to_xinerama_index (window->screen,
-                                                             window->fullscreen_monitors[2]);
-      data[3] = meta_screen_monitor_index_to_xinerama_index (window->screen,
-                                                             window->fullscreen_monitors[3]);
-
-      meta_verbose ("Setting _NET_WM_FULLSCREEN_MONITORS\n");
-      meta_error_trap_push (window->display);
-      XChangeProperty (window->display->xdisplay,
-                       window->xwindow,
-                       window->display->atom__NET_WM_FULLSCREEN_MONITORS,
-                       XA_CARDINAL, 32, PropModeReplace,
-                       (guchar*) data, 4);
-      meta_error_trap_pop (window->display);
+      if (window->fullscreen_monitors[0] >= 0)
+        {
+          data[0] = meta_screen_monitor_index_to_xinerama_index (window->screen,
+                                                                 window->fullscreen_monitors[0]);
+          data[1] = meta_screen_monitor_index_to_xinerama_index (window->screen,
+                                                                 window->fullscreen_monitors[1]);
+          data[2] = meta_screen_monitor_index_to_xinerama_index (window->screen,
+                                                                 window->fullscreen_monitors[2]);
+          data[3] = meta_screen_monitor_index_to_xinerama_index (window->screen,
+                                                                 window->fullscreen_monitors[3]);
+
+          meta_verbose ("Setting _NET_WM_FULLSCREEN_MONITORS\n");
+          meta_error_trap_push (window->display);
+          XChangeProperty (window->display->xdisplay,
+                           window->xwindow,
+                           window->display->atom__NET_WM_FULLSCREEN_MONITORS,
+                           XA_CARDINAL, 32, PropModeReplace,
+                           (guchar*) data, 4);
+          meta_error_trap_pop (window->display);
+        }
+      else
+        {
+          meta_verbose ("Clearing _NET_WM_FULLSCREEN_MONITORS\n");
+          meta_error_trap_push (window->display);
+          XDeleteProperty (window->display->xdisplay,
+                           window->xwindow,
+                           window->display->atom__NET_WM_FULLSCREEN_MONITORS);
+          meta_error_trap_pop (window->display);
+        }
     }
 }
 


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