|
|
88c283 |
From 575490895047e0709bc84826fe6d6a73028d7bbc Mon Sep 17 00:00:00 2001
|
|
|
776610 |
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
|
|
|
776610 |
Date: Wed, 12 Mar 2014 02:04:13 +0100
|
|
|
776610 |
Subject: [PATCH] constraints: Enforce X11 size limits
|
|
|
776610 |
|
|
|
776610 |
X11 limits windows to a maximum of 32767x32767, enforce that restriction
|
|
|
776610 |
to keep insanely huge windows from crashing the WM.
|
|
|
776610 |
---
|
|
|
776610 |
src/core/constraints.c | 42 ++++++++++++++++++++++++++++++++++++++++++
|
|
|
776610 |
1 file changed, 42 insertions(+)
|
|
|
776610 |
|
|
|
776610 |
diff --git a/src/core/constraints.c b/src/core/constraints.c
|
|
|
88c283 |
index 117131b15..379372245 100644
|
|
|
776610 |
--- a/src/core/constraints.c
|
|
|
776610 |
+++ b/src/core/constraints.c
|
|
|
88c283 |
@@ -109,6 +109,7 @@ typedef enum
|
|
|
776610 |
PRIORITY_TITLEBAR_VISIBLE = 4,
|
|
|
776610 |
PRIORITY_PARTIALLY_VISIBLE_ON_WORKAREA = 4,
|
|
|
776610 |
PRIORITY_CUSTOM_RULE = 4,
|
|
|
776610 |
+ PRIORITY_XLIMITS = 4,
|
|
|
776610 |
PRIORITY_MAXIMUM = 4 /* Dummy value used for loop end = max(all priorities) */
|
|
|
776610 |
} ConstraintPriority;
|
|
|
776610 |
|
|
|
88c283 |
@@ -201,6 +202,10 @@ static gboolean constrain_partially_onscreen (MetaWindow *window,
|
|
|
776610 |
ConstraintInfo *info,
|
|
|
776610 |
ConstraintPriority priority,
|
|
|
776610 |
gboolean check_only);
|
|
|
776610 |
+static gboolean constrain_xlimits (MetaWindow *window,
|
|
|
776610 |
+ ConstraintInfo *info,
|
|
|
776610 |
+ ConstraintPriority priority,
|
|
|
776610 |
+ gboolean check_only);
|
|
|
776610 |
|
|
|
776610 |
static void setup_constraint_info (ConstraintInfo *info,
|
|
|
776610 |
MetaWindow *window,
|
|
|
88c283 |
@@ -236,6 +241,7 @@ static const Constraint all_constraints[] = {
|
|
|
776610 |
{constrain_fully_onscreen, "constrain_fully_onscreen"},
|
|
|
776610 |
{constrain_titlebar_visible, "constrain_titlebar_visible"},
|
|
|
776610 |
{constrain_partially_onscreen, "constrain_partially_onscreen"},
|
|
|
776610 |
+ {constrain_xlimits, "constrain_xlimits"},
|
|
|
776610 |
{NULL, NULL}
|
|
|
776610 |
};
|
|
|
776610 |
|
|
|
88c283 |
@@ -1780,3 +1786,39 @@ constrain_partially_onscreen (MetaWindow *window,
|
|
|
776610 |
|
|
|
776610 |
return retval;
|
|
|
776610 |
}
|
|
|
776610 |
+
|
|
|
776610 |
+
|
|
|
776610 |
+#define MAX_WINDOW_SIZE 32767
|
|
|
776610 |
+
|
|
|
776610 |
+static gboolean
|
|
|
776610 |
+constrain_xlimits (MetaWindow *window,
|
|
|
776610 |
+ ConstraintInfo *info,
|
|
|
776610 |
+ ConstraintPriority priority,
|
|
|
776610 |
+ gboolean check_only)
|
|
|
776610 |
+{
|
|
|
776610 |
+ int max_w, max_h;
|
|
|
776610 |
+ gboolean constraint_already_satisfied;
|
|
|
776610 |
+
|
|
|
776610 |
+ if (priority > PRIORITY_XLIMITS)
|
|
|
776610 |
+ return TRUE;
|
|
|
776610 |
+
|
|
|
776610 |
+ max_w = max_h = MAX_WINDOW_SIZE;
|
|
|
776610 |
+
|
|
|
776610 |
+ if (window->frame)
|
|
|
776610 |
+ {
|
|
|
776610 |
+ MetaFrameBorders borders;
|
|
|
776610 |
+ meta_frame_calc_borders (window->frame, &borders);
|
|
|
776610 |
+
|
|
|
776610 |
+ max_w -= (borders.total.left + borders.total.right);
|
|
|
776610 |
+ max_h -= (borders.total.top + borders.total.bottom);
|
|
|
776610 |
+ }
|
|
|
776610 |
+
|
|
|
776610 |
+ constraint_already_satisfied = info->current.width < max_w && info->current.height < max_h;
|
|
|
776610 |
+ if (check_only || constraint_already_satisfied)
|
|
|
776610 |
+ return constraint_already_satisfied;
|
|
|
776610 |
+
|
|
|
776610 |
+ info->current.width = MIN (info->current.width, max_w);
|
|
|
776610 |
+ info->current.height = MIN (info->current.height, max_h);
|
|
|
776610 |
+
|
|
|
776610 |
+ return TRUE;
|
|
|
776610 |
+}
|
|
|
776610 |
--
|
|
|
88c283 |
2.21.0
|
|
|
776610 |
|