Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focus current tab #638

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ executable(
dependency('glib-2.0'),
dependency('gobject-2.0'),
dependency('gtk+-3.0'),
dependency('gdk-x11-3.0'),
dependency('granite', version: '>=6.1.0'),
dependency('libhandy-1', version: '>=0.83.0'),
vte_dep,
Expand Down
22 changes: 22 additions & 0 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,27 @@ public class Terminal.Application : Gtk.Application {
Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
Intl.textdomain (Config.GETTEXT_PACKAGE);

var act = new SimpleAction ("process-finished", VariantType.STRING);
add_action (act);
act.activate.connect ((v) => {
var now = new DateTime.now_local ();
size_t len;
var tid = v.get_string (out len);
foreach (var window in windows) {
foreach (var terminal in window.terminals) {
if (terminal.terminal_id == tid) {
window.set_active_terminal_tab (terminal.tab);
var ts = Gdk.X11.get_server_time ((Gdk.X11.Window) window.get_window ());
window.present_with_time (ts);
Comment on lines +70 to +71
Copy link
Contributor

Choose a reason for hiding this comment

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

should be using Gtk.get_current_event_time ()

Suggested change
var ts = Gdk.X11.get_server_time ((Gdk.X11.Window) window.get_window ());
window.present_with_time (ts);
window.present_with_time (Gtk.get_current_event_time ());

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

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

@Marukesu Does this work on your end? It doesn't for me. From what I've read, the timestamp that present_with_time receives must be a X11 server timestamp and the only way I was able to get it was using this Gdk.X11 call. I've tried Gdk.CURRENT_TIME and many types of datetime functions returning the current time as well.

I'm not a fan of adding this dependency too, but it was literally the only timestamp that worked for me.

window.grab_focus ();
terminal.tab.grab_focus ();
return ;
}
}
}
get_last_window ().present_with_time ((uint32) now.to_unix ());
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
get_last_window ().present_with_time ((uint32) now.to_unix ());
get_last_window ().present_with_time (Gtk.get_current_event_time ());

});
}

public Application () {
Expand Down Expand Up @@ -122,6 +143,7 @@ public class Terminal.Application : Gtk.Application {
var notification = new Notification (process_string);
notification.set_body (process);
notification.set_icon (process_icon);
notification.set_default_action_and_target_value ("app.process-finished", new Variant.string (id));
send_notification (null, notification);
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,10 @@ namespace Terminal {
return (TerminalWidget)((Gtk.Bin)tab.page).get_child ();
}

public void set_active_terminal_tab (Granite.Widgets.Tab tab) {
notebook.current = tab;
}

/** Compare every tab label with every other and resolve ambiguities **/
private void check_for_tabs_with_same_name () {
/* Take list copies so foreach clauses can be nested safely*/
Expand Down