]> www.fi.muni.cz Git - evince.git/commitdiff
[presentation] fixed update scale after screen change||window move
authorLukáš Bezdička <255993@mail.muni.cz>
Thu, 21 Apr 2011 09:31:09 +0000 (11:31 +0200)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Wed, 1 Jun 2011 11:09:21 +0000 (13:09 +0200)
libview/ev-view-presentation.c

index 14cd0dabacb4f31d960a5a7b14076ff4de3011d4..fa8ceff958e41eec03993d3b8967a9fd98463c67 100644 (file)
@@ -1235,42 +1235,60 @@ ev_view_presentation_motion_notify_event (GtkWidget      *widget,
        return FALSE;
 }
 
-static void
-ev_view_presentation_resize_cb (EvViewPresentation *pview,
-                                                               gpointer data)
- {
+static GdkRectangle
+ev_view_presentation_get_monitor_geometry (EvViewPresentation *pview)
+{
        GdkScreen                  *screen = gtk_widget_get_screen (GTK_WIDGET(pview));
        GdkRectangle        monitor;
        gint                monitor_num;
 
        monitor_num = gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (GTK_WIDGET(pview)));
        gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
-       if(!(pview->monitor_width == monitor.width)||!(pview->monitor_height = monitor.height)) {
+
+       return monitor;
+}
+
+static void
+ev_view_presentation_update_scale (EvViewPresentation *pview)
+{
+       GdkRectangle monitor = ev_view_presentation_get_monitor_geometry (pview);
+
+       if((pview->monitor_width != monitor.width)||(pview->monitor_height != monitor.height)) {
                pview->monitor_width = monitor.width;
                pview->monitor_height = monitor.height;
 
                pview->scale = 0;
-        ev_view_presentation_reset_jobs (pview);
-        ev_view_presentation_update_current_page (pview, pview->current_page);
+       ev_view_presentation_reset_jobs (pview);
+       ev_view_presentation_update_current_page (pview, pview->current_page);
        }
 }
 
+static void
+ev_view_presentation_size_allocate (GtkWidget *widget,
+                                                                       GtkAllocation *allocation)
+{
+       gtk_widget_set_allocation (widget, allocation);
+    if (gtk_widget_get_realized (widget))
+       gdk_window_move_resize (gtk_widget_get_window (widget),
+                                allocation->x,
+                                allocation->y,
+                                allocation->width,
+                                allocation->height);
+       ev_view_presentation_update_scale (EV_VIEW_PRESENTATION (widget));
+}
+
 static gboolean
 init_presentation (GtkWidget *widget)
 {
        EvViewPresentation *pview = EV_VIEW_PRESENTATION (widget);
-       GdkScreen          *screen = gtk_widget_get_screen (widget);
-       GdkRectangle        monitor;
-       gint                monitor_num;
+       GdkRectangle monitor = ev_view_presentation_get_monitor_geometry (pview);
 
-       g_signal_connect_swapped(G_OBJECT(widget), "size-allocate",
-       G_CALLBACK(ev_view_presentation_resize_cb),G_OBJECT(pview));
-
-       monitor_num = gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window (widget));
-       gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
        pview->monitor_width = monitor.width;
        pview->monitor_height = monitor.height;
 
+       g_signal_connect_swapped (G_OBJECT (widget), "screen-changed",
+                      G_CALLBACK (ev_view_presentation_update_scale), pview);
+
        ev_view_presentation_update_current_page (pview, pview->current_page);
        ev_view_presentation_hide_cursor_timeout_start (pview);
 
@@ -1316,7 +1334,7 @@ ev_view_presentation_realize (GtkWidget *widget)
                                           window);
 
        g_idle_add ((GSourceFunc)init_presentation, widget);
-}
+       }
 
 static void
 ev_view_presentation_change_page (EvViewPresentation *pview,
@@ -1460,6 +1478,7 @@ ev_view_presentation_class_init (EvViewPresentationClass *klass)
 
         gobject_class->dispose = ev_view_presentation_dispose;
 
+       widget_class->size_allocate = ev_view_presentation_size_allocate;
        widget_class->get_preferred_width = ev_view_presentation_get_preferred_width;
        widget_class->get_preferred_height = ev_view_presentation_get_preferred_height;
        widget_class->realize = ev_view_presentation_realize;