Simplify window showing and hiding
As suggested by @bebehei make x_win_{show,hide} callable at any time and avoid double checking the queue length.
This commit is contained in:
parent
69100790a1
commit
7ac054b3cc
15
src/dunst.c
15
src/dunst.c
@ -51,20 +51,17 @@ static gboolean run(void *data)
|
||||
|
||||
static gint64 next_timeout = 0;
|
||||
|
||||
// Call draw before showing the window to avoid flickering
|
||||
if (queues_length_displayed() > 0) {
|
||||
bool active = queues_length_displayed() > 0;
|
||||
|
||||
if (active) {
|
||||
// Call draw before showing the window to avoid flickering
|
||||
draw();
|
||||
}
|
||||
|
||||
if (!x_win_visible(win) && queues_length_displayed() > 0) {
|
||||
x_win_show(win);
|
||||
}
|
||||
|
||||
if (x_win_visible(win) && queues_length_displayed() == 0) {
|
||||
} else {
|
||||
x_win_hide(win);
|
||||
}
|
||||
|
||||
if (x_win_visible(win)) {
|
||||
if (active) {
|
||||
gint64 now = time_monotonic_now();
|
||||
gint64 sleep = queues_get_next_datachange(now);
|
||||
gint64 timeout_at = now + sleep;
|
||||
|
@ -674,9 +674,8 @@ void x_win_destroy(window_x11 *win)
|
||||
void x_win_show(window_x11 *win)
|
||||
{
|
||||
/* window is already mapped or there's nothing to show */
|
||||
if (win->visible || queues_length_displayed() == 0) {
|
||||
if (win->visible)
|
||||
return;
|
||||
}
|
||||
|
||||
x_shortcut_grab(&settings.close_ks);
|
||||
x_shortcut_grab(&settings.close_all_ks);
|
||||
@ -706,6 +705,9 @@ void x_win_show(window_x11 *win)
|
||||
*/
|
||||
void x_win_hide(window_x11 *win)
|
||||
{
|
||||
if (!win->visible)
|
||||
return;
|
||||
|
||||
x_shortcut_ungrab(&settings.close_ks);
|
||||
x_shortcut_ungrab(&settings.close_all_ks);
|
||||
x_shortcut_ungrab(&settings.context_ks);
|
||||
|
Loading…
x
Reference in New Issue
Block a user