window: Move get_session_geometry to WindowX11
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3254>
This commit is contained in:
parent
751ef5abd2
commit
70f8cc433e
@ -691,24 +691,6 @@ gboolean meta_window_should_show (MetaWindow *window);
|
|||||||
|
|
||||||
void meta_window_update_struts (MetaWindow *window);
|
void meta_window_update_struts (MetaWindow *window);
|
||||||
|
|
||||||
/* 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
|
|
||||||
* request.
|
|
||||||
*/
|
|
||||||
void meta_window_get_gravity_position (MetaWindow *window,
|
|
||||||
MetaGravity gravity,
|
|
||||||
int *x,
|
|
||||||
int *y);
|
|
||||||
/* Get geometry for saving in the session; x/y are gravity
|
|
||||||
* position, and w/h are in resize inc above the base size.
|
|
||||||
*/
|
|
||||||
void meta_window_get_session_geometry (MetaWindow *window,
|
|
||||||
int *x,
|
|
||||||
int *y,
|
|
||||||
int *width,
|
|
||||||
int *height);
|
|
||||||
|
|
||||||
gboolean meta_window_geometry_contains_rect (MetaWindow *window,
|
gboolean meta_window_geometry_contains_rect (MetaWindow *window,
|
||||||
MtkRectangle *rect);
|
MtkRectangle *rect);
|
||||||
|
|
||||||
|
@ -4260,107 +4260,6 @@ meta_window_update_layout (MetaWindow *window)
|
|||||||
window->unconstrained_rect.height);
|
window->unconstrained_rect.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
meta_window_get_gravity_position (MetaWindow *window,
|
|
||||||
MetaGravity gravity,
|
|
||||||
int *root_x,
|
|
||||||
int *root_y)
|
|
||||||
{
|
|
||||||
MtkRectangle frame_extents;
|
|
||||||
int w, h;
|
|
||||||
int x, y;
|
|
||||||
|
|
||||||
w = window->rect.width;
|
|
||||||
h = window->rect.height;
|
|
||||||
|
|
||||||
if (gravity == META_GRAVITY_STATIC)
|
|
||||||
{
|
|
||||||
frame_extents = window->rect;
|
|
||||||
if (window->frame)
|
|
||||||
{
|
|
||||||
frame_extents.x = window->frame->rect.x + window->frame->child_x;
|
|
||||||
frame_extents.y = window->frame->rect.y + window->frame->child_y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (window->frame == NULL)
|
|
||||||
frame_extents = window->rect;
|
|
||||||
else
|
|
||||||
frame_extents = window->frame->rect;
|
|
||||||
}
|
|
||||||
|
|
||||||
x = frame_extents.x;
|
|
||||||
y = frame_extents.y;
|
|
||||||
|
|
||||||
switch (gravity)
|
|
||||||
{
|
|
||||||
case META_GRAVITY_NORTH:
|
|
||||||
case META_GRAVITY_CENTER:
|
|
||||||
case META_GRAVITY_SOUTH:
|
|
||||||
/* Find center of frame. */
|
|
||||||
x += frame_extents.width / 2;
|
|
||||||
/* Center client window on that point. */
|
|
||||||
x -= w / 2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case META_GRAVITY_SOUTH_EAST:
|
|
||||||
case META_GRAVITY_EAST:
|
|
||||||
case META_GRAVITY_NORTH_EAST:
|
|
||||||
/* Find right edge of frame */
|
|
||||||
x += frame_extents.width;
|
|
||||||
/* Align left edge of client at that point. */
|
|
||||||
x -= w;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (gravity)
|
|
||||||
{
|
|
||||||
case META_GRAVITY_WEST:
|
|
||||||
case META_GRAVITY_CENTER:
|
|
||||||
case META_GRAVITY_EAST:
|
|
||||||
/* Find center of frame. */
|
|
||||||
y += frame_extents.height / 2;
|
|
||||||
/* Center client window there. */
|
|
||||||
y -= h / 2;
|
|
||||||
break;
|
|
||||||
case META_GRAVITY_SOUTH_WEST:
|
|
||||||
case META_GRAVITY_SOUTH:
|
|
||||||
case META_GRAVITY_SOUTH_EAST:
|
|
||||||
/* Find south edge of frame */
|
|
||||||
y += frame_extents.height;
|
|
||||||
/* Place bottom edge of client there */
|
|
||||||
y -= h;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (root_x)
|
|
||||||
*root_x = x;
|
|
||||||
if (root_y)
|
|
||||||
*root_y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
meta_window_get_session_geometry (MetaWindow *window,
|
|
||||||
int *x,
|
|
||||||
int *y,
|
|
||||||
int *width,
|
|
||||||
int *height)
|
|
||||||
{
|
|
||||||
meta_window_get_gravity_position (window,
|
|
||||||
window->size_hints.win_gravity,
|
|
||||||
x, y);
|
|
||||||
|
|
||||||
*width = (window->rect.width - window->size_hints.base_width) /
|
|
||||||
window->size_hints.width_inc;
|
|
||||||
*height = (window->rect.height - window->size_hints.base_height) /
|
|
||||||
window->size_hints.height_inc;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
meta_window_geometry_contains_rect (MetaWindow *window,
|
meta_window_geometry_contains_rect (MetaWindow *window,
|
||||||
MtkRectangle *rect)
|
MtkRectangle *rect)
|
||||||
|
@ -1042,7 +1042,7 @@ save_state (MetaContext *context)
|
|||||||
/* Gravity */
|
/* Gravity */
|
||||||
{
|
{
|
||||||
int x, y, w, h;
|
int x, y, w, h;
|
||||||
meta_window_get_session_geometry (window, &x, &y, &w, &h);
|
meta_window_x11_get_session_geometry (window, &x, &y, &w, &h);
|
||||||
|
|
||||||
fprintf (outfile,
|
fprintf (outfile,
|
||||||
" <geometry x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" gravity=\"%s\"/>\n",
|
" <geometry x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" gravity=\"%s\"/>\n",
|
||||||
|
@ -136,4 +136,11 @@ void meta_window_x11_set_frame_xwindow (MetaWindow *window,
|
|||||||
|
|
||||||
gboolean meta_window_x11_is_ssd (MetaWindow *window);
|
gboolean meta_window_x11_is_ssd (MetaWindow *window);
|
||||||
|
|
||||||
|
void meta_window_x11_get_session_geometry (MetaWindow *window,
|
||||||
|
int *x,
|
||||||
|
int *y,
|
||||||
|
int *width,
|
||||||
|
int *height);
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
@ -2605,6 +2605,116 @@ meta_window_same_client (MetaWindow *window,
|
|||||||
(meta_window_x11_get_xwindow (other_window) & ~resource_mask));
|
(meta_window_x11_get_xwindow (other_window) & ~resource_mask));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* 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
|
||||||
|
* request.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
meta_window_x11_get_gravity_position (MetaWindow *window,
|
||||||
|
MetaGravity gravity,
|
||||||
|
int *root_x,
|
||||||
|
int *root_y)
|
||||||
|
{
|
||||||
|
MtkRectangle frame_extents;
|
||||||
|
int w, h;
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
w = window->rect.width;
|
||||||
|
h = window->rect.height;
|
||||||
|
|
||||||
|
if (gravity == META_GRAVITY_STATIC)
|
||||||
|
{
|
||||||
|
frame_extents = window->rect;
|
||||||
|
if (window->frame)
|
||||||
|
{
|
||||||
|
frame_extents.x = window->frame->rect.x + window->frame->child_x;
|
||||||
|
frame_extents.y = window->frame->rect.y + window->frame->child_y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (window->frame == NULL)
|
||||||
|
frame_extents = window->rect;
|
||||||
|
else
|
||||||
|
frame_extents = window->frame->rect;
|
||||||
|
}
|
||||||
|
|
||||||
|
x = frame_extents.x;
|
||||||
|
y = frame_extents.y;
|
||||||
|
|
||||||
|
switch (gravity)
|
||||||
|
{
|
||||||
|
case META_GRAVITY_NORTH:
|
||||||
|
case META_GRAVITY_CENTER:
|
||||||
|
case META_GRAVITY_SOUTH:
|
||||||
|
/* Find center of frame. */
|
||||||
|
x += frame_extents.width / 2;
|
||||||
|
/* Center client window on that point. */
|
||||||
|
x -= w / 2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case META_GRAVITY_SOUTH_EAST:
|
||||||
|
case META_GRAVITY_EAST:
|
||||||
|
case META_GRAVITY_NORTH_EAST:
|
||||||
|
/* Find right edge of frame */
|
||||||
|
x += frame_extents.width;
|
||||||
|
/* Align left edge of client at that point. */
|
||||||
|
x -= w;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (gravity)
|
||||||
|
{
|
||||||
|
case META_GRAVITY_WEST:
|
||||||
|
case META_GRAVITY_CENTER:
|
||||||
|
case META_GRAVITY_EAST:
|
||||||
|
/* Find center of frame. */
|
||||||
|
y += frame_extents.height / 2;
|
||||||
|
/* Center client window there. */
|
||||||
|
y -= h / 2;
|
||||||
|
break;
|
||||||
|
case META_GRAVITY_SOUTH_WEST:
|
||||||
|
case META_GRAVITY_SOUTH:
|
||||||
|
case META_GRAVITY_SOUTH_EAST:
|
||||||
|
/* Find south edge of frame */
|
||||||
|
y += frame_extents.height;
|
||||||
|
/* Place bottom edge of client there */
|
||||||
|
y -= h;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (root_x)
|
||||||
|
*root_x = x;
|
||||||
|
if (root_y)
|
||||||
|
*root_y = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get geometry for saving in the session; x/y are gravity
|
||||||
|
* position, and w/h are in resize inc above the base size.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
meta_window_x11_get_session_geometry (MetaWindow *window,
|
||||||
|
int *x,
|
||||||
|
int *y,
|
||||||
|
int *width,
|
||||||
|
int *height)
|
||||||
|
{
|
||||||
|
meta_window_x11_get_gravity_position (window,
|
||||||
|
window->size_hints.win_gravity,
|
||||||
|
x, y);
|
||||||
|
|
||||||
|
*width = (window->rect.width - window->size_hints.base_width) /
|
||||||
|
window->size_hints.width_inc;
|
||||||
|
*height = (window->rect.height - window->size_hints.base_height) /
|
||||||
|
window->size_hints.height_inc;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
meta_window_move_resize_request (MetaWindow *window,
|
meta_window_move_resize_request (MetaWindow *window,
|
||||||
guint value_mask,
|
guint value_mask,
|
||||||
@ -2645,7 +2755,7 @@ meta_window_move_resize_request (MetaWindow *window,
|
|||||||
* server-side position in effect when the configure request was
|
* server-side position in effect when the configure request was
|
||||||
* generated.
|
* generated.
|
||||||
*/
|
*/
|
||||||
meta_window_get_gravity_position (window,
|
meta_window_x11_get_gravity_position (window,
|
||||||
gravity,
|
gravity,
|
||||||
&x, &y);
|
&x, &y);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user