[mutter] wayland: Sync surface actor state when changing main monitor



commit fffb863f372a71e3bd38df7a58721eeabc53f538
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Tue Mar 3 11:13:05 2015 +0800

    wayland: Sync surface actor state when changing main monitor
    
    In order to switch to the correct surface actor scale given the monitor
    the surface is on, without relying on the client committing a new state
    given some other side effect, sync the surface actor state when the main
    monitor associated with the corresponding window changed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=744933

 src/compositor/meta-surface-actor-wayland.c |   17 +++++++++++++++++
 src/compositor/meta-surface-actor-wayland.h |    2 ++
 src/core/window-private.h                   |    2 ++
 src/core/window.c                           |   25 +++++++++++++++++++------
 src/wayland/window-wayland.c                |   17 +++++++++++++++++
 src/x11/window-x11.c                        |    7 +++++++
 6 files changed, 64 insertions(+), 6 deletions(-)
---
diff --git a/src/compositor/meta-surface-actor-wayland.c b/src/compositor/meta-surface-actor-wayland.c
index 7957399..a70d8e1 100644
--- a/src/compositor/meta-surface-actor-wayland.c
+++ b/src/compositor/meta-surface-actor-wayland.c
@@ -175,6 +175,23 @@ meta_surface_actor_wayland_sync_state (MetaSurfaceActorWayland *self)
     }
 }
 
+void
+meta_surface_actor_wayland_sync_state_recursive (MetaSurfaceActorWayland *self)
+{
+  MetaWaylandSurface *surface = meta_surface_actor_wayland_get_surface (self);
+  GList *iter;
+
+  meta_surface_actor_wayland_sync_state (self);
+
+  for (iter = surface->subsurfaces; iter != NULL; iter = iter->next)
+    {
+      MetaWaylandSurface *subsurf = iter->data;
+
+      meta_surface_actor_wayland_sync_state_recursive (
+        META_SURFACE_ACTOR_WAYLAND (subsurf->surface_actor));
+    }
+}
+
 static MetaWindow *
 meta_surface_actor_wayland_get_window (MetaSurfaceActor *actor)
 {
diff --git a/src/compositor/meta-surface-actor-wayland.h b/src/compositor/meta-surface-actor-wayland.h
index 8ef2b05..28fd43c 100644
--- a/src/compositor/meta-surface-actor-wayland.h
+++ b/src/compositor/meta-surface-actor-wayland.h
@@ -65,6 +65,8 @@ double meta_surface_actor_wayland_get_scale (MetaSurfaceActorWayland *actor);
 
 void meta_surface_actor_wayland_sync_state (MetaSurfaceActorWayland *self);
 
+void meta_surface_actor_wayland_sync_state_recursive (MetaSurfaceActorWayland *self);
+
 G_END_DECLS
 
 #endif /* __META_SURFACE_ACTOR_WAYLAND_H__ */
diff --git a/src/core/window-private.h b/src/core/window-private.h
index 1ae29fc..136635c 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -482,6 +482,8 @@ struct _MetaWindowClass
   gboolean (*update_icon)        (MetaWindow       *window,
                                   cairo_surface_t **icon,
                                   cairo_surface_t **mini_icon);
+  void (*main_monitor_changed)   (MetaWindow *window,
+                                  const MetaMonitorInfo *old);
 };
 
 /* These differ from window->has_foo_func in that they consider
diff --git a/src/core/window.c b/src/core/window.c
index b8245a3..3e80dc8 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -761,6 +761,20 @@ meta_window_update_desc (MetaWindow *window)
     window->desc = g_strdup_printf ("0x%lx", window->xwindow);
 }
 
+static void
+meta_window_main_monitor_changed (MetaWindow *window,
+                                  const MetaMonitorInfo *old)
+{
+  META_WINDOW_GET_CLASS (window)->main_monitor_changed (window, old);
+
+  if (old)
+    g_signal_emit_by_name (window->screen, "window-left-monitor",
+                           old->number, window);
+  if (window->monitor)
+    g_signal_emit_by_name (window->screen, "window-entered-monitor",
+                           window->monitor->number, window);
+}
+
 MetaWindow *
 _meta_window_shared_new (MetaDisplay         *display,
                          MetaScreen          *screen,
@@ -1128,7 +1142,7 @@ _meta_window_shared_new (MetaDisplay         *display,
       meta_window_update_struts (window);
     }
 
-  g_signal_emit_by_name (window->screen, "window-entered-monitor", window->monitor->number, window);
+  meta_window_main_monitor_changed (window, NULL);
 
   /* Must add window to stack before doing move/resize, since the
    * window might have fullscreen size (i.e. should have been
@@ -1369,9 +1383,10 @@ meta_window_unmanage (MetaWindow  *window,
 
   if (window->monitor)
     {
-      g_signal_emit_by_name (window->screen, "window-left-monitor",
-                             window->monitor->number, window);
+      const MetaMonitorInfo *old = window->monitor;
+
       window->monitor = NULL;
+      meta_window_main_monitor_changed (window, old);
     }
 
   if (!window->override_redirect)
@@ -3568,9 +3583,7 @@ meta_window_update_monitor (MetaWindow *window,
           window->screen->active_workspace != window->workspace)
         meta_window_change_workspace (window, window->screen->active_workspace);
 
-      if (old)
-        g_signal_emit_by_name (window->screen, "window-left-monitor", old->number, window);
-      g_signal_emit_by_name (window->screen, "window-entered-monitor", window->monitor->number, window);
+      meta_window_main_monitor_changed (window, old);
 
       /* If we're changing monitors, we need to update the has_maximize_func flag,
        * as the working area has changed. */
