diff --git a/src/common.h b/src/common.h index a2871c0..997f637 100644 --- a/src/common.h +++ b/src/common.h @@ -345,6 +345,8 @@ typedef struct session { xcb_sync_fence_t sync_fence; // === Operation related === + /// Flags related to the root window + uint64_t root_flags; /// Program options. options_t o; /// Whether we have hit unredirection timeout. diff --git a/src/compton.c b/src/compton.c index 0d3f6bf..275e0b2 100644 --- a/src/compton.c +++ b/src/compton.c @@ -48,8 +48,8 @@ #ifdef CONFIG_DBUS #include "dbus.h" #endif -#include "options.h" #include "event.h" +#include "options.h" /// Get session_t pointer from a pointer to a member of session_t #define session_ptr(ptr, member) \ @@ -58,7 +58,6 @@ (session_t *)((char *)__mptr - offsetof(session_t, member)); \ }) - static bool must_use redir_start(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 session_t *ps_g = NULL; +void set_root_flags(session_t *ps, uint64_t flags) { + ps->root_flags |= flags; +} + /** * 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]); free(ps->xinerama_scr_regs); } - cxfree(ps->xinerama_scrs); + free(ps->xinerama_scrs); ps->xinerama_scrs = NULL; ps->xinerama_nscrs = 0; } @@ -397,6 +400,23 @@ xcb_window_t find_client_win(session_t *ps, xcb_window_t w) { 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) { // XXX need better, more general name for `fade_running`. It really // 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); } - // === 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; win *t = paint_preprocess(ps, &fade_running); ps->tmout_unredir_hit = false; @@ -1435,6 +1459,8 @@ static void _draw_callback(EV_P_ session_t *ps, int revents) { if (!fade_running) ps->fade_time = 0L; + // TODO xcb_ungrab_server + ps->redraw_needed = false; } diff --git a/src/compton.h b/src/compton.h index 182af66..1e3e26a 100644 --- a/src/compton.h +++ b/src/compton.h @@ -25,6 +25,10 @@ #include "win.h" #include "x.h" +enum root_flags { + ROOT_FLAGS_SCREEN_CHANGE = 1 +}; + // == Functions == // TODO move static inline functions that are only used in compton.c, into // compton.c @@ -62,6 +66,8 @@ void queue_redraw(session_t *ps); void discard_ignore(session_t *ps, unsigned long sequence); +void set_root_flags(session_t *ps, uint64_t flags); + /** * Set a switch_t 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); free(r); } - -// vim: set et sw=2 : diff --git a/src/event.c b/src/event.c index 1c38a32..417377d 100644 --- a/src/event.c +++ b/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; } -/** - * 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 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. @@ -603,8 +586,7 @@ void ev_handle(session_t *ps, xcb_generic_event_t *ev) { } if (ps->randr_exists && ev->response_type == (ps->randr_event + XCB_RANDR_SCREEN_CHANGE_NOTIFY)) { - ev_screen_change_notify( - ps, (xcb_randr_screen_change_notify_event_t *)ev); + set_root_flags(ps, ROOT_FLAGS_SCREEN_CHANGE); break; } if (ps->damage_event + XCB_DAMAGE_NOTIFY == ev->response_type) {