Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 7 additions & 19 deletions src/Application.vala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright 2011-2023 elementary, Inc. (https://elementary.io)
* SPDX-License-Identifier: LGPL-3.0-only
* SPDX-License-Identifier: LGPL-3.0-or-later
* SPDX-FileCopyrightText: 2011-2025 elementary, Inc. (https://elementary.io)
*/

public class Terminal.Application : Gtk.Application {
Expand Down Expand Up @@ -46,18 +46,7 @@ public class Terminal.Application : Gtk.Application {
}
}

// This is a hack to avoid using Gdk-Xii dependency. Using present_with_time ()
// with the current event time does not work either on X11 or Wayland perhaps
// because the triggering event did not occur on the Terminal window?
// Using set_keep_above () at least works on X11 but not on Wayland
//TODO It may well be possible to use present () on Gtk4 so this needs revisiting
window_to_present.set_keep_above (true);
window_to_present.present ();
window_to_present.grab_focus ();
Idle.add (() => {
window_to_present.set_keep_above (false);
return Source.REMOVE;
});
});

add_main_option ("version", 'v', 0, OptionArg.NONE, _("Show version"), null);
Expand Down Expand Up @@ -196,7 +185,7 @@ public class Terminal.Application : Gtk.Application {
terminal.tab.icon = process_icon;
}

if (!(Gdk.WindowState.FOCUSED in terminal.main_window.get_window ().get_state ())) {
if (!(get_active_window ().is_active)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know this was already available in GTK3, very cool!

var notification = new Notification (process_string);
notification.set_body (process);
notification.set_icon (process_icon);
Expand All @@ -210,12 +199,11 @@ public class Terminal.Application : Gtk.Application {
withdraw_notification_for_terminal (terminal, id, tab_change_handler, focus_in_handler);
});

focus_in_handler = terminal.main_window.focus_in_event.connect (() => {
withdraw_notification_for_terminal (terminal, id, tab_change_handler, focus_in_handler);

return Gdk.EVENT_PROPAGATE;
focus_in_handler = terminal.main_window.notify["is-active"].connect (() => {
if (terminal.main_window.is_active) {
withdraw_notification_for_terminal (terminal, id, tab_change_handler, focus_in_handler);
}
});

}
});

Expand Down