summaryrefslogtreecommitdiff
path: root/src/core/constraints.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/constraints.c')
-rw-r--r--src/core/constraints.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/core/constraints.c b/src/core/constraints.c
index c31c525d..c3acb128 100644
--- a/src/core/constraints.c
+++ b/src/core/constraints.c
@@ -142,6 +142,10 @@ typedef struct
GList *usable_xinerama_region;
} ConstraintInfo;
+static gboolean constrain_modal_dialog (MetaWindow *window,
+ ConstraintInfo *info,
+ ConstraintPriority priority,
+ gboolean check_only);
static gboolean constrain_maximization (MetaWindow *window,
ConstraintInfo *info,
ConstraintPriority priority,
@@ -222,6 +226,7 @@ typedef struct {
} Constraint;
static const Constraint all_constraints[] = {
+ {constrain_modal_dialog, "constrain_modal_dialog"},
{constrain_maximization, "constrain_maximization"},
{constrain_tiling, "constrain_tiling"},
{constrain_fullscreen, "constrain_fullscreen"},
@@ -784,6 +789,48 @@ get_size_limits (const MetaWindow *window,
}
static gboolean
+constrain_modal_dialog (MetaWindow *window,
+ ConstraintInfo *info,
+ ConstraintPriority priority,
+ gboolean check_only)
+{
+ int x, y;
+ MetaWindow *parent = meta_window_get_transient_for (window);
+ gboolean constraint_already_satisfied;
+
+ if (!meta_prefs_get_attach_modal_dialogs ())
+ return TRUE;
+ if (window->type != META_WINDOW_MODAL_DIALOG || !parent || parent == window)
+ return TRUE;
+
+ x = parent->rect.x + (parent->rect.width / 2 - info->current.width / 2);
+ y = 0;
+ if (parent->frame)
+ {
+ MetaFrameGeometry fgeom;
+
+ x += parent->frame->rect.x;
+ y += parent->frame->rect.y;
+
+ meta_frame_calc_geometry (parent->frame, &fgeom);
+ y += fgeom.top_height;
+
+ y += info->fgeom->top_height;
+ }
+ else
+ y = parent->rect.y + info->fgeom->top_height;
+
+ constraint_already_satisfied = (x == info->current.x) && (y == info->current.y);
+
+ if (check_only || constraint_already_satisfied)
+ return constraint_already_satisfied;
+
+ info->current.y = y;
+ info->current.x = x;
+ return TRUE;
+}
+
+static gboolean
constrain_maximization (MetaWindow *window,
ConstraintInfo *info,
ConstraintPriority priority,