diff --git a/src/core/window-private.h b/src/core/window-private.h index 22f88e768..a76cab96b 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -691,24 +691,6 @@ gboolean meta_window_should_show (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, MtkRectangle *rect); diff --git a/src/core/window.c b/src/core/window.c index 0b3ea4e94..da5e4e112 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -4260,107 +4260,6 @@ meta_window_update_layout (MetaWindow *window) 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 meta_window_geometry_contains_rect (MetaWindow *window, MtkRectangle *rect) diff --git a/src/x11/session.c b/src/x11/session.c index 8da4cc089..19c0a0236 100644 --- a/src/x11/session.c +++ b/src/x11/session.c @@ -1042,7 +1042,7 @@ save_state (MetaContext *context) /* Gravity */ { 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, " \n", diff --git a/src/x11/window-x11-private.h b/src/x11/window-x11-private.h index 1c8f0f7c0..67af4bbe5 100644 --- a/src/x11/window-x11-private.h +++ b/src/x11/window-x11-private.h @@ -136,4 +136,11 @@ void meta_window_x11_set_frame_xwindow (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 diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index 936678ebf..aa0cb2206 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -2605,6 +2605,116 @@ meta_window_same_client (MetaWindow *window, (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 meta_window_move_resize_request (MetaWindow *window, guint value_mask, @@ -2645,9 +2755,9 @@ meta_window_move_resize_request (MetaWindow *window, * server-side position in effect when the configure request was * generated. */ - meta_window_get_gravity_position (window, - gravity, - &x, &y); + meta_window_x11_get_gravity_position (window, + gravity, + &x, &y); allow_position_change = FALSE;