kathenas / rpms / mutter

Forked from rpms/mutter 5 years ago
Clone

Blame SOURCES/0004-wayland-force-X-clients-to-redraw-on-resume.patch

88c283
From a4a703c75e208badf78c81558994a249797dbb0a Mon Sep 17 00:00:00 2001
776610
From: Ray Strode <rstrode@redhat.com>
776610
Date: Sat, 12 Jan 2019 12:38:01 -0500
776610
Subject: [PATCH 4/9] wayland: force X clients to redraw on resume
776610
776610
On nvidia, the textures backing Xwayland client window contents get
776610
corrupted on suspend.  Xwayland currently doesn't handle this situation
776610
itself.
776610
776610
For now, in order to work around this issue, send an empty output
776610
change event to Xwayland.  This will cause it to force Expose events
776610
to get sent to all clients and get them to redraw.
776610
---
776610
 .../native/meta-monitor-manager-kms.c         |  7 +++
776610
 src/wayland/meta-wayland-outputs.c            | 47 +++++++++++++++++++
776610
 src/wayland/meta-wayland-outputs.h            |  1 +
776610
 3 files changed, 55 insertions(+)
776610
776610
diff --git a/src/backends/native/meta-monitor-manager-kms.c b/src/backends/native/meta-monitor-manager-kms.c
88c283
index 9a0364441..7bcceee97 100644
776610
--- a/src/backends/native/meta-monitor-manager-kms.c
776610
+++ b/src/backends/native/meta-monitor-manager-kms.c
88c283
@@ -60,6 +60,7 @@
88c283
 #include "clutter/clutter.h"
88c283
 #include "meta/main.h"
88c283
 #include "meta/meta-x11-errors.h"
776610
+#include "wayland/meta-wayland-outputs.h"
776610
 
776610
 #define DRM_CARD_UDEV_DEVICE_TYPE "drm_minor"
776610
 
88c283
@@ -505,9 +506,15 @@ void
776610
 meta_monitor_manager_kms_resume (MetaMonitorManagerKms *manager_kms)
776610
 {
776610
   MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_kms);
776610
+  ClutterBackend *clutter_backend = clutter_get_default_backend ();
776610
+  CoglContext *cogl_context =
776610
+    clutter_backend_get_cogl_context (clutter_backend);
776610
 
776610
   meta_monitor_manager_kms_connect_uevent_handler (manager_kms);
776610
   handle_hotplug_event (manager);
776610
+
776610
+  if (cogl_has_feature (cogl_context, COGL_FEATURE_ID_UNSTABLE_TEXTURES))
776610
+    meta_wayland_outputs_redraw (meta_wayland_compositor_get_default ());
776610
 }
776610
 
776610
 static gboolean
776610
diff --git a/src/wayland/meta-wayland-outputs.c b/src/wayland/meta-wayland-outputs.c
88c283
index 099e87ab9..bc69d699d 100644
776610
--- a/src/wayland/meta-wayland-outputs.c
776610
+++ b/src/wayland/meta-wayland-outputs.c
88c283
@@ -496,6 +496,53 @@ meta_wayland_compositor_update_outputs (MetaWaylandCompositor *compositor,
776610
   return new_table;
776610
 }
776610
 
776610
+void
776610
+meta_wayland_outputs_redraw (MetaWaylandCompositor *compositor)
776610
+{
776610
+  MetaMonitorManager *monitor_manager;
776610
+  GList *logical_monitors, *l;
776610
+
776610
+  monitor_manager = meta_monitor_manager_get ();
776610
+
776610
+  logical_monitors =
776610
+    meta_monitor_manager_get_logical_monitors (monitor_manager);
776610
+
776610
+  for (l = logical_monitors; l; l = l->next)
776610
+    {
776610
+      MetaLogicalMonitor *logical_monitor = l->data;
776610
+      MetaWaylandOutput *wayland_output;
776610
+      GList *iter;
776610
+
776610
+      if (logical_monitor->winsys_id == 0)
776610
+        continue;
776610
+
776610
+      wayland_output =
776610
+        g_hash_table_lookup (compositor->outputs,
776610
+                             GSIZE_TO_POINTER (logical_monitor->winsys_id));
776610
+
776610
+      if (wayland_output == NULL)
776610
+        continue;
776610
+
776610
+      /* Just output a "changes done" event for one of the outputs, with no actual changes.
776610
+       * xwayland takes this as a cue to send expose events to all X clients.
776610
+       */
776610
+      for (iter = wayland_output->resources; iter; iter = iter->next)
776610
+        {
776610
+          struct wl_resource *resource = iter->data;
776610
+          if (wl_resource_get_version (resource) >= WL_OUTPUT_DONE_SINCE_VERSION)
776610
+            wl_output_send_done (resource);
776610
+        }
776610
+
776610
+      for (iter = wayland_output->xdg_output_resources; iter; iter = iter->next)
776610
+        {
776610
+          struct wl_resource *xdg_output = iter->data;
776610
+          zxdg_output_v1_send_done (xdg_output);
776610
+        }
776610
+
776610
+      break;
776610
+    }
776610
+}
776610
+
776610
 static void
776610
 on_monitors_changed (MetaMonitorManager    *monitors,
776610
                      MetaWaylandCompositor *compositor)
776610
diff --git a/src/wayland/meta-wayland-outputs.h b/src/wayland/meta-wayland-outputs.h
88c283
index ff15a81bd..d649e0fa1 100644
776610
--- a/src/wayland/meta-wayland-outputs.h
776610
+++ b/src/wayland/meta-wayland-outputs.h
88c283
@@ -49,5 +49,6 @@ struct _MetaWaylandOutput
776610
 };
776610
 
776610
 void meta_wayland_outputs_init (MetaWaylandCompositor *compositor);
776610
+void meta_wayland_outputs_redraw (MetaWaylandCompositor *compositor);
776610
 
776610
 #endif /* META_WAYLAND_OUTPUTS_H */
776610
-- 
88c283
2.21.0
776610