@@ -25,8 +25,8 @@ public class Gala.ShellClientsManager : Object {
2525 private NotificationsClient notifications_client;
2626 private ManagedClient [] protocol_clients = {};
2727
28- private GLib . HashTable<Meta . Window , PanelWindow > windows = new GLib .HashTable<Meta . Window , PanelWindow > (null , null );
29- private GLib . HashTable<Meta . Window , CenteredWindow > centered_windows = new GLib .HashTable<Meta . Window , CenteredWindow > (null , null );
28+ private GLib . HashTable<Meta . Window , PanelWindow > panel_windows = new GLib .HashTable<Meta . Window , PanelWindow > (null , null );
29+ private GLib . HashTable<Meta . Window , WindowPositioner > positioned_windows = new GLib .HashTable<Meta . Window , WindowPositioner > (null , null );
3030
3131 private ShellClientsManager (WindowManager wm ) {
3232 Object (wm: wm);
@@ -144,18 +144,18 @@ public class Gala.ShellClientsManager : Object {
144144 }
145145
146146 public void set_anchor (Meta .Window window , Meta .Side side ) {
147- if (window in windows ) {
148- windows [window]. update_anchor (side);
147+ if (window in panel_windows ) {
148+ panel_windows [window]. update_anchor (side);
149149 return ;
150150 }
151151
152152 make_dock (window);
153153 // TODO: Return if requested by window that's not a trusted client?
154154
155- windows [window] = new PanelWindow (wm, window, side);
155+ panel_windows [window] = new PanelWindow (wm, window, side);
156156
157157 // connect_after so we make sure the PanelWindow can destroy its barriers and struts
158- window. unmanaging. connect_after (() = > windows . remove (window ));
158+ window. unmanaging. connect_after ((_window ) = > panel_windows . remove (_window ));
159159 }
160160
161161 /**
@@ -166,37 +166,45 @@ public class Gala.ShellClientsManager : Object {
166166 * TODO: Maybe use for strut only?
167167 */
168168 public void set_size (Meta .Window window , int width , int height ) {
169- if (! (window in windows )) {
169+ if (! (window in panel_windows )) {
170170 warning (" Set anchor for window before size." );
171171 return ;
172172 }
173173
174- windows [window]. set_size (width, height);
174+ panel_windows [window]. set_size (width, height);
175175 }
176176
177177 public void set_hide_mode (Meta .Window window , Pantheon .Desktop .HideMode hide_mode ) {
178- if (! (window in windows )) {
178+ if (! (window in panel_windows )) {
179179 warning (" Set anchor for window before hide mode." );
180180 return ;
181181 }
182182
183- windows [window]. set_hide_mode (hide_mode);
183+ panel_windows [window]. set_hide_mode (hide_mode);
184184 }
185185
186- public void make_centered (Meta .Window window ) {
187- if (window in centered_windows) {
188- return ;
189- }
186+ public void make_centered (Meta .Window window ) requires (!is_itself_positioned (window )) {
187+ positioned_windows[window] = new WindowPositioner (window, wm, (ref x, ref y) = > {
188+ unowned var display = wm. get_display ();
189+ var monitor_geom = display. get_monitor_geometry (display. get_primary_monitor ());
190+ var window_rect = window. get_frame_rect ();
190191
191- centered_windows[window] = new CenteredWindow (wm, window);
192+ x = monitor_geom. x + (monitor_geom. width - window_rect. width) / 2 ;
193+ y = monitor_geom. y + (monitor_geom. height - window_rect. height) / 2 ;
194+ });
195+
196+ // connect_after so we make sure that any queued move is unqueued
197+ window. unmanaging. connect_after ((_window) = > positioned_windows. remove (_window));
198+ }
192199
193- window. unmanaging. connect_after (() = > centered_windows. remove (window));
200+ private bool is_itself_positioned (Meta .Window window ) {
201+ return (window in positioned_windows) || (window in panel_windows);
194202 }
195203
196204 public bool is_positioned_window (Meta .Window window ) {
197- bool positioned = (window in centered_windows) || (window in windows );
205+ bool positioned = is_itself_positioned (window);
198206 window. foreach_ancestor ((ancestor) = > {
199- if (ancestor in centered_windows || ancestor in windows ) {
207+ if (ancestor in positioned_windows || ancestor in panel_windows ) {
200208 positioned = true ;
201209 }
202210
0 commit comments