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