From e333794f616e61a7ee38d79def79455b2ff359ec Mon Sep 17 00:00:00 2001 From: Michael James Gratton Date: Wed, 7 Feb 2018 15:01:34 +1100 Subject: [PATCH] Work around present() not actually raising windows under Wayland. This uses the method of using present_with_time() with value instead of Gdk.CURRENT_TIME as the arg value, as suggested in Bug 766284. Fixes Bug 776881 under Wayland, maybe also under X11. * src/client/application/geary-application.vala (GearyApplication), src/client/composer/composer-container.vala (ComposerContainer): Use workaround in present(). * src/client/application/geary-controller.vala (GearyController), src/client/application/secret-mediator.vala (SecretMediator): Use GearyApplication.present() instead of calling it directly on the main window, as needed. * src/client/composer/composer-embed.vala (ComposerEmbed): Just use the base class's present rather that duplicating the old implementation. --- src/client/application/geary-application.vala | 9 ++++++--- src/client/application/geary-controller.vala | 18 ++++++++---------- src/client/application/secret-mediator.vala | 19 ++++++++++--------- src/client/composer/composer-container.vala | 7 ++++++- src/client/composer/composer-embed.vala | 4 ---- 5 files changed, 30 insertions(+), 27 deletions(-) diff --git a/src/client/application/geary-application.vala b/src/client/application/geary-application.vala index 48f0ea6b..d1ef67fb 100644 --- a/src/client/application/geary-application.vala +++ b/src/client/application/geary-application.vala @@ -222,9 +222,12 @@ public class GearyApplication : Gtk.Application { if (controller.main_window == null) return false; - // When the app is started hidden, show_all() never gets - // called, do so here to prevent an empty window appearing. - controller.main_window.present(); + // Use present_with_time and a made up time so the present + // actually works, as a work around for Bug 766284 + // . + this.controller.main_window.present_with_time( + (uint32) (get_real_time() / 1000) + ); return true; } diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala index c9d34065..307f1780 100644 --- a/src/client/application/geary-controller.vala +++ b/src/client/application/geary-controller.vala @@ -1437,13 +1437,11 @@ public class GearyController : Geary.BaseObject { if (conversation != null) main_window.conversation_list_view.select_conversation(conversation); } - + private void on_indicator_activated_application(uint32 timestamp) { - // When the app is started hidden, show_all() never gets - // called, do so here to prevent an empty window appearing. - main_window.present_with_time(timestamp); + this.application.present(); } - + private void on_indicator_activated_composer(uint32 timestamp) { on_indicator_activated_application(timestamp); on_new_message(null); @@ -2286,7 +2284,7 @@ public class GearyController : Geary.BaseObject { // Find out what to do with the inline composers. // TODO: Remove this in favor of automatically saving drafts - main_window.present(); + this.application.present(); Gee.List composers_to_destroy = new Gee.ArrayList(); foreach (ComposerWidget cw in composer_widgets) { if (cw.state != ComposerWidget.ComposerState.DETACHED) @@ -2468,17 +2466,17 @@ public class GearyController : Geary.BaseObject { && !current_folder.properties.is_local_only && current_account != null && (current_folder as Geary.FolderSupport.Move) != null); } - + public bool confirm_delete(int num_messages) { - main_window.present(); + this.application.present(); ConfirmationDialog dialog = new ConfirmationDialog(main_window, ngettext( "Do you want to permanently delete this message?", "Do you want to permanently delete these messages?", num_messages), null, _("Delete"), "destructive-action"); - + return (dialog.run() == Gtk.ResponseType.OK); } - + private async void archive_or_delete_selection_async(bool archive, bool trash, Cancellable? cancellable) throws Error { if (!can_switch_conversation_view()) diff --git a/src/client/application/secret-mediator.vala b/src/client/application/secret-mediator.vala index 5ed538cf..57215d50 100644 --- a/src/client/application/secret-mediator.vala +++ b/src/client/application/secret-mediator.vala @@ -115,18 +115,19 @@ public class SecretMediator : Geary.CredentialsMediator, Object { // to serialize the code int token = yield dialog_mutex.claim_async(null); - // If the main window is hidden, make it visible now and present to user as transient parent - Gtk.Window? main_window = this.instance.get_active_window(); - if (main_window != null && !main_window.visible) { - main_window.present_with_time(Gdk.CURRENT_TIME); - } + // Ensure main window present to the window + this.instance.present(); - PasswordDialog password_dialog = new PasswordDialog(main_window, services.has_smtp(), - account_information, services); + PasswordDialog password_dialog = new PasswordDialog( + this.instance.get_active_window(), + services.has_smtp(), + account_information, + services + ); bool result = password_dialog.run(); - + dialog_mutex.release(ref token); - + if (!result) { // user cancelled the dialog imap_password = null; diff --git a/src/client/composer/composer-container.vala b/src/client/composer/composer-container.vala index ba831e64..6a1edf64 100644 --- a/src/client/composer/composer-container.vala +++ b/src/client/composer/composer-container.vala @@ -19,7 +19,12 @@ public interface ComposerContainer { public abstract Gtk.ApplicationWindow top_window { get; } public virtual void present() { - this.top_window.present(); + // Use present_with_time and a made up time so the present + // actually works, as a work around for Bug 766284 + // . + this.top_window.present_with_time( + (uint32) (get_real_time() / 1000) + ); } public virtual unowned Gtk.Widget get_focus() { diff --git a/src/client/composer/composer-embed.vala b/src/client/composer/composer-embed.vala index 37d67bcf..460e164e 100644 --- a/src/client/composer/composer-embed.vala +++ b/src/client/composer/composer-embed.vala @@ -186,10 +186,6 @@ public class ComposerEmbed : Gtk.EventBox, ComposerContainer { return ret; } - public void present() { - top_window.present(); - } - public void vanish() { hide(); this.composer.state = ComposerWidget.ComposerState.DETACHED;