Skip to content

Commit de07297

Browse files
committed
Re-set floating notification position on map
1 parent e32ca0a commit de07297

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

src/controlCenter/controlCenter.vala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,22 @@ namespace SwayNotificationCenter {
5151

5252
unowned Gdk.Surface surface = get_surface ();
5353
if (!(surface is Gdk.Surface)) {
54+
warn_if_reached ();
5455
return;
5556
}
5657

5758
ulong id = 0;
5859
id = surface.enter_monitor.connect ((monitor) => {
5960
surface.disconnect (id);
61+
debug ("ControlCenter mapped on monitor: %s",
62+
Functions.monitor_to_string (monitor));
6063
swaync_daemon.show_blank_windows (monitor);
6164
});
6265
});
63-
this.unmap.connect (swaync_daemon.hide_blank_windows);
66+
this.unmap.connect (() => {
67+
debug ("ControlCenter un-mapped");
68+
swaync_daemon.hide_blank_windows ();
69+
});
6470

6571
/*
6672
* Handling of bank window presses (pressing outside of ControlCenter)
@@ -238,6 +244,7 @@ namespace SwayNotificationCenter {
238244

239245
/** Resets the UI positions */
240246
private void set_anchor () {
247+
debug ("ControlCenter set_anchor");
241248
PositionX pos_x = ConfigModel.instance.control_center_positionX;
242249
if (pos_x == PositionX.NONE) {
243250
pos_x = ConfigModel.instance.positionX;

src/main.vala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ namespace SwayNotificationCenter {
7272
monitors = display.get_monitors ();
7373
assert_nonnull (monitors);
7474

75+
monitors.items_changed.connect (() => {
76+
info ("Monitors Changed:");
77+
print_monitors ();
78+
});
7579
print_monitors ();
7680

7781
swaync_daemon = new SwayncDaemon ();

src/notificationWindow/notificationWindow.vala

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,25 @@ namespace SwayNotificationCenter {
5555
}
5656
this.set_anchor ();
5757

58+
this.map.connect (() => {
59+
set_anchor ();
60+
61+
unowned Gdk.Surface surface = get_surface ();
62+
if (!(surface is Gdk.Surface)) {
63+
warn_if_reached ();
64+
return;
65+
}
66+
ulong id = 0;
67+
id = surface.enter_monitor.connect ((monitor) => {
68+
surface.disconnect (id);
69+
debug ("NotificationWindow mapped on monitor: %s",
70+
Functions.monitor_to_string (monitor));
71+
});
72+
});
73+
this.unmap.connect (() => {
74+
debug ("NotificationWindow un-mapped");
75+
});
76+
5877
// -1 should set it to the content size unless it exceeds max_height
5978
scrolled_window.set_min_content_height (-1);
6079
scrolled_window.set_max_content_height (
@@ -99,6 +118,7 @@ namespace SwayNotificationCenter {
99118
}
100119

101120
private void set_anchor () {
121+
debug ("NotificationWindow set_anchor");
102122
if (swaync_daemon.use_layer_shell) {
103123
GtkLayerShell.set_layer (this, ConfigModel.instance.layer.to_layer ());
104124

0 commit comments

Comments
 (0)