mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 01:50:42 -05:00
Remove meta_window_new_with_attrs
The compositor code used to handle X windows that didn't have a
corresponding MetaWindow (see commit d538690b
), which is why the
attribute query is separated.
As that doesn't happen any more, we can clean up. No functional changes.
Suggested by Owen Taylor.
https://bugzilla.gnome.org/show_bug.cgi?id=721345
This commit is contained in:
parent
7278f9bd6b
commit
2579e48f21
@ -2787,14 +2787,14 @@ event_callback (XEvent *event,
|
|||||||
&& meta_display_screen_for_root (display, event->xmap.event))
|
&& meta_display_screen_for_root (display, event->xmap.event))
|
||||||
{
|
{
|
||||||
window = meta_window_new (display, event->xmap.window,
|
window = meta_window_new (display, event->xmap.window,
|
||||||
FALSE);
|
FALSE, META_COMP_EFFECT_CREATE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MapRequest:
|
case MapRequest:
|
||||||
if (window == NULL)
|
if (window == NULL)
|
||||||
{
|
{
|
||||||
window = meta_window_new (display, event->xmaprequest.window,
|
window = meta_window_new (display, event->xmaprequest.window,
|
||||||
FALSE);
|
FALSE, META_COMP_EFFECT_CREATE);
|
||||||
}
|
}
|
||||||
/* if frame was receiver it's some malicious send event or something */
|
/* if frame was receiver it's some malicious send event or something */
|
||||||
else if (!frame_was_receiver && window)
|
else if (!frame_was_receiver && window)
|
||||||
|
@ -877,59 +877,12 @@ meta_screen_free (MetaScreen *screen,
|
|||||||
meta_display_ungrab (display);
|
meta_display_ungrab (display);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct
|
void
|
||||||
{
|
meta_screen_manage_all_windows (MetaScreen *screen)
|
||||||
Window xwindow;
|
|
||||||
XWindowAttributes attrs;
|
|
||||||
} WindowInfo;
|
|
||||||
|
|
||||||
static GList *
|
|
||||||
list_windows (MetaScreen *screen)
|
|
||||||
{
|
{
|
||||||
Window ignored1, ignored2;
|
Window ignored1, ignored2;
|
||||||
Window *children;
|
Window *children;
|
||||||
guint n_children, i;
|
guint n_children, i;
|
||||||
GList *result;
|
|
||||||
|
|
||||||
XQueryTree (screen->display->xdisplay,
|
|
||||||
screen->xroot,
|
|
||||||
&ignored1, &ignored2, &children, &n_children);
|
|
||||||
|
|
||||||
result = NULL;
|
|
||||||
for (i = 0; i < n_children; ++i)
|
|
||||||
{
|
|
||||||
WindowInfo *info = g_new0 (WindowInfo, 1);
|
|
||||||
|
|
||||||
meta_error_trap_push_with_return (screen->display);
|
|
||||||
|
|
||||||
XGetWindowAttributes (screen->display->xdisplay,
|
|
||||||
children[i], &info->attrs);
|
|
||||||
|
|
||||||
if (meta_error_trap_pop_with_return (screen->display))
|
|
||||||
{
|
|
||||||
meta_verbose ("Failed to get attributes for window 0x%lx\n",
|
|
||||||
children[i]);
|
|
||||||
g_free (info);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
info->xwindow = children[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
result = g_list_prepend (result, info);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (children)
|
|
||||||
XFree (children);
|
|
||||||
|
|
||||||
return g_list_reverse (result);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
meta_screen_manage_all_windows (MetaScreen *screen)
|
|
||||||
{
|
|
||||||
GList *windows;
|
|
||||||
GList *list;
|
|
||||||
|
|
||||||
meta_display_grab (screen->display);
|
meta_display_grab (screen->display);
|
||||||
|
|
||||||
@ -937,21 +890,22 @@ meta_screen_manage_all_windows (MetaScreen *screen)
|
|||||||
screen->guard_window = create_guard_window (screen->display->xdisplay,
|
screen->guard_window = create_guard_window (screen->display->xdisplay,
|
||||||
screen);
|
screen);
|
||||||
|
|
||||||
windows = list_windows (screen);
|
|
||||||
|
|
||||||
meta_stack_freeze (screen->stack);
|
meta_stack_freeze (screen->stack);
|
||||||
for (list = windows; list != NULL; list = list->next)
|
|
||||||
|
XQueryTree (screen->display->xdisplay,
|
||||||
|
screen->xroot,
|
||||||
|
&ignored1, &ignored2, &children, &n_children);
|
||||||
|
|
||||||
|
for (i = 0; i < n_children; ++i)
|
||||||
{
|
{
|
||||||
WindowInfo *info = list->data;
|
meta_window_new (screen->display, children[i], TRUE,
|
||||||
|
META_COMP_EFFECT_NONE);
|
||||||
meta_window_new_with_attrs (screen->display, info->xwindow, TRUE,
|
|
||||||
META_COMP_EFFECT_NONE,
|
|
||||||
&info->attrs);
|
|
||||||
}
|
}
|
||||||
meta_stack_thaw (screen->stack);
|
|
||||||
|
|
||||||
g_list_foreach (windows, (GFunc)g_free, NULL);
|
if (children)
|
||||||
g_list_free (windows);
|
XFree (children);
|
||||||
|
|
||||||
|
meta_stack_thaw (screen->stack);
|
||||||
|
|
||||||
meta_display_ungrab (screen->display);
|
meta_display_ungrab (screen->display);
|
||||||
}
|
}
|
||||||
|
@ -483,13 +483,9 @@ struct _MetaWindowClass
|
|||||||
#define META_WINDOW_ALLOWS_VERTICAL_RESIZE(w) (META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS (w) && (w)->size_hints.min_height < (w)->size_hints.max_height)
|
#define META_WINDOW_ALLOWS_VERTICAL_RESIZE(w) (META_WINDOW_ALLOWS_RESIZE_EXCEPT_HINTS (w) && (w)->size_hints.min_height < (w)->size_hints.max_height)
|
||||||
|
|
||||||
MetaWindow* meta_window_new (MetaDisplay *display,
|
MetaWindow* meta_window_new (MetaDisplay *display,
|
||||||
Window xwindow,
|
|
||||||
gboolean must_be_viewable);
|
|
||||||
MetaWindow* meta_window_new_with_attrs (MetaDisplay *display,
|
|
||||||
Window xwindow,
|
Window xwindow,
|
||||||
gboolean must_be_viewable,
|
gboolean must_be_viewable,
|
||||||
MetaCompEffect effect,
|
MetaCompEffect effect);
|
||||||
XWindowAttributes *attrs);
|
|
||||||
void meta_window_unmanage (MetaWindow *window,
|
void meta_window_unmanage (MetaWindow *window,
|
||||||
guint32 timestamp);
|
guint32 timestamp);
|
||||||
void meta_window_calc_showing (MetaWindow *window);
|
void meta_window_calc_showing (MetaWindow *window);
|
||||||
|
@ -659,53 +659,6 @@ maybe_leave_show_desktop_mode (MetaWindow *window)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MetaWindow*
|
|
||||||
meta_window_new (MetaDisplay *display,
|
|
||||||
Window xwindow,
|
|
||||||
gboolean must_be_viewable)
|
|
||||||
{
|
|
||||||
XWindowAttributes attrs;
|
|
||||||
MetaWindow *window;
|
|
||||||
|
|
||||||
meta_display_grab (display);
|
|
||||||
meta_error_trap_push (display); /* Push a trap over all of window
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
window = meta_window_new_with_attrs (display, xwindow,
|
|
||||||
must_be_viewable,
|
|
||||||
META_COMP_EFFECT_CREATE,
|
|
||||||
&attrs);
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
meta_error_trap_pop (display);
|
|
||||||
meta_display_ungrab (display);
|
|
||||||
|
|
||||||
return window;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The MUTTER_WM_CLASS_FILTER environment variable is designed for
|
/* The MUTTER_WM_CLASS_FILTER environment variable is designed for
|
||||||
* performance and regression testing environments where we want to do
|
* performance and regression testing environments where we want to do
|
||||||
* tests with only a limited set of windows and ignore all other windows
|
* tests with only a limited set of windows and ignore all other windows
|
||||||
@ -816,12 +769,12 @@ meta_window_should_attach_to_parent (MetaWindow *window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MetaWindow*
|
MetaWindow*
|
||||||
meta_window_new_with_attrs (MetaDisplay *display,
|
meta_window_new (MetaDisplay *display,
|
||||||
Window xwindow,
|
Window xwindow,
|
||||||
gboolean must_be_viewable,
|
gboolean must_be_viewable,
|
||||||
MetaCompEffect effect,
|
MetaCompEffect effect)
|
||||||
XWindowAttributes *attrs)
|
|
||||||
{
|
{
|
||||||
|
XWindowAttributes attrs;
|
||||||
MetaWindow *window;
|
MetaWindow *window;
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
MetaWorkspace *space;
|
MetaWorkspace *space;
|
||||||
@ -830,8 +783,6 @@ meta_window_new_with_attrs (MetaDisplay *display,
|
|||||||
MetaMoveResizeFlags flags;
|
MetaMoveResizeFlags flags;
|
||||||
MetaScreen *screen;
|
MetaScreen *screen;
|
||||||
|
|
||||||
g_assert (attrs != NULL);
|
|
||||||
|
|
||||||
meta_verbose ("Attempting to manage 0x%lx\n", xwindow);
|
meta_verbose ("Attempting to manage 0x%lx\n", xwindow);
|
||||||
|
|
||||||
if (meta_display_xwindow_is_a_no_focus_window (display, xwindow))
|
if (meta_display_xwindow_is_a_no_focus_window (display, xwindow))
|
||||||
@ -841,12 +792,41 @@ meta_window_new_with_attrs (MetaDisplay *display,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Grab server */
|
||||||
|
meta_display_grab (display);
|
||||||
|
meta_error_trap_push (display); /* Push a trap over all of window
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
screen = NULL;
|
screen = NULL;
|
||||||
for (tmp = display->screens; tmp != NULL; tmp = tmp->next)
|
for (tmp = display->screens; tmp != NULL; tmp = tmp->next)
|
||||||
{
|
{
|
||||||
MetaScreen *scr = tmp->data;
|
MetaScreen *scr = tmp->data;
|
||||||
|
|
||||||
if (scr->xroot == attrs->root)
|
if (scr->xroot == attrs.root)
|
||||||
{
|
{
|
||||||
screen = tmp->data;
|
screen = tmp->data;
|
||||||
break;
|
break;
|
||||||
@ -856,14 +836,14 @@ meta_window_new_with_attrs (MetaDisplay *display,
|
|||||||
g_assert (screen);
|
g_assert (screen);
|
||||||
|
|
||||||
/* A black list of override redirect windows that we don't need to manage: */
|
/* A black list of override redirect windows that we don't need to manage: */
|
||||||
if (attrs->override_redirect &&
|
if (attrs.override_redirect &&
|
||||||
(xwindow == screen->no_focus_window ||
|
(xwindow == screen->no_focus_window ||
|
||||||
xwindow == screen->flash_window ||
|
xwindow == screen->flash_window ||
|
||||||
xwindow == screen->wm_sn_selection_window ||
|
xwindow == screen->wm_sn_selection_window ||
|
||||||
attrs->class == InputOnly ||
|
attrs.class == InputOnly ||
|
||||||
/* any windows created via meta_create_offscreen_window: */
|
/* any windows created via meta_create_offscreen_window: */
|
||||||
(attrs->x == -100 && attrs->y == -100
|
(attrs.x == -100 && attrs.y == -100
|
||||||
&& attrs->width == 1 && attrs->height == 1) ||
|
&& attrs.width == 1 && attrs.height == 1) ||
|
||||||
xwindow == screen->wm_cm_selection_window ||
|
xwindow == screen->wm_cm_selection_window ||
|
||||||
xwindow == screen->guard_window ||
|
xwindow == screen->guard_window ||
|
||||||
(display->compositor &&
|
(display->compositor &&
|
||||||
@ -873,34 +853,32 @@ meta_window_new_with_attrs (MetaDisplay *display,
|
|||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
meta_verbose ("Not managing our own windows\n");
|
meta_verbose ("Not managing our own windows\n");
|
||||||
|
meta_error_trap_pop (display);
|
||||||
|
meta_display_ungrab (display);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (maybe_filter_window (display, xwindow, must_be_viewable, attrs))
|
if (maybe_filter_window (display, xwindow, must_be_viewable, &attrs))
|
||||||
{
|
{
|
||||||
meta_verbose ("Not managing filtered window\n");
|
meta_verbose ("Not managing filtered window\n");
|
||||||
|
meta_error_trap_pop (display);
|
||||||
|
meta_display_ungrab (display);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Grab server */
|
meta_verbose ("must_be_viewable = %d attrs.map_state = %d (%s)\n",
|
||||||
meta_display_grab (display);
|
|
||||||
meta_error_trap_push (display); /* Push a trap over all of window
|
|
||||||
* creation, to reduce XSync() calls
|
|
||||||
*/
|
|
||||||
|
|
||||||
meta_verbose ("must_be_viewable = %d attrs->map_state = %d (%s)\n",
|
|
||||||
must_be_viewable,
|
must_be_viewable,
|
||||||
attrs->map_state,
|
attrs.map_state,
|
||||||
(attrs->map_state == IsUnmapped) ?
|
(attrs.map_state == IsUnmapped) ?
|
||||||
"IsUnmapped" :
|
"IsUnmapped" :
|
||||||
(attrs->map_state == IsViewable) ?
|
(attrs.map_state == IsViewable) ?
|
||||||
"IsViewable" :
|
"IsViewable" :
|
||||||
(attrs->map_state == IsUnviewable) ?
|
(attrs.map_state == IsUnviewable) ?
|
||||||
"IsUnviewable" :
|
"IsUnviewable" :
|
||||||
"(unknown)");
|
"(unknown)");
|
||||||
|
|
||||||
existing_wm_state = WithdrawnState;
|
existing_wm_state = WithdrawnState;
|
||||||
if (must_be_viewable && attrs->map_state != IsViewable)
|
if (must_be_viewable && attrs.map_state != IsViewable)
|
||||||
{
|
{
|
||||||
/* Only manage if WM_STATE is IconicState or NormalState */
|
/* Only manage if WM_STATE is IconicState or NormalState */
|
||||||
gulong state;
|
gulong state;
|
||||||
@ -938,14 +916,14 @@ meta_window_new_with_attrs (MetaDisplay *display,
|
|||||||
meta_error_trap_pop_with_return (display);
|
meta_error_trap_pop_with_return (display);
|
||||||
|
|
||||||
event_mask = PropertyChangeMask | ColormapChangeMask;
|
event_mask = PropertyChangeMask | ColormapChangeMask;
|
||||||
if (attrs->override_redirect)
|
if (attrs.override_redirect)
|
||||||
event_mask |= StructureNotifyMask;
|
event_mask |= StructureNotifyMask;
|
||||||
|
|
||||||
/* If the window is from this client (a menu, say) we need to augment
|
/* If the window is from this client (a menu, say) we need to augment
|
||||||
* the event mask, not replace it. For windows from other clients,
|
* the event mask, not replace it. For windows from other clients,
|
||||||
* attrs->your_event_mask will be empty at this point.
|
* attrs.your_event_mask will be empty at this point.
|
||||||
*/
|
*/
|
||||||
XSelectInput (display->xdisplay, xwindow, attrs->your_event_mask | event_mask);
|
XSelectInput (display->xdisplay, xwindow, attrs.your_event_mask | event_mask);
|
||||||
|
|
||||||
{
|
{
|
||||||
unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
|
unsigned char mask_bits[XIMaskLen (XI_LASTEVENT)] = { 0 };
|
||||||
@ -967,11 +945,11 @@ meta_window_new_with_attrs (MetaDisplay *display,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Get rid of any borders */
|
/* Get rid of any borders */
|
||||||
if (attrs->border_width != 0)
|
if (attrs.border_width != 0)
|
||||||
XSetWindowBorderWidth (display->xdisplay, xwindow, 0);
|
XSetWindowBorderWidth (display->xdisplay, xwindow, 0);
|
||||||
|
|
||||||
/* Get rid of weird gravities */
|
/* Get rid of weird gravities */
|
||||||
if (attrs->win_gravity != NorthWestGravity)
|
if (attrs.win_gravity != NorthWestGravity)
|
||||||
{
|
{
|
||||||
XSetWindowAttributes set_attrs;
|
XSetWindowAttributes set_attrs;
|
||||||
|
|
||||||
@ -1018,22 +996,22 @@ meta_window_new_with_attrs (MetaDisplay *display,
|
|||||||
|
|
||||||
window->desc = g_strdup_printf ("0x%lx", window->xwindow);
|
window->desc = g_strdup_printf ("0x%lx", window->xwindow);
|
||||||
|
|
||||||
window->override_redirect = attrs->override_redirect;
|
window->override_redirect = attrs.override_redirect;
|
||||||
|
|
||||||
/* avoid tons of stack updates */
|
/* avoid tons of stack updates */
|
||||||
meta_stack_freeze (window->screen->stack);
|
meta_stack_freeze (window->screen->stack);
|
||||||
|
|
||||||
window->rect.x = attrs->x;
|
window->rect.x = attrs.x;
|
||||||
window->rect.y = attrs->y;
|
window->rect.y = attrs.y;
|
||||||
window->rect.width = attrs->width;
|
window->rect.width = attrs.width;
|
||||||
window->rect.height = attrs->height;
|
window->rect.height = attrs.height;
|
||||||
|
|
||||||
/* And border width, size_hints are the "request" */
|
/* And border width, size_hints are the "request" */
|
||||||
window->border_width = attrs->border_width;
|
window->border_width = attrs.border_width;
|
||||||
window->size_hints.x = attrs->x;
|
window->size_hints.x = attrs.x;
|
||||||
window->size_hints.y = attrs->y;
|
window->size_hints.y = attrs.y;
|
||||||
window->size_hints.width = attrs->width;
|
window->size_hints.width = attrs.width;
|
||||||
window->size_hints.height = attrs->height;
|
window->size_hints.height = attrs.height;
|
||||||
/* initialize the remaining size_hints as if size_hints.flags were zero */
|
/* initialize the remaining size_hints as if size_hints.flags were zero */
|
||||||
meta_set_normal_hints (window, NULL);
|
meta_set_normal_hints (window, NULL);
|
||||||
|
|
||||||
@ -1041,9 +1019,9 @@ meta_window_new_with_attrs (MetaDisplay *display,
|
|||||||
window->saved_rect = window->rect;
|
window->saved_rect = window->rect;
|
||||||
window->user_rect = window->rect;
|
window->user_rect = window->rect;
|
||||||
|
|
||||||
window->depth = attrs->depth;
|
window->depth = attrs.depth;
|
||||||
window->xvisual = attrs->visual;
|
window->xvisual = attrs.visual;
|
||||||
window->colormap = attrs->colormap;
|
window->colormap = attrs.colormap;
|
||||||
|
|
||||||
window->title = NULL;
|
window->title = NULL;
|
||||||
window->icon_name = NULL;
|
window->icon_name = NULL;
|
||||||
@ -1078,7 +1056,7 @@ meta_window_new_with_attrs (MetaDisplay *display,
|
|||||||
window->minimized = FALSE;
|
window->minimized = FALSE;
|
||||||
window->tab_unminimized = FALSE;
|
window->tab_unminimized = FALSE;
|
||||||
window->iconic = FALSE;
|
window->iconic = FALSE;
|
||||||
window->mapped = attrs->map_state != IsUnmapped;
|
window->mapped = attrs.map_state != IsUnmapped;
|
||||||
window->hidden = FALSE;
|
window->hidden = FALSE;
|
||||||
window->visible_to_compositor = FALSE;
|
window->visible_to_compositor = FALSE;
|
||||||
window->pending_compositor_effect = effect;
|
window->pending_compositor_effect = effect;
|
||||||
|
Loading…
Reference in New Issue
Block a user