Skip to content

Commit e03351c

Browse files
lenemterzeebok
andauthored
NotificationStack: update positions when monitors change (#2480)
Co-authored-by: Ryan Kornheisl <[email protected]>
1 parent 8cfd4af commit e03351c

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/NotificationStack.vala

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,16 @@ public class Gala.NotificationStack : Object {
8686
notification.add_transition (TRANSITION_ENTRY_NAME, entry);
8787
}
8888

89-
var primary = display.get_primary_monitor ();
90-
var area = display.get_workspace_manager ().get_active_workspace ().get_work_area_for_monitor (primary);
91-
var scale = display.get_monitor_scale (primary);
92-
9389
/**
9490
* We will make space for the incoming notification
9591
* by shifting all current notifications by height
9692
* and then add it to the notifications list.
9793
*/
98-
update_positions (scale, window_rect.height);
94+
update_positions (window_rect.height);
95+
96+
var primary = display.get_primary_monitor ();
97+
var area = display.get_workspace_manager ().get_active_workspace ().get_work_area_for_monitor (primary);
98+
var scale = display.get_monitor_scale (primary);
9999

100100
int notification_x_pos = area.x + area.width - window_rect.width;
101101
if (Clutter.get_default_text_direction () == Clutter.TextDirection.RTL) {
@@ -114,9 +114,13 @@ public class Gala.NotificationStack : Object {
114114
stack_width = Utils.scale_to_int (WIDTH + MARGIN, scale);
115115

116116
stack_y = area.y;
117+
118+
update_positions ();
117119
}
118120

119-
private void update_positions (float scale, float add_y = 0.0f) {
121+
private void update_positions (float add_y = 0.0f) {
122+
var scale = display.get_monitor_scale (display.get_primary_monitor ());
123+
120124
var y = stack_y + TOP_OFFSET + add_y + Utils.scale_to_int (ADDITIONAL_MARGIN, scale);
121125
var i = notifications.size;
122126
var delay_step = i > 0 ? 150 / i : 0;
@@ -173,11 +177,8 @@ public class Gala.NotificationStack : Object {
173177
notification.x += stack_width;
174178
}
175179

176-
var primary = display.get_primary_monitor ();
177-
var scale = display.get_monitor_scale (primary);
178-
179180
notifications.remove (notification);
180-
update_positions (scale);
181+
update_positions ();
181182
}
182183

183184
/**

0 commit comments

Comments
 (0)