Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
ximper-shell-notification-center
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
ximper-shell-notification-center
Commits
9a251ed1
Commit
9a251ed1
authored
Jun 25, 2022
by
Erik Reider
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed nasty hover bug after first notification
parent
c1bc6f4a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
15 deletions
+39
-15
notiDaemon.vala
src/notiDaemon/notiDaemon.vala
+8
-10
notificationWindow.ui
src/notificationWindow/notificationWindow.ui
+1
-1
notificationWindow.vala
src/notificationWindow/notificationWindow.vala
+30
-4
No files found.
src/notiDaemon/notiDaemon.vala
View file @
9a251ed1
...
...
@@ -7,7 +7,6 @@ namespace SwayNotificationCenter {
new
HashTable
<
string
,
uint32
>
(
str_hash
,
str_equal
);
public
ControlCenter
control_center
;
public
NotificationWindow
noti_window
;
public
NotiDaemon
(
SwayncDaemon
swaync_daemon
)
{
this
.
notify
[
"dnd"
].
connect
(()
=>
on_dnd_toggle
(
dnd
));
...
...
@@ -15,7 +14,6 @@ namespace SwayNotificationCenter {
// Init dnd from gsettings
self_settings
.
bind
(
"dnd-state"
,
this
,
"dnd"
,
SettingsBindFlags
.
DEFAULT
);
this
.
noti_window
=
new
NotificationWindow
();
this
.
control_center
=
new
ControlCenter
(
swaync_daemon
,
this
);
}
...
...
@@ -25,7 +23,7 @@ namespace SwayNotificationCenter {
*/
public
void
set_noti_window_visibility
(
bool
value
)
throws
DBusError
,
IOError
{
noti_window
.
change_visibility
(
value
);
NotificationWindow
.
instance
.
change_visibility
(
value
);
}
/** Toggles the current Do Not Disturb state */
...
...
@@ -53,7 +51,7 @@ namespace SwayNotificationCenter {
/** Method to close notification and send DISMISSED signal */
public
void
manually_close_notification
(
uint32
id
,
bool
timeout
)
throws
DBusError
,
IOError
{
noti_window
.
close_notification
(
id
);
NotificationWindow
.
instance
.
close_notification
(
id
);
if
(!
timeout
)
{
control_center
.
close_notification
(
id
);
NotificationClosed
(
id
,
ClosedReasons
.
DISMISSED
);
...
...
@@ -66,14 +64,14 @@ namespace SwayNotificationCenter {
/** Closes all popup and controlcenter notifications */
public
void
close_all_notifications
()
throws
DBusError
,
IOError
{
noti_window
.
close_all_notifications
();
NotificationWindow
.
instance
.
close_all_notifications
();
control_center
.
close_all_notifications
();
}
/** Closes latest popup notification */
public
void
hide_latest_notification
(
bool
close
)
throws
DBusError
,
IOError
{
uint32
?
id
=
noti_window
.
get_latest_notification
();
uint32
?
id
=
NotificationWindow
.
instance
.
get_latest_notification
();
if
(
id
==
null
)
return
;
manually_close_notification
(
id
,
!
close
);
}
...
...
@@ -157,7 +155,7 @@ namespace SwayNotificationCenter {
// Replace notification logic
if
(
id
==
replaces_id
)
{
param
.
replaces
=
true
;
noti_window
.
close_notification
(
id
);
NotificationWindow
.
instance
.
close_notification
(
id
);
control_center
.
close_notification
(
id
,
true
);
}
else
if
(
param
.
synchronous
!=
null
&&
param
.
synchronous
.
length
>
0
)
{
...
...
@@ -168,7 +166,7 @@ namespace SwayNotificationCenter {
param
.
synchronous
,
null
,
out
r_id
))
{
param
.
replaces
=
true
;
// Close the notification
noti_window
.
close_notification
(
r_id
);
NotificationWindow
.
instance
.
close_notification
(
r_id
);
control_center
.
close_notification
(
r_id
,
true
);
}
synchronous_ids
.
set
(
param
.
synchronous
,
id
);
...
...
@@ -179,7 +177,7 @@ namespace SwayNotificationCenter {
&&
!
control_center
.
get_visibility
())
{
if
(
param
.
urgency
==
UrgencyLevels
.
CRITICAL
||
(!
dnd
&&
param
.
urgency
!=
UrgencyLevels
.
CRITICAL
))
{
noti_window
.
add_notification
(
param
,
this
);
NotificationWindow
.
instance
.
add_notification
(
param
,
this
);
}
}
// Only add notification to CC if it isn't IGNORED and not transient
...
...
@@ -255,7 +253,7 @@ namespace SwayNotificationCenter {
*/
[
DBus
(
name
=
"CloseNotification"
)]
public
void
close_notification
(
uint32
id
)
throws
DBusError
,
IOError
{
noti_window
.
close_notification
(
id
);
NotificationWindow
.
instance
.
close_notification
(
id
);
control_center
.
close_notification
(
id
);
NotificationClosed
(
id
,
ClosedReasons
.
CLOSED_BY_CLOSENOTIFICATION
);
}
...
...
src/notificationWindow/notificationWindow.ui
View file @
9a251ed1
...
...
@@ -2,7 +2,7 @@
<!-- Generated with glade 3.38.2 -->
<interface>
<requires
lib=
"gtk+"
version=
"3.24"
/>
<template
class=
"SwayNotificationCenterNoti
fication
Window"
parent=
"GtkApplicationWindow"
>
<template
class=
"SwayNotificationCenterNotiWindow"
parent=
"GtkApplicationWindow"
>
<property
name=
"can-focus"
>
False
</property>
<property
name=
"role"
>
NotificationWindow
</property>
<property
name=
"resizable"
>
False
</property>
...
...
src/notificationWindow/notificationWindow.vala
View file @
9a251ed1
namespace
SwayNotificationCenter
{
public
class
NotificationWindow
:
Object
{
private
static
NotiWindow
?
window
=
null
;
// Use a NotiWindow singleton due to a nasty notification
// enter_notify_event bug where GTK still thinks that the cursor is at
// that location after closing the last notification. The next notification
// would sometimes automatically be hovered...
public
static
NotiWindow
instance
{
get
{
if
(
window
==
null
)
{
window
=
new
NotiWindow
();
}
else
if
(!
window
.
get_mapped
()
||
!
window
.
get_realized
()
||
!(
window
.
get_child
()
is
Gtk
.
Widget
))
{
window
.
destroy
();
window
=
new
NotiWindow
();
}
return
window
;
}
}
}
[
GtkTemplate
(
ui
=
"/org/erikreider/sway-notification-center/notificationWindow/notificationWindow.ui"
)]
public
class
Noti
fication
Window
:
Gtk
.
ApplicationWindow
{
public
class
NotiWindow
:
Gtk
.
ApplicationWindow
{
[
GtkChild
]
unowned
Gtk
.
ScrolledWindow
scrolled_window
;
...
...
@@ -15,7 +36,7 @@ namespace SwayNotificationCenter {
private
const
int
MAX_HEIGHT
=
600
;
public
Noti
fication
Window
()
{
public
NotiWindow
()
{
if
(!
GtkLayerShell
.
is_supported
())
{
stderr
.
printf
(
"GTKLAYERSHELL IS NOT SUPPORTED!\n"
);
stderr
.
printf
(
"Swaync only works on Wayland!\n"
);
...
...
@@ -113,8 +134,13 @@ namespace SwayNotificationCenter {
noti
.
destroy
();
}
if
(!
this
.
get_realized
())
return
;
if
(
box
.
get_children
().
length
()
==
0
)
this
.
hide
();
if
(!
get_realized
()
||
!
get_mapped
()
||
!(
get_child
()
is
Gtk
.
Widget
)
||
box
.
get_children
().
length
()
==
0
)
{
close
();
return
;
}
}
public
void
add_notification
(
NotifyParams
param
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment