Fixing disappearing and out of place jumpy windows

This commit is contained in:
jon 2020-09-30 19:52:21 +02:00
parent 260358201a
commit 93130338e2
2 changed files with 20 additions and 7 deletions

View File

@ -36,9 +36,9 @@
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <ev.h> #include <ev.h>
#include <pixman.h> #include <pixman.h>
#include <xcb/xproto.h>
#include <xcb/render.h> #include <xcb/render.h>
#include <xcb/sync.h> #include <xcb/sync.h>
#include <xcb/xproto.h>
#include "uthash_extra.h" #include "uthash_extra.h"
#ifdef CONFIG_OPENGL #ifdef CONFIG_OPENGL
@ -55,11 +55,11 @@
#include "backend/driver.h" #include "backend/driver.h"
#include "compiler.h" #include "compiler.h"
#include "config.h" #include "config.h"
#include "list.h"
#include "region.h" #include "region.h"
#include "render.h"
#include "types.h" #include "types.h"
#include "utils.h" #include "utils.h"
#include "list.h"
#include "render.h"
#include "win_defs.h" #include "win_defs.h"
#include "x.h" #include "x.h"
@ -534,8 +534,12 @@ static inline void wintype_arr_enable(bool arr[]) {
} }
} }
/** /**
* Get current system clock in milliseconds. * Get current system clock in milliseconds.
*/ */
int64_t get_time_ms(void); int64_t get_time_ms(void);
/**
* Get current system clock in microseconds * 40.
*/
int64_t get_time_40us(void);

View File

@ -124,6 +124,15 @@ static inline void free_xinerama_info(session_t *ps) {
* Get current system clock in milliseconds. * Get current system clock in milliseconds.
*/ */
int64_t get_time_ms(void) { 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; struct timespec tp;
clock_gettime(CLOCK_MONOTONIC, &tp); clock_gettime(CLOCK_MONOTONIC, &tp);
// return (int64_t)tp.tv_sec * 1000 + (int64_t)tp.tv_nsec / 1000000; // 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 // Fading step calculation
long steps = 0L; long steps = 0L;
auto now = get_time_ms(); auto now = get_time_40us();
if (ps->fade_time) { if (ps->fade_time) {
assert(now >= ps->fade_time); assert(now >= ps->fade_time);
steps = (now - ps->fade_time) / ps->o.fade_delta; steps = (now - ps->fade_time) / ps->o.fade_delta;