[gucharmap] charmap: Fix storing window size



commit 9723243ddf0c030aeb60f5db43af117adef5d948
Author: Christian Persch <chpe gnome org>
Date:   Thu Mar 3 19:00:59 2016 +0100

    charmap: Fix storing window size
    
    With newer gtk+, storing the size from the configure-event makes the window
    grow on restore, since that size will include the CSD borders. Use
    size-allocate event instead and gtk_window_get_size().

 gucharmap/gucharmap-settings.c |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)
---
diff --git a/gucharmap/gucharmap-settings.c b/gucharmap/gucharmap-settings.c
index 565fc84..1501bf3 100644
--- a/gucharmap/gucharmap-settings.c
+++ b/gucharmap/gucharmap-settings.c
@@ -62,15 +62,19 @@ free_window_state (WindowState *state)
   g_slice_free (WindowState, state);
 }
 
-static gboolean
-window_configure_event_cb (GtkWidget *widget,
-                           GdkEventConfigure *event,
-                           WindowState *state)
+static void
+window_size_allocate_cb (GtkWidget *widget,
+                         GtkAllocation *allocation,
+                         WindowState *state)
 {
+  int width, height;
+
+  gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
+
   if (!state->is_maximised && !state->is_fullscreen &&
-      (state->width != event->width || state->height != event->height)) {
-    state->width = event->width;
-    state->height = event->height;
+      (state->width != width || state->height != height)) {
+    state->width = width;
+    state->height = height;
 
     if (state->timeout_id == 0) {
       state->timeout_id = g_timeout_add_seconds (WINDOW_STATE_TIMEOUT,
@@ -78,8 +82,6 @@ window_configure_event_cb (GtkWidget *widget,
                                                  state);
     }
   }
-
-  return FALSE;
 }
 
 static gboolean
@@ -122,8 +124,8 @@ gucharmap_settings_add_window (GtkWindow *window)
   g_object_set_data_full (G_OBJECT (window), "GamesConf::WindowState",
                           state, (GDestroyNotify) free_window_state);
 
-  g_signal_connect (window, "configure-event",
-                    G_CALLBACK (window_configure_event_cb), state);
+  g_signal_connect_after (window, "size-allocate",
+                          G_CALLBACK (window_size_allocate_cb), state);
   g_signal_connect (window, "window-state-event",
                     G_CALLBACK (window_state_event_cb), state);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]