From 8f5afaafb681c2b37828fd241c5317742cf8aba2 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Fri, 22 Dec 2017 22:23:17 +0100 Subject: [PATCH] Do not redraw window on PropertyChange When receiving a PropertyChange XEvent, it's mostly because the focus of another window changed to another window. This isn't actually neccessary for dunst. We need the event only, to know, when the screens have switched. As redrawing the screen became more expensive with the drop of GTK3, we have to ignore this event and only really redraw the window, when the focus has moved to another screen. --- src/x11/x.c | 11 ++++++++++- src/x11/x.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/x11/x.c b/src/x11/x.c index 881b1af..0f38487 100644 --- a/src/x11/x.c +++ b/src/x11/x.c @@ -730,6 +730,7 @@ static void x_win_move(int width, int height) int x, y; screen_info *scr = get_active_screen(); + xctx.cur_screen = scr->scr; /* calculate window position */ if (xctx.geometry.mask & XNegative) { x = (scr->dim.x + (scr->dim.w - width)) + xctx.geometry.x; @@ -908,9 +909,17 @@ gboolean x_mainloop_fd_dispatch(GSource *source, GSourceFunc callback, gpointer break; case FocusIn: case FocusOut: - case PropertyNotify: wake_up(); break; + case PropertyNotify: + /* Ignore PropertyNotify, when we're still on the + * same screen. PropertyNotify is only neccessary + * to detect a focus change to another screen + */ + if( settings.f_mode != FOLLOW_NONE + && get_active_screen()->scr != xctx.cur_screen) + wake_up(); + break; default: screen_check_event(ev); break; diff --git a/src/x11/x.h b/src/x11/x.h index 3b08ca4..8ee757a 100644 --- a/src/x11/x.h +++ b/src/x11/x.h @@ -25,6 +25,7 @@ typedef struct _keyboard_shortcut { typedef struct _xctx { Atom utf8; Display *dpy; + int cur_screen; Window win; bool visible; dimension_t geometry;