summaryrefslogtreecommitdiff
path: root/src/core/constraints.c
diff options
context:
space:
mode:
authorGiovanni Campagna <gcampagn@redhat.com>2013-09-02 11:22:11 +0200
committerAlberts Muktupāvels <alberts.muktupavels@gmail.com>2017-03-02 23:37:12 +0200
commit10fc45724bded4bd21a2af38b72ca39145180c54 (patch)
tree936b2270d8cd8d832100aa9ab30b8c0595ae3fc5 /src/core/constraints.c
parent28698a5344ce71eac28ee29d6c198bd67a4fd3a2 (diff)
downloadmetacity-10fc45724bded4bd21a2af38b72ca39145180c54.tar.gz
constraints: account for decorations when positioning modal dialogs
What we want to achieve is that the dialog is visually centered on the parent, including the decorations for both, and making sure that CSD/frame_extents are respected. https://bugzilla.gnome.org/show_bug.cgi?id=707194
Diffstat (limited to 'src/core/constraints.c')
-rw-r--r--src/core/constraints.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/core/constraints.c b/src/core/constraints.c
index db4e8d67..dda3350a 100644
--- a/src/core/constraints.c
+++ b/src/core/constraints.c
@@ -822,18 +822,28 @@ constrain_modal_dialog (MetaWindow *window,
{
int x, y;
MetaWindow *parent = meta_window_get_transient_for (window);
+ MetaRectangle child_rect, parent_rect;
gboolean constraint_already_satisfied;
if (!meta_window_is_attached_dialog (window))
return TRUE;
- x = parent->rect.x + (parent->rect.width / 2 - info->current.width / 2);
- y = parent->rect.y + (parent->rect.height / 2 - info->current.height / 2);
- if (parent->frame)
- {
- x += parent->frame->rect.x;
- y += parent->frame->rect.y;
- }
+ /* We want to center the dialog on the parent, including the decorations
+ for both of them. info->current is in client X window coordinates, so we need
+ to convert them to frame coordinates, apply the centering and then
+ convert back to client.
+ */
+
+ child_rect = info->current;
+ extend_by_frame (window, &child_rect, info->borders);
+
+ meta_window_get_outer_rect (parent, &parent_rect);
+
+ child_rect.x = parent_rect.x + (parent_rect.width / 2 - child_rect.width / 2);
+ child_rect.y = parent_rect.y + (parent_rect.height / 2 - child_rect.height / 2);
+ unextend_by_frame (window, &child_rect, info->borders);
+ x = child_rect.x;
+ y = child_rect.y;
constraint_already_satisfied = (x == info->current.x) && (y == info->current.y);