From 93130338e28e89881b8a06e3da68961bbb51d949 Mon Sep 17 00:00:00 2001 From: jon Date: Wed, 30 Sep 2020 19:52:21 +0200 Subject: [PATCH] Fixing disappearing and out of place jumpy windows --- src/common.h | 16 ++++++++++------ src/picom.c | 11 ++++++++++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/common.h b/src/common.h index 31a8af8..341dc7d 100644 --- a/src/common.h +++ b/src/common.h @@ -36,9 +36,9 @@ #include #include #include -#include #include #include +#include #include "uthash_extra.h" #ifdef CONFIG_OPENGL @@ -55,11 +55,11 @@ #include "backend/driver.h" #include "compiler.h" #include "config.h" +#include "list.h" #include "region.h" +#include "render.h" #include "types.h" #include "utils.h" -#include "list.h" -#include "render.h" #include "win_defs.h" #include "x.h" @@ -254,11 +254,11 @@ typedef struct session { // Cached blur convolution kernels. struct x_convolution_kernel **blur_kerns_cache; /// If we should quit - bool quit:1; + bool quit : 1; /// Whether there are pending updates, like window creation, etc. /// TODO use separate flags for dfferent kinds of updates so we don't /// waste our time. - bool pending_updates:1; + bool pending_updates : 1; // === Expose event related === /// Pointer to an array of XRectangle-s of exposed region. @@ -534,8 +534,12 @@ static inline void wintype_arr_enable(bool arr[]) { } } - /** * Get current system clock in milliseconds. */ int64_t get_time_ms(void); + +/** + * Get current system clock in microseconds * 40. + */ +int64_t get_time_40us(void); diff --git a/src/picom.c b/src/picom.c index 202a928..97e921e 100644 --- a/src/picom.c +++ b/src/picom.c @@ -124,6 +124,15 @@ static inline void free_xinerama_info(session_t *ps) { * Get current system clock in milliseconds. */ int64_t get_time_ms(void) { + struct timespec tp; + clock_gettime(CLOCK_MONOTONIC, &tp); + return (int64_t)tp.tv_sec * 1000 + (int64_t)tp.tv_nsec / 1000000; +} + +/** + * Get current system clock in microseconds * 40. + */ +int64_t get_time_40us(void) { struct timespec tp; clock_gettime(CLOCK_MONOTONIC, &tp); // return (int64_t)tp.tv_sec * 1000 + (int64_t)tp.tv_nsec / 1000000; @@ -425,7 +434,7 @@ static struct managed_win *paint_preprocess(session_t *ps, bool *fade_running) { // Fading step calculation long steps = 0L; - auto now = get_time_ms(); + auto now = get_time_40us(); if (ps->fade_time) { assert(now >= ps->fade_time); steps = (now - ps->fade_time) / ps->o.fade_delta;