Fix alt-tab behaviour when notification is active

This commit is contained in:
fiaxh 2017-04-11 00:04:27 +02:00
parent 9bc83539d1
commit 71fab50c8e
3 changed files with 13 additions and 7 deletions

View file

@ -107,6 +107,7 @@ CUSTOM_VAPIS
${CMAKE_BINARY_DIR}/exports/dino_internal.vapi ${CMAKE_BINARY_DIR}/exports/dino_internal.vapi
PACKAGES PACKAGES
${MAIN_PACKAGES} ${MAIN_PACKAGES}
gdk-x11-3.0
GRESOURCES GRESOURCES
${MAIN_GRESOURCES_XML} ${MAIN_GRESOURCES_XML}
) )

View file

@ -9,8 +9,6 @@ public class Dino.Ui.Application : Dino.Application {
public Application() throws Error { public Application() throws Error {
Notify.init("dino"); Notify.init("dino");
notifications = new Notifications(stream_interaction);
notifications.start();
Environment.set_application_name("Dino"); Environment.set_application_name("Dino");
Gtk.Window.set_default_icon_name("dino"); Gtk.Window.set_default_icon_name("dino");
IconTheme.get_default().add_resource_path("/org/dino-im/icons"); IconTheme.get_default().add_resource_path("/org/dino-im/icons");
@ -18,6 +16,8 @@ public class Dino.Ui.Application : Dino.Application {
activate.connect(() => { activate.connect(() => {
create_set_app_menu(); create_set_app_menu();
window = new UnifiedWindow(this, stream_interaction); window = new UnifiedWindow(this, stream_interaction);
notifications = new Notifications(stream_interaction, window);
notifications.start();
notifications.conversation_selected.connect(window.on_conversation_selected); notifications.conversation_selected.connect(window.on_conversation_selected);
window.show(); window.show();
}); });

View file

@ -10,6 +10,7 @@ public class Notifications : Object {
public signal void conversation_selected(Conversation conversation); public signal void conversation_selected(Conversation conversation);
private StreamInteractor stream_interactor; private StreamInteractor stream_interactor;
private Gtk.Window window;
private HashMap<Conversation, Notify.Notification> notifications = new HashMap<Conversation, Notify.Notification>(Conversation.hash_func, Conversation.equals_func); private HashMap<Conversation, Notify.Notification> notifications = new HashMap<Conversation, Notify.Notification>(Conversation.hash_func, Conversation.equals_func);
private enum ClosedReason { // org.freedesktop.Notifications.NotificationClosed private enum ClosedReason { // org.freedesktop.Notifications.NotificationClosed
@ -19,8 +20,9 @@ public class Notifications : Object {
UNDEFINED = 4 UNDEFINED = 4
} }
public Notifications(StreamInteractor stream_interactor) { public Notifications(StreamInteractor stream_interactor, Gtk.Window window) {
this.stream_interactor = stream_interactor; this.stream_interactor = stream_interactor;
this.window = window;
} }
public void start() { public void start() {
@ -32,10 +34,13 @@ public class Notifications : Object {
if (!notifications.has_key(conversation)) { if (!notifications.has_key(conversation)) {
notifications[conversation] = new Notify.Notification("", null, null); notifications[conversation] = new Notify.Notification("", null, null);
notifications[conversation].set_hint("transient", true); notifications[conversation].set_hint("transient", true);
notifications[conversation].closed.connect(() => { notifications[conversation].add_action("default", "Open", () => {
if (notifications[conversation].closed_reason == ClosedReason.USER_DISMISSED) {
// USER_DISMISSED + transient = very probably clicked on
conversation_selected(conversation); 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();
} }
}); });
} }