Merge pull request #545 from tsipinakis/bugfix/x11-opt

Draw event optimizations
This commit is contained in:
Nikos Tsipinakis 2018-09-24 20:25:17 +03:00 committed by GitHub
commit 740ebdd5a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 20 deletions

View File

@ -51,20 +51,17 @@ static gboolean run(void *data)
static gint64 next_timeout = 0; static gint64 next_timeout = 0;
if (!x_win_visible(win) && queues_length_displayed() > 0) { bool active = queues_length_displayed() > 0;
if (active) {
// Call draw before showing the window to avoid flickering
draw(); draw();
x_win_show(win); x_win_show(win);
} } else {
if (x_win_visible(win) && queues_length_displayed() == 0) {
x_win_hide(win); x_win_hide(win);
} }
if (x_win_visible(win)) { if (active) {
draw();
}
if (x_win_visible(win)) {
gint64 now = time_monotonic_now(); gint64 now = time_monotonic_now();
gint64 sleep = queues_get_next_datachange(now); gint64 sleep = queues_get_next_datachange(now);
gint64 timeout_at = now + sleep; gint64 timeout_at = now + sleep;

View File

@ -326,22 +326,16 @@ gboolean x_mainloop_fd_dispatch(GSource *source, GSourceFunc callback, gpointer
wake_up(); wake_up();
} }
break; break;
case FocusIn:
LOG_D("XEvent: processing 'FocusIn'");
wake_up();
break;
case FocusOut:
LOG_D("XEvent: processing 'FocusOut'");
wake_up();
break;
case CreateNotify: case CreateNotify:
LOG_D("XEvent: processing 'CreateNotify'"); LOG_D("XEvent: processing 'CreateNotify'");
if (win->visible && if (win->visible &&
ev.xcreatewindow.override_redirect == 0) ev.xcreatewindow.override_redirect == 0)
XRaiseWindow(xctx.dpy, win->xwin); XRaiseWindow(xctx.dpy, win->xwin);
break; break;
case FocusIn:
case FocusOut:
case PropertyNotify: case PropertyNotify:
LOG_D("XEvent: processing 'PropertyNotify'"); LOG_D("XEvent: Checking for active sceen changes");
fullscreen_now = have_fullscreen_window(); fullscreen_now = have_fullscreen_window();
scr = get_active_screen(); scr = get_active_screen();
@ -669,9 +663,8 @@ void x_win_destroy(struct window_x11 *win)
void x_win_show(struct window_x11 *win) void x_win_show(struct window_x11 *win)
{ {
/* window is already mapped or there's nothing to show */ /* window is already mapped or there's nothing to show */
if (win->visible || queues_length_displayed() == 0) { if (win->visible)
return; return;
}
x_shortcut_grab(&settings.close_ks); x_shortcut_grab(&settings.close_ks);
x_shortcut_grab(&settings.close_all_ks); x_shortcut_grab(&settings.close_all_ks);
@ -701,6 +694,9 @@ void x_win_show(struct window_x11 *win)
*/ */
void x_win_hide(struct window_x11 *win) void x_win_hide(struct window_x11 *win)
{ {
if (!win->visible)
return;
x_shortcut_ungrab(&settings.close_ks); x_shortcut_ungrab(&settings.close_ks);
x_shortcut_ungrab(&settings.close_all_ks); x_shortcut_ungrab(&settings.close_all_ks);
x_shortcut_ungrab(&settings.context_ks); x_shortcut_ungrab(&settings.context_ks);