[evince] Use monitor height instead of screen height to calculate page scale in presentation mode
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] Use monitor height instead of screen height to calculate page scale in presentation mode
- Date: Sat, 13 Mar 2010 13:54:03 +0000 (UTC)
commit 0c3040ad65632ef58234bbbb68af8513e94307bc
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Sat Mar 13 14:30:19 2010 +0100
Use monitor height instead of screen height to calculate page scale in presentation mode
Fixes presentation mode in dual head setups. Fixes bug #608924.
libview/ev-view-presentation.c | 46 +++++++++++++++++++++------------------
shell/ev-window.c | 7 ++++-
2 files changed, 30 insertions(+), 23 deletions(-)
---
diff --git a/libview/ev-view-presentation.c b/libview/ev-view-presentation.c
index 05f8799..5074e4e 100644
--- a/libview/ev-view-presentation.c
+++ b/libview/ev-view-presentation.c
@@ -62,6 +62,7 @@ struct _EvViewPresentation
guint rotation;
EvPresentationState state;
gdouble scale;
+ gint monitor_height;
/* Cursors */
EvViewCursor cursor;
@@ -168,9 +169,9 @@ ev_view_presentation_get_scale_for_page (EvViewPresentation *pview,
ev_document_get_page_size (pview->document, page, &width, &height);
if (pview->rotation == 90 || pview->rotation == 270)
- return GTK_WIDGET (pview)->allocation.height / width;
+ return pview->monitor_height / width;
else
- return GTK_WIDGET (pview)->allocation.height / height;
+ return pview->monitor_height / height;
}
static void
@@ -953,19 +954,9 @@ static void
ev_view_presentation_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
- EvViewPresentation *pview = EV_VIEW_PRESENTATION (widget);
- GdkScreen *screen = gtk_widget_get_screen (widget);
-
- allocation->x = 0;
- allocation->y = 0;
- allocation->width = gdk_screen_get_width (screen);
- allocation->height = gdk_screen_get_height (screen);
-
GTK_WIDGET_CLASS (ev_view_presentation_parent_class)->size_allocate (widget, allocation);
- ev_view_presentation_update_scale (pview);
-
- gtk_widget_queue_draw (widget);
+ widget->allocation = *allocation;
}
static void
@@ -1200,6 +1191,25 @@ ev_view_presentation_motion_notify_event (GtkWidget *widget,
return FALSE;
}
+static gboolean
+init_presentation (GtkWidget *widget)
+{
+ EvViewPresentation *pview = EV_VIEW_PRESENTATION (widget);
+ GdkScreen *screen = gtk_widget_get_screen (widget);
+ GdkRectangle monitor;
+ gint monitor_num;
+
+ monitor_num = gdk_screen_get_monitor_at_window (screen, widget->window);
+ gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
+ pview->monitor_height = monitor.height;
+
+ ev_view_presentation_update_scale (pview);
+ ev_view_presentation_update_current_page (pview, pview->current_page);
+ ev_view_presentation_hide_cursor_timeout_start (pview);
+
+ return FALSE;
+}
+
static void
ev_view_presentation_realize (GtkWidget *widget)
{
@@ -1223,7 +1233,7 @@ ev_view_presentation_realize (GtkWidget *widget)
GDK_KEY_PRESS_MASK |
GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK |
- GDK_ENTER_NOTIFY_MASK |
+ GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK;
widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
@@ -1236,7 +1246,7 @@ ev_view_presentation_realize (GtkWidget *widget)
gdk_window_set_background (widget->window, &widget->style->black);
- gtk_widget_queue_resize (widget);
+ g_idle_add ((GSourceFunc)init_presentation, widget);
}
static void
@@ -1328,7 +1338,6 @@ ev_view_presentation_constructor (GType type,
{
GObject *object;
EvViewPresentation *pview;
- GtkAllocation a;
object = G_OBJECT_CLASS (ev_view_presentation_parent_class)->constructor (type,
n_construct_properties,
@@ -1340,11 +1349,6 @@ ev_view_presentation_constructor (GType type,
ev_page_cache_set_flags (pview->page_cache, EV_PAGE_DATA_INCLUDE_LINKS);
}
- /* Call allocate asap to update page scale */
- ev_view_presentation_size_allocate (GTK_WIDGET (pview), &a);
- ev_view_presentation_update_current_page (pview, pview->current_page);
- ev_view_presentation_hide_cursor_timeout_start (pview);
-
return object;
}
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 93f674b..0ceb24f 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -3622,9 +3622,9 @@ ev_window_run_presentation (EvWindow *window)
gtk_box_pack_start (GTK_BOX (window->priv->main_box),
window->priv->presentation_view,
- FALSE, FALSE, 0);
- gtk_widget_show (window->priv->presentation_view);
+ TRUE, TRUE, 0);
+ gtk_widget_hide (window->priv->hpaned);
ev_window_update_presentation_action (window);
update_chrome_visibility (window);
@@ -3632,6 +3632,8 @@ ev_window_run_presentation (EvWindow *window)
if (fullscreen_window)
gtk_window_fullscreen (GTK_WINDOW (window));
+ gtk_widget_show (window->priv->presentation_view);
+
ev_application_screensaver_disable (EV_APP);
if (window->priv->metadata && !ev_window_is_empty (window))
@@ -3654,6 +3656,7 @@ ev_window_stop_presentation (EvWindow *window,
window->priv->presentation_view);
window->priv->presentation_view = NULL;
+ gtk_widget_show (window->priv->hpaned);
ev_window_update_presentation_action (window);
update_chrome_visibility (window);
if (unfullscreen_window)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]