[epiphany/wip/fixes: 13/15] download: Handle focus stealing prevention properly
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/fixes: 13/15] download: Handle focus stealing prevention properly
- Date: Sun, 6 Mar 2016 20:14:50 +0000 (UTC)
commit a4523b2d68617394d906436f46b52f06cc7875cc
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Sat Mar 5 13:33:57 2016 -0600
download: Handle focus stealing prevention properly
Currently, we always pass the start time of the download to
ephy_embed_shell_launch_handler for focus stealing preventing. This is
wrong as it causes apps to not be focused when opening files manually.
For example, I became confused today when I tried to open an image file,
and it opened in eog, but eog appeared beneath the Epiphany window and
did not receive focus, so I could not see it.
Instead, use the current time for focus stealing prevention when the
download action is activated from somewhere external to this file (e.g.
the downloads popover), and only use the start time when the download
action is set in advance via ephy_download_set_download_action(), or
when opening the download automatically without user interaction.
https://bugzilla.gnome.org/show_bug.cgi?id=610586
embed/ephy-download.c | 70 +++++++++++++++++++++++++++---------------------
1 files changed, 39 insertions(+), 31 deletions(-)
---
diff --git a/embed/ephy-download.c b/embed/ephy-download.c
index 78858d2..b7633cb 100644
--- a/embed/ephy-download.c
+++ b/embed/ephy-download.c
@@ -414,6 +414,42 @@ ephy_download_failed (EphyDownload *download,
return FALSE;
}
+static gboolean
+ephy_download_do_download_action_internal (EphyDownload *download,
+ EphyDownloadActionType action,
+ guint32 user_time)
+{
+ GFile *destination;
+ const char *destination_uri;
+ gboolean ret = FALSE;
+
+ destination_uri = webkit_download_get_destination (download->download);
+ destination = g_file_new_for_uri (destination_uri);
+
+ switch ((action ? action : download->action)) {
+ case EPHY_DOWNLOAD_ACTION_OPEN:
+ LOG ("ephy_download_do_download_action: open");
+ ret = ephy_embed_shell_launch_handler (ephy_embed_shell_get_default (),
+ destination, NULL, user_time);
+ /* Fall through if we did not open anything. */
+ if (ret)
+ break;
+ case EPHY_DOWNLOAD_ACTION_BROWSE_TO:
+ LOG ("ephy_download_do_download_action: browse_to");
+ ret = ephy_file_browse_to (destination, user_time);
+ break;
+ case EPHY_DOWNLOAD_ACTION_NONE:
+ LOG ("ephy_download_do_download_action: none");
+ ret = TRUE;
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+ g_object_unref (destination);
+
+ return ret;
+}
+
/**
* ephy_download_do_download_action:
* @download: an #EphyDownload
@@ -430,35 +466,7 @@ gboolean
ephy_download_do_download_action (EphyDownload *download,
EphyDownloadActionType action)
{
- GFile *destination;
- const char *destination_uri;
- gboolean ret = FALSE;
-
- destination_uri = webkit_download_get_destination (download->download);
- destination = g_file_new_for_uri (destination_uri);
-
- switch ((action ? action : download->action)) {
- case EPHY_DOWNLOAD_ACTION_OPEN:
- LOG ("ephy_download_do_download_action: open");
- ret = ephy_embed_shell_launch_handler (ephy_embed_shell_get_default (),
- destination, NULL, download->start_time);
- /* Fall through if we did not open anything. */
- if (ret)
- break;
- case EPHY_DOWNLOAD_ACTION_BROWSE_TO:
- LOG ("ephy_download_do_download_action: browse_to");
- ret = ephy_file_browse_to (destination, download->start_time);
- break;
- case EPHY_DOWNLOAD_ACTION_NONE:
- LOG ("ephy_download_do_download_action: none");
- ret = TRUE;
- break;
- default:
- g_assert_not_reached ();
- }
- g_object_unref (destination);
-
- return ret;
+ return ephy_download_do_download_action_internal (download, action, g_get_real_time ());
}
static void
@@ -695,9 +703,9 @@ download_finished_cb (WebKitDownload *wk_download,
if (g_settings_get_boolean (EPHY_SETTINGS_MAIN, EPHY_PREFS_AUTO_DOWNLOADS) &&
download->action == EPHY_DOWNLOAD_ACTION_NONE)
- ephy_download_do_download_action (download, EPHY_DOWNLOAD_ACTION_OPEN);
+ ephy_download_do_download_action_internal (download, EPHY_DOWNLOAD_ACTION_OPEN, download->start_time);
else
- ephy_download_do_download_action (download, download->action);
+ ephy_download_do_download_action_internal (download, download->action, download->start_time);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]