Port from xdamage to xcb-damage
No functional changes intended. The new xcb_damage_query_version() was previously done by XDamageQueryExtension() internally. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
0a98ef79ef
commit
62b847323c
2
Makefile
2
Makefile
|
@ -9,7 +9,7 @@ MANDIR ?= $(PREFIX)/share/man/man1
|
||||||
APPDIR ?= $(PREFIX)/share/applications
|
APPDIR ?= $(PREFIX)/share/applications
|
||||||
ICODIR ?= $(PREFIX)/share/icons/hicolor/
|
ICODIR ?= $(PREFIX)/share/icons/hicolor/
|
||||||
|
|
||||||
PACKAGES = x11 x11-xcb xcb-renderutil xcb-render xcb-damage xcb-image xcomposite xfixes xdamage xrender xext xrandr
|
PACKAGES = x11 x11-xcb xcb-renderutil xcb-render xcb-damage xcb-image xcomposite xfixes xrender xext xrandr
|
||||||
LIBS = -lm -lrt
|
LIBS = -lm -lrt
|
||||||
INCS =
|
INCS =
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,6 @@
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
#include <X11/extensions/Xcomposite.h>
|
#include <X11/extensions/Xcomposite.h>
|
||||||
#include <X11/extensions/Xdamage.h>
|
|
||||||
#include <X11/extensions/Xrender.h>
|
#include <X11/extensions/Xrender.h>
|
||||||
#include <X11/extensions/shape.h>
|
#include <X11/extensions/shape.h>
|
||||||
#include <X11/extensions/Xrandr.h>
|
#include <X11/extensions/Xrandr.h>
|
||||||
|
@ -97,6 +96,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <xcb/render.h>
|
#include <xcb/render.h>
|
||||||
|
#include <xcb/damage.h>
|
||||||
|
|
||||||
// Workarounds for missing definitions in very old versions of X headers,
|
// Workarounds for missing definitions in very old versions of X headers,
|
||||||
// thanks to consolers for reporting
|
// thanks to consolers for reporting
|
||||||
|
@ -1063,7 +1063,7 @@ struct win {
|
||||||
/// Whether the window was damaged after last paint.
|
/// Whether the window was damaged after last paint.
|
||||||
bool pixmap_damaged;
|
bool pixmap_damaged;
|
||||||
/// Damage of the window.
|
/// Damage of the window.
|
||||||
Damage damage;
|
xcb_damage_damage_t damage;
|
||||||
/// Paint info of the window.
|
/// Paint info of the window.
|
||||||
paint_t paint;
|
paint_t paint;
|
||||||
/// Bounding shape of the window.
|
/// Bounding shape of the window.
|
||||||
|
|
|
@ -1975,15 +1975,16 @@ repair_win(session_t *ps, win *w) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
XserverRegion parts;
|
XserverRegion parts;
|
||||||
|
xcb_connection_t *c = XGetXCBConnection(ps->dpy);
|
||||||
|
|
||||||
if (!w->ever_damaged) {
|
if (!w->ever_damaged) {
|
||||||
parts = win_extents(ps, w);
|
parts = win_extents(ps, w);
|
||||||
set_ignore_next(ps);
|
set_ignore_next(ps);
|
||||||
XDamageSubtract(ps->dpy, w->damage, None, None);
|
xcb_damage_subtract(c, w->damage, XCB_NONE, XCB_NONE);
|
||||||
} else {
|
} else {
|
||||||
parts = XFixesCreateRegion(ps->dpy, 0, 0);
|
parts = XFixesCreateRegion(ps->dpy, 0, 0);
|
||||||
set_ignore_next(ps);
|
set_ignore_next(ps);
|
||||||
XDamageSubtract(ps->dpy, w->damage, None, parts);
|
xcb_damage_subtract(c, w->damage, XCB_NONE, parts);
|
||||||
XFixesTranslateRegion(ps->dpy, parts,
|
XFixesTranslateRegion(ps->dpy, parts,
|
||||||
w->g.x + w->g.border_width,
|
w->g.x + w->g.border_width,
|
||||||
w->g.y + w->g.border_width);
|
w->g.y + w->g.border_width);
|
||||||
|
@ -2465,8 +2466,9 @@ root_damaged(session_t *ps) {
|
||||||
free_root_tile(ps);
|
free_root_tile(ps);
|
||||||
/* }
|
/* }
|
||||||
if (root_damage) {
|
if (root_damage) {
|
||||||
|
xcb_connection_t *c = XGetXCBConnection(ps->dpy);
|
||||||
XserverRegion parts = XFixesCreateRegion(ps->dpy, 0, 0);
|
XserverRegion parts = XFixesCreateRegion(ps->dpy, 0, 0);
|
||||||
XDamageSubtract(ps->dpy, root_damage, None, parts);
|
xcb_damage_subtract(c, root_damage, XCB_NONE, parts);
|
||||||
add_damage(ps, parts);
|
add_damage(ps, parts);
|
||||||
} */
|
} */
|
||||||
}
|
}
|
||||||
|
@ -2505,7 +2507,7 @@ xerror(Display __attribute__((unused)) *dpy, XErrorEvent *ev) {
|
||||||
|
|
||||||
o = ev->error_code - ps->damage_error;
|
o = ev->error_code - ps->damage_error;
|
||||||
switch (o) {
|
switch (o) {
|
||||||
CASESTRRET2(BadDamage);
|
CASESTRRET2(XCB_DAMAGE_BAD_DAMAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
o = ev->error_code - ps->render_error;
|
o = ev->error_code - ps->render_error;
|
||||||
|
@ -2713,7 +2715,7 @@ ev_name(session_t *ps, xcb_generic_event_t *ev) {
|
||||||
CASESTRRET(ClientMessage);
|
CASESTRRET(ClientMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps->damage_event + XDamageNotify == ev->response_type)
|
if (ps->damage_event + XCB_DAMAGE_NOTIFY == ev->response_type)
|
||||||
return "Damage";
|
return "Damage";
|
||||||
|
|
||||||
if (ps->shape_exists && ev->response_type == ps->shape_event)
|
if (ps->shape_exists && ev->response_type == ps->shape_event)
|
||||||
|
@ -2761,7 +2763,7 @@ ev_window(session_t *ps, xcb_generic_event_t *ev) {
|
||||||
case ClientMessage:
|
case ClientMessage:
|
||||||
return ((xcb_client_message_event_t *)ev)->window;
|
return ((xcb_client_message_event_t *)ev)->window;
|
||||||
default:
|
default:
|
||||||
if (ps->damage_event + XDamageNotify == ev->response_type) {
|
if (ps->damage_event + XCB_DAMAGE_NOTIFY == ev->response_type) {
|
||||||
return ((xcb_damage_notify_event_t *)ev)->drawable;
|
return ((xcb_damage_notify_event_t *)ev)->drawable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3200,7 +3202,7 @@ ev_handle(session_t *ps, xcb_generic_event_t *ev) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_EVENTS
|
#ifdef DEBUG_EVENTS
|
||||||
if (ev->response_type == ps->damage_event + XDamageNotify) {
|
if (ev->response_type == ps->damage_event + XCB_DAMAGE_NOTIFY) {
|
||||||
Window wid = ev_window(ps, ev);
|
Window wid = ev_window(ps, ev);
|
||||||
char *window_name = NULL;
|
char *window_name = NULL;
|
||||||
ev_window_name(ps, wid, &window_name);
|
ev_window_name(ps, wid, &window_name);
|
||||||
|
@ -3257,7 +3259,7 @@ ev_handle(session_t *ps, xcb_generic_event_t *ev) {
|
||||||
ev_screen_change_notify(ps, (xcb_randr_screen_change_notify_event_t *) ev);
|
ev_screen_change_notify(ps, (xcb_randr_screen_change_notify_event_t *) ev);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (ps->damage_event + XDamageNotify == ev->response_type) {
|
if (ps->damage_event + XCB_DAMAGE_NOTIFY == ev->response_type) {
|
||||||
ev_damage_notify(ps, (xcb_damage_notify_event_t *) ev);
|
ev_damage_notify(ps, (xcb_damage_notify_event_t *) ev);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -5296,6 +5298,8 @@ session_init(session_t *ps_old, int argc, char **argv) {
|
||||||
}
|
}
|
||||||
XSetEventQueueOwner(ps->dpy, XCBOwnsEventQueue);
|
XSetEventQueueOwner(ps->dpy, XCBOwnsEventQueue);
|
||||||
}
|
}
|
||||||
|
xcb_connection_t *c = XGetXCBConnection(ps->dpy);
|
||||||
|
const xcb_query_extension_reply_t *ext_info;
|
||||||
|
|
||||||
XSetErrorHandler(xerror);
|
XSetErrorHandler(xerror);
|
||||||
if (ps->o.synchronize) {
|
if (ps->o.synchronize) {
|
||||||
|
@ -5320,6 +5324,8 @@ session_init(session_t *ps_old, int argc, char **argv) {
|
||||||
ps->root_width = DisplayWidth(ps->dpy, ps->scr);
|
ps->root_width = DisplayWidth(ps->dpy, ps->scr);
|
||||||
ps->root_height = DisplayHeight(ps->dpy, ps->scr);
|
ps->root_height = DisplayHeight(ps->dpy, ps->scr);
|
||||||
|
|
||||||
|
xcb_prefetch_extension_data(c, &xcb_damage_id);
|
||||||
|
|
||||||
if (!XRenderQueryExtension(ps->dpy,
|
if (!XRenderQueryExtension(ps->dpy,
|
||||||
&ps->render_event, &ps->render_error)) {
|
&ps->render_event, &ps->render_error)) {
|
||||||
fprintf(stderr, "No render extension\n");
|
fprintf(stderr, "No render extension\n");
|
||||||
|
@ -5343,10 +5349,15 @@ session_init(session_t *ps_old, int argc, char **argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!XDamageQueryExtension(ps->dpy, &ps->damage_event, &ps->damage_error)) {
|
ext_info = xcb_get_extension_data(c, &xcb_damage_id);
|
||||||
|
if (!ext_info || !ext_info->present) {
|
||||||
fprintf(stderr, "No damage extension\n");
|
fprintf(stderr, "No damage extension\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
ps->damage_event = ext_info->first_event;
|
||||||
|
ps->damage_error = ext_info->first_error;
|
||||||
|
xcb_discard_reply(c,
|
||||||
|
xcb_damage_query_version(c, XCB_DAMAGE_MAJOR_VERSION, XCB_DAMAGE_MINOR_VERSION).sequence);
|
||||||
|
|
||||||
if (!XFixesQueryExtension(ps->dpy, &ps->xfixes_event, &ps->xfixes_error)) {
|
if (!XFixesQueryExtension(ps->dpy, &ps->xfixes_event, &ps->xfixes_error)) {
|
||||||
fprintf(stderr, "No XFixes extension\n");
|
fprintf(stderr, "No XFixes extension\n");
|
||||||
|
|
|
@ -157,11 +157,11 @@ free_picture(session_t *ps, Picture *p) {
|
||||||
* Destroy a <code>Damage</code>.
|
* Destroy a <code>Damage</code>.
|
||||||
*/
|
*/
|
||||||
inline static void
|
inline static void
|
||||||
free_damage(session_t *ps, Damage *p) {
|
free_damage(session_t *ps, xcb_damage_damage_t *p) {
|
||||||
if (*p) {
|
if (*p) {
|
||||||
// BadDamage will be thrown if the window is destroyed
|
// BadDamage will be thrown if the window is destroyed
|
||||||
set_ignore_next(ps);
|
set_ignore_next(ps);
|
||||||
XDamageDestroy(ps->dpy, *p);
|
xcb_damage_destroy(XGetXCBConnection(ps->dpy), *p);
|
||||||
*p = None;
|
*p = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -892,7 +892,7 @@ bool add_win(session_t *ps, Window id, Window prev) {
|
||||||
// Create Damage for window
|
// Create Damage for window
|
||||||
new->damage = xcb_generate_id(c);
|
new->damage = xcb_generate_id(c);
|
||||||
xcb_generic_error_t *e = xcb_request_check(c,
|
xcb_generic_error_t *e = xcb_request_check(c,
|
||||||
xcb_damage_create_checked(c, new->damage, id, XDamageReportNonEmpty));
|
xcb_damage_create_checked(c, new->damage, id, XCB_DAMAGE_REPORT_LEVEL_NON_EMPTY));
|
||||||
if (e) {
|
if (e) {
|
||||||
free(e);
|
free(e);
|
||||||
free(new);
|
free(new);
|
||||||
|
|
Loading…
Reference in New Issue