Convert use of SHAPE extension to XCB

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2018-09-29 11:29:51 +02:00
parent aa8cb217c8
commit 83a4853419
5 changed files with 24 additions and 15 deletions

View File

@ -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 =

View File

@ -83,7 +83,6 @@
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/extensions/Xfixes.h>
#include <X11/extensions/shape.h>
#include <X11/extensions/Xdbe.h>
#ifdef CONFIG_XSYNC
#include <X11/extensions/sync.h>
@ -97,6 +96,7 @@
#include <xcb/render.h>
#include <xcb/damage.h>
#include <xcb/randr.h>
#include <xcb/shape.h>
// Workarounds for missing definitions in very old versions of X headers,
// thanks to consolers for reporting

View File

@ -10,7 +10,6 @@
#include <ctype.h>
#include <string.h>
#include <xcb/shape.h>
#include <xcb/randr.h>
#include <xcb/damage.h>
#include <xcb/render.h>
@ -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;
}

View File

@ -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));
}
}

View File

@ -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;
}