summaryrefslogtreecommitdiff
path: root/src/compositor/compositor.c
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2011-06-21 14:05:59 -0400
committerColin Walters <walters@verbum.org>2011-06-21 15:22:31 -0400
commitc18940a5a250240d2b6fbf74f40eaf5d7791db88 (patch)
tree9d22de60d3de525851f256aaf468d8f8f7a3c957 /src/compositor/compositor.c
parentb533ad2669c593bc060d4f8de3002c7ad212b647 (diff)
downloadmutter-c18940a5a250240d2b6fbf74f40eaf5d7791db88.tar.gz
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
Diffstat (limited to 'src/compositor/compositor.c')
-rw-r--r--src/compositor/compositor.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index 74989900f..e770ef5e1 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);