@@ -10,34 +10,21 @@ public class Gala.PanelWindow : Object {
1010
1111 public WindowManager wm { get ; construct; }
1212 public Meta . Window window { get ; construct; }
13+ public Pantheon . Desktop . Anchor anchor { get ; construct set ; }
1314
14- public bool hidden { get ; private set ; default = false ; }
15-
16- public Meta . Side anchor;
15+ private WindowPositioner window_positioner;
1716
1817 private PanelClone clone;
1918
20- private uint idle_move_id = 0 ;
21-
2219 private int width = - 1 ;
2320 private int height = - 1 ;
2421
25- public PanelWindow (WindowManager wm , Meta .Window window , Meta .Side anchor ) {
26- Object (wm: wm, window: window);
27-
28- // Meta.Side seems to be currently not supported as GLib.Object property ...?
29- // At least it always crashed for me with some paramspec, g_type_fundamental backtrace
30- this . anchor = anchor;
22+ public PanelWindow (WindowManager wm, Meta . Window window, Pantheon . Desktop . Anchor anchor) {
23+ Object (wm: wm, window: window, anchor: anchor);
3124 }
3225
3326 construct {
34- window. size_changed. connect (position_window);
35-
3627 window. unmanaging. connect (() = > {
37- if (idle_move_id != 0 ) {
38- Source . remove (idle_move_id);
39- }
40-
4128 if (window_struts. remove (window)) {
4229 update_struts ();
4330 }
@@ -47,13 +34,18 @@ public class Gala.PanelWindow : Object {
4734
4835 clone = new PanelClone (wm, this );
4936
50- var monitor_manager = wm. get_display (). get_context (). get_backend (). get_monitor_manager ();
51- monitor_manager. monitors_changed. connect (() = > update_anchor (anchor));
52- monitor_manager. monitors_changed_internal. connect (() = > update_anchor (anchor));
37+ unowned var display = wm. get_display ();
5338
54- var workspace_manager = wm . get_display () . get_workspace_manager ();
39+ unowned var workspace_manager = display . get_workspace_manager ();
5540 workspace_manager. workspace_added. connect (update_strut);
5641 workspace_manager. workspace_removed. connect (update_strut);
42+
43+ window. size_changed. connect (update_strut);
44+ window. position_changed. connect (update_strut);
45+
46+ window_positioner = new WindowPositioner (display, window, WindowPositioner . Position . from_anchor (anchor));
47+
48+ notify[" anchor" ]. connect (() = > window_positioner. position = WindowPositioner . Position . from_anchor (anchor));
5749 }
5850
5951#if HAS_MUTTER45
@@ -83,73 +75,9 @@ public class Gala.PanelWindow : Object {
8375 this . width = width;
8476 this . height = height;
8577
86- position_window ();
87- set_hide_mode (clone. hide_mode); // Resetup barriers etc.
88- }
89-
90- public void update_anchor (Meta . Side anchor) {
91- this . anchor = anchor;
92-
93- position_window ();
94- set_hide_mode (clone. hide_mode); // Resetup barriers etc.
95- }
96-
97- private void position_window () {
98- var display = wm. get_display ();
99- var monitor_geom = display. get_monitor_geometry (display. get_primary_monitor ());
100- var window_rect = window. get_frame_rect ();
101-
102- switch (anchor) {
103- case TOP :
104- position_window_top (monitor_geom, window_rect);
105- break ;
106-
107- case BOTTOM :
108- position_window_bottom (monitor_geom, window_rect);
109- break ;
110-
111- default:
112- warning (" Side not supported yet" );
113- break ;
114- }
115-
11678 update_strut ();
11779 }
11880
119- #if HAS_MUTTER45
120- private void position_window_top (Mtk . Rectangle monitor_geom, Mtk . Rectangle window_rect) {
121- #else
122- private void position_window_top (Meta . Rectangle monitor_geom, Meta . Rectangle window_rect) {
123- #endif
124- var x = monitor_geom. x + (monitor_geom. width - window_rect. width) / 2 ;
125-
126- move_window_idle (x, monitor_geom. y);
127- }
128-
129- #if HAS_MUTTER45
130- private void position_window_bottom (Mtk . Rectangle monitor_geom, Mtk . Rectangle window_rect) {
131- #else
132- private void position_window_bottom (Meta . Rectangle monitor_geom, Meta . Rectangle window_rect) {
133- #endif
134- var x = monitor_geom. x + (monitor_geom. width - window_rect. width) / 2 ;
135- var y = monitor_geom. y + monitor_geom. height - window_rect. height;
136-
137- move_window_idle (x, y);
138- }
139-
140- private void move_window_idle (int x, int y) {
141- if (idle_move_id != 0 ) {
142- Source . remove (idle_move_id);
143- }
144-
145- idle_move_id = Idle . add (() = > {
146- window. move_frame (false , x, y);
147-
148- idle_move_id = 0 ;
149- return Source . REMOVE ;
150- });
151- }
152-
15381 public void set_hide_mode (Pantheon . Desktop . HideMode hide_mode) {
15482 clone. hide_mode = hide_mode;
15583
@@ -173,7 +101,7 @@ public class Gala.PanelWindow : Object {
173101
174102 Meta . Strut strut = {
175103 rect,
176- anchor
104+ side_from_anchor ( anchor)
177105 };
178106
179107 window_struts[window] = strut;
@@ -199,4 +127,20 @@ public class Gala.PanelWindow : Object {
199127 update_struts ();
200128 }
201129 }
130+
131+ private Meta . Side side_from_anchor (Pantheon . Desktop . Anchor anchor) {
132+ switch (anchor) {
133+ case BOTTOM :
134+ return BOTTOM ;
135+
136+ case LEFT :
137+ return LEFT ;
138+
139+ case RIGHT :
140+ return RIGHT ;
141+
142+ default:
143+ return TOP ;
144+ }
145+ }
202146}
0 commit comments