Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Commit

Permalink
ensure end session dialog requests keyboard focus (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
itsravenous committed Aug 30, 2023
1 parent 8888adc commit 2bbf149
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
17 changes: 10 additions & 7 deletions src/Indicator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class Session.Indicator : Wingpanel.Indicator {
icon_theme.add_resource_path ("/io/elementary/wingpanel/session");

EndSessionDialogServer.init ();
EndSessionDialogServer.get_default ().show_dialog.connect ((type) => show_dialog ((Widgets.EndSessionDialogType)type));
EndSessionDialogServer.get_default ().show_dialog.connect ((type, timestamp) => show_dialog ((Widgets.EndSessionDialogType)type, timestamp));

manager = new Session.Services.UserManager ();
}
Expand All @@ -75,14 +75,15 @@ public class Session.Indicator : Wingpanel.Indicator {
});

indicator_icon.button_press_event.connect ((e) => {
var timestamp = Gtk.get_current_event_time ();
if (e.button == Gdk.BUTTON_MIDDLE) {
if (session_interface == null) {
init_interfaces.begin ((obj, res) => {
init_interfaces.end (res);
show_shutdown_dialog ();
show_shutdown_dialog (timestamp);
});
} else {
show_shutdown_dialog ();
show_shutdown_dialog (timestamp);
}

return Gdk.EVENT_STOP;
Expand Down Expand Up @@ -212,7 +213,7 @@ public class Session.Indicator : Wingpanel.Indicator {
});

shutdown_button.clicked.connect (() => {
show_shutdown_dialog ();
show_shutdown_dialog (Gtk.get_current_event_time ());
});

logout_button.clicked.connect (() => {
Expand Down Expand Up @@ -255,7 +256,7 @@ public class Session.Indicator : Wingpanel.Indicator {
return main_box;
}

private void show_shutdown_dialog () {
private void show_shutdown_dialog (uint32 triggering_event_timestamp) {
close ();

if (server_type == Wingpanel.IndicatorManager.ServerType.SESSION) {
Expand All @@ -271,7 +272,7 @@ public class Session.Indicator : Wingpanel.Indicator {
}
});
} else {
show_dialog (Widgets.EndSessionDialogType.RESTART);
show_dialog (Widgets.EndSessionDialogType.RESTART, triggering_event_timestamp);
}
}

Expand Down Expand Up @@ -313,7 +314,7 @@ public class Session.Indicator : Wingpanel.Indicator {

public override void closed () {}

private void show_dialog (Widgets.EndSessionDialogType type) {
private void show_dialog (Widgets.EndSessionDialogType type, uint32 triggering_event_timestamp) {
close ();

if (current_dialog != null) {
Expand Down Expand Up @@ -367,6 +368,8 @@ public class Session.Indicator : Wingpanel.Indicator {
});

current_dialog.show_all ();

current_dialog.present_with_time (triggering_event_timestamp);
}

private async void update_tooltip () {
Expand Down
4 changes: 2 additions & 2 deletions src/Services/EndSessionDialogServer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class Session.EndSessionDialogServer : Object {
}

[DBus (visible = false)]
public signal void show_dialog (uint type);
public signal void show_dialog (uint type, uint32 triggering_event_timestamp);

public signal void confirmed_logout ();
public signal void confirmed_reboot ();
Expand All @@ -61,6 +61,6 @@ public class Session.EndSessionDialogServer : Object {
throw new DBusError.NOT_SUPPORTED ("Hibernate, suspend and hybrid sleep are not supported actions yet");
}

show_dialog (type);
show_dialog (type, timestamp);
}
}

0 comments on commit 2bbf149

Please sign in to comment.