-
-
Notifications
You must be signed in to change notification settings - Fork 32
Introduce WindowSystem #363
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,25 @@ | ||
| /* | ||
| * Copyright 2022 elementary, Inc. <https://elementary.io> | ||
| * Copyright 2022, 2025 elementary, Inc. <https://elementary.io> | ||
| * Copyright 2022 Corentin Noël <[email protected]> | ||
| * SPDX-License-Identifier: GPL-3.0-or-later | ||
| */ | ||
|
|
||
| public class Dock.AppWindow : GLib.Object { | ||
| public class Dock.Window : GLib.Object { | ||
| public uint64 uid { get; construct set; } | ||
|
|
||
| public string app_id { get; private set; default = ""; } | ||
| public bool has_focus { get; private set; default = false; } | ||
| public bool on_active_workspace { get; private set; default = false; } | ||
|
|
||
| public AppWindow (uint64 uid) { | ||
| public Window (uint64 uid) { | ||
| Object (uid: uid); | ||
| } | ||
|
|
||
| public void update_properties (GLib.HashTable<string, Variant> properties) { | ||
| if ("app-id" in properties) { | ||
| app_id = properties["app-id"].get_string (); | ||
| } | ||
|
|
||
| if ("has-focus" in properties) { | ||
| has_focus = (bool) properties["has-focus"]; | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| /* | ||
| * SPDX-License-Identifier: GPL-3.0 | ||
| * SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io) | ||
| */ | ||
|
|
||
| public class Dock.WindowSystem : Object { | ||
| private static GLib.Once<WindowSystem> instance; | ||
| public static unowned WindowSystem get_default () { | ||
| return instance.once (() => { return new WindowSystem (); }); | ||
| } | ||
|
|
||
| public DesktopIntegration? desktop_integration { get; private set; } | ||
| public Gee.List<Window> windows { get; private owned set; } | ||
|
|
||
| private WindowSystem () {} | ||
|
|
||
| construct { | ||
| windows = new Gee.LinkedList<Window> (); | ||
| load.begin (); | ||
| } | ||
|
|
||
| private async void load () { | ||
| try { | ||
| desktop_integration = yield GLib.Bus.get_proxy<Dock.DesktopIntegration> ( | ||
| SESSION, | ||
| "org.pantheon.gala", | ||
| "/org/pantheon/gala/DesktopInterface" | ||
| ); | ||
|
|
||
| yield sync_windows (); | ||
|
|
||
| desktop_integration.windows_changed.connect (sync_windows); | ||
| } catch (Error e) { | ||
| critical ("Failed to get desktop integration: %s", e.message); | ||
| } | ||
| } | ||
|
|
||
| private Window? find_window (uint64 uid) { | ||
| return windows.first_match ((win) => { | ||
| return win.uid == uid; | ||
| }); | ||
| } | ||
|
|
||
| private async void sync_windows () requires (desktop_integration != null) { | ||
| DesktopIntegration.Window[] di_windows; | ||
| try { | ||
| di_windows = yield desktop_integration.get_windows (); | ||
| } catch (Error e) { | ||
| critical (e.message); | ||
| return; | ||
| } | ||
|
|
||
| var new_windows = new Gee.LinkedList<Window> (); | ||
| foreach (unowned var di_window in di_windows) { | ||
| var window = find_window (di_window.uid); | ||
| if (window == null) { | ||
| window = new Window (di_window.uid); | ||
| } | ||
|
|
||
| window.update_properties (di_window.properties); | ||
|
|
||
| new_windows.add (window); | ||
| } | ||
|
|
||
| windows = new_windows; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.