Delay incoming notifications when fullscreens set
This commit is contained in:
parent
bda8c1dbb2
commit
f89ce8e16f
@ -48,8 +48,10 @@ void wake_up(void)
|
|||||||
|
|
||||||
static gboolean run(void *data)
|
static gboolean run(void *data)
|
||||||
{
|
{
|
||||||
queues_check_timeouts(x_is_idle());
|
bool fullscreen = have_fullscreen_window();
|
||||||
queues_update();
|
|
||||||
|
queues_check_timeouts(x_is_idle(), fullscreen);
|
||||||
|
queues_update(fullscreen);
|
||||||
|
|
||||||
static gint64 next_timeout = 0;
|
static gint64 next_timeout = 0;
|
||||||
|
|
||||||
|
23
src/queues.c
23
src/queues.c
@ -284,12 +284,14 @@ void queues_history_push_all(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* see queues.h */
|
/* see queues.h */
|
||||||
void queues_check_timeouts(bool idle)
|
void queues_check_timeouts(bool idle, bool fullscreen)
|
||||||
{
|
{
|
||||||
/* nothing to do */
|
/* nothing to do */
|
||||||
if (displayed->length == 0)
|
if (displayed->length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
bool is_idle = fullscreen ? false : idle;
|
||||||
|
|
||||||
GList *iter = g_queue_peek_head_link(displayed);
|
GList *iter = g_queue_peek_head_link(displayed);
|
||||||
while (iter) {
|
while (iter) {
|
||||||
notification *n = iter->data;
|
notification *n = iter->data;
|
||||||
@ -302,7 +304,7 @@ void queues_check_timeouts(bool idle)
|
|||||||
iter = iter->next;
|
iter = iter->next;
|
||||||
|
|
||||||
/* don't timeout when user is idle */
|
/* don't timeout when user is idle */
|
||||||
if (idle && !n->transient) {
|
if (is_idle && !n->transient) {
|
||||||
n->start = g_get_monotonic_time();
|
n->start = g_get_monotonic_time();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -320,7 +322,7 @@ void queues_check_timeouts(bool idle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* see queues.h */
|
/* see queues.h */
|
||||||
void queues_update(void)
|
void queues_update(bool fullscreen)
|
||||||
{
|
{
|
||||||
if (pause_displayed) {
|
if (pause_displayed) {
|
||||||
while (displayed->length > 0) {
|
while (displayed->length > 0) {
|
||||||
@ -331,25 +333,34 @@ void queues_update(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* move notifications from queue to displayed */
|
/* move notifications from queue to displayed */
|
||||||
while (waiting->length > 0) {
|
GList *iter = g_queue_peek_head_link(waiting);
|
||||||
|
while (iter) {
|
||||||
|
notification *n = iter->data;
|
||||||
|
GList *nextiter = iter->next;
|
||||||
|
|
||||||
if (displayed_limit > 0 && displayed->length >= displayed_limit) {
|
if (displayed_limit > 0 && displayed->length >= displayed_limit) {
|
||||||
/* the list is full */
|
/* the list is full */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
notification *n = g_queue_pop_head(waiting);
|
|
||||||
|
|
||||||
if (!n)
|
if (!n)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (fullscreen && n->fullscreen == FS_DELAY) {
|
||||||
|
iter = nextiter;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
n->start = g_get_monotonic_time();
|
n->start = g_get_monotonic_time();
|
||||||
|
|
||||||
if (!n->redisplayed && n->script) {
|
if (!n->redisplayed && n->script) {
|
||||||
notification_run_script(n);
|
notification_run_script(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_queue_delete_link(waiting, iter);
|
||||||
g_queue_insert_sorted(displayed, n, notification_cmp_data, NULL);
|
g_queue_insert_sorted(displayed, n, notification_cmp_data, NULL);
|
||||||
|
|
||||||
|
iter = nextiter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,8 +125,10 @@ void queues_history_push_all(void);
|
|||||||
*
|
*
|
||||||
* @param idle the program's idle status. Important to calculate the
|
* @param idle the program's idle status. Important to calculate the
|
||||||
* timeout for transient notifications
|
* timeout for transient notifications
|
||||||
|
* @param fullscreen the desktop's fullscreen status. Important to
|
||||||
|
* calculate the timeout for transient notifications
|
||||||
*/
|
*/
|
||||||
void queues_check_timeouts(bool idle);
|
void queues_check_timeouts(bool idle, bool fullscreen);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move inserted notifications from waiting queue to displayed queue
|
* Move inserted notifications from waiting queue to displayed queue
|
||||||
@ -135,8 +137,11 @@ void queues_check_timeouts(bool idle);
|
|||||||
*
|
*
|
||||||
* @post Call wake_up() to synchronize the queues with the UI
|
* @post Call wake_up() to synchronize the queues with the UI
|
||||||
* (which closes old and shows new notifications on screen)
|
* (which closes old and shows new notifications on screen)
|
||||||
|
*
|
||||||
|
* @param fullscreen the desktop's fullscreen status. Important to
|
||||||
|
* move notifications to the right queue
|
||||||
*/
|
*/
|
||||||
void queues_update(void);
|
void queues_update(bool fullscreen);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate the distance to the next event, when an element in the
|
* Calculate the distance to the next event, when an element in the
|
||||||
|
Loading…
x
Reference in New Issue
Block a user