Skip to content

Commit

Permalink
Merge branch 'less-xlib' into next
Browse files Browse the repository at this point in the history
Closes #14
  • Loading branch information
yshui committed Oct 10, 2018
2 parents 6a8df0a + 9bb3327 commit de6e2f5
Show file tree
Hide file tree
Showing 7 changed files with 267 additions and 265 deletions.
8 changes: 7 additions & 1 deletion src/c2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1463,7 +1463,13 @@ c2_match_once_leaf(session_t *ps, win *w, const c2_l_t *pleaf,
idx, 1L, c2_get_atom_type(pleaf), pleaf->format);
Atom atom = winprop_get_int(prop);
if (atom) {
tgt_free = XGetAtomName(ps->dpy, atom);
xcb_get_atom_name_reply_t *reply =
xcb_get_atom_name_reply(ps->c, xcb_get_atom_name(ps->c, atom), NULL);
if (reply) {
tgt_free = strndup(
xcb_get_atom_name_name(reply), xcb_get_atom_name_name_length(reply));
free(reply);
}
}
if (tgt_free) {
tgt = tgt_free;
Expand Down
25 changes: 22 additions & 3 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,8 @@ typedef struct session {
Display *dpy;
/// Default screen.
int scr;
/// XCB connection.
xcb_connection_t *c;
/// Default visual.
xcb_visualid_t vis;
/// Pict formats info
Expand Down Expand Up @@ -1696,12 +1698,29 @@ cxfree(void *data) {
XFree(data);
}

static inline void _Noreturn
die(const char *msg) {
puts(msg);
exit(1);
}

/**
* Wrapper of XInternAtom() for convenience.
*/
static inline Atom
static inline xcb_atom_t
get_atom(session_t *ps, const char *atom_name) {
return XInternAtom(ps->dpy, atom_name, False);
xcb_intern_atom_reply_t *reply =
xcb_intern_atom_reply(ps->c,
xcb_intern_atom(ps->c, False, strlen(atom_name), atom_name),
NULL);

xcb_atom_t atom = XCB_NONE;
if (reply) {
atom = reply->atom;
free(reply);
} else
die("Failed to intern atoms, bail out");
return atom;
}

/**
Expand Down Expand Up @@ -2072,7 +2091,7 @@ xr_sync_(session_t *ps, Drawable d
if (!ps->o.xrender_sync)
return;

XSync(ps->dpy, False);
x_sync(ps->c);
#ifdef CONFIG_XSYNC
if (ps->o.xrender_sync_fence && ps->xsync_exists) {
// TODO: If everybody just follows the rules stated in X Sync prototype,
Expand Down
Loading

0 comments on commit de6e2f5

Please sign in to comment.