-
-
Notifications
You must be signed in to change notification settings - Fork 77
Use WindowPositioner for panel positions #2109
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 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5f5e890
Use WindowPositioner for panel positions
leolost2605 83fdc7d
Fix X
leolost2605 d76d71e
Merge branch 'main' into leolost/panel-window-use-window-positioner
lenemter 1e8438e
Merge branch 'main' into leolost/panel-window-use-window-positioner
leolost2605 c6a68a8
Work around X blockage
leolost2605 f4590ff
Adjust to barriers in HideTracker
leolost2605 4efd67a
Merge branch 'main' into leolost/panel-window-use-window-positioner
leolost2605 9bbea70
Merge branch 'main' into leolost/panel-window-use-window-positioner
leolost2605 97cfa04
Merge branch 'main' into leolost/panel-window-use-window-positioner
zeebok eff2bc9
Merge branch 'main' into leolost/panel-window-use-window-positioner
lenemter 5e5c9a5
Merge branch 'main' into leolost/panel-window-use-window-positioner
leolost2605 fb92b1e
Use unowned, rm new line
leolost2605 7aa4d26
Merge branch 'main' into leolost/panel-window-use-window-positioner
lenemter 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 |
|---|---|---|
|
|
@@ -13,35 +13,23 @@ public class Gala.PanelWindow : Object { | |
| public WindowManager wm { get; construct; } | ||
| public Meta.Window window { get; construct; } | ||
|
|
||
| public bool hidden { get; private set; default = false; } | ||
| public Pantheon.Desktop.Anchor anchor { get; construct set; } | ||
|
|
||
| public Meta.Side anchor; | ||
| private WindowPositioner window_positioner; | ||
|
|
||
| private Barrier? barrier; | ||
|
|
||
| private PanelClone clone; | ||
|
|
||
| private uint idle_move_id = 0; | ||
|
|
||
| private int width = -1; | ||
| private int height = -1; | ||
|
|
||
| public PanelWindow (WindowManager wm, Meta.Window window, Meta.Side anchor) { | ||
| Object (wm: wm, window: window); | ||
|
|
||
| // Meta.Side seems to be currently not supported as GLib.Object property ...? | ||
| // At least it always crashed for me with some paramspec, g_type_fundamental backtrace | ||
| this.anchor = anchor; | ||
| public PanelWindow (WindowManager wm, Meta.Window window, Pantheon.Desktop.Anchor anchor) { | ||
| Object (wm: wm, window: window, anchor: anchor); | ||
| } | ||
|
|
||
| construct { | ||
| window.size_changed.connect (position_window); | ||
|
|
||
| window.unmanaging.connect (() => { | ||
| if (idle_move_id != 0) { | ||
| Source.remove (idle_move_id); | ||
| } | ||
|
|
||
| destroy_barrier (); | ||
|
|
||
| if (window_struts.remove (window)) { | ||
|
|
@@ -53,13 +41,24 @@ public class Gala.PanelWindow : Object { | |
|
|
||
| clone = new PanelClone (wm, this); | ||
|
|
||
| var monitor_manager = wm.get_display ().get_context ().get_backend ().get_monitor_manager (); | ||
| monitor_manager.monitors_changed.connect (() => update_anchor (anchor)); | ||
| monitor_manager.monitors_changed_internal.connect (() => update_anchor (anchor)); | ||
| var display = wm.get_display (); | ||
leolost2605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| var monitor_manager = display.get_context ().get_backend ().get_monitor_manager (); | ||
| monitor_manager.monitors_changed.connect (() => set_hide_mode (clone.hide_mode)); //Make sure barriers are still on the primary monitor | ||
|
|
||
| var workspace_manager = wm.get_display ().get_workspace_manager (); | ||
| var workspace_manager = display.get_workspace_manager (); | ||
leolost2605 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| workspace_manager.workspace_added.connect (update_strut); | ||
| workspace_manager.workspace_removed.connect (update_strut); | ||
|
|
||
| window.size_changed.connect (update_strut); | ||
| window.position_changed.connect (update_strut); | ||
|
|
||
| window_positioner = new WindowPositioner (display, window, WindowPositioner.Position.from_anchor (anchor)); | ||
|
|
||
| notify["anchor"].connect (() => { | ||
|
||
| window_positioner.position = WindowPositioner.Position.from_anchor (anchor); | ||
| set_hide_mode (clone.hide_mode); // Resetup barriers etc., TODO: replace with update_strut once barriers are handled in hidetracker | ||
| }); | ||
| } | ||
|
|
||
| #if HAS_MUTTER45 | ||
|
|
@@ -84,73 +83,9 @@ public class Gala.PanelWindow : Object { | |
| this.width = width; | ||
| this.height = height; | ||
|
|
||
| position_window (); | ||
| set_hide_mode (clone.hide_mode); // Resetup barriers etc. | ||
| } | ||
|
|
||
| public void update_anchor (Meta.Side anchor) { | ||
| this.anchor = anchor; | ||
|
|
||
| position_window (); | ||
| set_hide_mode (clone.hide_mode); // Resetup barriers etc. | ||
| } | ||
|
|
||
| private void position_window () { | ||
| var display = wm.get_display (); | ||
| var monitor_geom = display.get_monitor_geometry (display.get_primary_monitor ()); | ||
| var window_rect = get_custom_window_rect (); | ||
|
|
||
| switch (anchor) { | ||
| case TOP: | ||
| position_window_top (monitor_geom, window_rect); | ||
| break; | ||
|
|
||
| case BOTTOM: | ||
| position_window_bottom (monitor_geom, window_rect); | ||
| break; | ||
|
|
||
| default: | ||
| warning ("Side not supported yet"); | ||
| break; | ||
| } | ||
|
|
||
| update_strut (); | ||
| } | ||
|
|
||
| #if HAS_MUTTER45 | ||
| private void position_window_top (Mtk.Rectangle monitor_geom, Mtk.Rectangle window_rect) { | ||
| #else | ||
| private void position_window_top (Meta.Rectangle monitor_geom, Meta.Rectangle window_rect) { | ||
| #endif | ||
| var x = monitor_geom.x + (monitor_geom.width - window_rect.width) / 2; | ||
|
|
||
| move_window_idle (x, monitor_geom.y); | ||
| } | ||
|
|
||
| #if HAS_MUTTER45 | ||
| private void position_window_bottom (Mtk.Rectangle monitor_geom, Mtk.Rectangle window_rect) { | ||
| #else | ||
| private void position_window_bottom (Meta.Rectangle monitor_geom, Meta.Rectangle window_rect) { | ||
| #endif | ||
| var x = monitor_geom.x + (monitor_geom.width - window_rect.width) / 2; | ||
| var y = monitor_geom.y + monitor_geom.height - window_rect.height; | ||
|
|
||
| move_window_idle (x, y); | ||
| } | ||
|
|
||
| private void move_window_idle (int x, int y) { | ||
| if (idle_move_id != 0) { | ||
| Source.remove (idle_move_id); | ||
| } | ||
|
|
||
| idle_move_id = Idle.add (() => { | ||
| window.move_frame (false, x, y); | ||
|
|
||
| idle_move_id = 0; | ||
| return Source.REMOVE; | ||
| }); | ||
| } | ||
|
|
||
| public void set_hide_mode (Pantheon.Desktop.HideMode hide_mode) { | ||
| clone.hide_mode = hide_mode; | ||
|
|
||
|
|
@@ -177,7 +112,7 @@ public class Gala.PanelWindow : Object { | |
|
|
||
| Meta.Strut strut = { | ||
| rect, | ||
| anchor | ||
| side_from_anchor (anchor) | ||
| }; | ||
|
|
||
| window_struts[window] = strut; | ||
|
|
@@ -270,4 +205,20 @@ public class Gala.PanelWindow : Object { | |
|
|
||
| barrier.trigger.connect (clone.show); | ||
| } | ||
|
|
||
| private Meta.Side side_from_anchor (Pantheon.Desktop.Anchor anchor) { | ||
| switch (anchor) { | ||
| case BOTTOM: | ||
| return BOTTOM; | ||
|
|
||
| case LEFT: | ||
| return LEFT; | ||
|
|
||
| case RIGHT: | ||
| return RIGHT; | ||
|
|
||
| default: | ||
| return TOP; | ||
| } | ||
| } | ||
| } | ||
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
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.