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
0d368c2f
Unverified
Commit
0d368c2f
authored
Sep 26, 2023
by
Erik Reider
Committed by
GitHub
Sep 26, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove notification replace flicker (#320)
parent
7de2c71b
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
35 deletions
+67
-35
controlCenter.vala
src/controlCenter/controlCenter.vala
+19
-5
notiDaemon.vala
src/notiDaemon/notiDaemon.vala
+26
-18
notiModel.vala
src/notiModel/notiModel.vala
+0
-4
notification.vala
src/notification/notification.vala
+0
-0
notificationWindow.vala
src/notificationWindow/notificationWindow.vala
+21
-7
swayncDaemon.vala
src/swayncDaemon/swayncDaemon.vala
+1
-1
No files found.
src/controlCenter/controlCenter.vala
View file @
0d368c2f
...
@@ -174,7 +174,7 @@ namespace SwayNotificationCenter {
...
@@ -174,7 +174,7 @@ namespace SwayNotificationCenter {
}
else
if
(
children
.
last
().
data
==
noti
)
{
}
else
if
(
children
.
last
().
data
==
noti
)
{
if
(
list_position
>
0
)
list_position
--;
if
(
list_position
>
0
)
list_position
--;
}
}
close_notification
(
noti
.
param
.
applied_id
);
close_notification
(
noti
.
param
.
applied_id
,
true
);
}
}
break
;
break
;
case
"C"
:
case
"C"
:
...
@@ -458,11 +458,11 @@ namespace SwayNotificationCenter {
...
@@ -458,11 +458,11 @@ namespace SwayNotificationCenter {
on_visibility_change
();
on_visibility_change
();
}
}
public
void
close_notification
(
uint32
id
,
bool
replaces
=
false
)
{
public
void
close_notification
(
uint32
id
,
bool
dismiss
)
{
foreach
(
var
w
in
list_box
.
get_children
())
{
foreach
(
var
w
in
list_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
)
{
if
(
replace
s
)
{
if
(
!
dismis
s
)
{
noti
.
remove_noti_timeout
();
noti
.
remove_noti_timeout
();
noti
.
destroy
();
noti
.
destroy
();
}
else
{
}
else
{
...
@@ -474,8 +474,22 @@ namespace SwayNotificationCenter {
...
@@ -474,8 +474,22 @@ namespace SwayNotificationCenter {
}
}
}
}
public
void
add_notification
(
NotifyParams
param
,
public
void
replace_notification
(
uint32
id
,
NotifyParams
new_params
)
{
NotiDaemon
noti_daemon
)
{
foreach
(
var
w
in
list_box
.
get_children
())
{
var
noti
=
(
Notification
)
w
;
if
(
noti
!=
null
&&
noti
.
param
.
applied_id
==
id
)
{
noti
.
replace_notification
(
new_params
);
// Position the notification in the beginning of the list
list_box
.
invalidate_sort
();
return
;
}
}
// Add a new notification if the old one isn't visible
add_notification
(
new_params
);
}
public
void
add_notification
(
NotifyParams
param
)
{
var
noti
=
new
Notification
.
regular
(
param
,
var
noti
=
new
Notification
.
regular
(
param
,
noti_daemon
,
noti_daemon
,
NotificationType
.
CONTROL_CENTER
);
NotificationType
.
CONTROL_CENTER
);
...
...
src/notiDaemon/notiDaemon.vala
View file @
0d368c2f
...
@@ -62,9 +62,9 @@ namespace SwayNotificationCenter {
...
@@ -62,9 +62,9 @@ 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
,
fals
e
);
NotificationWindow
.
instance
.
close_notification
(
id
,
tru
e
);
if
(!
timeout
)
{
if
(!
timeout
)
{
control_center
.
close_notification
(
id
);
control_center
.
close_notification
(
id
,
true
);
NotificationClosed
(
id
,
ClosedReasons
.
DISMISSED
);
NotificationClosed
(
id
,
ClosedReasons
.
DISMISSED
);
swaync_daemon
.
subscribe_v2
(
control_center
.
notification_count
(),
swaync_daemon
.
subscribe_v2
(
control_center
.
notification_count
(),
...
@@ -170,11 +170,10 @@ namespace SwayNotificationCenter {
...
@@ -170,11 +170,10 @@ namespace SwayNotificationCenter {
debug
(
"Notification: %s\n"
,
param
.
to_string
());
debug
(
"Notification: %s\n"
,
param
.
to_string
());
// Replace notification logic
// Get the notification id to replace
uint32
replace_notification
=
0
;
if
(
id
==
replaces_id
)
{
if
(
id
==
replaces_id
)
{
param
.
replaces
=
true
;
replace_notification
=
id
;
NotificationWindow
.
instance
.
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
)
{
// Tries replacing without replaces_id instead
// Tries replacing without replaces_id instead
...
@@ -182,29 +181,38 @@ namespace SwayNotificationCenter {
...
@@ -182,29 +181,38 @@ namespace SwayNotificationCenter {
// if there is any notification to replace
// if there is any notification to replace
if
(
synchronous_ids
.
lookup_extended
(
if
(
synchronous_ids
.
lookup_extended
(
param
.
synchronous
,
null
,
out
r_id
))
{
param
.
synchronous
,
null
,
out
r_id
))
{
param
.
replaces
=
true
;
replace_notification
=
r_id
;
// Close the notification
NotificationWindow
.
instance
.
close_notification
(
r_id
,
true
);
control_center
.
close_notification
(
r_id
,
true
);
}
}
synchronous_ids
.
set
(
param
.
synchronous
,
id
);
synchronous_ids
.
set
(
param
.
synchronous
,
id
);
}
}
// Only show popup notification if it is ENABLED or TRANSIENT
// Only show popup notification if it is ENABLED or TRANSIENT
if
((
state
==
NotificationStatusEnum
.
ENABLED
||
state
==
NotificationStatusEnum
.
TRANSIENT
)
if
((
state
==
NotificationStatusEnum
.
ENABLED
||
state
==
NotificationStatusEnum
.
TRANSIENT
)
&&
!
control_center
.
get_visibility
()
)
{
&&
!
control_center
.
get_visibility
()
// Also check if urgency is Critical and not inhibited and dnd
// Also check if urgency is Critical and not inhibited and dnd
if
(
param
.
urgency
==
UrgencyLevels
.
CRITICAL
||
&&
(
param
.
urgency
==
UrgencyLevels
.
CRITICAL
(!
dnd
&&
!
swaync_daemon
.
inhibited
||
(!
dnd
&&
!
swaync_daemon
.
inhibited
&&
param
.
urgency
!=
UrgencyLevels
.
CRITICAL
)))
{
&&
param
.
urgency
!=
UrgencyLevels
.
CRITICAL
))
{
if
(
replace_notification
>
0
)
{
NotificationWindow
.
instance
.
add_notification
(
param
,
this
);
NotificationWindow
.
instance
.
replace_notification
(
replace_notification
,
param
);
}
else
{
NotificationWindow
.
instance
.
add_notification
(
param
);
}
}
}
else
if
(
replace_notification
>
0
)
{
// Remove the old notification due to it not being replaced
NotificationWindow
.
instance
.
close_notification
(
replace_notification
,
false
);
}
}
// Only add notification to CC if it isn't IGNORED and not transient/TRANSIENT
// Only add notification to CC if it isn't IGNORED and not transient/TRANSIENT
if
(
state
!=
NotificationStatusEnum
.
IGNORED
if
(
state
!=
NotificationStatusEnum
.
IGNORED
&&
state
!=
NotificationStatusEnum
.
TRANSIENT
&&
state
!=
NotificationStatusEnum
.
TRANSIENT
&&
!
param
.
transient
)
{
&&
!
param
.
transient
)
{
control_center
.
add_notification
(
param
,
this
);
if
(
replace_notification
>
0
)
{
control_center
.
replace_notification
(
replace_notification
,
param
);
}
else
{
control_center
.
add_notification
(
param
);
}
}
else
if
(
replace_notification
>
0
)
{
// Remove the old notification due to it not being replaced
control_center
.
close_notification
(
replace_notification
,
false
);
}
}
#if WANT_SCRIPTING
#if WANT_SCRIPTING
...
@@ -292,8 +300,8 @@ namespace SwayNotificationCenter {
...
@@ -292,8 +300,8 @@ 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
,
fals
e
);
NotificationWindow
.
instance
.
close_notification
(
id
,
tru
e
);
control_center
.
close_notification
(
id
);
control_center
.
close_notification
(
id
,
true
);
NotificationClosed
(
id
,
ClosedReasons
.
CLOSED_BY_CLOSENOTIFICATION
);
NotificationClosed
(
id
,
ClosedReasons
.
CLOSED_BY_CLOSENOTIFICATION
);
}
}
...
...
src/notiModel/notiModel.vala
View file @
0d368c2f
...
@@ -112,9 +112,6 @@ namespace SwayNotificationCenter {
...
@@ -112,9 +112,6 @@ namespace SwayNotificationCenter {
public
Array
<
Action
>
actions
{
get
;
set
;
}
public
Array
<
Action
>
actions
{
get
;
set
;
}
/** If the notification replaces another */
public
bool
replaces
{
get
;
set
;
}
public
NotifyParams
(
uint32
applied_id
,
public
NotifyParams
(
uint32
applied_id
,
string
app_name
,
string
app_name
,
uint32
replaces_id
,
uint32
replaces_id
,
...
@@ -134,7 +131,6 @@ namespace SwayNotificationCenter {
...
@@ -134,7 +131,6 @@ namespace SwayNotificationCenter {
this
.
expire_timeout
=
expire_timeout
;
this
.
expire_timeout
=
expire_timeout
;
this
.
time
=
(
int64
)
(
get_real_time
()
*
0.000001
);
this
.
time
=
(
int64
)
(
get_real_time
()
*
0.000001
);
this
.
replaces
=
false
;
this
.
has_synch
=
false
;
this
.
has_synch
=
false
;
parse_hints
();
parse_hints
();
...
...
src/notification/notification.vala
View file @
0d368c2f
This diff is collapsed.
Click to expand it.
src/notificationWindow/notificationWindow.vala
View file @
0d368c2f
...
@@ -170,7 +170,7 @@ namespace SwayNotificationCenter {
...
@@ -170,7 +170,7 @@ namespace SwayNotificationCenter {
}
}
}
}
private
void
remove_notification
(
Notification
?
noti
,
bool
replace
s
)
{
private
void
remove_notification
(
Notification
?
noti
,
bool
dismis
s
)
{
// Remove notification and its destruction timeout
// Remove notification and its destruction timeout
if
(
noti
!=
null
)
{
if
(
noti
!=
null
)
{
#if HAVE_LATEST_GTK_LAYER_SHELL
#if HAVE_LATEST_GTK_LAYER_SHELL
...
@@ -188,7 +188,7 @@ namespace SwayNotificationCenter {
...
@@ -188,7 +188,7 @@ namespace SwayNotificationCenter {
noti
.
destroy
();
noti
.
destroy
();
}
}
if
(
!
replace
s
if
(
dismis
s
&&
(!
get_realized
()
&&
(!
get_realized
()
||
!
get_mapped
()
||
!
get_mapped
()
||
!(
get_child
()
is
Gtk
.
Widget
)
||
!(
get_child
()
is
Gtk
.
Widget
)
...
@@ -198,10 +198,9 @@ namespace SwayNotificationCenter {
...
@@ -198,10 +198,9 @@ namespace SwayNotificationCenter {
}
}
}
}
public
void
add_notification
(
NotifyParams
param
,
public
void
add_notification
(
NotifyParams
param
)
{
NotiDaemon
noti_daemon
)
{
var
noti
=
new
Notification
.
timed
(
param
,
var
noti
=
new
Notification
.
timed
(
param
,
noti_daemon
,
swaync_daemon
.
noti_daemon
,
NotificationType
.
POPUP
,
NotificationType
.
POPUP
,
ConfigModel
.
instance
.
timeout
,
ConfigModel
.
instance
.
timeout
,
ConfigModel
.
instance
.
timeout_low
,
ConfigModel
.
instance
.
timeout_low
,
...
@@ -234,16 +233,31 @@ namespace SwayNotificationCenter {
...
@@ -234,16 +233,31 @@ namespace SwayNotificationCenter {
scroll_to_start
(
list_reverse
);
scroll_to_start
(
list_reverse
);
}
}
public
void
close_notification
(
uint32
id
,
bool
replace
s
)
{
public
void
close_notification
(
uint32
id
,
bool
dismis
s
)
{
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
,
replace
s
);
remove_notification
(
noti
,
dismis
s
);
break
;
break
;
}
}
}
}
}
}
public
void
replace_notification
(
uint32
id
,
NotifyParams
new_params
)
{
foreach
(
var
w
in
box
.
get_children
())
{
var
noti
=
(
Notification
)
w
;
if
(
noti
!=
null
&&
noti
.
param
.
applied_id
==
id
)
{
noti
.
replace_notification
(
new_params
);
// Position the notification in the beginning of the list
box
.
reorder_child
(
noti
,
(
int
)
box
.
get_children
().
length
());
return
;
}
}
// Display a new notification if the old one isn't visible
add_notification
(
new_params
);
}
public
uint32
?
get_latest_notification
()
{
public
uint32
?
get_latest_notification
()
{
List
<
weak
Gtk
.
Widget
>
children
=
box
.
get_children
();
List
<
weak
Gtk
.
Widget
>
children
=
box
.
get_children
();
if
(
children
.
is_empty
())
return
null
;
if
(
children
.
is_empty
())
return
null
;
...
...
src/swayncDaemon/swayncDaemon.vala
View file @
0d368c2f
...
@@ -251,7 +251,7 @@ namespace SwayNotificationCenter {
...
@@ -251,7 +251,7 @@ namespace SwayNotificationCenter {
/** Closes a specific notification with the `id` */
/** Closes a specific notification with the `id` */
public
void
close_notification
(
uint32
id
)
throws
DBusError
,
IOError
{
public
void
close_notification
(
uint32
id
)
throws
DBusError
,
IOError
{
noti_daemon
.
control_center
.
close_notification
(
id
);
noti_daemon
.
control_center
.
close_notification
(
id
,
true
);
}
}
/**
/**
...
...
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