[evince] shell: Save correct position and size of window in Metadata



commit 937e77fc7b078cce3cd2839a42212c124baff9f4
Author: José Aliste <jose aliste gmail com>
Date:   Wed Feb 14 00:41:09 2018 -0300

    shell: Save correct position and size of window in Metadata
    
    Since now Gtk manages (sometimes) client decorations, it is
    not safe to use the values we get from configure events or
    size allocate events and we must call gtk_window_get_size
    and gtk_window_get_position
    
    Patch by iskatu posteo org
    
    https://bugzilla.gnome.org/show_bug.cgi?id=783242

 shell/ev-window.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 8e73108..8ed743b 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -5880,6 +5880,7 @@ window_configure_event_cb (EvWindow *window, GdkEventConfigure *event, gpointer
 {
        GdkWindowState state;
        gdouble document_width, document_height;
+       gint window_x, window_y, window_width, window_height;
 
        if (!window->priv->metadata)
                return FALSE;
@@ -5890,14 +5891,16 @@ window_configure_event_cb (EvWindow *window, GdkEventConfigure *event, gpointer
                if (window->priv->document) {
                        ev_document_get_max_page_size (window->priv->document,
                                                       &document_width, &document_height);
+                       gtk_window_get_size (GTK_WINDOW (window), &window_width, &window_height);
+                       gtk_window_get_position (GTK_WINDOW (window), &window_x, &window_y);
                        g_settings_set (window->priv->default_settings, "window-ratio", "(dd)",
-                                       (double)event->width / document_width,
-                                       (double)event->height / document_height);
+                                       (double)window_width / document_width,
+                                       (double)window_height / document_height);
 
-                       ev_metadata_set_int (window->priv->metadata, "window_x", event->x);
-                       ev_metadata_set_int (window->priv->metadata, "window_y", event->y);
-                       ev_metadata_set_int (window->priv->metadata, "window_width", event->width);
-                       ev_metadata_set_int (window->priv->metadata, "window_height", event->height);
+                       ev_metadata_set_int (window->priv->metadata, "window_x", window_x);
+                       ev_metadata_set_int (window->priv->metadata, "window_y", window_y);
+                       ev_metadata_set_int (window->priv->metadata, "window_width",window_width);
+                       ev_metadata_set_int (window->priv->metadata, "window_height", window_height);
                }
        }
 


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