Avoid moving and resizing override-redirect windows

Override-redirect windows should not be moved or resized by the
window manager.

- Mark override-redirect windows as already placed to avoid
  placing them when first shown.
- Don't move-resize newly created override-redirect MetaWindow
- Don't queue a resize on override-redirect windows when reading
  their WM_TRANSIENT_FOR hint.
- Add g_return_if_fail (!window->override_redirect) to catch
  unexpected code paths that might result in override-redirect
  windows being moved or resized.

http://bugzilla.gnome.org/show_bug.cgi?id=582639
This commit is contained in:
Owen W. Taylor 2009-06-15 18:25:07 -04:00
parent dc2d8acc92
commit 729fb2e0b4
2 changed files with 32 additions and 14 deletions

View File

@ -1446,7 +1446,7 @@ reload_transient_for (MetaWindow *window,
window->xtransient_for != window->xgroup_leader) window->xtransient_for != window->xgroup_leader)
meta_window_group_leader_changed (window); meta_window_group_leader_changed (window);
if (!window->constructing) if (!window->constructing && !window->override_redirect)
meta_window_queue (window, META_QUEUE_MOVE_RESIZE); meta_window_queue (window, META_QUEUE_MOVE_RESIZE);
} }

View File

@ -678,8 +678,9 @@ meta_window_new_with_attrs (MetaDisplay *display,
window->hidden = 0; window->hidden = 0;
/* if already mapped, no need to worry about focus-on-first-time-showing */ /* if already mapped, no need to worry about focus-on-first-time-showing */
window->showing_for_first_time = !window->mapped; window->showing_for_first_time = !window->mapped;
/* if already mapped we don't want to do the placement thing */ /* if already mapped we don't want to do the placement thing;
window->placed = (window->mapped && !window->hidden); * override-redirect windows are placed by the app */
window->placed = ((window->mapped && !window->hidden) || window->override_redirect);
if (window->placed) if (window->placed)
meta_topic (META_DEBUG_PLACEMENT, meta_topic (META_DEBUG_PLACEMENT,
"Not placing window 0x%lx since it's already mapped\n", "Not placing window 0x%lx since it's already mapped\n",
@ -963,13 +964,14 @@ meta_window_new_with_attrs (MetaDisplay *display,
*/ */
flags = flags =
META_IS_CONFIGURE_REQUEST | META_IS_MOVE_ACTION | META_IS_RESIZE_ACTION; META_IS_CONFIGURE_REQUEST | META_IS_MOVE_ACTION | META_IS_RESIZE_ACTION;
meta_window_move_resize_internal (window, if (!window->override_redirect)
flags, meta_window_move_resize_internal (window,
window->size_hints.win_gravity, flags,
window->size_hints.x, window->size_hints.win_gravity,
window->size_hints.y, window->size_hints.x,
window->size_hints.width, window->size_hints.y,
window->size_hints.height); window->size_hints.width,
window->size_hints.height);
/* Now try applying saved stuff from the session */ /* Now try applying saved stuff from the session */
{ {
@ -1958,6 +1960,9 @@ meta_window_queue (MetaWindow *window, guint queuebits)
{ {
guint queuenum; guint queuenum;
/* Easier to debug by checking here rather than in the idle */
g_return_if_fail (!window->override_redirect || (queuebits & META_QUEUE_MOVE_RESIZE) == 0);
for (queuenum=0; queuenum<NUMBER_OF_QUEUES; queuenum++) for (queuenum=0; queuenum<NUMBER_OF_QUEUES; queuenum++)
{ {
if (queuebits & 1<<queuenum) if (queuebits & 1<<queuenum)
@ -3628,6 +3633,8 @@ meta_window_move_resize_internal (MetaWindow *window,
MetaRectangle new_rect; MetaRectangle new_rect;
MetaRectangle old_rect; MetaRectangle old_rect;
g_return_if_fail (!window->override_redirect);
is_configure_request = (flags & META_IS_CONFIGURE_REQUEST) != 0; is_configure_request = (flags & META_IS_CONFIGURE_REQUEST) != 0;
do_gravity_adjust = (flags & META_DO_GRAVITY_ADJUST) != 0; do_gravity_adjust = (flags & META_DO_GRAVITY_ADJUST) != 0;
is_user_action = (flags & META_IS_USER_ACTION) != 0; is_user_action = (flags & META_IS_USER_ACTION) != 0;
@ -4028,6 +4035,8 @@ meta_window_resize (MetaWindow *window,
int x, y; int x, y;
MetaMoveResizeFlags flags; MetaMoveResizeFlags flags;
g_return_if_fail (!window->override_redirect);
meta_window_get_position (window, &x, &y); meta_window_get_position (window, &x, &y);
flags = (user_op ? META_IS_USER_ACTION : 0) | META_IS_RESIZE_ACTION; flags = (user_op ? META_IS_USER_ACTION : 0) | META_IS_RESIZE_ACTION;
@ -4043,8 +4052,12 @@ meta_window_move (MetaWindow *window,
int root_x_nw, int root_x_nw,
int root_y_nw) int root_y_nw)
{ {
MetaMoveResizeFlags flags = MetaMoveResizeFlags flags;
(user_op ? META_IS_USER_ACTION : 0) | META_IS_MOVE_ACTION;
g_return_if_fail (!window->override_redirect);
flags = (user_op ? META_IS_USER_ACTION : 0) | META_IS_MOVE_ACTION;
meta_window_move_resize_internal (window, meta_window_move_resize_internal (window,
flags, flags,
NorthWestGravity, NorthWestGravity,
@ -4061,8 +4074,11 @@ meta_window_move_resize (MetaWindow *window,
int w, int w,
int h) int h)
{ {
MetaMoveResizeFlags flags = MetaMoveResizeFlags flags;
(user_op ? META_IS_USER_ACTION : 0) |
g_return_if_fail (!window->override_redirect);
flags = (user_op ? META_IS_USER_ACTION : 0) |
META_IS_MOVE_ACTION | META_IS_RESIZE_ACTION; META_IS_MOVE_ACTION | META_IS_RESIZE_ACTION;
meta_window_move_resize_internal (window, meta_window_move_resize_internal (window,
flags, flags,
@ -7176,6 +7192,8 @@ meta_window_shove_titlebar_onscreen (MetaWindow *window)
int horiz_amount, vert_amount; int horiz_amount, vert_amount;
int newx, newy; int newx, newy;
g_return_if_fail (!window->override_redirect);
/* If there's no titlebar, don't bother */ /* If there's no titlebar, don't bother */
if (!window->frame) if (!window->frame)
return; return;