From 83a48534194b60bc91a63144997dc5c25f22b38d Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sat, 29 Sep 2018 11:29:51 +0200 Subject: [PATCH] Convert use of SHAPE extension to XCB Signed-off-by: Uli Schlachter --- Makefile | 2 +- src/common.h | 2 +- src/compton.c | 15 ++++++++++----- src/compton.h | 6 ++++-- src/win.c | 14 ++++++++------ 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 62a4d1e..1dc8d2c 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ MANDIR ?= $(PREFIX)/share/man/man1 APPDIR ?= $(PREFIX)/share/applications ICODIR ?= $(PREFIX)/share/icons/hicolor/ -PACKAGES = x11 x11-xcb xcb-renderutil xcb-render xcb-damage xcb-randr xcb-composite xcb-image xfixes xext +PACKAGES = x11 x11-xcb xcb-renderutil xcb-render xcb-damage xcb-randr xcb-composite xcb-shape xcb-image xfixes xext LIBS = -lm -lrt INCS = diff --git a/src/common.h b/src/common.h index 68c103a..8b21ad1 100644 --- a/src/common.h +++ b/src/common.h @@ -83,7 +83,6 @@ #include #include #include -#include #include #ifdef CONFIG_XSYNC #include @@ -97,6 +96,7 @@ #include #include #include +#include // Workarounds for missing definitions in very old versions of X headers, // thanks to consolers for reporting diff --git a/src/compton.c b/src/compton.c index f8ec4a9..35a619d 100644 --- a/src/compton.c +++ b/src/compton.c @@ -10,7 +10,6 @@ #include #include -#include #include #include #include @@ -2027,6 +2026,8 @@ repair_win(session_t *ps, win *w) { void map_win(session_t *ps, Window id) { + xcb_connection_t *c = XGetXCBConnection(ps->dpy); + // Unmap overlay window if it got mapped but we are currently not // in redirected state. if (ps->overlay && id == ps->overlay && !ps->redirected) { @@ -2058,7 +2059,7 @@ map_win(session_t *ps, Window id) { // Notify compton when the shape of a window changes if (ps->shape_exists) { - XShapeSelectInput(ps->dpy, id, ShapeNotifyMask); + xcb_shape_select_input(c, id, 1); } // Make sure the XSelectInput() requests are sent @@ -4722,8 +4723,8 @@ init_overlay(session_t *ps) { // Set window region of the overlay window, code stolen from // compiz-0.8.8 XserverRegion region = XFixesCreateRegion(ps->dpy, NULL, 0); - XFixesSetWindowShapeRegion(ps->dpy, ps->overlay, ShapeBounding, 0, 0, 0); - XFixesSetWindowShapeRegion(ps->dpy, ps->overlay, ShapeInput, 0, 0, region); + XFixesSetWindowShapeRegion(ps->dpy, ps->overlay, XCB_SHAPE_SK_BOUNDING, 0, 0, 0); + XFixesSetWindowShapeRegion(ps->dpy, ps->overlay, XCB_SHAPE_SK_INPUT, 0, 0, region); XFixesDestroyRegion(ps->dpy, region); // Listen to Expose events on the overlay @@ -5382,6 +5383,7 @@ session_init(session_t *ps_old, int argc, char **argv) { xcb_prefetch_extension_data(c, &xcb_render_id); xcb_prefetch_extension_data(c, &xcb_composite_id); xcb_prefetch_extension_data(c, &xcb_damage_id); + xcb_prefetch_extension_data(c, &xcb_shape_id); xcb_prefetch_extension_data(c, &xcb_randr_id); ext_info = xcb_get_extension_data(c, &xcb_render_id); @@ -5454,7 +5456,10 @@ session_init(session_t *ps_old, int argc, char **argv) { get_cfg(ps, argc, argv, false); // Query X Shape - if (XShapeQueryExtension(ps->dpy, &ps->shape_event, &ps->shape_error)) { + ext_info = xcb_get_extension_data(c, &xcb_shape_id); + if (ext_info && ext_info->present) { + ps->shape_event = ext_info->first_event; + ps->shape_error = ext_info->first_error; ps->shape_exists = true; } diff --git a/src/compton.h b/src/compton.h index cc7d753..37628bd 100644 --- a/src/compton.h +++ b/src/compton.h @@ -355,6 +355,8 @@ check_fade_fin(session_t *ps, win *w) { */ static inline void win_ev_stop(session_t *ps, win *w) { + xcb_connection_t *c = XGetXCBConnection(ps->dpy); + // Will get BadWindow if the window is destroyed set_ignore_next(ps); XSelectInput(ps->dpy, w->id, 0); @@ -365,8 +367,8 @@ win_ev_stop(session_t *ps, win *w) { } if (ps->shape_exists) { - set_ignore_next(ps); - XShapeSelectInput(ps->dpy, w->id, 0); + set_ignore_cookie(ps, + xcb_shape_select_input(c, w->id, 0)); } } diff --git a/src/win.c b/src/win.c index 179c71b..af7ac92 100644 --- a/src/win.c +++ b/src/win.c @@ -231,13 +231,15 @@ int win_get_role(session_t *ps, win *w) { */ static inline bool win_bounding_shaped(const session_t *ps, Window wid) { if (ps->shape_exists) { - Bool bounding_shaped = False, clip_shaped = False; - int x_bounding, y_bounding, x_clip, y_clip; - unsigned int w_bounding, h_bounding, w_clip, h_clip; + xcb_shape_query_extents_reply_t *reply; + Bool bounding_shaped; + xcb_connection_t *c = XGetXCBConnection(ps->dpy); + + reply = xcb_shape_query_extents_reply(c, + xcb_shape_query_extents(c, wid), NULL); + bounding_shaped = reply && reply->bounding_shaped; + free(reply); - XShapeQueryExtents(ps->dpy, wid, &bounding_shaped, - &x_bounding, &y_bounding, &w_bounding, &h_bounding, - &clip_shaped, &x_clip, &y_clip, &w_clip, &h_clip); return bounding_shaped; }