diff --git a/src/core/window.c b/src/core/window.c index 2515ff6b4..05f7dcfa2 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -798,28 +798,12 @@ meta_window_new (MetaDisplay *display, * creation, to reduce XSync() calls */ - meta_error_trap_push_with_return (display); - - if (XGetWindowAttributes (display->xdisplay, xwindow, &attrs)) - { - if(meta_error_trap_pop_with_return (display) != Success) - { - meta_verbose ("Failed to get attributes for window 0x%lx\n", - xwindow); - meta_error_trap_pop (display); - meta_display_ungrab (display); - return NULL; - } - } - else - { - meta_error_trap_pop_with_return (display); - meta_verbose ("Failed to get attributes for window 0x%lx\n", - xwindow); - meta_error_trap_pop (display); - meta_display_ungrab (display); - return NULL; - } + if (!XGetWindowAttributes (display->xdisplay, xwindow, &attrs)) + { + meta_verbose ("Failed to get attributes for window 0x%lx\n", + xwindow); + goto error; + } screen = NULL; for (tmp = display->screens; tmp != NULL; tmp = tmp->next) @@ -853,17 +837,13 @@ meta_window_new (MetaDisplay *display, ) ) { meta_verbose ("Not managing our own windows\n"); - meta_error_trap_pop (display); - meta_display_ungrab (display); - return NULL; + goto error; } if (maybe_filter_window (display, xwindow, must_be_viewable, &attrs)) { meta_verbose ("Not managing filtered window\n"); - meta_error_trap_pop (display); - meta_display_ungrab (display); - return NULL; + goto error; } meta_verbose ("must_be_viewable = %d attrs.map_state = %d (%s)\n", @@ -891,9 +871,7 @@ meta_window_new (MetaDisplay *display, (state == IconicState || state == NormalState))) { meta_verbose ("Deciding not to manage unmapped or unviewable window 0x%lx\n", xwindow); - meta_error_trap_pop (display); - meta_display_ungrab (display); - return NULL; + goto error; } existing_wm_state = state; @@ -901,19 +879,16 @@ meta_window_new (MetaDisplay *display, wm_state_to_string (existing_wm_state)); } - meta_error_trap_push_with_return (display); - /* * XAddToSaveSet can only be called on windows created by a different client. * with Mutter we want to be able to create manageable windows from within - * the process (such as a dummy desktop window), so we do not want this - * call failing to prevent the window from being managed -- wrap it in its - * own error trap (we use the _with_return() version here to ensure that - * XSync() is done on the pop, otherwise the error will not get caught). + * the process (such as a dummy desktop window). As we do not want this + * call failing to prevent the window from being managed, we call this + * before creating the return-checked error trap. */ - meta_error_trap_push_with_return (display); XAddToSaveSet (display->xdisplay, xwindow); - meta_error_trap_pop_with_return (display); + + meta_error_trap_push_with_return (display); event_mask = PropertyChangeMask | ColormapChangeMask; if (attrs.override_redirect) @@ -965,9 +940,7 @@ meta_window_new (MetaDisplay *display, { meta_verbose ("Window 0x%lx disappeared just as we tried to manage it\n", xwindow); - meta_error_trap_pop (display); - meta_display_ungrab (display); - return NULL; + goto error; } @@ -1477,6 +1450,11 @@ meta_window_new (MetaDisplay *display, g_signal_emit_by_name (window->display, "window-marked-urgent", window); return window; + +error: + meta_error_trap_pop (display); + meta_display_ungrab (display); + return NULL; } /* This function should only be called from the end of meta_window_new_with_attrs () */