Blame SOURCES/deal-more-gracefully-with-oversized-windows.patch

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