mirror of
https://github.com/yshui/picom.git
synced 2025-03-03 16:14:36 -05:00
core: use a long-lived XFixes region
This is a workaround for #301. This doesn't fix the bug, but by allocating X resources much less frequently, this should make the bug almost never happen. Also, it might generally be a good idea to not create/destroy X resources so often. (XFixes Region accounts for >99% of the resource creations/destructions) Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
82403578b3
commit
292c1e57f6
3 changed files with 18 additions and 5 deletions
|
@ -230,6 +230,10 @@ typedef struct session {
|
||||||
bool tmout_unredir_hit;
|
bool tmout_unredir_hit;
|
||||||
/// Whether we need to redraw the screen
|
/// Whether we need to redraw the screen
|
||||||
bool redraw_needed;
|
bool redraw_needed;
|
||||||
|
|
||||||
|
/// Cache a xfixes region so we don't need to allocate it everytime.
|
||||||
|
/// A workaround for yshui/picom#301
|
||||||
|
xcb_xfixes_region_t damaged_region;
|
||||||
/// The region needs to painted on next paint.
|
/// The region needs to painted on next paint.
|
||||||
region_t *damage;
|
region_t *damage;
|
||||||
/// The region damaged on the last paint.
|
/// The region damaged on the last paint.
|
||||||
|
|
|
@ -591,11 +591,9 @@ static inline void repair_win(session_t *ps, struct managed_win *w) {
|
||||||
set_ignore_cookie(
|
set_ignore_cookie(
|
||||||
ps, xcb_damage_subtract(ps->c, w->damage, XCB_NONE, XCB_NONE));
|
ps, xcb_damage_subtract(ps->c, w->damage, XCB_NONE, XCB_NONE));
|
||||||
} else {
|
} else {
|
||||||
xcb_xfixes_region_t tmp = x_new_id(ps->c);
|
set_ignore_cookie(
|
||||||
xcb_xfixes_create_region(ps->c, tmp, 0, NULL);
|
ps, xcb_damage_subtract(ps->c, w->damage, XCB_NONE, ps->damaged_region));
|
||||||
set_ignore_cookie(ps, xcb_damage_subtract(ps->c, w->damage, XCB_NONE, tmp));
|
x_fetch_region(ps->c, ps->damaged_region, &parts);
|
||||||
x_fetch_region(ps->c, tmp, &parts);
|
|
||||||
xcb_xfixes_destroy_region(ps->c, tmp);
|
|
||||||
pixman_region32_translate(&parts, w->g.x + w->g.border_width,
|
pixman_region32_translate(&parts, w->g.x + w->g.border_width,
|
||||||
w->g.y + w->g.border_width);
|
w->g.y + w->g.border_width);
|
||||||
}
|
}
|
||||||
|
|
11
src/picom.c
11
src/picom.c
|
@ -1750,6 +1750,12 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
|
||||||
XCB_XFIXES_MINOR_VERSION)
|
XCB_XFIXES_MINOR_VERSION)
|
||||||
.sequence);
|
.sequence);
|
||||||
|
|
||||||
|
ps->damaged_region = x_new_id(ps->c);
|
||||||
|
if (!XCB_AWAIT_VOID(xcb_xfixes_create_region, ps->c, ps->damaged_region, 0, NULL)) {
|
||||||
|
log_fatal("Failed to create a XFixes region");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
ext_info = xcb_get_extension_data(ps->c, &xcb_glx_id);
|
ext_info = xcb_get_extension_data(ps->c, &xcb_glx_id);
|
||||||
if (ext_info && ext_info->present) {
|
if (ext_info && ext_info->present) {
|
||||||
ps->glx_exists = true;
|
ps->glx_exists = true;
|
||||||
|
@ -2279,6 +2285,11 @@ static void session_destroy(session_t *ps) {
|
||||||
ps->debug_window = XCB_NONE;
|
ps->debug_window = XCB_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ps->damaged_region != XCB_NONE) {
|
||||||
|
xcb_xfixes_destroy_region(ps->c, ps->damaged_region);
|
||||||
|
ps->damaged_region = XCB_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
if (ps->o.experimental_backends) {
|
if (ps->o.experimental_backends) {
|
||||||
// backend is deinitialized in unredirect()
|
// backend is deinitialized in unredirect()
|
||||||
assert(ps->backend_data == NULL);
|
assert(ps->backend_data == NULL);
|
||||||
|
|
Loading…
Add table
Reference in a new issue