Skip to content

Commit a7a1bf5

Browse files
committed
Added more debug logging
1 parent 65ed832 commit a7a1bf5

1 file changed

Lines changed: 62 additions & 7 deletions

File tree

src/notificationWindow/notificationWindow.vala

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ namespace SwayNotificationCenter {
1414

1515
private const int MAX_HEIGHT = 600;
1616

17+
private bool is_mapped = false;
18+
private bool is_mapped_on_monitor = false;
19+
1720
public NotificationWindow () {
1821
Object (css_name: "notificationwindow");
1922
if (app.use_layer_shell) {
@@ -46,21 +49,70 @@ namespace SwayNotificationCenter {
4649
});
4750
}
4851

52+
private inline string get_debug_map_string () {
53+
unowned Gdk.Surface ?surface = get_surface ();
54+
string[] strs = {
55+
" GTK-Mapped: %s".printf (get_mapped ().to_string ()),
56+
" Mapped: %s".printf (is_mapped.to_string ()),
57+
" Mapped_On_Monitor: %s".printf (is_mapped_on_monitor.to_string ()),
58+
" GTK-Visible: %s".printf (visible.to_string ()),
59+
" GTK-IsVisible: %s".printf (is_visible ().to_string ()),
60+
" GTK-Realized: %s".printf (get_realized ().to_string ()),
61+
" GTK-InDestruction: %s".printf (in_destruction ().to_string ()),
62+
" GTK-Default-W: %d".printf (default_width),
63+
" GTK-Default-H: %d".printf (default_height),
64+
" GTK-Request-W: %d".printf (width_request),
65+
" GTK-Request-H: %d".printf (height_request),
66+
" GTK-Width: %d".printf (get_width ()),
67+
" GTK-Height: %d".printf (get_height ()),
68+
" GTK-Alloc_Width: %d".printf (get_allocated_width ()),
69+
" GTK-Alloc_Height: %d".printf (get_allocated_height ()),
70+
" GTK-Surf_Mapped: %s".printf (
71+
surface != null ? surface.get_mapped ().to_string () : "null"),
72+
" GTK-Surf_IsDestroyed: %s".printf (
73+
surface != null ? surface.is_destroyed ().to_string () : "null"),
74+
" GTK-Surf_Width: %d".printf (surface != null ? surface.get_width () : -1),
75+
" GTK-Surf_Height: %d".printf (surface != null ? surface.get_height () : -1),
76+
};
77+
return string.joinv ("\n", strs);
78+
}
79+
4980
protected override void map () {
5081
base.map ();
51-
debug ("NotificationWindow mapped, waiting for enter-monitor signal");
82+
debug ("NotificationWindow mapped, waiting for enter-monitor signal\n%s",
83+
get_debug_map_string ());
84+
is_mapped = true;
85+
5286
set_anchor ();
5387

5488
unowned Gdk.Surface surface = get_surface ();
5589
if (!(surface is Gdk.Surface)) {
5690
warn_if_reached ();
5791
return;
5892
}
59-
ulong id = 0;
60-
id = surface.enter_monitor.connect ((monitor) => {
61-
surface.disconnect (id);
62-
debug ("NotificationWindow mapped on monitor: %s",
63-
Functions.monitor_to_string (monitor));
93+
ulong surface_enter_id = 0;
94+
uint timer_id = 0;
95+
96+
timer_id = Timeout.add_seconds_once (3, () => {
97+
if (surface_enter_id != 0) {
98+
surface.disconnect (timer_id);
99+
timer_id = 0;
100+
}
101+
critical ("Not mapped in time!\n%s", get_debug_map_string ());
102+
});
103+
surface_enter_id = surface.enter_monitor.connect ((monitor) => {
104+
surface.disconnect (surface_enter_id);
105+
surface_enter_id = 0;
106+
107+
is_mapped_on_monitor = true;
108+
109+
if (timer_id != 0) {
110+
Source.remove (timer_id);
111+
timer_id = 0;
112+
}
113+
debug ("NotificationWindow mapped on monitor: %s\n%s",
114+
Functions.monitor_to_string (monitor),
115+
get_debug_map_string ());
64116

65117
// Only set ON_DEMAND after the surface has been mapped
66118
Idle.add_once (() => set_keyboard_mode ());
@@ -69,7 +121,9 @@ namespace SwayNotificationCenter {
69121

70122
protected override void unmap () {
71123
base.unmap ();
72-
debug ("NotificationWindow un-mapped");
124+
is_mapped = false;
125+
is_mapped_on_monitor = false;
126+
debug ("NotificationWindow un-mapped\n%s", get_debug_map_string ());
73127

74128
set_keyboard_mode ();
75129

@@ -314,6 +368,7 @@ namespace SwayNotificationCenter {
314368
ConfigModel.instance.timeout,
315369
ConfigModel.instance.timeout_low,
316370
ConfigModel.instance.timeout_critical);
371+
debug ("Add floating notification debug:\n%s", get_debug_map_string ());
317372
if (!visible) {
318373
// Destroy the wl_surface to get a new "enter-monitor" signal and
319374
// fixes issues where keyboard shortcuts stop working after clearing

0 commit comments

Comments
 (0)