Fixed bug where replacing notifitions aren't visible
This commit is contained in:
@@ -51,7 +51,7 @@ namespace SwayNotificationCenter {
|
|||||||
/** Method to close notification and send DISMISSED signal */
|
/** Method to close notification and send DISMISSED signal */
|
||||||
public void manually_close_notification (uint32 id, bool timeout)
|
public void manually_close_notification (uint32 id, bool timeout)
|
||||||
throws DBusError, IOError {
|
throws DBusError, IOError {
|
||||||
NotificationWindow.instance.close_notification (id);
|
NotificationWindow.instance.close_notification (id, false);
|
||||||
if (!timeout) {
|
if (!timeout) {
|
||||||
control_center.close_notification (id);
|
control_center.close_notification (id);
|
||||||
NotificationClosed (id, ClosedReasons.DISMISSED);
|
NotificationClosed (id, ClosedReasons.DISMISSED);
|
||||||
@@ -155,7 +155,7 @@ namespace SwayNotificationCenter {
|
|||||||
// Replace notification logic
|
// Replace notification logic
|
||||||
if (id == replaces_id) {
|
if (id == replaces_id) {
|
||||||
param.replaces = true;
|
param.replaces = true;
|
||||||
NotificationWindow.instance.close_notification (id);
|
NotificationWindow.instance.close_notification (id, true);
|
||||||
control_center.close_notification (id, true);
|
control_center.close_notification (id, true);
|
||||||
} else if (param.synchronous != null
|
} else if (param.synchronous != null
|
||||||
&& param.synchronous.length > 0) {
|
&& param.synchronous.length > 0) {
|
||||||
@@ -166,7 +166,7 @@ namespace SwayNotificationCenter {
|
|||||||
param.synchronous, null, out r_id)) {
|
param.synchronous, null, out r_id)) {
|
||||||
param.replaces = true;
|
param.replaces = true;
|
||||||
// Close the notification
|
// Close the notification
|
||||||
NotificationWindow.instance.close_notification (r_id);
|
NotificationWindow.instance.close_notification (r_id, true);
|
||||||
control_center.close_notification (r_id, true);
|
control_center.close_notification (r_id, true);
|
||||||
}
|
}
|
||||||
synchronous_ids.set (param.synchronous, id);
|
synchronous_ids.set (param.synchronous, id);
|
||||||
@@ -253,7 +253,7 @@ namespace SwayNotificationCenter {
|
|||||||
*/
|
*/
|
||||||
[DBus (name = "CloseNotification")]
|
[DBus (name = "CloseNotification")]
|
||||||
public void close_notification (uint32 id) throws DBusError, IOError {
|
public void close_notification (uint32 id) throws DBusError, IOError {
|
||||||
NotificationWindow.instance.close_notification (id);
|
NotificationWindow.instance.close_notification (id, false);
|
||||||
control_center.close_notification (id);
|
control_center.close_notification (id);
|
||||||
NotificationClosed (id, ClosedReasons.CLOSED_BY_CLOSENOTIFICATION);
|
NotificationClosed (id, ClosedReasons.CLOSED_BY_CLOSENOTIFICATION);
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
<!-- Generated with glade 3.38.2 -->
|
<!-- Generated with glade 3.38.2 -->
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.24"/>
|
<requires lib="gtk+" version="3.24"/>
|
||||||
<template class="SwayNotificationCenterNotiWindow" parent="GtkApplicationWindow">
|
<template class="SwayNotificationCenterNotificationWindow" parent="GtkApplicationWindow">
|
||||||
<property name="can-focus">False</property>
|
<property name="can-focus">False</property>
|
||||||
<property name="role">NotificationWindow</property>
|
<property name="role">NotificationWindow</property>
|
||||||
<property name="resizable">False</property>
|
<property name="resizable">False</property>
|
||||||
|
@@ -1,27 +1,27 @@
|
|||||||
namespace SwayNotificationCenter {
|
namespace SwayNotificationCenter {
|
||||||
public class NotificationWindow : Object {
|
[GtkTemplate (ui = "/org/erikreider/sway-notification-center/notificationWindow/notificationWindow.ui")]
|
||||||
private static NotiWindow ? window = null;
|
public class NotificationWindow : Gtk.ApplicationWindow {
|
||||||
// Use a NotiWindow singleton due to a nasty notification
|
private static NotificationWindow ? window = null;
|
||||||
// enter_notify_event bug where GTK still thinks that the cursor is at
|
/**
|
||||||
// that location after closing the last notification. The next notification
|
* A NotificationWindow singleton due to a nasty notification
|
||||||
// would sometimes automatically be hovered...
|
* enter_notify_event bug where GTK still thinks that the cursor is at
|
||||||
public static NotiWindow instance {
|
* that location after closing the last notification. The next notification
|
||||||
|
* would sometimes automatically be hovered...
|
||||||
|
* The only way to "solve" this is to close the window and reopen a new one.
|
||||||
|
*/
|
||||||
|
public static NotificationWindow instance {
|
||||||
get {
|
get {
|
||||||
if (window == null) {
|
if (window == null) {
|
||||||
window = new NotiWindow ();
|
window = new NotificationWindow ();
|
||||||
} else if (!window.get_mapped () ||
|
} else if (!window.get_mapped () ||
|
||||||
!window.get_realized () ||
|
!window.get_realized () ||
|
||||||
!(window.get_child () is Gtk.Widget)) {
|
!(window.get_child () is Gtk.Widget)) {
|
||||||
window.destroy ();
|
window.destroy ();
|
||||||
window = new NotiWindow ();
|
window = new NotificationWindow ();
|
||||||
}
|
}
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[GtkTemplate (ui = "/org/erikreider/sway-notification-center/notificationWindow/notificationWindow.ui")]
|
|
||||||
public class NotiWindow : Gtk.ApplicationWindow {
|
|
||||||
|
|
||||||
[GtkChild]
|
[GtkChild]
|
||||||
unowned Gtk.ScrolledWindow scrolled_window;
|
unowned Gtk.ScrolledWindow scrolled_window;
|
||||||
@@ -36,7 +36,7 @@ namespace SwayNotificationCenter {
|
|||||||
|
|
||||||
private const int MAX_HEIGHT = 600;
|
private const int MAX_HEIGHT = 600;
|
||||||
|
|
||||||
public NotiWindow () {
|
private NotificationWindow () {
|
||||||
if (!GtkLayerShell.is_supported ()) {
|
if (!GtkLayerShell.is_supported ()) {
|
||||||
stderr.printf ("GTKLAYERSHELL IS NOT SUPPORTED!\n");
|
stderr.printf ("GTKLAYERSHELL IS NOT SUPPORTED!\n");
|
||||||
stderr.printf ("Swaync only works on Wayland!\n");
|
stderr.printf ("Swaync only works on Wayland!\n");
|
||||||
@@ -123,21 +123,22 @@ namespace SwayNotificationCenter {
|
|||||||
public void close_all_notifications () {
|
public void close_all_notifications () {
|
||||||
if (!this.get_realized ()) return;
|
if (!this.get_realized ()) return;
|
||||||
foreach (var w in box.get_children ()) {
|
foreach (var w in box.get_children ()) {
|
||||||
remove_notification ((Notification) w);
|
remove_notification ((Notification) w, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void remove_notification (Notification noti) {
|
private void remove_notification (Notification ? noti, bool replaces) {
|
||||||
// Remove notification and its destruction timeout
|
// Remove notification and its destruction timeout
|
||||||
if (noti != null) {
|
if (noti != null) {
|
||||||
noti.remove_noti_timeout ();
|
noti.remove_noti_timeout ();
|
||||||
noti.destroy ();
|
noti.destroy ();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!get_realized ()
|
if (!replaces
|
||||||
|| !get_mapped ()
|
&& (!get_realized ()
|
||||||
|| !(get_child () is Gtk.Widget)
|
|| !get_mapped ()
|
||||||
|| box.get_children ().length () == 0) {
|
|| !(get_child () is Gtk.Widget)
|
||||||
|
|| box.get_children ().length () == 0)) {
|
||||||
close ();
|
close ();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -167,11 +168,11 @@ namespace SwayNotificationCenter {
|
|||||||
scroll_to_start (list_reverse);
|
scroll_to_start (list_reverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close_notification (uint32 id) {
|
public void close_notification (uint32 id, bool replaces) {
|
||||||
foreach (var w in box.get_children ()) {
|
foreach (var w in box.get_children ()) {
|
||||||
var noti = (Notification) w;
|
var noti = (Notification) w;
|
||||||
if (noti != null && noti.param.applied_id == id) {
|
if (noti != null && noti.param.applied_id == id) {
|
||||||
remove_notification (noti);
|
remove_notification (noti, replaces);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user