[mutter] compositor: Loop and retry to get compositor selection when replacing
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] compositor: Loop and retry to get compositor selection when replacing
- Date: Tue, 21 Jun 2011 19:22:10 +0000 (UTC)
commit c18940a5a250240d2b6fbf74f40eaf5d7791db88
Author: Colin Walters <walters verbum org>
Date: Tue Jun 21 14:05:59 2011 -0400
compositor: Loop and retry to get compositor selection when replacing
There are unavoidable race conditions here when another process is
replacing us. As a band aid, loop for 5 seconds.
https://bugzilla.gnome.org/show_bug.cgi?id=653121
src/compositor/compositor.c | 32 +++++++++++++++++++++++++-------
1 files changed, 25 insertions(+), 7 deletions(-)
---
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index 7498990..e770ef5 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -11,6 +11,7 @@
#include <meta/compositor-mutter.h>
#include "xprops.h"
#include <meta/prefs.h>
+#include <meta/main.h>
#include <meta/meta-shadow-factory.h>
#include "meta-window-actor-private.h"
#include "meta-window-group.h"
@@ -474,20 +475,37 @@ meta_compositor_manage_screen (MetaCompositor *compositor,
gint width, height;
XWindowAttributes attr;
long event_mask;
+ guint n_retries;
+ guint max_retries;
/* Check if the screen is already managed */
if (meta_screen_get_compositor_data (screen))
return;
- meta_error_trap_push_with_return (display);
- XCompositeRedirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
- XSync (xdisplay, FALSE);
+ if (meta_get_replace_current_wm ())
+ max_retries = 5;
+ else
+ max_retries = 1;
+
+ n_retries = 0;
- if (meta_error_trap_pop_with_return (display))
+ /* We can race with an exiting process to claim compositing over the root window;
+ * There's really not a great way to deal with this, so we just sleep and retry.
+ */
+ while (TRUE)
{
- g_warning ("Another compositing manager is running on screen %i",
- screen_number);
- return;
+ meta_error_trap_push_with_return (display);
+ XCompositeRedirectSubwindows (xdisplay, xroot, CompositeRedirectManual);
+ XSync (xdisplay, FALSE);
+
+ if (!meta_error_trap_pop_with_return (display))
+ break;
+
+ if (n_retries == max_retries)
+ g_error ("Another compositing manager is running on screen %i", screen_number);
+
+ n_retries++;
+ g_usleep (G_USEC_PER_SEC);
}
info = g_new0 (MetaCompScreen, 1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]