core: unmap overlay window when we first acquire it

It used to be unmap when we receive its MapNotify, but now since we discard
events received before we grab X server, that event it lost. But it
turns out we can just unmap it when it's first created, no need to wait
for the MapNotify.

Partially fix #160

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-04-27 14:15:40 +01:00
parent ad8211e341
commit a40fdb86e1
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
3 changed files with 27 additions and 20 deletions

View File

@ -1104,20 +1104,17 @@ static bool init_overlay(session_t *ps) {
if (ps->overlay) { if (ps->overlay) {
// Set window region of the overlay window, code stolen from // Set window region of the overlay window, code stolen from
// compiz-0.8.8 // compiz-0.8.8
xcb_generic_error_t *e; if (!XCB_AWAIT_VOID(xcb_shape_mask, ps->c, XCB_SHAPE_SO_SET,
e = XCB_SYNCED_VOID(xcb_shape_mask, ps->c, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, ps->overlay, 0, 0, 0)) {
XCB_SHAPE_SK_BOUNDING, ps->overlay, 0, 0, 0);
if (e) {
log_fatal("Failed to set the bounding shape of overlay, giving " log_fatal("Failed to set the bounding shape of overlay, giving "
"up."); "up.");
exit(1); return false;
} }
e = XCB_SYNCED_VOID(xcb_shape_rectangles, ps->c, XCB_SHAPE_SO_SET, if (!XCB_AWAIT_VOID(xcb_shape_rectangles, ps->c, XCB_SHAPE_SO_SET,
XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED, XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED,
ps->overlay, 0, 0, 0, NULL); ps->overlay, 0, 0, 0, NULL)) {
if (e) {
log_fatal("Failed to set the input shape of overlay, giving up."); log_fatal("Failed to set the input shape of overlay, giving up.");
exit(1); return false;
} }
// Listen to Expose events on the overlay // Listen to Expose events on the overlay
@ -1128,17 +1125,15 @@ static bool init_overlay(session_t *ps) {
// overlay // overlay
// root_damage = XDamageCreate(ps->dpy, root, XDamageReportNonEmpty); // root_damage = XDamageCreate(ps->dpy, root, XDamageReportNonEmpty);
// Unmap overlay, firstly. But this typically does not work because // Unmap the overlay, we will map it when needed in redir_start
// the window isn't created yet. XCB_AWAIT_VOID(xcb_unmap_window, ps->c, ps->overlay);
// xcb_unmap_window(c, ps->overlay);
// XFlush(ps->dpy);
} else { } else {
log_error("Cannot get X Composite overlay window. Falling " log_error("Cannot get X Composite overlay window. Falling "
"back to painting on root window."); "back to painting on root window.");
} }
log_debug("overlay = %#010x", ps->overlay); log_debug("overlay = %#010x", ps->overlay);
return ps->overlay; return true;
} }
/** /**
@ -1850,7 +1845,7 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
log_fatal("No XRandR extension. sw-opti, refresh-rate or " log_fatal("No XRandR extension. sw-opti, refresh-rate or "
"xinerama-shadow-crop " "xinerama-shadow-crop "
"cannot be enabled."); "cannot be enabled.");
exit(1); goto err;
} }
} }
@ -1864,7 +1859,9 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
// Overlay must be initialized before double buffer, and before creation // Overlay must be initialized before double buffer, and before creation
// of OpenGL context. // of OpenGL context.
init_overlay(ps); if (!init_overlay(ps)) {
goto err;
}
ps->drivers = detect_driver(ps->c, ps->backend_data, ps->root); ps->drivers = detect_driver(ps->c, ps->backend_data, ps->root);

View File

@ -169,7 +169,6 @@ static inline void ev_focus_out(session_t *ps, xcb_focus_out_event_t *ev) {
static inline void ev_create_notify(session_t *ps, xcb_create_notify_event_t *ev) { static inline void ev_create_notify(session_t *ps, xcb_create_notify_event_t *ev) {
assert(ev->parent == ps->root); assert(ev->parent == ps->root);
// TODO delay fill_win
add_win_top(ps, ev->window); add_win_top(ps, ev->window);
} }

17
src/x.h
View File

@ -47,9 +47,20 @@ struct xvisual_info {
xcb_visualid_t visual; xcb_visualid_t visual;
}; };
#define XCB_SYNCED_VOID(func, c, ...) \ #define XCB_AWAIT_VOID(func, c, ...) \
xcb_request_check(c, func##_checked(c, __VA_ARGS__)); ({ \
#define XCB_SYNCED(func, c, ...) \ bool success = true; \
__auto_type e = xcb_request_check(c, func##_checked(c, __VA_ARGS__)); \
if (e) { \
x_print_error(e->sequence, e->major_code, e->minor_code, \
e->error_code); \
free(e); \
success = false; \
} \
success; \
})
#define XCB_AWAIT(func, c, ...) \
({ \ ({ \
xcb_generic_error_t *e = NULL; \ xcb_generic_error_t *e = NULL; \
__auto_type r = func##_reply(c, func(c, __VA_ARGS__), &e); \ __auto_type r = func##_reply(c, func(c, __VA_ARGS__), &e); \