[epiphany] Really handle focus stealing prevention properly"
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Really handle focus stealing prevention properly"
- Date: Tue, 22 Nov 2016 00:10:25 +0000 (UTC)
commit 6ff26acccd0b90ec364681dc7d87b76818b6349f
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Mon Nov 21 17:55:16 2016 -0600
Really handle focus stealing prevention properly"
This reverts commit 0283906a4ba772d447bde4a9c5b738a6e027edaa and also
fixes the bug, all in one!
The original commit was not correct: it conflated UNIX time
(g_get_real_time) with X11 time (gtk_get_current_event_time). The
easiest way to fix it would be to simply call the later instead of the
former, but I also want to revert to using the more explicit API where
the caller must pass the user time manually, so do that too.
embed/ephy-download.c | 54 +++++++++++++++-------------------
embed/ephy-download.h | 5 ++-
lib/widgets/ephy-download-widget.c | 3 +-
lib/widgets/ephy-downloads-popover.c | 4 ++-
4 files changed, 32 insertions(+), 34 deletions(-)
---
diff --git a/embed/ephy-download.c b/embed/ephy-download.c
index 0f0715c..fae5ab9 100644
--- a/embed/ephy-download.c
+++ b/embed/ephy-download.c
@@ -409,10 +409,22 @@ ephy_download_failed (EphyDownload *download,
return FALSE;
}
-static gboolean
-ephy_download_do_download_action_internal (EphyDownload *download,
- EphyDownloadActionType action,
- guint32 user_time)
+/**
+ * ephy_download_do_download_action:
+ * @download: an #EphyDownload
+ * @action: one of #EphyDownloadActionType
+ * @user_time: GDK timestamp, for focus-stealing prevention
+ *
+ * Executes the given @action for @download, this can be any of
+ * #EphyDownloadActionType.
+ *
+ * Returns: %TRUE if the action was executed succesfully.
+ *
+ **/
+gboolean
+ephy_download_do_download_action (EphyDownload *download,
+ EphyDownloadActionType action,
+ guint32 user_time)
{
GFile *destination;
const char *destination_uri;
@@ -422,16 +434,16 @@ ephy_download_do_download_action_internal (EphyDownload *download,
destination = g_file_new_for_uri (destination_uri);
switch ((action ? action : download->action)) {
+ 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_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);
+ if (!ret)
+ ret = ephy_file_browse_to (destination, user_time);
break;
case EPHY_DOWNLOAD_ACTION_NONE:
LOG ("ephy_download_do_download_action: none");
@@ -445,24 +457,6 @@ ephy_download_do_download_action_internal (EphyDownload *download,
return ret;
}
-/**
- * ephy_download_do_download_action:
- * @download: an #EphyDownload
- * @action: one of #EphyDownloadActionType
- *
- * Executes the given @action for @download, this can be any of
- * #EphyDownloadActionType.
- *
- * Returns: %TRUE if the action was executed succesfully.
- *
- **/
-gboolean
-ephy_download_do_download_action (EphyDownload *download,
- EphyDownloadActionType action)
-{
- return ephy_download_do_download_action_internal (download, action, g_get_real_time ());
-}
-
static void
ephy_download_dispose (GObject *object)
{
@@ -697,9 +691,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_internal (download, EPHY_DOWNLOAD_ACTION_OPEN, download->start_time);
+ ephy_download_do_download_action (download, EPHY_DOWNLOAD_ACTION_OPEN, download->start_time);
else
- ephy_download_do_download_action_internal (download, download->action, download->start_time);
+ ephy_download_do_download_action (download, download->action, download->start_time);
}
static void
diff --git a/embed/ephy-download.h b/embed/ephy-download.h
index 1792eaa..e71ff01 100644
--- a/embed/ephy-download.h
+++ b/embed/ephy-download.h
@@ -58,7 +58,8 @@ guint32 ephy_download_get_start_time (EphyDownload *download);
EphyDownloadActionType ephy_download_get_action (EphyDownload *download);
void ephy_download_set_action (EphyDownload *download,
EphyDownloadActionType action);
-gboolean ephy_download_do_download_action (EphyDownload *download,
- EphyDownloadActionType action);
+gboolean ephy_download_do_download_action (EphyDownload *download,
+ EphyDownloadActionType action,
+ guint32 user_time);
G_END_DECLS
diff --git a/lib/widgets/ephy-download-widget.c b/lib/widgets/ephy-download-widget.c
index 2e905c5..659675f 100644
--- a/lib/widgets/ephy-download-widget.c
+++ b/lib/widgets/ephy-download-widget.c
@@ -274,7 +274,8 @@ widget_action_button_clicked_cb (EphyDownloadWidget *widget)
ephy_downloads_manager_remove_download (manager, widget->download);
} else {
ephy_download_do_download_action (widget->download,
- EPHY_DOWNLOAD_ACTION_BROWSE_TO);
+ EPHY_DOWNLOAD_ACTION_BROWSE_TO,
+ gtk_get_current_event_time ());
}
}
diff --git a/lib/widgets/ephy-downloads-popover.c b/lib/widgets/ephy-downloads-popover.c
index 6d1dce9..060e98e 100644
--- a/lib/widgets/ephy-downloads-popover.c
+++ b/lib/widgets/ephy-downloads-popover.c
@@ -50,7 +50,9 @@ download_box_row_activated_cb (EphyDownloadsPopover *popover,
if (!ephy_download_succeeded (download))
return;
- ephy_download_do_download_action (download, EPHY_DOWNLOAD_ACTION_OPEN);
+ ephy_download_do_download_action (download,
+ EPHY_DOWNLOAD_ACTION_OPEN,
+ gtk_get_current_event_time ());
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]