Move pause_display to queues.c
Hint for dbus.c lines (134,138): pause_display => (displayed->length == 0)
This commit is contained in:
parent
59ac6d0f88
commit
c70da444a9
11
src/dunst.c
11
src/dunst.c
@ -36,7 +36,6 @@ typedef struct _x11_source {
|
|||||||
} x11_source_t;
|
} x11_source_t;
|
||||||
|
|
||||||
/* index of colors fit to urgency level */
|
/* index of colors fit to urgency level */
|
||||||
bool pause_display = false;
|
|
||||||
|
|
||||||
GMainLoop *mainloop = NULL;
|
GMainLoop *mainloop = NULL;
|
||||||
|
|
||||||
@ -85,7 +84,7 @@ void update_lists()
|
|||||||
{
|
{
|
||||||
check_timeouts();
|
check_timeouts();
|
||||||
|
|
||||||
if (pause_display) {
|
if (queues_pause_status()) {
|
||||||
while (displayed->length > 0) {
|
while (displayed->length > 0) {
|
||||||
g_queue_insert_sorted(queue, g_queue_pop_head(displayed),
|
g_queue_insert_sorted(queue, g_queue_pop_head(displayed),
|
||||||
notification_cmp_data, NULL);
|
notification_cmp_data, NULL);
|
||||||
@ -130,11 +129,11 @@ gboolean run(void *data)
|
|||||||
timeout_cnt--;
|
timeout_cnt--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (displayed->length > 0 && !xctx.visible && !pause_display) {
|
if (displayed->length > 0 && !xctx.visible) {
|
||||||
x_win_show();
|
x_win_show();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xctx.visible && (pause_display || displayed->length == 0)) {
|
if (xctx.visible && displayed->length == 0) {
|
||||||
x_win_hide();
|
x_win_hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +161,7 @@ gboolean run(void *data)
|
|||||||
|
|
||||||
gboolean pause_signal(gpointer data)
|
gboolean pause_signal(gpointer data)
|
||||||
{
|
{
|
||||||
pause_display = true;
|
queues_pause_on();
|
||||||
wake_up();
|
wake_up();
|
||||||
|
|
||||||
return G_SOURCE_CONTINUE;
|
return G_SOURCE_CONTINUE;
|
||||||
@ -170,7 +169,7 @@ gboolean pause_signal(gpointer data)
|
|||||||
|
|
||||||
gboolean unpause_signal(gpointer data)
|
gboolean unpause_signal(gpointer data)
|
||||||
{
|
{
|
||||||
pause_display = false;
|
queues_pause_off();
|
||||||
wake_up();
|
wake_up();
|
||||||
|
|
||||||
return G_SOURCE_CONTINUE;
|
return G_SOURCE_CONTINUE;
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
#define ColBG 0
|
#define ColBG 0
|
||||||
|
|
||||||
extern GSList *rules;
|
extern GSList *rules;
|
||||||
extern bool pause_display;
|
|
||||||
extern const char *color_strings[3][3];
|
extern const char *color_strings[3][3];
|
||||||
|
|
||||||
/* return id of notification */
|
/* return id of notification */
|
||||||
|
@ -294,12 +294,12 @@ void notification_init(notification *n)
|
|||||||
|
|
||||||
// TODO: this does not belong into notification_init
|
// TODO: this does not belong into notification_init
|
||||||
if (strcmp("DUNST_COMMAND_PAUSE", n->summary) == 0) {
|
if (strcmp("DUNST_COMMAND_PAUSE", n->summary) == 0) {
|
||||||
pause_display = true;
|
queues_pause_on();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp("DUNST_COMMAND_RESUME", n->summary) == 0) {
|
if (strcmp("DUNST_COMMAND_RESUME", n->summary) == 0) {
|
||||||
pause_display = false;
|
queues_pause_off();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
16
src/queues.c
16
src/queues.c
@ -16,6 +16,7 @@ GQueue *history = NULL; /* history of displayed notifications */
|
|||||||
|
|
||||||
unsigned int displayed_limit = 0;
|
unsigned int displayed_limit = 0;
|
||||||
int next_notification_id = 1;
|
int next_notification_id = 1;
|
||||||
|
bool pause_displayed = false;
|
||||||
|
|
||||||
static int queues_stack_duplicate(notification *n);
|
static int queues_stack_duplicate(notification *n);
|
||||||
|
|
||||||
@ -244,6 +245,21 @@ gint64 queues_get_next_datachange(gint64 time)
|
|||||||
return sleep != G_MAXINT64 ? sleep : -1;
|
return sleep != G_MAXINT64 ? sleep : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void queues_pause_on(void)
|
||||||
|
{
|
||||||
|
pause_displayed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void queues_pause_off(void)
|
||||||
|
{
|
||||||
|
pause_displayed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool queues_pause_status(void)
|
||||||
|
{
|
||||||
|
return pause_displayed;
|
||||||
|
}
|
||||||
|
|
||||||
static void teardown_notification(gpointer data)
|
static void teardown_notification(gpointer data)
|
||||||
{
|
{
|
||||||
notification *n = data;
|
notification *n = data;
|
||||||
|
11
src/queues.h
11
src/queues.h
@ -74,6 +74,17 @@ void move_all_to_history(void);
|
|||||||
*/
|
*/
|
||||||
gint64 queues_get_next_datachange(gint64 time);
|
gint64 queues_get_next_datachange(gint64 time);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pause queue-management of dunst
|
||||||
|
* pause_on = paused (no notifications displayed)
|
||||||
|
* pause_off = running
|
||||||
|
*
|
||||||
|
* Calling update_lists is neccessary
|
||||||
|
*/
|
||||||
|
void queues_pause_on(void);
|
||||||
|
void queues_pause_off(void);
|
||||||
|
bool queues_pause_status(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove all notifications from all lists
|
* Remove all notifications from all lists
|
||||||
* and free the notifications
|
* and free the notifications
|
||||||
|
Loading…
x
Reference in New Issue
Block a user