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

3c14d2
From 45b76b121a6f7fd01742b78f9c44a48a3caffbf0 Mon Sep 17 00:00:00 2001
3c14d2
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
3c14d2
Date: Fri, 10 Jan 2014 06:26:57 -0500
3c14d2
Subject: [PATCH 1/2] window-actor: Guard against %NULL frame mask
3c14d2
3c14d2
Creating a new cogl texture may fail, in which case the intent to
3c14d2
free it will crash. While something is clearly wrong (insanely
3c14d2
large window, oom, ...), crashing the WM is harsh and we should
3c14d2
try to avoid it if at all possible, so carry on.
3c14d2
3c14d2
https://bugzilla.gnome.org/show_bug.cgi?id=722266
3c14d2
---
3c14d2
 src/compositor/meta-window-actor.c | 3 ++-
3c14d2
 1 file changed, 2 insertions(+), 1 deletion(-)
3c14d2
3c14d2
diff --git a/src/compositor/meta-window-actor.c b/src/compositor/meta-window-actor.c
3c14d2
index 42d1257..055b413 100644
3c14d2
--- a/src/compositor/meta-window-actor.c
3c14d2
+++ b/src/compositor/meta-window-actor.c
3c14d2
@@ -2181,7 +2181,8 @@ build_and_scan_frame_mask (MetaWindowActor       *self,
3c14d2
 
3c14d2
   meta_shaped_texture_set_mask_texture (META_SHAPED_TEXTURE (priv->actor),
3c14d2
                                         mask_texture);
3c14d2
-  cogl_object_unref (mask_texture);
3c14d2
+  if (mask_texture)
3c14d2
+    cogl_object_unref (mask_texture);
3c14d2
 
3c14d2
   g_free (mask_data);
3c14d2
 }
3c14d2
-- 
3c14d2
1.9.0
3c14d2
3c14d2
3c14d2
From bd6fa34598b774de36c4c65d2cfa577c24f18722 Mon Sep 17 00:00:00 2001
3c14d2
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
3c14d2
Date: Wed, 12 Mar 2014 02:04:13 +0100
3c14d2
Subject: [PATCH 2/2] constraints: Enforce X11 size limits
3c14d2
3c14d2
X11 limits windows to a maximum of 32767x32767, enforce that restriction
3c14d2
to keep insanely huge windows from crashing the WM.
3c14d2
---
3c14d2
 src/core/constraints.c | 39 +++++++++++++++++++++++++++++++++++++++
3c14d2
 1 file changed, 39 insertions(+)
3c14d2
3c14d2
diff --git a/src/core/constraints.c b/src/core/constraints.c
3c14d2
index 606baea..2a510e0 100644
3c14d2
--- a/src/core/constraints.c
3c14d2
+++ b/src/core/constraints.c
3c14d2
@@ -104,6 +104,7 @@ typedef enum
3c14d2
   PRIORITY_SIZE_HINTS_LIMITS = 3,
3c14d2
   PRIORITY_TITLEBAR_VISIBLE = 4,
3c14d2
   PRIORITY_PARTIALLY_VISIBLE_ON_WORKAREA = 4,
3c14d2
+  PRIORITY_XLIMITS = 4,
3c14d2
   PRIORITY_MAXIMUM = 4 /* Dummy value used for loop end = max(all priorities) */
3c14d2
 } ConstraintPriority;
3c14d2
 
3c14d2
@@ -192,6 +193,10 @@ static gboolean constrain_partially_onscreen (MetaWindow         *window,
3c14d2
                                               ConstraintInfo     *info,
3c14d2
                                               ConstraintPriority  priority,
3c14d2
                                               gboolean            check_only);
3c14d2
+static gboolean constrain_xlimits            (MetaWindow         *window,
3c14d2
+                                              ConstraintInfo     *info,
3c14d2
+                                              ConstraintPriority  priority,
3c14d2
+                                              gboolean            check_only);
3c14d2
 
3c14d2
 static void setup_constraint_info        (ConstraintInfo      *info,
3c14d2
                                           MetaWindow          *window,
3c14d2
@@ -236,6 +241,7 @@ static const Constraint all_constraints[] = {
3c14d2
   {constrain_fully_onscreen,     "constrain_fully_onscreen"},
3c14d2
   {constrain_titlebar_visible,   "constrain_titlebar_visible"},
3c14d2
   {constrain_partially_onscreen, "constrain_partially_onscreen"},
3c14d2
+  {constrain_xlimits,            "constrain_xlimits"},
3c14d2
   {NULL,                         NULL}
3c14d2
 };
3c14d2
 
3c14d2
@@ -1518,3 +1524,36 @@ constrain_partially_onscreen (MetaWindow         *window,
3c14d2
 
3c14d2
   return retval;
3c14d2
 }
3c14d2
+
3c14d2
+
3c14d2
+#define MAX_WINDOW_SIZE 32767
3c14d2
+
3c14d2
+static gboolean
3c14d2
+constrain_xlimits (MetaWindow         *window,
3c14d2
+                   ConstraintInfo     *info,
3c14d2
+                   ConstraintPriority  priority,
3c14d2
+                   gboolean            check_only)
3c14d2
+{
3c14d2
+  int max_w, max_h;
3c14d2
+  gboolean constraint_already_satisfied;
3c14d2
+
3c14d2
+  if (priority > PRIORITY_XLIMITS)
3c14d2
+    return TRUE;
3c14d2
+
3c14d2
+  max_w = MAX_WINDOW_SIZE;
3c14d2
+  if (window->frame)
3c14d2
+    max_w -= (info->borders->total.left + info->borders->total.right);
3c14d2
+
3c14d2
+  max_h = MAX_WINDOW_SIZE;
3c14d2
+  if (window->frame)
3c14d2
+    max_h -= (info->borders->total.top + info->borders->total.bottom);
3c14d2
+
3c14d2
+  constraint_already_satisfied = info->current.width < max_w && info->current.height < max_h;
3c14d2
+  if (check_only || constraint_already_satisfied)
3c14d2
+    return constraint_already_satisfied;
3c14d2
+
3c14d2
+  info->current.width = MIN (info->current.width, max_w);
3c14d2
+  info->current.height = MIN (info->current.height, max_h);
3c14d2
+
3c14d2
+  return TRUE;
3c14d2
+}
3c14d2
-- 
3c14d2
1.9.0
3c14d2