diff --git a/src/wayland/window-wayland.c b/src/wayland/window-wayland.c
index b358a73..b7016b9 100644
--- a/src/wayland/window-wayland.c
+++ b/src/wayland/window-wayland.c
@@ -31,6 +31,7 @@
 #include "boxes-private.h"
 #include "stack-tracker.h"
 #include "meta-wayland-surface.h"
+#include "compositor/meta-surface-actor-wayland.h"
 
 struct _MetaWindowWayland
 {
@@ -271,6 +272,21 @@ meta_window_wayland_move_resize_internal (MetaWindow                *window,
 }
 
 static void
+meta_window_wayland_main_monitor_changed (MetaWindow *window,
+                                          const MetaMonitorInfo *old)
+{
+  MetaWaylandSurface *surface = window->surface;
+
+  if (surface)
+    {
+      MetaSurfaceActorWayland *actor =
+        META_SURFACE_ACTOR_WAYLAND (surface->surface_actor);
+
+      meta_surface_actor_wayland_sync_state_recursive (actor);
+    }
+}
+
+static void
 appears_focused_changed (GObject    *object,
                          GParamSpec *pspec,
                          gpointer    user_data)
@@ -308,6 +324,7 @@ meta_window_wayland_class_init (MetaWindowWaylandClass *klass)
   window_class->grab_op_began = meta_window_wayland_grab_op_began;
   window_class->grab_op_ended = meta_window_wayland_grab_op_ended;
   window_class->move_resize_internal = meta_window_wayland_move_resize_internal;
+  window_class->main_monitor_changed = meta_window_wayland_main_monitor_changed;
 }
 
 MetaWindow *
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
index 5a741eb..ec3656e 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -1471,6 +1471,12 @@ meta_window_x11_update_icon (MetaWindow       *window,
 }
 
 static void
+meta_window_x11_main_monitor_changed (MetaWindow *window,
+                                      const MetaMonitorInfo *old)
+{
+}
+
+static void
 meta_window_x11_class_init (MetaWindowX11Class *klass)
 {
   MetaWindowClass *window_class = META_WINDOW_CLASS (klass);
@@ -1488,6 +1494,7 @@ meta_window_x11_class_init (MetaWindowX11Class *klass)
   window_class->update_struts = meta_window_x11_update_struts;
   window_class->get_default_skip_hints = meta_window_x11_get_default_skip_hints;
   window_class->update_icon = meta_window_x11_update_icon;
+  window_class->main_monitor_changed = meta_window_x11_main_monitor_changed;
 }
 
 void


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