[balsa] Save the correct window geometry



commit 4288ae3e1fc28acc961c8821c8e7cdbf953cd414
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Mon Nov 21 12:14:17 2016 -0500

    Save the correct window geometry
    
        * libbalsa/source-viewer.c (lsv_size_allocate_cb): save the window
          geometry from gtk_window_get_size instead of the GtkAllocation.
        * src/balsa-mblist.c (bmbl_mru_size_allocate_cb): ditto.
        * src/message-window.c (size_alloc_cb): ditto.
        * src/sendmsg-window.c (sw_size_alloc_cb): ditto.
        * src/main-window.c (bw_window_state_event_cb): simplify the
          code.

 ChangeLog                |   12 ++++++++++++
 libbalsa/source-viewer.c |   19 ++++++++++++-------
 src/balsa-mblist.c       |   19 +++++++++++++------
 src/main-window.c        |    4 ++--
 src/message-window.c     |   17 ++++++++++-------
 src/sendmsg-window.c     |   16 ++++++++++------
 6 files changed, 59 insertions(+), 28 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0538513..2c445e5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2016-11-21  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       Save the correct window geometry
+
+       * libbalsa/source-viewer.c (lsv_size_allocate_cb): save the window
+         geometry from gtk_window_get_size instead of the GtkAllocation.
+       * src/balsa-mblist.c (bmbl_mru_size_allocate_cb): ditto.
+       * src/message-window.c (size_alloc_cb): ditto.
+       * src/sendmsg-window.c (sw_size_alloc_cb): ditto.
+       * src/main-window.c (bw_window_state_event_cb): simplify the
+         code.
+
 2016-11-20  Peter Bloomfield  <pbloomfield bellsouth net>
 
        Disable accelerated compositing in webkit2, to avoid some gdk
diff --git a/libbalsa/source-viewer.c b/libbalsa/source-viewer.c
index 399fc69..208005f 100644
--- a/libbalsa/source-viewer.c
+++ b/libbalsa/source-viewer.c
@@ -169,17 +169,22 @@ lsv_window_destroy_notify(LibBalsaSourceViewerInfo * lsvi)
 */
 
 static void
-lsv_size_allocate_cb(GtkWindow * window, GtkAllocation * alloc,
+lsv_size_allocate_cb(GtkWidget * window, GtkAllocation * alloc,
                      LibBalsaSourceViewerInfo * lsvi)
 {
     GdkWindow *gdk_window;
+    gboolean maximized;
 
-    if ((gdk_window = gtk_widget_get_window(lsvi->window))
-        && !(gdk_window_get_state(gdk_window)
-             & GDK_WINDOW_STATE_MAXIMIZED)) {
-        *lsvi->width  = alloc->width;
-        *lsvi->height = alloc->height;
-    }
+    gdk_window = gtk_widget_get_window(window);
+    if (gdk_window == NULL)
+        return;
+
+    maximized =
+        (gdk_window_get_state(gdk_window) &
+         (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)) != 0;
+
+    if (!maximized)
+        gtk_window_get_size(GTK_WINDOW(window), lsvi->width, lsvi->height);
 }
 
 #define BALSA_SOURCE_VIEWER "balsa-source-viewer"
diff --git a/src/balsa-mblist.c b/src/balsa-mblist.c
index b8f6388..02b4eee 100644
--- a/src/balsa-mblist.c
+++ b/src/balsa-mblist.c
@@ -1847,14 +1847,21 @@ bmbl_mru_size_allocate_cb(GtkWidget * widget, GdkRectangle * allocation,
                           gpointer user_data)
 {
     GdkWindow *gdk_window;
+    gboolean maximized;
+
+    gdk_window = gtk_widget_get_window(widget);
+    if (gdk_window == NULL)
+        return;
 
     /* Maximizing a GtkDialog may not be possible, but we check anyway. */
-    if ((gdk_window = gtk_widget_get_window(widget))
-        && !(gdk_window_get_state(gdk_window)
-             & GDK_WINDOW_STATE_MAXIMIZED)) {
-        balsa_app.mru_tree_width  = allocation->width;
-        balsa_app.mru_tree_height = allocation->height;
-    }
+    maximized =
+        (gdk_window_get_state(gdk_window) &
+         (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)) != 0;
+
+    if (!maximized)
+        gtk_window_get_size(GTK_WINDOW(widget),
+                            & balsa_app.mru_tree_width,
+                            & balsa_app.mru_tree_height);
 }
 
 static void
diff --git a/src/main-window.c b/src/main-window.c
index 4b6e98a..fc6ddbd 100644
--- a/src/main-window.c
+++ b/src/main-window.c
@@ -654,8 +654,8 @@ bw_window_state_event_cb(BalsaWindow * window,
     /* Note when we are either maximized or fullscreen, to avoid saving
      * nonsensical geometry. */
     balsa_app.mw_maximized =
-        (event->new_window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0
-        || (event->new_window_state & GDK_WINDOW_STATE_FULLSCREEN) != 0;
+        (event->new_window_state & (GDK_WINDOW_STATE_MAXIMIZED |
+                                    GDK_WINDOW_STATE_FULLSCREEN)) != 0;
 
     return FALSE;
 }
diff --git a/src/message-window.c b/src/message-window.c
index 75c3570..5a76993 100644
--- a/src/message-window.c
+++ b/src/message-window.c
@@ -519,15 +519,18 @@ size_alloc_cb(GtkWidget * window, GtkAllocation * alloc)
 {
     GdkWindow *gdk_window;
 
-    if (!(gdk_window = gtk_widget_get_window(window)))
+    gdk_window = gtk_widget_get_window(window);
+    if (gdk_window == NULL)
         return;
 
-    if (!(balsa_app.message_window_maximized =
-          (gdk_window_get_state(gdk_window)
-           & GDK_WINDOW_STATE_MAXIMIZED))) {
-        balsa_app.message_window_height = alloc->height;
-        balsa_app.message_window_width = alloc->width;
-    }
+    balsa_app.message_window_maximized =
+        (gdk_window_get_state(gdk_window) &
+         (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)) != 0;
+
+    if (!balsa_app.message_window_maximized)
+        gtk_window_get_size(GTK_WINDOW(window),
+                            & balsa_app.message_window_width,
+                            & balsa_app.message_window_height);
 }
 
 static void
diff --git a/src/sendmsg-window.c b/src/sendmsg-window.c
index 091e300..3ea776f 100644
--- a/src/sendmsg-window.c
+++ b/src/sendmsg-window.c
@@ -1311,14 +1311,18 @@ sw_size_alloc_cb(GtkWidget * window, GtkAllocation * alloc)
 {
     GdkWindow *gdk_window;
 
-    if (!(gdk_window = gtk_widget_get_window(window)))
+    gdk_window = gtk_widget_get_window(window);
+    if (gdk_window == NULL)
         return;
 
-    if (!(balsa_app.sw_maximized = gdk_window_get_state(gdk_window)
-          & GDK_WINDOW_STATE_MAXIMIZED)) {
-        balsa_app.sw_height = alloc->height;
-        balsa_app.sw_width  = alloc->width;
-    }
+    balsa_app.sw_maximized =
+        (gdk_window_get_state(gdk_window) &
+         (GDK_WINDOW_STATE_MAXIMIZED | GDK_WINDOW_STATE_FULLSCREEN)) != 0;
+
+    if (!balsa_app.sw_maximized)
+        gtk_window_get_size(GTK_WINDOW(window),
+                            & balsa_app.sw_width,
+                            & balsa_app.sw_height);
 }
 
 


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