mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 01:20:42 -05:00
window: Refactor all move/resize operations to be in frame rect space
For Wayland, we want to have everything possible in terms of the frame rect, or "window geometry" as the Wayland protocol calls it, in order to properly eliminate some flashing when changing states to fullscreen or similar. For this, we need to heavily refactor how the code is structured, and make it so that meta_window_move_resize_internal is specified in terms of the frame rect coordinate space, and transforming all entry points to meta_window_move_resize_internal. This is a big commit that's hard to tear apart. I tried to split it as best I can, but there's still just a large amount of changes that need to happen at once. Expect some regressions from this. Sorry for any temporary regression that this might cause.
This commit is contained in:
parent
afb41f715b
commit
6e06648f7a
@ -29,6 +29,9 @@
|
||||
#include <meta/errors.h>
|
||||
#include "util-private.h"
|
||||
|
||||
#include "x11/window-x11.h"
|
||||
#include "x11/window-x11-private.h"
|
||||
|
||||
/* Looks up the MetaWindow representing the frame of the given X window.
|
||||
* Used as a helper function by a bunch of the functions below.
|
||||
*
|
||||
@ -69,6 +72,8 @@ meta_core_get (Display *xdisplay,
|
||||
|
||||
MetaDisplay *display = meta_display_for_x_display (xdisplay);
|
||||
MetaWindow *window = meta_display_lookup_x_window (display, xwindow);
|
||||
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
||||
MetaWindowX11Private *priv = window_x11->priv;
|
||||
|
||||
va_start (args, xwindow);
|
||||
|
||||
@ -103,10 +108,10 @@ meta_core_get (Display *xdisplay,
|
||||
if (!*((gboolean*)answer)) goto out; /* see above */
|
||||
break;
|
||||
case META_CORE_GET_CLIENT_WIDTH:
|
||||
*((gint*)answer) = window->rect.width;
|
||||
*((gint*)answer) = priv->client_rect.width;
|
||||
break;
|
||||
case META_CORE_GET_CLIENT_HEIGHT:
|
||||
*((gint*)answer) = window->rect.height;
|
||||
*((gint*)answer) = priv->client_rect.height;
|
||||
break;
|
||||
case META_CORE_GET_FRAME_FLAGS:
|
||||
*((MetaFrameFlags*)answer) = meta_frame_get_flags (window->frame);
|
||||
|
@ -1826,9 +1826,9 @@ meta_display_begin_grab_op (MetaDisplay *display,
|
||||
"Grab op %u on window %s successful\n",
|
||||
display->grab_op, window ? window->desc : "(null)");
|
||||
|
||||
meta_window_get_client_root_coords (display->grab_window,
|
||||
&display->grab_initial_window_pos);
|
||||
meta_window_get_frame_rect (display->grab_window, &display->grab_anchor_window_pos);
|
||||
meta_window_get_frame_rect (display->grab_window,
|
||||
&display->grab_initial_window_pos);
|
||||
display->grab_anchor_window_pos = display->grab_initial_window_pos;
|
||||
|
||||
if (meta_is_wayland_compositor ())
|
||||
meta_display_sync_wayland_input_focus (display);
|
||||
|
@ -202,7 +202,7 @@ meta_window_destroy_frame (MetaWindow *window)
|
||||
XReparentWindow (window->display->xdisplay,
|
||||
window->xwindow,
|
||||
window->screen->xroot,
|
||||
/* Using anything other than meta_window_get_position()
|
||||
/* Using anything other than client root window coordinates
|
||||
* coordinates here means we'll need to ensure a configure
|
||||
* notify event is sent; see bug 399552.
|
||||
*/
|
||||
|
@ -1906,12 +1906,12 @@ process_mouse_move_resize_grab (MetaDisplay *display,
|
||||
else if (window->tile_mode != META_TILE_NONE)
|
||||
meta_window_tile (window);
|
||||
else
|
||||
meta_window_move_resize (display->grab_window,
|
||||
TRUE,
|
||||
display->grab_initial_window_pos.x,
|
||||
display->grab_initial_window_pos.y,
|
||||
display->grab_initial_window_pos.width,
|
||||
display->grab_initial_window_pos.height);
|
||||
meta_window_move_resize_frame (display->grab_window,
|
||||
TRUE,
|
||||
display->grab_initial_window_pos.x,
|
||||
display->grab_initial_window_pos.y,
|
||||
display->grab_initial_window_pos.width,
|
||||
display->grab_initial_window_pos.height);
|
||||
|
||||
/* End grab */
|
||||
return FALSE;
|
||||
@ -1968,12 +1968,12 @@ process_keyboard_move_grab (MetaDisplay *display,
|
||||
if (window->shaken_loose)
|
||||
meta_window_maximize (window, META_MAXIMIZE_BOTH);
|
||||
else
|
||||
meta_window_move_resize (display->grab_window,
|
||||
TRUE,
|
||||
display->grab_initial_window_pos.x,
|
||||
display->grab_initial_window_pos.y,
|
||||
display->grab_initial_window_pos.width,
|
||||
display->grab_initial_window_pos.height);
|
||||
meta_window_move_resize_frame (display->grab_window,
|
||||
TRUE,
|
||||
display->grab_initial_window_pos.x,
|
||||
display->grab_initial_window_pos.y,
|
||||
display->grab_initial_window_pos.width,
|
||||
display->grab_initial_window_pos.height);
|
||||
}
|
||||
|
||||
/* When moving by increments, we still snap to edges if the move
|
||||
@ -2185,12 +2185,12 @@ process_keyboard_resize_grab (MetaDisplay *display,
|
||||
if (event->keyval == CLUTTER_KEY_Escape)
|
||||
{
|
||||
/* End resize and restore to original state. */
|
||||
meta_window_move_resize (display->grab_window,
|
||||
TRUE,
|
||||
display->grab_initial_window_pos.x,
|
||||
display->grab_initial_window_pos.y,
|
||||
display->grab_initial_window_pos.width,
|
||||
display->grab_initial_window_pos.height);
|
||||
meta_window_move_resize_frame (display->grab_window,
|
||||
TRUE,
|
||||
display->grab_initial_window_pos.x,
|
||||
display->grab_initial_window_pos.y,
|
||||
display->grab_initial_window_pos.width,
|
||||
display->grab_initial_window_pos.height);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -357,7 +357,8 @@ struct _MetaWindow
|
||||
/* if non-NULL, the bounds of the window frame */
|
||||
cairo_region_t *frame_bounds;
|
||||
|
||||
/* if non-NULL, the bounding shape region of the window */
|
||||
/* if non-NULL, the bounding shape region of the window. Relative to
|
||||
* the server-side client window. */
|
||||
cairo_region_t *shape_region;
|
||||
|
||||
/* if non-NULL, the opaque region _NET_WM_OPAQUE_REGION */
|
||||
@ -403,32 +404,23 @@ struct _MetaWindow
|
||||
gboolean has_custom_frame_extents;
|
||||
GtkBorder custom_frame_extents;
|
||||
|
||||
/* The size we set the window to last (i.e. what we believe
|
||||
* to be its actual size on the server). The x, y are
|
||||
* the actual server-side x,y so are relative to the frame
|
||||
* (meaning that they just hold the frame width and height)
|
||||
* or the root window (meaning they specify the location
|
||||
* of the top left of the inner window) as appropriate.
|
||||
*/
|
||||
/* The rectangles here are in "frame rect" coordinates. See the
|
||||
* comment at the top of meta_window_move_resize_internal() for more
|
||||
* information. */
|
||||
|
||||
/* The current window geometry of the window. */
|
||||
MetaRectangle rect;
|
||||
|
||||
/* The geometry to restore when we unmaximize. The position is in
|
||||
* root window coords, even if there's a frame, which contrasts with
|
||||
* window->rect above. Note that this gives the position and size
|
||||
* of the client window (i.e. ignoring the frame).
|
||||
*/
|
||||
/* The geometry to restore when we unmaximize. */
|
||||
MetaRectangle saved_rect;
|
||||
|
||||
/* This is the geometry the window will have if no constraints have
|
||||
* applied. We use this whenever we are moving implicitly (for example,
|
||||
* if we move to avoid a panel, we can snap back to this position if
|
||||
* the panel moves again). Note that this gives the position and size
|
||||
* of the client window (i.e. ignoring the frame).
|
||||
*
|
||||
* Position always in root coords, unlike window->rect.
|
||||
* the panel moves again).
|
||||
*/
|
||||
MetaRectangle unconstrained_rect;
|
||||
|
||||
|
||||
/* Cached net_wm_icon_geometry */
|
||||
MetaRectangle icon_geometry;
|
||||
|
||||
@ -539,12 +531,6 @@ void meta_window_update_fullscreen_monitors (MetaWindow *window,
|
||||
unsigned long left,
|
||||
unsigned long right);
|
||||
|
||||
void meta_window_move_resize (MetaWindow *window,
|
||||
gboolean user_op,
|
||||
int root_x_nw,
|
||||
int root_y_nw,
|
||||
int w,
|
||||
int h);
|
||||
void meta_window_resize_frame_with_gravity (MetaWindow *window,
|
||||
gboolean user_op,
|
||||
int w,
|
||||
@ -559,17 +545,6 @@ gboolean meta_window_should_be_showing (MetaWindow *window);
|
||||
|
||||
void meta_window_update_struts (MetaWindow *window);
|
||||
|
||||
/* this gets root coords */
|
||||
void meta_window_get_position (MetaWindow *window,
|
||||
int *x,
|
||||
int *y);
|
||||
|
||||
/* Gets root coords for x, y, width & height of client window; uses
|
||||
* meta_window_get_position for x & y.
|
||||
*/
|
||||
void meta_window_get_client_root_coords (MetaWindow *window,
|
||||
MetaRectangle *rect);
|
||||
|
||||
/* gets position we need to set to stay in current position,
|
||||
* assuming position will be gravity-compensated. i.e.
|
||||
* this is the position a client would send in a configure
|
||||
@ -716,7 +691,7 @@ void meta_window_update_resize (MetaWindow *window,
|
||||
void meta_window_move_resize_internal (MetaWindow *window,
|
||||
MetaMoveResizeFlags flags,
|
||||
int gravity,
|
||||
MetaRectangle client_rect);
|
||||
MetaRectangle frame_rect);
|
||||
|
||||
void meta_window_grab_op_began (MetaWindow *window, MetaGrabOp op);
|
||||
void meta_window_grab_op_ended (MetaWindow *window, MetaGrabOp op);
|
||||
|
@ -2654,15 +2654,11 @@ meta_window_save_rect (MetaWindow *window)
|
||||
{
|
||||
window->saved_rect.x = window->rect.x;
|
||||
window->saved_rect.width = window->rect.width;
|
||||
if (window->frame)
|
||||
window->saved_rect.x += window->frame->rect.x;
|
||||
}
|
||||
if (!window->maximized_vertically)
|
||||
{
|
||||
window->saved_rect.y = window->rect.y;
|
||||
window->saved_rect.height = window->rect.height;
|
||||
if (window->frame)
|
||||
window->saved_rect.y += window->frame->rect.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3016,12 +3012,12 @@ unmaximize_window_before_freeing (MetaWindow *window)
|
||||
* Moreover, it will need to know the unmaximized geometry,
|
||||
* therefore move_resize the window to saved_rect here
|
||||
* before closing it. */
|
||||
meta_window_move_resize (window,
|
||||
FALSE,
|
||||
window->saved_rect.x,
|
||||
window->saved_rect.y,
|
||||
window->saved_rect.width,
|
||||
window->saved_rect.height);
|
||||
meta_window_move_resize_frame (window,
|
||||
FALSE,
|
||||
window->saved_rect.x,
|
||||
window->saved_rect.y,
|
||||
window->saved_rect.width,
|
||||
window->saved_rect.height);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3078,7 +3074,7 @@ meta_window_unmaximize_internal (MetaWindow *window,
|
||||
/* Unmaximize to the saved_rect position in the direction(s)
|
||||
* being unmaximized.
|
||||
*/
|
||||
meta_window_get_client_root_coords (window, &target_rect);
|
||||
target_rect = old_rect;
|
||||
|
||||
/* Avoid unmaximizing to "almost maximized" size when the previous size
|
||||
* is greater then 80% of the work area use MAX_UNMAXIMIZED_WINDOW_AREA of the work area as upper limit
|
||||
@ -3115,7 +3111,9 @@ meta_window_unmaximize_internal (MetaWindow *window,
|
||||
/* Window's size hints may have changed while maximized, making
|
||||
* saved_rect invalid. #329152
|
||||
*/
|
||||
meta_window_frame_rect_to_client_rect (window, &target_rect, &target_rect);
|
||||
ensure_size_hints_satisfied (&target_rect, &window->size_hints);
|
||||
meta_window_client_rect_to_frame_rect (window, &target_rect, &target_rect);
|
||||
|
||||
meta_window_move_resize_internal (window,
|
||||
META_IS_MOVE_ACTION | META_IS_RESIZE_ACTION,
|
||||
@ -3139,9 +3137,6 @@ meta_window_unmaximize_internal (MetaWindow *window,
|
||||
window->display->grab_window == window)
|
||||
{
|
||||
window->display->grab_anchor_window_pos = window->unconstrained_rect;
|
||||
meta_window_client_rect_to_frame_rect (window,
|
||||
&window->display->grab_anchor_window_pos,
|
||||
&window->display->grab_anchor_window_pos);
|
||||
}
|
||||
|
||||
meta_window_recalc_features (window);
|
||||
@ -3182,9 +3177,6 @@ meta_window_unmaximize_with_gravity (MetaWindow *window,
|
||||
desired_rect.width = new_width;
|
||||
desired_rect.height = new_height;
|
||||
|
||||
meta_window_frame_rect_to_client_rect (window, &desired_rect, &desired_rect);
|
||||
|
||||
meta_window_get_position (window, &desired_rect.x, &desired_rect.y);
|
||||
meta_window_unmaximize_internal (window, directions, &desired_rect, gravity);
|
||||
}
|
||||
|
||||
@ -3298,12 +3290,12 @@ meta_window_unmake_fullscreen (MetaWindow *window)
|
||||
meta_window_recalc_features (window);
|
||||
set_net_wm_state (window);
|
||||
|
||||
meta_window_move_resize (window,
|
||||
FALSE,
|
||||
target_rect.x,
|
||||
target_rect.y,
|
||||
target_rect.width,
|
||||
target_rect.height);
|
||||
meta_window_move_resize_frame (window,
|
||||
FALSE,
|
||||
target_rect.x,
|
||||
target_rect.y,
|
||||
target_rect.width,
|
||||
target_rect.height);
|
||||
|
||||
meta_window_update_layer (window);
|
||||
|
||||
@ -3650,13 +3642,27 @@ void
|
||||
meta_window_move_resize_internal (MetaWindow *window,
|
||||
MetaMoveResizeFlags flags,
|
||||
int gravity,
|
||||
MetaRectangle client_rect)
|
||||
MetaRectangle frame_rect)
|
||||
{
|
||||
/* The rectangle here that's passed in is always the root position
|
||||
* of the client window. For undecorated or client-decorated windows,
|
||||
* this is the root position of the X11 window. For server-decorated
|
||||
* windows, this is the root position of the client area of the window.
|
||||
/* The rectangle here that's passed in *always* in "frame rect"
|
||||
* coordinates. That means the position of the frame's visible bounds,
|
||||
* with x and y being absolute (root window) coordinates.
|
||||
*
|
||||
* For an X11 framed window, the client window's server rectangle is
|
||||
* inset from this rectangle by the frame's visible borders, and the
|
||||
* frame window's server rectangle is outset by the invisible borders.
|
||||
*
|
||||
* For an X11 unframed window, the rectangle here directly matches
|
||||
* the server's rectangle, since the visible and invisible borders
|
||||
* are both 0.
|
||||
*
|
||||
* For an X11 CSD window, the client window's server rectangle is
|
||||
* outset from this rectagle by the client-specified frame extents.
|
||||
*
|
||||
* For a Wayland window, this rectangle can simply be sent directly
|
||||
* to the client.
|
||||
*/
|
||||
|
||||
gboolean did_placement;
|
||||
MetaRectangle unconstrained_rect;
|
||||
MetaRectangle constrained_rect;
|
||||
@ -3679,18 +3685,15 @@ meta_window_move_resize_internal (MetaWindow *window,
|
||||
* resizing the old rectangle with the given gravity. */
|
||||
if ((flags & (META_IS_MOVE_ACTION | META_IS_RESIZE_ACTION)) == META_IS_RESIZE_ACTION)
|
||||
{
|
||||
MetaRectangle old_rect;
|
||||
|
||||
meta_window_get_client_root_coords (window, &old_rect);
|
||||
meta_rectangle_resize_with_gravity (&old_rect,
|
||||
meta_rectangle_resize_with_gravity (&window->rect,
|
||||
&unconstrained_rect,
|
||||
gravity,
|
||||
client_rect.width,
|
||||
client_rect.height);
|
||||
frame_rect.width,
|
||||
frame_rect.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
unconstrained_rect = client_rect;
|
||||
unconstrained_rect = frame_rect;
|
||||
}
|
||||
|
||||
/* If this is only a move, then ignore the passed in size and
|
||||
@ -3711,15 +3714,11 @@ meta_window_move_resize_internal (MetaWindow *window,
|
||||
MetaRectangle old_rect;
|
||||
meta_window_get_frame_rect (window, &old_rect);
|
||||
|
||||
meta_window_client_rect_to_frame_rect (window, &constrained_rect, &constrained_rect);
|
||||
|
||||
meta_window_constrain (window,
|
||||
flags,
|
||||
gravity,
|
||||
&old_rect,
|
||||
&constrained_rect);
|
||||
|
||||
meta_window_frame_rect_to_client_rect (window, &constrained_rect, &constrained_rect);
|
||||
}
|
||||
|
||||
/* Do the protocol-specific move/resize logic */
|
||||
@ -3741,12 +3740,6 @@ meta_window_move_resize_internal (MetaWindow *window,
|
||||
|
||||
meta_window_update_monitor (window);
|
||||
|
||||
/* Invariants leaving this function are:
|
||||
* a) window->rect and frame->rect reflect the actual
|
||||
* server-side size/pos of window->xwindow and frame->xwindow
|
||||
* b) all constraints are obeyed by window->rect and frame->rect
|
||||
*/
|
||||
|
||||
if ((result & META_MOVE_RESIZE_RESULT_FRAME_SHAPE_CHANGED) && window->frame_bounds)
|
||||
{
|
||||
cairo_region_destroy (window->frame_bounds);
|
||||
@ -3783,7 +3776,6 @@ meta_window_move_frame (MetaWindow *window,
|
||||
g_return_if_fail (!window->override_redirect);
|
||||
|
||||
flags = (user_op ? META_IS_USER_ACTION : 0) | META_IS_MOVE_ACTION;
|
||||
meta_window_frame_rect_to_client_rect (window, &rect, &rect);
|
||||
meta_window_move_resize_internal (window, flags, NorthWestGravity, rect);
|
||||
}
|
||||
|
||||
@ -3828,10 +3820,14 @@ meta_window_move_resize_frame (MetaWindow *window,
|
||||
int w,
|
||||
int h)
|
||||
{
|
||||
MetaMoveResizeFlags flags;
|
||||
MetaRectangle rect = { root_x_nw, root_y_nw, w, h };
|
||||
meta_window_frame_rect_to_client_rect (window, &rect, &rect);
|
||||
|
||||
meta_window_move_resize (window, user_op, rect.x, rect.y, rect.width, rect.height);
|
||||
g_return_if_fail (!window->override_redirect);
|
||||
|
||||
flags = (user_op ? META_IS_USER_ACTION : 0) | META_IS_MOVE_ACTION | META_IS_RESIZE_ACTION;
|
||||
|
||||
meta_window_move_resize_internal (window, flags, NorthWestGravity, rect);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3867,30 +3863,6 @@ meta_window_move_to_monitor (MetaWindow *window,
|
||||
meta_screen_queue_check_fullscreen (window->screen);
|
||||
}
|
||||
|
||||
void
|
||||
meta_window_move_resize (MetaWindow *window,
|
||||
gboolean user_op,
|
||||
int root_x_nw,
|
||||
int root_y_nw,
|
||||
int w,
|
||||
int h)
|
||||
{
|
||||
MetaMoveResizeFlags flags;
|
||||
MetaRectangle rect;
|
||||
|
||||
g_return_if_fail (!window->override_redirect);
|
||||
|
||||
flags = (user_op ? META_IS_USER_ACTION : 0) |
|
||||
META_IS_MOVE_ACTION | META_IS_RESIZE_ACTION;
|
||||
|
||||
rect.x = root_x_nw;
|
||||
rect.y = root_y_nw;
|
||||
rect.width = w;
|
||||
rect.height = h;
|
||||
|
||||
meta_window_move_resize_internal (window, flags, NorthWestGravity, rect);
|
||||
}
|
||||
|
||||
void
|
||||
meta_window_resize_frame_with_gravity (MetaWindow *window,
|
||||
gboolean user_op,
|
||||
@ -3904,8 +3876,6 @@ meta_window_resize_frame_with_gravity (MetaWindow *window,
|
||||
rect.width = w;
|
||||
rect.height = h;
|
||||
|
||||
meta_window_frame_rect_to_client_rect (window, &rect, &rect);
|
||||
|
||||
flags = (user_op ? META_IS_USER_ACTION : 0) | META_IS_RESIZE_ACTION;
|
||||
meta_window_move_resize_internal (window, flags, gravity, rect);
|
||||
}
|
||||
@ -3913,11 +3883,11 @@ meta_window_resize_frame_with_gravity (MetaWindow *window,
|
||||
static void
|
||||
meta_window_move_resize_now (MetaWindow *window)
|
||||
{
|
||||
meta_window_move_resize (window, FALSE,
|
||||
window->unconstrained_rect.x,
|
||||
window->unconstrained_rect.y,
|
||||
window->unconstrained_rect.width,
|
||||
window->unconstrained_rect.height);
|
||||
meta_window_move_resize_frame (window, FALSE,
|
||||
window->unconstrained_rect.x,
|
||||
window->unconstrained_rect.y,
|
||||
window->unconstrained_rect.width,
|
||||
window->unconstrained_rect.height);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -3960,36 +3930,6 @@ idle_move_resize (gpointer data)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
meta_window_get_position (MetaWindow *window,
|
||||
int *x,
|
||||
int *y)
|
||||
{
|
||||
if (window->frame)
|
||||
{
|
||||
if (x)
|
||||
*x = window->frame->rect.x + window->frame->child_x;
|
||||
if (y)
|
||||
*y = window->frame->rect.y + window->frame->child_y;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x)
|
||||
*x = window->rect.x;
|
||||
if (y)
|
||||
*y = window->rect.y;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
meta_window_get_client_root_coords (MetaWindow *window,
|
||||
MetaRectangle *rect)
|
||||
{
|
||||
meta_window_get_position (window, &rect->x, &rect->y);
|
||||
rect->width = window->rect.width;
|
||||
rect->height = window->rect.height;
|
||||
}
|
||||
|
||||
void
|
||||
meta_window_get_gravity_position (MetaWindow *window,
|
||||
int gravity,
|
||||
@ -4108,7 +4048,10 @@ meta_window_get_input_rect (const MetaWindow *window,
|
||||
if (window->frame)
|
||||
*rect = window->frame->rect;
|
||||
else
|
||||
*rect = window->rect;
|
||||
{
|
||||
*rect = window->rect;
|
||||
meta_window_frame_rect_to_client_rect ((MetaWindow *) window, rect, rect);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4218,30 +4161,7 @@ void
|
||||
meta_window_get_frame_rect (const MetaWindow *window,
|
||||
MetaRectangle *rect)
|
||||
{
|
||||
if (window->frame)
|
||||
{
|
||||
MetaFrameBorders borders;
|
||||
*rect = window->frame->rect;
|
||||
meta_frame_calc_borders (window->frame, &borders);
|
||||
|
||||
rect->x += borders.invisible.left;
|
||||
rect->y += borders.invisible.top;
|
||||
rect->width -= borders.invisible.left + borders.invisible.right;
|
||||
rect->height -= borders.invisible.top + borders.invisible.bottom;
|
||||
}
|
||||
else
|
||||
{
|
||||
*rect = window->rect;
|
||||
|
||||
if (window->has_custom_frame_extents)
|
||||
{
|
||||
const GtkBorder *extents = &window->custom_frame_extents;
|
||||
rect->x += extents->left;
|
||||
rect->y += extents->top;
|
||||
rect->width -= extents->left + extents->right;
|
||||
rect->height -= extents->top + extents->bottom;
|
||||
}
|
||||
}
|
||||
*rect = window->rect;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -4276,22 +4196,18 @@ void
|
||||
meta_window_get_client_area_rect (const MetaWindow *window,
|
||||
cairo_rectangle_int_t *rect)
|
||||
{
|
||||
if (window->frame)
|
||||
{
|
||||
rect->x = window->frame->child_x;
|
||||
rect->y = window->frame->child_y;
|
||||
}
|
||||
else
|
||||
{
|
||||
rect->x = 0;
|
||||
rect->y = 0;
|
||||
}
|
||||
MetaFrameBorders borders;
|
||||
|
||||
rect->width = window->rect.width;
|
||||
meta_frame_calc_borders (window->frame, &borders);
|
||||
|
||||
rect->x = borders.total.left;
|
||||
rect->y = borders.total.top;
|
||||
|
||||
rect->width = window->rect.width - borders.visible.left - borders.visible.right;
|
||||
if (window->shaded)
|
||||
rect->height = 0;
|
||||
else
|
||||
rect->height = window->rect.height;
|
||||
rect->height = window->rect.height - borders.visible.top - borders.visible.bottom;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -55,6 +55,10 @@ struct _MetaWindowX11Private
|
||||
int border_width;
|
||||
|
||||
MetaResizePopup *grab_resize_popup;
|
||||
|
||||
/* These are in server coordinates. If we have a frame, it's
|
||||
* relative to the frame. */
|
||||
MetaRectangle client_rect;
|
||||
};
|
||||
|
||||
G_END_DECLS
|
||||
|
@ -210,8 +210,8 @@ send_configure_notify (MetaWindow *window)
|
||||
event.xconfigure.display = window->display->xdisplay;
|
||||
event.xconfigure.event = window->xwindow;
|
||||
event.xconfigure.window = window->xwindow;
|
||||
event.xconfigure.x = window->rect.x - priv->border_width;
|
||||
event.xconfigure.y = window->rect.y - priv->border_width;
|
||||
event.xconfigure.x = priv->client_rect.x - priv->border_width;
|
||||
event.xconfigure.y = priv->client_rect.y - priv->border_width;
|
||||
if (window->frame)
|
||||
{
|
||||
if (window->withdrawn)
|
||||
@ -233,8 +233,8 @@ send_configure_notify (MetaWindow *window)
|
||||
event.xconfigure.y += window->frame->rect.y;
|
||||
}
|
||||
}
|
||||
event.xconfigure.width = window->rect.width;
|
||||
event.xconfigure.height = window->rect.height;
|
||||
event.xconfigure.width = priv->client_rect.width;
|
||||
event.xconfigure.height = priv->client_rect.height;
|
||||
event.xconfigure.border_width = priv->border_width; /* requested not actual */
|
||||
event.xconfigure.above = None; /* FIXME */
|
||||
event.xconfigure.override_redirect = False;
|
||||
@ -492,6 +492,7 @@ meta_window_apply_session_info (MetaWindow *window,
|
||||
flags = META_IS_MOVE_ACTION | META_IS_RESIZE_ACTION;
|
||||
|
||||
adjust_for_gravity (window, FALSE, gravity, &rect);
|
||||
meta_window_client_rect_to_frame_rect (window, &rect, &rect);
|
||||
meta_window_move_resize_internal (window, flags, gravity, rect);
|
||||
}
|
||||
}
|
||||
@ -547,6 +548,7 @@ meta_window_x11_manage (MetaWindow *window)
|
||||
rect.height = window->size_hints.height;
|
||||
|
||||
adjust_for_gravity (window, TRUE, gravity, &rect);
|
||||
meta_window_client_rect_to_frame_rect (window, &rect, &rect);
|
||||
meta_window_move_resize_internal (window, flags, gravity, rect);
|
||||
}
|
||||
}
|
||||
@ -785,6 +787,22 @@ meta_window_x11_focus (MetaWindow *window,
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_window_get_client_root_coords (MetaWindow *window,
|
||||
MetaRectangle *rect)
|
||||
{
|
||||
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
||||
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
||||
|
||||
*rect = priv->client_rect;
|
||||
|
||||
if (window->frame)
|
||||
{
|
||||
rect->x += window->frame->rect.x;
|
||||
rect->y += window->frame->rect.y;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_window_refresh_resize_popup (MetaWindow *window)
|
||||
{
|
||||
@ -1003,9 +1021,7 @@ meta_window_x11_move_resize_internal (MetaWindow *window,
|
||||
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
||||
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
||||
MetaFrameBorders borders;
|
||||
int root_x_nw, root_y_nw;
|
||||
int w, h;
|
||||
int client_move_x, client_move_y;
|
||||
MetaRectangle client_rect;
|
||||
int size_dx, size_dy;
|
||||
XWindowChanges values;
|
||||
unsigned int mask;
|
||||
@ -1021,32 +1037,22 @@ meta_window_x11_move_resize_internal (MetaWindow *window,
|
||||
|
||||
is_configure_request = (flags & META_IS_CONFIGURE_REQUEST) != 0;
|
||||
|
||||
/* meta_window_constrain() might have maximized the window after placement,
|
||||
* changing the borders.
|
||||
*/
|
||||
meta_frame_calc_borders (window->frame, &borders);
|
||||
|
||||
root_x_nw = constrained_rect.x;
|
||||
root_y_nw = constrained_rect.y;
|
||||
w = constrained_rect.width;
|
||||
h = constrained_rect.height;
|
||||
size_dx = constrained_rect.x - window->rect.width;
|
||||
size_dy = constrained_rect.y - window->rect.height;
|
||||
|
||||
size_dx = w - window->rect.width;
|
||||
size_dy = h - window->rect.height;
|
||||
|
||||
if (size_dx != 0 || size_dy != 0)
|
||||
need_resize_client = TRUE;
|
||||
|
||||
window->rect.width = w;
|
||||
window->rect.height = h;
|
||||
window->rect = constrained_rect;
|
||||
|
||||
if (window->frame)
|
||||
{
|
||||
int new_w, new_h;
|
||||
int new_x, new_y;
|
||||
|
||||
new_w = window->rect.width + borders.total.left + borders.total.right;
|
||||
/* Compute new frame size */
|
||||
new_w = window->rect.width + borders.invisible.left + borders.invisible.right;
|
||||
|
||||
new_h = borders.total.top + borders.total.bottom;
|
||||
new_h = borders.invisible.top + borders.invisible.bottom;
|
||||
if (!window->shaded)
|
||||
new_h += window->rect.height;
|
||||
|
||||
@ -1058,19 +1064,9 @@ meta_window_x11_move_resize_internal (MetaWindow *window,
|
||||
window->frame->rect.height = new_h;
|
||||
}
|
||||
|
||||
meta_topic (META_DEBUG_GEOMETRY,
|
||||
"Calculated frame size %dx%d\n",
|
||||
window->frame->rect.width,
|
||||
window->frame->rect.height);
|
||||
}
|
||||
|
||||
if (window->frame)
|
||||
{
|
||||
int new_x, new_y;
|
||||
|
||||
/* Compute new frame coords */
|
||||
new_x = root_x_nw - borders.total.left;
|
||||
new_y = root_y_nw - borders.total.top;
|
||||
new_x = window->rect.x - borders.invisible.left;
|
||||
new_y = window->rect.y - borders.invisible.top;
|
||||
|
||||
if (new_x != window->frame->rect.x ||
|
||||
new_y != window->frame->rect.y)
|
||||
@ -1079,22 +1075,35 @@ meta_window_x11_move_resize_internal (MetaWindow *window,
|
||||
window->frame->rect.x = new_x;
|
||||
window->frame->rect.y = new_y;
|
||||
}
|
||||
|
||||
client_move_x = borders.total.left;
|
||||
client_move_y = borders.total.top;
|
||||
}
|
||||
else
|
||||
|
||||
/* Calculate the new client rect */
|
||||
meta_window_frame_rect_to_client_rect (window, &constrained_rect, &client_rect);
|
||||
|
||||
/* The above client_rect is in root window coordinates. The
|
||||
* values we need to pass to XConfigureWindow are in parent
|
||||
* coordinates, so if the window is in a frame, we need to
|
||||
* correct the x/y positions here. */
|
||||
if (window->frame)
|
||||
{
|
||||
client_move_x = root_x_nw;
|
||||
client_move_y = root_y_nw;
|
||||
client_rect.x = borders.total.left;
|
||||
client_rect.y = borders.total.top;
|
||||
}
|
||||
|
||||
if (client_move_x != window->rect.x ||
|
||||
client_move_y != window->rect.y)
|
||||
if (client_rect.x != priv->client_rect.x ||
|
||||
client_rect.y != priv->client_rect.y)
|
||||
{
|
||||
need_move_client = TRUE;
|
||||
window->rect.x = client_move_x;
|
||||
window->rect.y = client_move_y;
|
||||
priv->client_rect.x = client_rect.x;
|
||||
priv->client_rect.y = client_rect.y;
|
||||
}
|
||||
|
||||
if (client_rect.width != priv->client_rect.width ||
|
||||
client_rect.height != priv->client_rect.height)
|
||||
{
|
||||
need_resize_client = TRUE;
|
||||
priv->client_rect.width = client_rect.width;
|
||||
priv->client_rect.height = client_rect.height;
|
||||
}
|
||||
|
||||
/* If frame extents have changed, fill in other frame fields and
|
||||
@ -1186,10 +1195,10 @@ meta_window_x11_move_resize_internal (MetaWindow *window,
|
||||
need_move_frame, need_resize_frame);
|
||||
|
||||
values.border_width = 0;
|
||||
values.x = client_move_x;
|
||||
values.y = client_move_y;
|
||||
values.width = window->rect.width;
|
||||
values.height = window->rect.height;
|
||||
values.x = client_rect.x;
|
||||
values.y = client_rect.y;
|
||||
values.width = client_rect.width;
|
||||
values.height = client_rect.height;
|
||||
|
||||
mask = 0;
|
||||
if (is_configure_request && priv->border_width != 0)
|
||||
@ -1768,6 +1777,8 @@ void
|
||||
meta_window_x11_update_input_region (MetaWindow *window)
|
||||
{
|
||||
cairo_region_t *region = NULL;
|
||||
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
||||
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
||||
|
||||
/* Decorated windows don't have an input region, because
|
||||
we don't shape the frame to match the client windows
|
||||
@ -1804,8 +1815,8 @@ meta_window_x11_update_input_region (MetaWindow *window)
|
||||
(n_rects == 1 &&
|
||||
(rects[0].x != 0 ||
|
||||
rects[0].y != 0 ||
|
||||
rects[0].width != window->rect.width ||
|
||||
rects[0].height != window->rect.height)))
|
||||
rects[0].width != priv->client_rect.width ||
|
||||
rects[0].height != priv->client_rect.height)))
|
||||
region = region_create_from_x_rectangles (rects, n_rects);
|
||||
|
||||
XFree (rects);
|
||||
@ -1818,8 +1829,8 @@ meta_window_x11_update_input_region (MetaWindow *window)
|
||||
|
||||
client_area.x = 0;
|
||||
client_area.y = 0;
|
||||
client_area.width = window->rect.width;
|
||||
client_area.height = window->rect.height;
|
||||
client_area.width = priv->client_rect.width;
|
||||
client_area.height = priv->client_rect.height;
|
||||
|
||||
/* The shape we get back from the client may have coordinates
|
||||
* outside of the frame. The X SHAPE Extension requires that
|
||||
@ -1850,6 +1861,8 @@ meta_window_set_shape_region (MetaWindow *window,
|
||||
void
|
||||
meta_window_x11_update_shape_region (MetaWindow *window)
|
||||
{
|
||||
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
|
||||
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
|
||||
cairo_region_t *region = NULL;
|
||||
|
||||
if (META_DISPLAY_HAS_SHAPE (window->display))
|
||||
@ -1893,8 +1906,8 @@ meta_window_x11_update_shape_region (MetaWindow *window)
|
||||
|
||||
client_area.x = 0;
|
||||
client_area.y = 0;
|
||||
client_area.width = window->rect.width;
|
||||
client_area.height = window->rect.height;
|
||||
client_area.width = priv->client_rect.width;
|
||||
client_area.height = priv->client_rect.height;
|
||||
|
||||
/* The shape we get back from the client may have coordinates
|
||||
* outside of the frame. The X SHAPE Extension requires that
|
||||
@ -2080,6 +2093,7 @@ meta_window_move_resize_request (MetaWindow *window,
|
||||
rect.height = height;
|
||||
|
||||
adjust_for_gravity (window, TRUE, gravity, &rect);
|
||||
meta_window_client_rect_to_frame_rect (window, &rect, &rect);
|
||||
meta_window_move_resize_internal (window, flags, gravity, rect);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user