Skip to content

Commit

Permalink
Focus window when it demands attention (#2041)
Browse files Browse the repository at this point in the history
  • Loading branch information
lenemter authored Aug 21, 2024
1 parent c46810f commit c3d894a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/WindowAttentionTracker.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* SPDX-License-Identifier: GPL-3.0-or-later
* SPDX-FileCopyrightText: 2024 elementary, Inc. (https://elementary.io)
*/

public class Gala.WindowAttentionTracker : GLib.Object {
public static void init (Meta.Display display) {
display.window_demands_attention.connect (on_window_demands_attention);
display.window_marked_urgent.connect (on_window_demands_attention);
}

private static void on_window_demands_attention (Meta.Window window) {
window.raise ();
window.get_workspace ().activate_with_focus (window, window.display.get_current_time ());
}
}
1 change: 1 addition & 0 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ namespace Gala {
window_tracker = new WindowTracker ();
WindowStateSaver.init (window_tracker);
window_tracker.init (display);
WindowAttentionTracker.init (display);

notification_stack = new NotificationStack (display);

Expand Down
1 change: 1 addition & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ gala_bin_sources = files(
'ScreenSaverManager.vala',
'ScreenshotManager.vala',
'SessionManager.vala',
'WindowAttentionTracker.vala',
'WindowGrabTracker.vala',
'WindowListener.vala',
'WindowManager.vala',
Expand Down

0 comments on commit c3d894a

Please sign in to comment.