summaryrefslogtreecommitdiff
path: root/src/core/constraints.c
diff options
context:
space:
mode:
authorMaxim Ermilov <[email protected]>2014-09-27 17:43:54 +0300
committerVictor Kareh <[email protected]>2018-08-28 09:38:37 -0400
commit37fecf49392eb10ada1f4bf481d6ad6be56891dd (patch)
tree77e7190c06f6590a11ff305ce4066daba9825851 /src/core/constraints.c
parent4f47c5be61320102120fcae6c8c04f63c5b4f5b5 (diff)
downloadmarco-37fecf49392eb10ada1f4bf481d6ad6be56891dd.tar.bz2
marco-37fecf49392eb10ada1f4bf481d6ad6be56891dd.tar.xz
Optionally attach modal dialogs
Add a preference /apps/mutter/general/attach_modal_dialogs. When true, instead of having independent titlebars, modal dialogs appear attached to the titlebar of the parent window and are moved together with the parent window. https://bugzilla.gnome.org/show_bug.cgi?id=612726 NOTE: Patch copied from mutter and adapted for metacity.
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,