event: lazify screen update
Set root screen change flag in event handler, and update in draw_callback. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
e414fee91f
commit
e8f2298159
|
@ -345,6 +345,8 @@ typedef struct session {
|
||||||
xcb_sync_fence_t sync_fence;
|
xcb_sync_fence_t sync_fence;
|
||||||
|
|
||||||
// === Operation related ===
|
// === Operation related ===
|
||||||
|
/// Flags related to the root window
|
||||||
|
uint64_t root_flags;
|
||||||
/// Program options.
|
/// Program options.
|
||||||
options_t o;
|
options_t o;
|
||||||
/// Whether we have hit unredirection timeout.
|
/// Whether we have hit unredirection timeout.
|
||||||
|
|
|
@ -48,8 +48,8 @@
|
||||||
#ifdef CONFIG_DBUS
|
#ifdef CONFIG_DBUS
|
||||||
#include "dbus.h"
|
#include "dbus.h"
|
||||||
#endif
|
#endif
|
||||||
#include "options.h"
|
|
||||||
#include "event.h"
|
#include "event.h"
|
||||||
|
#include "options.h"
|
||||||
|
|
||||||
/// Get session_t pointer from a pointer to a member of session_t
|
/// Get session_t pointer from a pointer to a member of session_t
|
||||||
#define session_ptr(ptr, member) \
|
#define session_ptr(ptr, member) \
|
||||||
|
@ -58,7 +58,6 @@
|
||||||
(session_t *)((char *)__mptr - offsetof(session_t, member)); \
|
(session_t *)((char *)__mptr - offsetof(session_t, member)); \
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
static bool must_use redir_start(session_t *ps);
|
static bool must_use redir_start(session_t *ps);
|
||||||
|
|
||||||
static void redir_stop(session_t *ps);
|
static void redir_stop(session_t *ps);
|
||||||
|
@ -85,6 +84,10 @@ const char *const BACKEND_STRS[NUM_BKEND + 1] = {"xrender", // BKEN
|
||||||
/// XXX Limit what xerror can access by not having this pointer
|
/// XXX Limit what xerror can access by not having this pointer
|
||||||
session_t *ps_g = NULL;
|
session_t *ps_g = NULL;
|
||||||
|
|
||||||
|
void set_root_flags(session_t *ps, uint64_t flags) {
|
||||||
|
ps->root_flags |= flags;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free Xinerama screen info.
|
* Free Xinerama screen info.
|
||||||
*
|
*
|
||||||
|
@ -96,7 +99,7 @@ static inline void free_xinerama_info(session_t *ps) {
|
||||||
pixman_region32_fini(&ps->xinerama_scr_regs[i]);
|
pixman_region32_fini(&ps->xinerama_scr_regs[i]);
|
||||||
free(ps->xinerama_scr_regs);
|
free(ps->xinerama_scr_regs);
|
||||||
}
|
}
|
||||||
cxfree(ps->xinerama_scrs);
|
free(ps->xinerama_scrs);
|
||||||
ps->xinerama_scrs = NULL;
|
ps->xinerama_scrs = NULL;
|
||||||
ps->xinerama_nscrs = 0;
|
ps->xinerama_nscrs = 0;
|
||||||
}
|
}
|
||||||
|
@ -397,6 +400,23 @@ xcb_window_t find_client_win(session_t *ps, xcb_window_t w) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void handle_root_flags(session_t *ps) {
|
||||||
|
if ((ps->root_flags & ROOT_FLAGS_SCREEN_CHANGE) != 0) {
|
||||||
|
if (ps->o.xinerama_shadow_crop) {
|
||||||
|
cxinerama_upd_scrs(ps);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ps->o.sw_opti && !ps->o.refresh_rate) {
|
||||||
|
update_refresh_rate(ps);
|
||||||
|
if (!ps->refresh_rate) {
|
||||||
|
log_warn("Refresh rate detection failed. swopti will be "
|
||||||
|
"temporarily disabled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ps->root_flags &= ~ROOT_FLAGS_SCREEN_CHANGE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static win *paint_preprocess(session_t *ps, bool *fade_running) {
|
static win *paint_preprocess(session_t *ps, bool *fade_running) {
|
||||||
// XXX need better, more general name for `fade_running`. It really
|
// XXX need better, more general name for `fade_running`. It really
|
||||||
// means if fade is still ongoing after the current frame is rendered
|
// means if fade is still ongoing after the current frame is rendered
|
||||||
|
@ -970,7 +990,6 @@ void update_ewmh_active_win(session_t *ps) {
|
||||||
win_set_focused(ps, w, true);
|
win_set_focused(ps, w, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// === Main ===
|
// === Main ===
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1406,6 +1425,11 @@ static void _draw_callback(EV_P_ session_t *ps, int revents) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO xcb_grab_server
|
||||||
|
// TODO clean up event queue
|
||||||
|
|
||||||
|
handle_root_flags(ps);
|
||||||
|
|
||||||
bool fade_running = false;
|
bool fade_running = false;
|
||||||
win *t = paint_preprocess(ps, &fade_running);
|
win *t = paint_preprocess(ps, &fade_running);
|
||||||
ps->tmout_unredir_hit = false;
|
ps->tmout_unredir_hit = false;
|
||||||
|
@ -1435,6 +1459,8 @@ static void _draw_callback(EV_P_ session_t *ps, int revents) {
|
||||||
if (!fade_running)
|
if (!fade_running)
|
||||||
ps->fade_time = 0L;
|
ps->fade_time = 0L;
|
||||||
|
|
||||||
|
// TODO xcb_ungrab_server
|
||||||
|
|
||||||
ps->redraw_needed = false;
|
ps->redraw_needed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,10 @@
|
||||||
#include "win.h"
|
#include "win.h"
|
||||||
#include "x.h"
|
#include "x.h"
|
||||||
|
|
||||||
|
enum root_flags {
|
||||||
|
ROOT_FLAGS_SCREEN_CHANGE = 1
|
||||||
|
};
|
||||||
|
|
||||||
// == Functions ==
|
// == Functions ==
|
||||||
// TODO move static inline functions that are only used in compton.c, into
|
// TODO move static inline functions that are only used in compton.c, into
|
||||||
// compton.c
|
// compton.c
|
||||||
|
@ -62,6 +66,8 @@ void queue_redraw(session_t *ps);
|
||||||
|
|
||||||
void discard_ignore(session_t *ps, unsigned long sequence);
|
void discard_ignore(session_t *ps, unsigned long sequence);
|
||||||
|
|
||||||
|
void set_root_flags(session_t *ps, uint64_t flags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a <code>switch_t</code> array of all unset wintypes to true.
|
* Set a <code>switch_t</code> array of all unset wintypes to true.
|
||||||
*/
|
*/
|
||||||
|
@ -151,5 +157,3 @@ static inline void dump_drawable(session_t *ps, xcb_drawable_t drawable) {
|
||||||
drawable, r->x, r->y, r->width, r->height, r->border_width, r->depth);
|
drawable, r->x, r->y, r->width, r->height, r->border_width, r->depth);
|
||||||
free(r);
|
free(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim: set et sw=2 :
|
|
||||||
|
|
20
src/event.c
20
src/event.c
|
@ -506,23 +506,6 @@ static inline void ev_shape_notify(session_t *ps, xcb_shape_notify_event_t *ev)
|
||||||
w->reg_ignore_valid = false;
|
w->reg_ignore_valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle ScreenChangeNotify events from X RandR extension.
|
|
||||||
*/
|
|
||||||
static void ev_screen_change_notify(session_t *ps,
|
|
||||||
xcb_randr_screen_change_notify_event_t attr_unused *ev) {
|
|
||||||
if (ps->o.xinerama_shadow_crop)
|
|
||||||
cxinerama_upd_scrs(ps);
|
|
||||||
|
|
||||||
if (ps->o.sw_opti && !ps->o.refresh_rate) {
|
|
||||||
update_refresh_rate(ps);
|
|
||||||
if (!ps->refresh_rate) {
|
|
||||||
log_warn("Refresh rate detection failed. swopti will be "
|
|
||||||
"temporarily disabled");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
ev_selection_clear(session_t *ps, xcb_selection_clear_event_t attr_unused *ev) {
|
ev_selection_clear(session_t *ps, xcb_selection_clear_event_t attr_unused *ev) {
|
||||||
// The only selection we own is the _NET_WM_CM_Sn selection.
|
// The only selection we own is the _NET_WM_CM_Sn selection.
|
||||||
|
@ -603,8 +586,7 @@ void ev_handle(session_t *ps, xcb_generic_event_t *ev) {
|
||||||
}
|
}
|
||||||
if (ps->randr_exists &&
|
if (ps->randr_exists &&
|
||||||
ev->response_type == (ps->randr_event + XCB_RANDR_SCREEN_CHANGE_NOTIFY)) {
|
ev->response_type == (ps->randr_event + XCB_RANDR_SCREEN_CHANGE_NOTIFY)) {
|
||||||
ev_screen_change_notify(
|
set_root_flags(ps, ROOT_FLAGS_SCREEN_CHANGE);
|
||||||
ps, (xcb_randr_screen_change_notify_event_t *)ev);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ps->damage_event + XCB_DAMAGE_NOTIFY == ev->response_type) {
|
if (ps->damage_event + XCB_DAMAGE_NOTIFY == ev->response_type) {
|
||||||
|
|
Loading…
Reference in New Issue