From 71fab50c8eb80db29d656fc12ce167ec70d71748 Mon Sep 17 00:00:00 2001 From: fiaxh Date: Tue, 11 Apr 2017 00:04:27 +0200 Subject: Fix alt-tab behaviour when notification is active --- main/src/ui/application.vala | 4 ++-- main/src/ui/notifications.vala | 15 ++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'main/src/ui') diff --git a/main/src/ui/application.vala b/main/src/ui/application.vala index c71124c1..35791b07 100644 --- a/main/src/ui/application.vala +++ b/main/src/ui/application.vala @@ -9,8 +9,6 @@ public class Dino.Ui.Application : Dino.Application { public Application() throws Error { Notify.init("dino"); - notifications = new Notifications(stream_interaction); - notifications.start(); Environment.set_application_name("Dino"); Gtk.Window.set_default_icon_name("dino"); IconTheme.get_default().add_resource_path("/org/dino-im/icons"); @@ -18,6 +16,8 @@ public class Dino.Ui.Application : Dino.Application { activate.connect(() => { create_set_app_menu(); window = new UnifiedWindow(this, stream_interaction); + notifications = new Notifications(stream_interaction, window); + notifications.start(); notifications.conversation_selected.connect(window.on_conversation_selected); window.show(); }); diff --git a/main/src/ui/notifications.vala b/main/src/ui/notifications.vala index 029a4b33..af2c80fe 100644 --- a/main/src/ui/notifications.vala +++ b/main/src/ui/notifications.vala @@ -10,6 +10,7 @@ public class Notifications : Object { public signal void conversation_selected(Conversation conversation); private StreamInteractor stream_interactor; + private Gtk.Window window; private HashMap notifications = new HashMap(Conversation.hash_func, Conversation.equals_func); private enum ClosedReason { // org.freedesktop.Notifications.NotificationClosed @@ -19,8 +20,9 @@ public class Notifications : Object { UNDEFINED = 4 } - public Notifications(StreamInteractor stream_interactor) { + public Notifications(StreamInteractor stream_interactor, Gtk.Window window) { this.stream_interactor = stream_interactor; + this.window = window; } public void start() { @@ -32,10 +34,13 @@ public class Notifications : Object { if (!notifications.has_key(conversation)) { notifications[conversation] = new Notify.Notification("", null, null); notifications[conversation].set_hint("transient", true); - notifications[conversation].closed.connect(() => { - if (notifications[conversation].closed_reason == ClosedReason.USER_DISMISSED) { - // USER_DISMISSED + transient = very probably clicked on - conversation_selected(conversation); + notifications[conversation].add_action("default", "Open", () => { + conversation_selected(conversation); + Gdk.X11.Window x11window = window.get_window() as Gdk.X11.Window; + if (x11window != null) { + window.present_with_time(Gdk.X11.get_server_time(x11window)); + } else { + window.present(); } }); } -- cgit v1.2.3-70-g09d2