raveit65 e20600d
From 89a5825eb20bfa91b91055e5a3dfe6445e6b9bd2 Mon Sep 17 00:00:00 2001
raveit65 e20600d
From: raveit65 <mate@raveit.de>
raveit65 e20600d
Date: Fri, 11 Jun 2021 21:26:40 +0200
raveit65 e20600d
Subject: [PATCH] Revert "pager: do not change workspace size from
raveit65 e20600d
 size_allocate"
raveit65 e20600d
raveit65 e20600d
This reverts commit 3456b747b6381f17d48629dd8fdd4d511e739b10.
raveit65 e20600d
---
raveit65 e20600d
 libwnck/pager.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++
raveit65 e20600d
 1 file changed, 59 insertions(+)
raveit65 e20600d
raveit65 e20600d
diff --git a/libwnck/pager.c b/libwnck/pager.c
raveit65 e20600d
index c769d62..a563a4d 100644
raveit65 e20600d
--- a/libwnck/pager.c
raveit65 e20600d
+++ b/libwnck/pager.c
raveit65 e20600d
@@ -122,6 +122,8 @@ static void     wnck_pager_get_preferred_height_for_width (GtkWidget *widget,
raveit65 e20600d
                                                            int        width,
raveit65 e20600d
                                                            int       *minimum_height,
raveit65 e20600d
                                                            int       *natural_height);
raveit65 e20600d
+static void     wnck_pager_size_allocate (GtkWidget        *widget,
raveit65 e20600d
+                                          GtkAllocation    *allocation);
raveit65 e20600d
 static gboolean wnck_pager_draw          (GtkWidget        *widget,
raveit65 e20600d
                                           cairo_t          *cr);
raveit65 e20600d
 static gboolean wnck_pager_button_press  (GtkWidget        *widget,
raveit65 e20600d
@@ -247,6 +249,7 @@ wnck_pager_class_init (WnckPagerClass *klass)
raveit65 e20600d
   widget_class->get_preferred_width_for_height = wnck_pager_get_preferred_width_for_height;
raveit65 e20600d
   widget_class->get_preferred_height = wnck_pager_get_preferred_height;
raveit65 e20600d
   widget_class->get_preferred_height_for_width = wnck_pager_get_preferred_height_for_width;
raveit65 e20600d
+  widget_class->size_allocate = wnck_pager_size_allocate;
raveit65 e20600d
   widget_class->draw = wnck_pager_draw;
raveit65 e20600d
   widget_class->button_press_event = wnck_pager_button_press;
raveit65 e20600d
   widget_class->button_release_event = wnck_pager_button_release;
raveit65 e20600d
@@ -684,6 +687,62 @@ wnck_pager_get_preferred_height_for_width (GtkWidget *widget,
raveit65 e20600d
   *natural_height = *minimum_height = MAX (height, 0);
raveit65 e20600d
 }
raveit65 e20600d
 
raveit65 e20600d
+static gboolean
raveit65 e20600d
+_wnck_pager_queue_resize (gpointer data)
raveit65 e20600d
+{
raveit65 e20600d
+  gtk_widget_queue_resize (GTK_WIDGET (data));
raveit65 e20600d
+  return FALSE;
raveit65 e20600d
+}
raveit65 e20600d
+
raveit65 e20600d
+static void
raveit65 e20600d
+wnck_pager_size_allocate (GtkWidget      *widget,
raveit65 e20600d
+                          GtkAllocation  *allocation)
raveit65 e20600d
+{
raveit65 e20600d
+  WnckPager *pager;
raveit65 e20600d
+  int workspace_size;
raveit65 e20600d
+  GtkBorder padding;
raveit65 e20600d
+  int width;
raveit65 e20600d
+  int height;
raveit65 e20600d
+
raveit65 e20600d
+  pager = WNCK_PAGER (widget);
raveit65 e20600d
+
raveit65 e20600d
+  width = allocation->width;
raveit65 e20600d
+  height = allocation->height;
raveit65 e20600d
+
raveit65 e20600d
+  _wnck_pager_get_padding (pager, &padding);
raveit65 e20600d
+  width  -= padding.left + padding.right;
raveit65 e20600d
+  height -= padding.top + padding.bottom;
raveit65 e20600d
+
raveit65 e20600d
+  g_assert (pager->priv->n_rows > 0);
raveit65 e20600d
+
raveit65 e20600d
+  if (pager->priv->orientation == GTK_ORIENTATION_VERTICAL)
raveit65 e20600d
+    {
raveit65 e20600d
+      if (pager->priv->show_all_workspaces)
raveit65 e20600d
+	workspace_size = (width - (pager->priv->n_rows - 1))  / pager->priv->n_rows;
raveit65 e20600d
+      else
raveit65 e20600d
+	workspace_size = width;
raveit65 e20600d
+    }
raveit65 e20600d
+  else
raveit65 e20600d
+    {
raveit65 e20600d
+      if (pager->priv->show_all_workspaces)
raveit65 e20600d
+	workspace_size = (height - (pager->priv->n_rows - 1))/ pager->priv->n_rows;
raveit65 e20600d
+      else
raveit65 e20600d
+	workspace_size = height;
raveit65 e20600d
+    }
raveit65 e20600d
+
raveit65 e20600d
+  workspace_size = MAX (workspace_size, 1);
raveit65 e20600d
+
raveit65 e20600d
+  if (workspace_size != pager->priv->workspace_size)
raveit65 e20600d
+    {
raveit65 e20600d
+      pager->priv->workspace_size = workspace_size;
raveit65 e20600d
+      g_idle_add (_wnck_pager_queue_resize, pager);
raveit65 e20600d
+      return;
raveit65 e20600d
+    }
raveit65 e20600d
+
raveit65 e20600d
+  GTK_WIDGET_CLASS (wnck_pager_parent_class)->size_allocate (widget,
raveit65 e20600d
+                                                             allocation);
raveit65 e20600d
+}
raveit65 e20600d
+
raveit65 e20600d
 static void
raveit65 e20600d
 get_workspace_rect (WnckPager    *pager,
raveit65 e20600d
                     int           space,
raveit65 e20600d
-- 
raveit65 e20600d
2.31.1
raveit65 e20600d