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

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