GNOME Bugzilla – Bug 571051
Evince steals focus when opening a file
Last modified: 2013-05-03 00:09:59 UTC
Evince steals focus and shows up on top of other windows. This is reproducible for me when I interact with Nautilus just after double-clicking a PDF file (before Evince pops up): the Nautilus window gets obscured by the newly opened Evince window, even after I click on another file in the Nautilus window before the Evince window shows up. This behaviour is highly annoying, and I believe Evince did behave correctly in the past. Any clue what's happening?
In a probably related note, evince is moving its window to the top when the file changes---this is driving me crazy in Fedora 10's evince 2.24.2.
Mariano, agreed, I'm having the same issue here. See bug #304249 for that. (Work-around: minimize the Evince window when writing/compiling LaTeX ;))
After some investigation, it turns out that calling gtk_window_maximize() and gtk_window_unmaximize() makes the window move to the front, at least with Metacity 2.24.x. The setup_size_from_metadata() function inside shell/ev-window.c is called on each document load, and this function calls either gtk_window_maximize() or gtk_window_unmaximize(), depending on the value coming from the "window_maximized" key stored in the metadata file for this uri. After applying the trivial patch below, Evince does no longer insists on moving the window to the top when a document is (re)loaded, but obviously this change removes the "remember maximization state" feature. Index: shell/ev-window.c =================================================================== --- shell/ev-window.c (revision 3425) +++ shell/ev-window.c (working copy) @@ -989,11 +989,11 @@ if (ev_metadata_manager_get (uri, "window_maximized", &maximized, FALSE)) { if (g_value_get_boolean (&maximized)) { - gtk_window_maximize (GTK_WINDOW (window)); + // gtk_window_maximize (GTK_WINDOW (window)); g_value_unset (&maximized); return; } else { - gtk_window_unmaximize (GTK_WINDOW (window)); + // gtk_window_unmaximize (GTK_WINDOW (window)); } g_value_unset (&maximized); }
(In reply to comment #3) > The setup_size_from_metadata() function inside > shell/ev-window.c is called on each document load, and > this function calls either gtk_window_maximize() or > gtk_window_unmaximize(), depending on the value coming > from the "window_maximized" key stored in the metadata > file for this uri. I should also point out that (un)maximizing is a no-op when reloading the document, since the window is already shown, and in the right state.
Created attachment 128320 [details] [review] Proposed fix This patch avoids resizing the window when reloading a document. This fixes the problem described in this bug report for me, and addresses the issue described 304249#131.
I meant bug #304249#c131
(In reply to comment #5) > Created an attachment (id=128320) [edit] > Proposed fix > > This patch avoids resizing the window when reloading a document. This fixes the > problem described in this bug report for me, and addresses the issue described > 304249#131. > The thing is that we should never use the metadata stuff when reloading the document. I've reworked the metadata handling when loading an re-loading. Please try it out (svn trunk r3426) and let me know whether it works. Thanks.
Confirming that current SVN trunk works just as well as after applying my patch... ;) Yes, I know the code is a lot cleaner now. Thanks.
Regarding this part of your patch: if (ev_metadata_manager_get (uri, "window_maximized", &maximized, FALSE)) { if (g_value_get_boolean (&maximized)) { gtk_window_maximize (GTK_WINDOW (window)); + g_value_unset (&maximized); + return; } else { gtk_window_unmaximize (GTK_WINDOW (window)); } g_value_unset (&maximized); } Does reusing "&maximized" and unsetting it twice not cause any problems? (Note: I don't know anything about GValue.)
Ehm, please disregard comment 9. I missed the "return" ;)
Carlos, while we're at it: setup_view_from_metadata() contains this piece of code: /* Fullscreen */ if (ev_metadata_manager_get (uri, "fullscreen", &fullscreen, FALSE)) { if (g_value_get_boolean (&fullscreen) && uri) { ev_window_run_fullscreen (window); } g_value_unset (&fullscreen); } This causes Evince to start in full screen mode, and there is no easy way out if you don't know what's happening (i.e. you don't know you have to press Escape). This is seriously bad UI IMHO, and I remember others complaining about this as well. What about ditching this? There is no use case for this feature.
See bug #309364, btw.
Should this be closed FIXED?
No, because comment 11 has not been addressed yet.
I am closing this as fixed. The missing part in comment 11 is already addressed with the toolbar that allows the user to leave the fullscreen state.