shithub: puzzles

Download patch

ref: 8dfe5cec31e784e4ece2955ecc8cc35ee7e8fbb3
parent: 5123b1bf68777ffa86e651f178046b26a87cf2d9
author: Simon Tatham <anakin@pobox.com>
date: Sat Dec 3 03:49:29 EST 2016

Stop using deprecated GTK 3 geometry-based functions.

Now we work out for ourselves how the drawing-area size relates to the
overall window size, by adding on the height of fe->menubar and/or
fe->statusbar.

--- a/gtk.c
+++ b/gtk.c
@@ -1935,6 +1935,24 @@
     return FALSE;
 }
 
+#if GTK_CHECK_VERSION(3,0,0)
+static int window_extra_height(frontend *fe)
+{
+    int ret = 0;
+    if (fe->menubar) {
+        GtkRequisition req;
+        gtk_widget_get_preferred_size(fe->menubar, &req, NULL);
+        ret += req.height;
+    }
+    if (fe->statusbar) {
+        GtkRequisition req;
+        gtk_widget_get_preferred_size(fe->statusbar, &req, NULL);
+        ret += req.height;
+    }
+    return ret;
+}
+#endif
+
 static void resize_fe(frontend *fe)
 {
     int x, y;
@@ -1942,7 +1960,7 @@
     get_size(fe, &x, &y);
 
 #if GTK_CHECK_VERSION(3,0,0)
-    gtk_window_resize_to_geometry(GTK_WINDOW(fe->window), x, y);
+    gtk_window_resize(GTK_WINDOW(fe->window), x, y + window_extra_height(fe));
 #else
     fe->drawing_area_shrink_pending = FALSE;
     gtk_drawing_area_size(GTK_DRAWING_AREA(fe->area), x, y);
@@ -2648,15 +2666,23 @@
 #endif
     {
         GdkGeometry geom;
-        geom.base_width = geom.base_height = 0;
+        geom.base_width = 0;
+#if GTK_CHECK_VERSION(3,0,0)
+        geom.base_height = window_extra_height(fe);
+        gtk_window_set_geometry_hints(GTK_WINDOW(fe->window), NULL,
+                                      &geom, GDK_HINT_BASE_SIZE);
+#else
+        geom.base_height = 0;
         gtk_window_set_geometry_hints(GTK_WINDOW(fe->window), fe->area,
                                       &geom, GDK_HINT_BASE_SIZE);
+#endif
     }
     fe->w = -1;
     fe->h = -1;
     get_size(fe, &x, &y);
 #if GTK_CHECK_VERSION(3,0,0)
-    gtk_window_set_default_geometry(GTK_WINDOW(fe->window), x, y);
+    gtk_window_set_default_size(GTK_WINDOW(fe->window),
+                                x, y + window_extra_height(fe));
 #else
     fe->drawing_area_shrink_pending = FALSE;
     gtk_drawing_area_size(GTK_DRAWING_AREA(fe->area), x, y);