A bit more xcb conversion

None -> XCB_NONE
Window -> xcb_window_t
Atom -> xcb_atom_t

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2018-12-27 20:45:38 +00:00
parent 86e744345e
commit 51d03132bf
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
11 changed files with 203 additions and 201 deletions

View File

@ -1362,7 +1362,7 @@ c2_match_once_leaf(session_t *ps, win *w, const c2_l_t *pleaf,
bool *pres, bool *perr) { bool *pres, bool *perr) {
assert(pleaf); assert(pleaf);
const Window wid = (pleaf->tgt_onframe ? w->client_win: w->id); const xcb_window_t wid = (pleaf->tgt_onframe ? w->client_win: w->id);
// Return if wid is missing // Return if wid is missing
if (!pleaf->predef && !wid) if (!pleaf->predef && !wid)

View File

@ -335,11 +335,11 @@ typedef struct glx_prog_main {
struct glx_prog_main { }; struct glx_prog_main { };
#endif #endif
#define PAINT_INIT { .pixmap = None, .pict = None } #define PAINT_INIT { .pixmap = XCB_NONE, .pict = XCB_NONE }
/// Linked list type of atoms. /// Linked list type of atoms.
typedef struct _latom { typedef struct _latom {
Atom atom; xcb_atom_t atom;
struct _latom *next; struct _latom *next;
} latom_t; } latom_t;
@ -439,7 +439,7 @@ typedef struct session {
/// Default depth. /// Default depth.
int depth; int depth;
/// Root window. /// Root window.
Window root; xcb_window_t root;
/// Height of root window. /// Height of root window.
int root_height; int root_height;
/// Width of root window. /// Width of root window.
@ -447,7 +447,7 @@ typedef struct session {
// Damage of root window. // Damage of root window.
// Damage root_damage; // Damage root_damage;
/// X Composite overlay window. Used if <code>--paint-on-overlay</code>. /// X Composite overlay window. Used if <code>--paint-on-overlay</code>.
Window overlay; xcb_window_t overlay;
/// Whether the root tile is filled by compton. /// Whether the root tile is filled by compton.
bool root_tile_fill; bool root_tile_fill;
/// Picture of the root window background. /// Picture of the root window background.
@ -463,7 +463,7 @@ typedef struct session {
paint_t tgt_buffer; paint_t tgt_buffer;
XSyncFence tgt_buffer_fence; XSyncFence tgt_buffer_fence;
/// Window ID of the window we register as a symbol. /// Window ID of the window we register as a symbol.
Window reg_win; xcb_window_t reg_win;
#ifdef CONFIG_OPENGL #ifdef CONFIG_OPENGL
/// Pointer to GLX data. /// Pointer to GLX data.
glx_session_t *psglx; glx_session_t *psglx;
@ -526,7 +526,7 @@ typedef struct session {
win *active_win; win *active_win;
/// Window ID of leader window of currently active window. Used for /// Window ID of leader window of currently active window. Used for
/// subsidiary window detection. /// subsidiary window detection.
Window active_leader; xcb_window_t active_leader;
// === Shadow/dimming related === // === Shadow/dimming related ===
/// 1x1 black Picture. /// 1x1 black Picture.
@ -626,32 +626,32 @@ typedef struct session {
// === Atoms === // === Atoms ===
/// Atom of property <code>_NET_WM_OPACITY</code>. /// Atom of property <code>_NET_WM_OPACITY</code>.
Atom atom_opacity; xcb_atom_t atom_opacity;
/// Atom of <code>_NET_FRAME_EXTENTS</code>. /// Atom of <code>_NET_FRAME_EXTENTS</code>.
Atom atom_frame_extents; xcb_atom_t atom_frame_extents;
/// Property atom to identify top-level frame window. Currently /// Property atom to identify top-level frame window. Currently
/// <code>WM_STATE</code>. /// <code>WM_STATE</code>.
Atom atom_client; xcb_atom_t atom_client;
/// Atom of property <code>WM_NAME</code>. /// Atom of property <code>WM_NAME</code>.
Atom atom_name; xcb_atom_t atom_name;
/// Atom of property <code>_NET_WM_NAME</code>. /// Atom of property <code>_NET_WM_NAME</code>.
Atom atom_name_ewmh; xcb_atom_t atom_name_ewmh;
/// Atom of property <code>WM_CLASS</code>. /// Atom of property <code>WM_CLASS</code>.
Atom atom_class; xcb_atom_t atom_class;
/// Atom of property <code>WM_WINDOW_ROLE</code>. /// Atom of property <code>WM_WINDOW_ROLE</code>.
Atom atom_role; xcb_atom_t atom_role;
/// Atom of property <code>WM_TRANSIENT_FOR</code>. /// Atom of property <code>WM_TRANSIENT_FOR</code>.
Atom atom_transient; xcb_atom_t atom_transient;
/// Atom of property <code>WM_CLIENT_LEADER</code>. /// Atom of property <code>WM_CLIENT_LEADER</code>.
Atom atom_client_leader; xcb_atom_t atom_client_leader;
/// Atom of property <code>_NET_ACTIVE_WINDOW</code>. /// Atom of property <code>_NET_ACTIVE_WINDOW</code>.
Atom atom_ewmh_active_win; xcb_atom_t atom_ewmh_active_win;
/// Atom of property <code>_COMPTON_SHADOW</code>. /// Atom of property <code>_COMPTON_SHADOW</code>.
Atom atom_compton_shadow; xcb_atom_t atom_compton_shadow;
/// Atom of property <code>_NET_WM_WINDOW_TYPE</code>. /// Atom of property <code>_NET_WM_WINDOW_TYPE</code>.
Atom atom_win_type; xcb_atom_t atom_win_type;
/// Array of atoms of all possible window types. /// Array of atoms of all possible window types.
Atom atoms_wintypes[NUM_WINTYPES]; xcb_atom_t atoms_wintypes[NUM_WINTYPES];
/// Linked list of additional atoms to track. /// Linked list of additional atoms to track.
latom_t *track_atom_lst; latom_t *track_atom_lst;
@ -888,7 +888,7 @@ get_atom(session_t *ps, const char *atom_name) {
/** /**
* Return the painting target window. * Return the painting target window.
*/ */
static inline Window static inline xcb_window_t
get_tgt_window(session_t *ps) { get_tgt_window(session_t *ps) {
return ps->overlay != XCB_NONE ? ps->overlay: ps->root; return ps->overlay != XCB_NONE ? ps->overlay: ps->root;
} }
@ -897,7 +897,7 @@ get_tgt_window(session_t *ps) {
* Find a window from window id in window linked list of the session. * Find a window from window id in window linked list of the session.
*/ */
static inline win * static inline win *
find_win(session_t *ps, Window id) { find_win(session_t *ps, xcb_window_t id) {
if (!id) if (!id)
return NULL; return NULL;
@ -918,7 +918,7 @@ find_win(session_t *ps, Window id) {
* @return struct win object of the found window, NULL if not found * @return struct win object of the found window, NULL if not found
*/ */
static inline win * static inline win *
find_toplevel(session_t *ps, Window id) { find_toplevel(session_t *ps, xcb_window_t id) {
if (!id) if (!id)
return NULL; return NULL;
@ -977,7 +977,7 @@ static inline void
free_fence(session_t *ps, XSyncFence *pfence) { free_fence(session_t *ps, XSyncFence *pfence) {
if (*pfence) if (*pfence)
XSyncDestroyFence(ps->dpy, *pfence); XSyncDestroyFence(ps->dpy, *pfence);
*pfence = None; *pfence = XCB_NONE;
} }
/** /**
@ -1045,21 +1045,25 @@ win_is_solid(session_t *ps, const win *w) {
* @param ps current session * @param ps current session
* @param w window to check * @param w window to check
* @param atom atom of property to check * @param atom atom of property to check
* @return 1 if it has the attribute, 0 otherwise * @return true if it has the attribute, false otherwise
*/ */
static inline bool static inline bool
wid_has_prop(const session_t *ps, Window w, Atom atom) { wid_has_prop(const session_t *ps, xcb_window_t w, xcb_atom_t atom) {
Atom type = None; auto r =
int format; xcb_get_property_reply(ps->c,
unsigned long nitems, after; xcb_get_property(ps->c, 0, w, atom,
unsigned char *data; XCB_GET_PROPERTY_TYPE_ANY, 0, 0),
NULL);
if (Success == XGetWindowProperty(ps->dpy, w, atom, 0, 0, False, if (!r) {
AnyPropertyType, &type, &format, &nitems, &after, &data)) { return false;
cxfree(data);
if (type) return true;
} }
auto rtype = r->type;
free(r);
if (rtype != XCB_NONE) {
return true;
}
return false; return false;
} }
@ -1084,10 +1088,6 @@ winprop_get_int(winprop_t prop) {
return tgt; return tgt;
} }
bool
wid_get_text_prop(session_t *ps, Window wid, Atom prop,
char ***pstrlst, int *pnstr);
void void
force_repaint(session_t *ps); force_repaint(session_t *ps);

View File

@ -85,7 +85,7 @@ static double
get_opacity_percent(win *w); get_opacity_percent(win *w);
static void static void
restack_win(session_t *ps, win *w, Window new_above); restack_win(session_t *ps, win *w, xcb_window_t new_above);
static void static void
update_ewmh_active_win(session_t *ps); update_ewmh_active_win(session_t *ps);
@ -300,7 +300,7 @@ cxinerama_upd_scrs(session_t *ps) {
* XXX move to win.c * XXX move to win.c
*/ */
static inline win * static inline win *
find_win_all(session_t *ps, const Window wid) { find_win_all(session_t *ps, const xcb_window_t wid) {
if (!wid || PointerRoot == wid || wid == ps->root || wid == ps->overlay) if (!wid || PointerRoot == wid || wid == ps->root || wid == ps->overlay)
return NULL; return NULL;
@ -422,7 +422,7 @@ should_ignore(session_t *ps, unsigned long sequence) {
/** /**
* Determine the event mask for a window. * Determine the event mask for a window.
*/ */
long determine_evmask(session_t *ps, Window wid, win_evmode_t mode) { long determine_evmask(session_t *ps, xcb_window_t wid, win_evmode_t mode) {
long evmask = 0; long evmask = 0;
win *w = NULL; win *w = NULL;
@ -452,7 +452,7 @@ long determine_evmask(session_t *ps, Window wid, win_evmode_t mode) {
* @param wid window ID * @param wid window ID
* @return struct _win object of the found window, NULL if not found * @return struct _win object of the found window, NULL if not found
*/ */
win *find_toplevel2(session_t *ps, Window wid) { win *find_toplevel2(session_t *ps, xcb_window_t wid) {
// TODO this should probably be an "update tree", then find_toplevel. // TODO this should probably be an "update tree", then find_toplevel.
// current approach is a bit more "racy" // current approach is a bit more "racy"
win *w = NULL; win *w = NULL;
@ -506,7 +506,7 @@ recheck_focus(session_t *ps) {
win *w = find_win_all(ps, wid); win *w = find_win_all(ps, wid);
log_trace("%#010" PRIx32 " (%#010lx \"%s\") focused.", wid, log_trace("%#010" PRIx32 " (%#010lx \"%s\") focused.", wid,
(w ? w->id: None), (w ? w->name: NULL)); (w ? w->id: XCB_NONE), (w ? w->name: NULL));
// And we set the focus state here // And we set the focus state here
if (w) { if (w) {
@ -833,7 +833,7 @@ finish_map_win(session_t *ps, win **_w) {
} }
void void
map_win(session_t *ps, Window id) { map_win(session_t *ps, xcb_window_t id) {
// Unmap overlay window if it got mapped but we are currently not // Unmap overlay window if it got mapped but we are currently not
// in redirected state. // in redirected state.
if (ps->overlay && id == ps->overlay && !ps->redirected) { if (ps->overlay && id == ps->overlay && !ps->redirected) {
@ -843,7 +843,7 @@ map_win(session_t *ps, Window id) {
win *w = find_win(ps, id); win *w = find_win(ps, id);
log_trace("(%#010lx \"%s\"): %p", id, (w ? w->name: NULL), w); log_trace("(%#010x \"%s\"): %p", id, (w ? w->name: NULL), w);
// Don't care about window mapping if it's an InputOnly window // Don't care about window mapping if it's an InputOnly window
// Try avoiding mapping a window twice // Try avoiding mapping a window twice
@ -885,7 +885,7 @@ map_win(session_t *ps, Window id) {
assert(w->client_win); assert(w->client_win);
log_trace("(%#010lx): type %s", w->id, WINTYPES[w->window_type]); log_trace("(%#010x): type %s", w->id, WINTYPES[w->window_type]);
// FocusIn/Out may be ignored when the window is unmapped, so we must // FocusIn/Out may be ignored when the window is unmapped, so we must
// recheck focus here // recheck focus here
@ -988,13 +988,13 @@ unmap_win(session_t *ps, win **_w) {
} }
static void static void
restack_win(session_t *ps, win *w, Window new_above) { restack_win(session_t *ps, win *w, xcb_window_t new_above) {
Window old_above; xcb_window_t old_above;
if (w->next) { if (w->next) {
old_above = w->next->id; old_above = w->next->id;
} else { } else {
old_above = None; old_above = XCB_NONE;
} }
if (old_above != new_above) { if (old_above != new_above) {
@ -1025,7 +1025,7 @@ restack_win(session_t *ps, win *w, Window new_above) {
} }
if (new_above && !found) { if (new_above && !found) {
log_error("(%#010lx, %#010lx): Failed to found new above window.", w->id, new_above); log_error("(%#010x, %#010x): Failed to found new above window.", w->id, new_above);
return; return;
} }
@ -1174,14 +1174,14 @@ configure_win(session_t *ps, xcb_configure_notify_event_t *ce) {
static void static void
circulate_win(session_t *ps, xcb_circulate_notify_event_t *ce) { circulate_win(session_t *ps, xcb_circulate_notify_event_t *ce) {
win *w = find_win(ps, ce->window); win *w = find_win(ps, ce->window);
Window new_above; xcb_window_t new_above;
if (!w) return; if (!w) return;
if (ce->place == PlaceOnTop) { if (ce->place == PlaceOnTop) {
new_above = ps->list->id; new_above = ps->list->id;
} else { } else {
new_above = None; new_above = XCB_NONE;
} }
restack_win(ps, w, new_above); restack_win(ps, w, new_above);
@ -1193,11 +1193,11 @@ finish_destroy_win(session_t *ps, win **_w) {
assert(w->destroyed); assert(w->destroyed);
win **prev = NULL, *i = NULL; win **prev = NULL, *i = NULL;
log_trace("(%#010lx): Starting...", w->id); log_trace("(%#010x): Starting...", w->id);
for (prev = &ps->list; (i = *prev); prev = &i->next) { for (prev = &ps->list; (i = *prev); prev = &i->next) {
if (w == i) { if (w == i) {
log_trace("(%#010lx \"%s\"): %p", w->id, w->name, w); log_trace("(%#010x \"%s\"): %p", w->id, w->name, w);
finish_unmap_win(ps, _w); finish_unmap_win(ps, _w);
*prev = w->next; *prev = w->next;
@ -1222,10 +1222,10 @@ finish_destroy_win(session_t *ps, win **_w) {
} }
static void static void
destroy_win(session_t *ps, Window id) { destroy_win(session_t *ps, xcb_window_t id) {
win *w = find_win(ps, id); win *w = find_win(ps, id);
log_trace("(%#010lx \"%s\"): %p", id, (w ? w->name: NULL), w); log_trace("(%#010x \"%s\"): %p", id, (w ? w->name: NULL), w);
if (w) { if (w) {
unmap_win(ps, &w); unmap_win(ps, &w);
@ -1428,7 +1428,7 @@ ev_name(session_t *ps, xcb_generic_event_t *ev) {
return buf; return buf;
} }
static inline Window attr_unused static inline xcb_window_t attr_unused
ev_window(session_t *ps, xcb_generic_event_t *ev) { ev_window(session_t *ps, xcb_generic_event_t *ev) {
switch (ev->response_type) { switch (ev->response_type) {
case FocusIn: case FocusIn:
@ -1643,7 +1643,7 @@ ev_expose(session_t *ps, xcb_expose_event_t *ev) {
static void static void
update_ewmh_active_win(session_t *ps) { update_ewmh_active_win(session_t *ps) {
// Search for the window // Search for the window
Window wid = wid_get_prop_window(ps, ps->root, ps->atom_ewmh_active_win); xcb_window_t wid = wid_get_prop_window(ps, ps->root, ps->atom_ewmh_active_win);
win *w = find_win_all(ps, wid); win *w = find_win_all(ps, wid);
// Mark the window focused. No need to unfocus the previous one. // Mark the window focused. No need to unfocus the previous one.
@ -1860,7 +1860,7 @@ ev_selection_clear(session_t *ps,
* Get a window's name from window ID. * Get a window's name from window ID.
*/ */
static inline void attr_unused static inline void attr_unused
ev_window_name(session_t *ps, Window wid, char **name) { ev_window_name(session_t *ps, xcb_window_t wid, char **name) {
*name = ""; *name = "";
if (wid) { if (wid) {
*name = "(Failed to get title)"; *name = "(Failed to get title)";
@ -1891,7 +1891,7 @@ ev_handle(session_t *ps, xcb_generic_event_t *ev) {
#ifdef DEBUG_EVENTS #ifdef DEBUG_EVENTS
if (ev->response_type != ps->damage_event + XCB_DAMAGE_NOTIFY) { if (ev->response_type != ps->damage_event + XCB_DAMAGE_NOTIFY) {
Window wid = ev_window(ps, ev); xcb_window_t 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);
@ -1994,7 +1994,7 @@ register_cm(session_t *ps) {
assert(!ps->reg_win); assert(!ps->reg_win);
ps->reg_win = XCreateSimpleWindow(ps->dpy, ps->root, 0, 0, 1, 1, 0, ps->reg_win = XCreateSimpleWindow(ps->dpy, ps->root, 0, 0, 1, 1, 0,
None, None); XCB_NONE, XCB_NONE);
if (!ps->reg_win) { if (!ps->reg_win) {
log_fatal("Failed to create window."); log_fatal("Failed to create window.");
@ -2072,7 +2072,7 @@ fork_after(session_t *ps) {
#ifdef CONFIG_OPENGL #ifdef CONFIG_OPENGL
// GLX context must be released and reattached on fork // GLX context must be released and reattached on fork
if (glx_has_context(ps) && !glXMakeCurrent(ps->dpy, None, NULL)) { if (glx_has_context(ps) && !glXMakeCurrent(ps->dpy, XCB_NONE, NULL)) {
log_fatal("Failed to detach GLX context."); log_fatal("Failed to detach GLX context.");
return false; return false;
} }
@ -2293,7 +2293,7 @@ init_overlay(session_t *ps) {
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 = %#010lx", ps->overlay); log_debug("overlay = %#010x", ps->overlay);
return ps->overlay; return ps->overlay;
} }
@ -2542,16 +2542,16 @@ session_init(session_t *ps_old, int argc, char **argv) {
.c = NULL, .c = NULL,
.vis = 0, .vis = 0,
.depth = 0, .depth = 0,
.root = None, .root = XCB_NONE,
.root_height = 0, .root_height = 0,
.root_width = 0, .root_width = 0,
// .root_damage = None, // .root_damage = XCB_NONE,
.overlay = None, .overlay = XCB_NONE,
.root_tile_fill = false, .root_tile_fill = false,
.root_tile_paint = PAINT_INIT, .root_tile_paint = PAINT_INIT,
.tgt_picture = None, .tgt_picture = XCB_NONE,
.tgt_buffer = PAINT_INIT, .tgt_buffer = PAINT_INIT,
.reg_win = None, .reg_win = XCB_NONE,
#ifdef CONFIG_OPENGL #ifdef CONFIG_OPENGL
.glx_prog_win = GLX_PROG_MAIN_INIT, .glx_prog_win = GLX_PROG_MAIN_INIT,
#endif #endif
@ -2571,7 +2571,7 @@ session_init(session_t *ps_old, int argc, char **argv) {
.stoppaint_force = UNSET, .stoppaint_force = UNSET,
.dbus = false, .dbus = false,
.benchmark = 0, .benchmark = 0,
.benchmark_wid = None, .benchmark_wid = XCB_NONE,
.logpath = NULL, .logpath = NULL,
.refresh_rate = 0, .refresh_rate = 0,
@ -2639,11 +2639,11 @@ session_init(session_t *ps_old, int argc, char **argv) {
.list = NULL, .list = NULL,
.active_win = NULL, .active_win = NULL,
.active_leader = None, .active_leader = XCB_NONE,
.black_picture = None, .black_picture = XCB_NONE,
.cshadow_picture = None, .cshadow_picture = XCB_NONE,
.white_picture = None, .white_picture = XCB_NONE,
.gaussian_map = NULL, .gaussian_map = NULL,
.cgsize = 0, .cgsize = 0,
.shadow_corner = NULL, .shadow_corner = NULL,
@ -2680,17 +2680,17 @@ session_init(session_t *ps_old, int argc, char **argv) {
#endif #endif
.xrfilter_convolution_exists = false, .xrfilter_convolution_exists = false,
.atom_opacity = None, .atom_opacity = XCB_NONE,
.atom_frame_extents = None, .atom_frame_extents = XCB_NONE,
.atom_client = None, .atom_client = XCB_NONE,
.atom_name = None, .atom_name = XCB_NONE,
.atom_name_ewmh = None, .atom_name_ewmh = XCB_NONE,
.atom_class = None, .atom_class = XCB_NONE,
.atom_role = None, .atom_role = XCB_NONE,
.atom_transient = None, .atom_transient = XCB_NONE,
.atom_ewmh_active_win = None, .atom_ewmh_active_win = XCB_NONE,
.atom_compton_shadow = None, .atom_compton_shadow = XCB_NONE,
.atom_win_type = None, .atom_win_type = XCB_NONE,
.atoms_wintypes = { 0 }, .atoms_wintypes = { 0 },
.track_atom_lst = NULL, .track_atom_lst = NULL,
@ -3145,10 +3145,10 @@ session_destroy(session_t *ps) {
// Free tgt_{buffer,picture} and root_picture // Free tgt_{buffer,picture} and root_picture
if (ps->tgt_buffer.pict == ps->tgt_picture) if (ps->tgt_buffer.pict == ps->tgt_picture)
ps->tgt_buffer.pict = None; ps->tgt_buffer.pict = XCB_NONE;
if (ps->tgt_picture == ps->root_picture) if (ps->tgt_picture == ps->root_picture)
ps->tgt_picture = None; ps->tgt_picture = XCB_NONE;
else else
free_picture(ps->c, &ps->tgt_picture); free_picture(ps->c, &ps->tgt_picture);
free_fence(ps, &ps->tgt_buffer_fence); free_fence(ps, &ps->tgt_buffer_fence);
@ -3186,13 +3186,13 @@ session_destroy(session_t *ps) {
// Release overlay window // Release overlay window
if (ps->overlay) { if (ps->overlay) {
xcb_composite_release_overlay_window(ps->c, ps->overlay); xcb_composite_release_overlay_window(ps->c, ps->overlay);
ps->overlay = None; ps->overlay = XCB_NONE;
} }
// Free reg_win // Free reg_win
if (ps->reg_win) { if (ps->reg_win) {
xcb_destroy_window(ps->c, ps->reg_win); xcb_destroy_window(ps->c, ps->reg_win);
ps->reg_win = None; ps->reg_win = XCB_NONE;
} }
// Flush all events // Flush all events

View File

@ -45,14 +45,14 @@
void add_damage(session_t *ps, const region_t *damage); void add_damage(session_t *ps, const region_t *damage);
long determine_evmask(session_t *ps, Window wid, win_evmode_t mode); long determine_evmask(session_t *ps, xcb_window_t wid, win_evmode_t mode);
xcb_window_t xcb_window_t
find_client_win(session_t *ps, xcb_window_t w); find_client_win(session_t *ps, xcb_window_t w);
win *find_toplevel2(session_t *ps, Window wid); win *find_toplevel2(session_t *ps, xcb_window_t wid);
void map_win(session_t *ps, Window id); void map_win(session_t *ps, xcb_window_t id);
/** /**
* Subtract two unsigned long values. * Subtract two unsigned long values.
@ -84,7 +84,7 @@ wintype_arr_enable_unset(switch_t arr[]) {
* @param wid window ID to search for * @param wid window ID to search for
*/ */
static inline bool static inline bool
array_wid_exists(const Window *arr, int count, Window wid) { array_wid_exists(const xcb_window_t *arr, int count, xcb_window_t wid) {
while (count--) { while (count--) {
if (arr[count] == wid) { if (arr[count] == wid) {
return true; return true;
@ -131,7 +131,7 @@ make_text_prop(session_t *ps, char *str) {
* Set a single-string text property on a window. * Set a single-string text property on a window.
*/ */
static inline bool static inline bool
wid_set_text_prop(session_t *ps, Window wid, Atom prop_atom, char *str) { wid_set_text_prop(session_t *ps, xcb_window_t wid, xcb_atom_t prop_atom, char *str) {
XTextProperty *pprop = make_text_prop(ps, str); XTextProperty *pprop = make_text_prop(ps, str);
if (!pprop) { if (!pprop) {
log_error("Failed to make text property: %s.", str); log_error("Failed to make text property: %s.", str);
@ -149,18 +149,15 @@ wid_set_text_prop(session_t *ps, Window wid, Atom prop_atom, char *str) {
* Dump an drawable's info. * Dump an drawable's info.
*/ */
static inline void static inline void
dump_drawable(session_t *ps, Drawable drawable) { dump_drawable(session_t *ps, xcb_drawable_t drawable) {
Window rroot = None; auto r = xcb_get_geometry_reply(ps->c, xcb_get_geometry(ps->c, drawable), NULL);
int x = 0, y = 0; if (!r) {
unsigned width = 0, height = 0, border = 0, depth = 0; log_trace("Drawable %#010x: Failed", drawable);
if (XGetGeometry(ps->dpy, drawable, &rroot, &x, &y, &width, &height, return;
&border, &depth)) {
log_trace("Drawable %#010lx: x = %u, y = %u, wid = %u, hei = %d, b = %u, d = %u",
drawable, x, y, width, height, border, depth);
}
else {
log_trace("Drawable %#010lx: Failed", drawable);
} }
log_trace("Drawable %#010x: x = %u, y = %u, wid = %u, hei = %d, b = %u, d = %u",
drawable, r->x, r->y, r->width, r->height, r->border_width, r->depth);
free(r);
} }
/** /**

View File

@ -119,7 +119,7 @@ typedef struct options_t {
/// Number of cycles to paint in benchmark mode. 0 for disabled. /// Number of cycles to paint in benchmark mode. 0 for disabled.
int benchmark; int benchmark;
/// Window to constantly repaint in benchmark mode. 0 for full-screen. /// Window to constantly repaint in benchmark mode. 0 for full-screen.
Window benchmark_wid; xcb_window_t benchmark_wid;
/// A list of conditions of windows not to paint. /// A list of conditions of windows not to paint.
c2_lptr_t *paint_blacklist; c2_lptr_t *paint_blacklist;
/// Whether to show all X errors. /// Whether to show all X errors.

View File

@ -432,7 +432,7 @@ cdbus_apdarg_double(session_t *ps, DBusMessage *msg, const void *data) {
static bool static bool
cdbus_apdarg_wid(session_t *ps, DBusMessage *msg, const void *data) { cdbus_apdarg_wid(session_t *ps, DBusMessage *msg, const void *data) {
assert(data); assert(data);
cdbus_window_t val = *(const Window *)data; cdbus_window_t val = *(const xcb_window_t *)data;
if (!dbus_message_append_args(msg, CDBUS_TYPE_WINDOW, &val, if (!dbus_message_append_args(msg, CDBUS_TYPE_WINDOW, &val,
DBUS_TYPE_INVALID)) { DBUS_TYPE_INVALID)) {
@ -565,7 +565,7 @@ cdbus_signal(session_t *ps, const char *name,
* Send a signal with a Window ID as argument. * Send a signal with a Window ID as argument.
*/ */
static inline bool static inline bool
cdbus_signal_wid(session_t *ps, const char *name, Window wid) { cdbus_signal_wid(session_t *ps, const char *name, xcb_window_t wid) {
return cdbus_signal(ps, name, cdbus_apdarg_wid, &wid); return cdbus_signal(ps, name, cdbus_apdarg_wid, &wid);
} }
@ -648,7 +648,7 @@ cdbus_reply_double(session_t *ps, DBusMessage *srcmsg, double val) {
* Send a reply with a wid argument. * Send a reply with a wid argument.
*/ */
static inline bool static inline bool
cdbus_reply_wid(session_t *ps, DBusMessage *srcmsg, Window wid) { cdbus_reply_wid(session_t *ps, DBusMessage *srcmsg, xcb_window_t wid) {
return cdbus_reply(ps, srcmsg, cdbus_apdarg_wid, &wid); return cdbus_reply(ps, srcmsg, cdbus_apdarg_wid, &wid);
} }
@ -754,7 +754,7 @@ cdbus_process_list_win(session_t *ps, DBusMessage *msg) {
*/ */
static bool static bool
cdbus_process_win_get(session_t *ps, DBusMessage *msg) { cdbus_process_win_get(session_t *ps, DBusMessage *msg) {
cdbus_window_t wid = None; cdbus_window_t wid = XCB_NONE;
const char *target = NULL; const char *target = NULL;
DBusError err = { }; DBusError err = { };
@ -858,7 +858,7 @@ cdbus_process_win_get(session_t *ps, DBusMessage *msg) {
*/ */
static bool static bool
cdbus_process_win_set(session_t *ps, DBusMessage *msg) { cdbus_process_win_set(session_t *ps, DBusMessage *msg) {
cdbus_window_t wid = None; cdbus_window_t wid = XCB_NONE;
const char *target = NULL; const char *target = NULL;
DBusError err = { }; DBusError err = { };
@ -942,11 +942,11 @@ cdbus_process_find_win(session_t *ps, DBusMessage *msg) {
if (!cdbus_msg_get_arg(msg, 0, DBUS_TYPE_STRING, &target)) if (!cdbus_msg_get_arg(msg, 0, DBUS_TYPE_STRING, &target))
return false; return false;
Window wid = None; xcb_window_t wid = XCB_NONE;
// Find window by client window // Find window by client window
if (!strcmp("client", target)) { if (!strcmp("client", target)) {
cdbus_window_t client = None; cdbus_window_t client = XCB_NONE;
if (!cdbus_msg_get_arg(msg, 1, CDBUS_TYPE_WINDOW, &client)) if (!cdbus_msg_get_arg(msg, 1, CDBUS_TYPE_WINDOW, &client))
return false; return false;
win *w = find_toplevel(ps, client); win *w = find_toplevel(ps, client);

View File

@ -71,7 +71,7 @@ static inline void attr_nonnull(1, 2) set_tgt_clip(session_t *ps, region_t *reg)
void free_picture(xcb_connection_t *c, xcb_render_picture_t *p) { void free_picture(xcb_connection_t *c, xcb_render_picture_t *p) {
if (*p) { if (*p) {
xcb_render_free_picture(c, *p); xcb_render_free_picture(c, *p);
*p = None; *p = XCB_NONE;
} }
} }
@ -147,7 +147,7 @@ static inline bool paint_isvalid(session_t *ps, const paint_t *ppaint) {
return false; return false;
#ifdef CONFIG_OPENGL #ifdef CONFIG_OPENGL
if (BKEND_GLX == ps->o.backend && !glx_tex_binded(ppaint->ptex, None)) if (BKEND_GLX == ps->o.backend && !glx_tex_binded(ppaint->ptex, XCB_NONE))
return false; return false;
#endif #endif
@ -192,12 +192,12 @@ void paint_one(session_t *ps, win *w, const region_t *reg_paint) {
// causing the jittering issue M4he reported in #7. // causing the jittering issue M4he reported in #7.
if (!paint_bind_tex(ps, &w->paint, 0, 0, 0, if (!paint_bind_tex(ps, &w->paint, 0, 0, 0,
(!ps->o.glx_no_rebind_pixmap && w->pixmap_damaged))) { (!ps->o.glx_no_rebind_pixmap && w->pixmap_damaged))) {
log_error("Failed to bind texture for window %#010lx.", w->id); log_error("Failed to bind texture for window %#010x.", w->id);
} }
w->pixmap_damaged = false; w->pixmap_damaged = false;
if (!paint_isvalid(ps, &w->paint)) { if (!paint_isvalid(ps, &w->paint)) {
log_error("Window %#010lx is missing painting data.", w->id); log_error("Window %#010x is missing painting data.", w->id);
return; return;
} }
@ -223,16 +223,16 @@ void paint_one(session_t *ps, win *w, const region_t *reg_paint) {
pixman_region32_fini(&reg); pixman_region32_fini(&reg);
} }
xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_SRC, pict, None, xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_SRC, pict, XCB_NONE,
newpict, 0, 0, 0, 0, 0, 0, wid, hei); newpict, 0, 0, 0, 0, 0, 0, wid, hei);
xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_DIFFERENCE, xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_DIFFERENCE,
ps->white_picture, None, newpict, 0, 0, 0, 0, ps->white_picture, XCB_NONE, newpict, 0, 0, 0, 0,
0, 0, wid, hei); 0, 0, wid, hei);
// We use an extra PictOpInReverse operation to get correct // We use an extra PictOpInReverse operation to get correct
// pixel alpha. There could be a better solution. // pixel alpha. There could be a better solution.
if (win_has_alpha(w)) if (win_has_alpha(w))
xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_IN_REVERSE, xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_IN_REVERSE,
pict, None, newpict, 0, 0, 0, 0, 0, pict, XCB_NONE, newpict, 0, 0, 0, 0, 0,
0, wid, hei); 0, wid, hei);
pict = newpict; pict = newpict;
} }
@ -367,7 +367,7 @@ static bool get_root_tile(session_t *ps) {
ps->root_tile_fill = false; ps->root_tile_fill = false;
bool fill = false; bool fill = false;
xcb_pixmap_t pixmap = None; xcb_pixmap_t pixmap = XCB_NONE;
// Get the values of background attributes // Get the values of background attributes
for (int p = 0; background_props_str[p]; p++) { for (int p = 0; background_props_str[p]; p++) {
@ -566,14 +566,14 @@ static bool win_build_shadow(session_t *ps, win *w, double opacity) {
// log_trace("(): building shadow for %s %d %d", w->name, width, height); // log_trace("(): building shadow for %s %d %d", w->name, width, height);
xcb_image_t *shadow_image = NULL; xcb_image_t *shadow_image = NULL;
xcb_pixmap_t shadow_pixmap = None, shadow_pixmap_argb = None; xcb_pixmap_t shadow_pixmap = XCB_NONE, shadow_pixmap_argb = XCB_NONE;
xcb_render_picture_t shadow_picture = None, shadow_picture_argb = None; xcb_render_picture_t shadow_picture = XCB_NONE, shadow_picture_argb = XCB_NONE;
xcb_gcontext_t gc = None; xcb_gcontext_t gc = XCB_NONE;
shadow_image = make_shadow(ps, opacity, width, height); shadow_image = make_shadow(ps, opacity, width, height);
if (!shadow_image) { if (!shadow_image) {
log_error("failed to make shadow"); log_error("failed to make shadow");
return None; return XCB_NONE;
} }
shadow_pixmap = shadow_pixmap =
@ -641,7 +641,7 @@ static inline void win_paint_shadow(session_t *ps, win *w, region_t *reg_paint)
paint_bind_tex(ps, &w->shadow_paint, 0, 0, 32, false); paint_bind_tex(ps, &w->shadow_paint, 0, 0, 32, false);
if (!paint_isvalid(ps, &w->shadow_paint)) { if (!paint_isvalid(ps, &w->shadow_paint)) {
log_error("Window %#010lx is missing shadow data.", w->id); log_error("Window %#010x is missing shadow data.", w->id);
return; return;
} }
@ -709,7 +709,7 @@ xr_blur_dst(session_t *ps, xcb_render_picture_t tgt_buffer, int x, int y, int wi
xcb_render_set_picture_filter( xcb_render_set_picture_filter(
ps->c, src_pict, strlen(XRFILTER_CONVOLUTION), XRFILTER_CONVOLUTION, ps->c, src_pict, strlen(XRFILTER_CONVOLUTION), XRFILTER_CONVOLUTION,
kwid * khei + 2, convolution_blur); kwid * khei + 2, convolution_blur);
xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_SRC, src_pict, None, xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_SRC, src_pict, XCB_NONE,
dst_pict, (rd_from_tgt ? x : 0), dst_pict, (rd_from_tgt ? x : 0),
(rd_from_tgt ? y : 0), 0, 0, (rd_from_tgt ? 0 : x), (rd_from_tgt ? y : 0), 0, 0, (rd_from_tgt ? 0 : x),
(rd_from_tgt ? 0 : y), wid, hei); (rd_from_tgt ? 0 : y), wid, hei);
@ -723,7 +723,7 @@ xr_blur_dst(session_t *ps, xcb_render_picture_t tgt_buffer, int x, int y, int wi
} }
if (src_pict != tgt_buffer) if (src_pict != tgt_buffer)
xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_SRC, src_pict, None, xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_SRC, src_pict, XCB_NONE,
tgt_buffer, 0, 0, 0, 0, x, y, wid, hei); tgt_buffer, 0, 0, 0, 0, x, y, wid, hei);
free_picture(ps->c, &tmp_picture); free_picture(ps->c, &tmp_picture);
@ -995,7 +995,7 @@ void paint_all(session_t *ps, region_t *region, const region_t *region_real, win
xcb_render_picture_t new_pict = x_create_picture_with_pictfmt( xcb_render_picture_t new_pict = x_create_picture_with_pictfmt(
ps, ps->root_width, ps->root_height, pictfmt, 0, NULL); ps, ps->root_width, ps->root_height, pictfmt, 0, NULL);
xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_SRC, xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_SRC,
ps->tgt_buffer.pict, None, new_pict, 0, 0, 0, ps->tgt_buffer.pict, XCB_NONE, new_pict, 0, 0, 0,
0, 0, 0, ps->root_width, ps->root_height); 0, 0, 0, ps->root_width, ps->root_height);
// Next, we set the region of paint and highlight it // Next, we set the region of paint and highlight it
@ -1008,12 +1008,12 @@ void paint_all(session_t *ps, region_t *region, const region_t *region_real, win
// Finally, clear clip region and put the whole thing on screen // Finally, clear clip region and put the whole thing on screen
x_set_picture_clip_region(ps, new_pict, 0, 0, &ps->screen_reg); x_set_picture_clip_region(ps, new_pict, 0, 0, &ps->screen_reg);
xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_SRC, new_pict, xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_SRC, new_pict,
None, ps->tgt_picture, 0, 0, 0, 0, 0, 0, XCB_NONE, ps->tgt_picture, 0, 0, 0, 0, 0, 0,
ps->root_width, ps->root_height); ps->root_width, ps->root_height);
xcb_render_free_picture(ps->c, new_pict); xcb_render_free_picture(ps->c, new_pict);
} else } else
xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_SRC, xcb_render_composite(ps->c, XCB_RENDER_PICT_OP_SRC,
ps->tgt_buffer.pict, None, ps->tgt_picture, ps->tgt_buffer.pict, XCB_NONE, ps->tgt_picture,
0, 0, 0, 0, 0, 0, ps->root_width, 0, 0, 0, 0, 0, 0, ps->root_width,
ps->root_height); ps->root_height);
break; break;
@ -1299,7 +1299,7 @@ void free_root_tile(session_t *ps) {
xcb_free_pixmap(ps->c, ps->root_tile_paint.pixmap); xcb_free_pixmap(ps->c, ps->root_tile_paint.pixmap);
ps->root_tile_paint.pixmap = XCB_NONE; ps->root_tile_paint.pixmap = XCB_NONE;
} }
ps->root_tile_paint.pixmap = None; ps->root_tile_paint.pixmap = XCB_NONE;
ps->root_tile_fill = false; ps->root_tile_fill = false;
} }

View File

@ -39,18 +39,18 @@
static inline void static inline void
clear_cache_win_leaders(session_t *ps) { clear_cache_win_leaders(session_t *ps) {
for (win *w = ps->list; w; w = w->next) for (win *w = ps->list; w; w = w->next)
w->cache_leader = None; w->cache_leader = XCB_NONE;
} }
static inline void static inline void
wid_set_opacity_prop(session_t *ps, Window wid, opacity_t val) { wid_set_opacity_prop(session_t *ps, xcb_window_t wid, opacity_t val) {
const uint32_t v = val; const uint32_t v = val;
xcb_change_property(ps->c, XCB_PROP_MODE_REPLACE, wid, ps->atom_opacity, xcb_change_property(ps->c, XCB_PROP_MODE_REPLACE, wid, ps->atom_opacity,
XCB_ATOM_CARDINAL, 32, 1, &v); XCB_ATOM_CARDINAL, 32, 1, &v);
} }
static inline void static inline void
wid_rm_opacity_prop(session_t *ps, Window wid) { wid_rm_opacity_prop(session_t *ps, xcb_window_t wid) {
xcb_delete_property(ps->c, wid, ps->atom_opacity); xcb_delete_property(ps->c, wid, ps->atom_opacity);
} }
@ -60,7 +60,7 @@ wid_rm_opacity_prop(session_t *ps, Window wid) {
* @param leader leader window ID * @param leader leader window ID
*/ */
static inline void static inline void
group_update_focused(session_t *ps, Window leader) { group_update_focused(session_t *ps, xcb_window_t leader) {
if (!leader) if (!leader)
return; return;
@ -79,7 +79,7 @@ group_update_focused(session_t *ps, Window leader) {
* @return true if the window group is focused, false otherwise * @return true if the window group is focused, false otherwise
*/ */
static inline bool static inline bool
group_is_focused(session_t *ps, Window leader) { group_is_focused(session_t *ps, xcb_window_t leader) {
if (!leader) if (!leader)
return false; return false;
@ -145,7 +145,7 @@ void win_rounded_corners(session_t *ps, win *w) {
if (!w->bounding_shaped) if (!w->bounding_shaped)
return; return;
// Quit if border_size() returns None // Quit if border_size() returns XCB_NONE
if (!pixman_region32_not_empty(&w->bounding_shape)) if (!pixman_region32_not_empty(&w->bounding_shape))
return; return;
@ -170,7 +170,7 @@ void win_rounded_corners(session_t *ps, win *w) {
} }
int win_get_name(session_t *ps, win *w) { int win_get_name(session_t *ps, win *w) {
XTextProperty text_prop = { NULL, None, 0, 0 }; XTextProperty text_prop = { NULL, XCB_NONE, 0, 0 };
char **strlst = NULL; char **strlst = NULL;
int nstr = 0; int nstr = 0;
@ -178,7 +178,7 @@ int win_get_name(session_t *ps, win *w) {
return 0; return 0;
if (!(wid_get_text_prop(ps, w->client_win, ps->atom_name_ewmh, &strlst, &nstr))) { if (!(wid_get_text_prop(ps, w->client_win, ps->atom_name_ewmh, &strlst, &nstr))) {
log_trace("(%#010lx): _NET_WM_NAME unset, falling back to WM_NAME.", w->client_win); log_trace("(%#010x): _NET_WM_NAME unset, falling back to WM_NAME.", w->client_win);
if (!(XGetWMName(ps->dpy, w->client_win, &text_prop) && text_prop.value)) { if (!(XGetWMName(ps->dpy, w->client_win, &text_prop) && text_prop.value)) {
return -1; return -1;
@ -203,7 +203,7 @@ int win_get_name(session_t *ps, win *w) {
XFreeStringList(strlst); XFreeStringList(strlst);
log_trace("(%#010lx): client = %#010lx, name = \"%s\", " log_trace("(%#010x): client = %#010x, name = \"%s\", "
"ret = %d", w->id, w->client_win, w->name, ret); "ret = %d", w->id, w->client_win, w->name, ret);
return ret; return ret;
} }
@ -224,7 +224,7 @@ int win_get_role(session_t *ps, win *w) {
XFreeStringList(strlst); XFreeStringList(strlst);
log_trace("(%#010lx): client = %#010lx, role = \"%s\", " log_trace("(%#010x): client = %#010x, role = \"%s\", "
"ret = %d", w->id, w->client_win, w->role, ret); "ret = %d", w->id, w->client_win, w->role, ret);
return ret; return ret;
} }
@ -232,7 +232,7 @@ int win_get_role(session_t *ps, win *w) {
/** /**
* Check if a window is bounding-shaped. * Check if a window is bounding-shaped.
*/ */
static inline bool win_bounding_shaped(const session_t *ps, Window wid) { static inline bool win_bounding_shaped(const session_t *ps, xcb_window_t wid) {
if (ps->shape_exists) { if (ps->shape_exists) {
xcb_shape_query_extents_reply_t *reply; xcb_shape_query_extents_reply_t *reply;
Bool bounding_shaped; Bool bounding_shaped;
@ -248,7 +248,7 @@ static inline bool win_bounding_shaped(const session_t *ps, Window wid) {
return false; return false;
} }
wintype_t wid_get_prop_wintype(session_t *ps, Window wid) { wintype_t wid_get_prop_wintype(session_t *ps, xcb_window_t wid) {
set_ignore_next(ps); set_ignore_next(ps);
winprop_t prop = wid_get_prop(ps, wid, ps->atom_win_type, 32L, XCB_ATOM_ATOM, 32); winprop_t prop = wid_get_prop(ps, wid, ps->atom_win_type, 32L, XCB_ATOM_ATOM, 32);
@ -266,7 +266,7 @@ wintype_t wid_get_prop_wintype(session_t *ps, Window wid) {
return WINTYPE_UNKNOWN; return WINTYPE_UNKNOWN;
} }
bool wid_get_opacity_prop(session_t *ps, Window wid, opacity_t def, bool wid_get_opacity_prop(session_t *ps, xcb_window_t wid, opacity_t def,
opacity_t *out) { opacity_t *out) {
bool ret = false; bool ret = false;
*out = def; *out = def;
@ -634,7 +634,7 @@ void win_upd_wintype(session_t *ps, win *w) {
* @param w struct _win of the parent window * @param w struct _win of the parent window
* @param client window ID of the client window * @param client window ID of the client window
*/ */
void win_mark_client(session_t *ps, win *w, Window client) { void win_mark_client(session_t *ps, win *w, xcb_window_t client) {
w->client_win = client; w->client_win = client;
// If the window isn't mapped yet, stop here, as the function will be // If the window isn't mapped yet, stop here, as the function will be
@ -679,9 +679,9 @@ void win_mark_client(session_t *ps, win *w, Window client) {
* @param w struct _win of the parent window * @param w struct _win of the parent window
*/ */
void win_unmark_client(session_t *ps, win *w) { void win_unmark_client(session_t *ps, win *w) {
Window client = w->client_win; xcb_window_t client = w->client_win;
w->client_win = None; w->client_win = XCB_NONE;
// Recheck event mask // Recheck event mask
xcb_change_window_attributes(ps->c, client, XCB_CW_EVENT_MASK, xcb_change_window_attributes(ps->c, client, XCB_CW_EVENT_MASK,
@ -702,15 +702,15 @@ void win_recheck_client(session_t *ps, win *w) {
// Always recursively look for a window with WM_STATE, as Fluxbox // Always recursively look for a window with WM_STATE, as Fluxbox
// sets override-redirect flags on all frame windows. // sets override-redirect flags on all frame windows.
Window cw = find_client_win(ps, w->id); xcb_window_t cw = find_client_win(ps, w->id);
if (cw) if (cw)
log_trace("(%#010lx): client %#010lx", w->id, cw); log_trace("(%#010x): client %#010x", w->id, cw);
// Set a window's client window to itself if we couldn't find a // Set a window's client window to itself if we couldn't find a
// client window // client window
if (!cw) { if (!cw) {
cw = w->id; cw = w->id;
w->wmwin = !w->a.override_redirect; w->wmwin = !w->a.override_redirect;
log_trace("(%#010lx): client self (%s)", w->id, log_trace("(%#010x): client self (%s)", w->id,
(w->wmwin ? "wmwin" : "override-redirected")); (w->wmwin ? "wmwin" : "override-redirected"));
} }
@ -723,13 +723,13 @@ void win_recheck_client(session_t *ps, win *w) {
} }
// TODO: probably split into win_new (in win.c) and add_win (in compton.c) // TODO: probably split into win_new (in win.c) and add_win (in compton.c)
bool add_win(session_t *ps, Window id, Window prev) { bool add_win(session_t *ps, xcb_window_t id, xcb_window_t prev) {
static const win win_def = { static const win win_def = {
.win_data = NULL, .win_data = NULL,
.next = NULL, .next = NULL,
.prev_trans = NULL, .prev_trans = NULL,
.id = None, .id = XCB_NONE,
.a = {}, .a = {},
#ifdef CONFIG_XINERAMA #ifdef CONFIG_XINERAMA
.xinerama_scr = -1, .xinerama_scr = -1,
@ -737,7 +737,7 @@ bool add_win(session_t *ps, Window id, Window prev) {
.pictfmt = NULL, .pictfmt = NULL,
.mode = WMODE_TRANS, .mode = WMODE_TRANS,
.ever_damaged = false, .ever_damaged = false,
.damage = None, .damage = XCB_NONE,
.pixmap_damaged = false, .pixmap_damaged = false,
.paint = PAINT_INIT, .paint = PAINT_INIT,
.flags = 0, .flags = 0,
@ -754,11 +754,11 @@ bool add_win(session_t *ps, Window id, Window prev) {
.to_paint = false, .to_paint = false,
.in_openclose = false, .in_openclose = false,
.client_win = None, .client_win = XCB_NONE,
.window_type = WINTYPE_UNKNOWN, .window_type = WINTYPE_UNKNOWN,
.wmwin = false, .wmwin = false,
.leader = None, .leader = XCB_NONE,
.cache_leader = None, .cache_leader = XCB_NONE,
.focused = false, .focused = false,
.focused_force = UNSET, .focused_force = UNSET,
@ -814,7 +814,7 @@ bool add_win(session_t *ps, Window id, Window prev) {
// Allocate and initialize the new win structure // Allocate and initialize the new win structure
auto new = cmalloc(win); auto new = cmalloc(win);
log_trace("(%#010lx): %p", id, new); log_trace("(%#010x): %p", id, new);
*new = win_def; *new = win_def;
pixman_region32_init(&new->bounding_shape); pixman_region32_init(&new->bounding_shape);
@ -933,10 +933,10 @@ void win_update_focused(session_t *ps, win *w) {
/** /**
* Set leader of a window. * Set leader of a window.
*/ */
static inline void win_set_leader(session_t *ps, win *w, Window nleader) { static inline void win_set_leader(session_t *ps, win *w, xcb_window_t nleader) {
// If the leader changes // If the leader changes
if (w->leader != nleader) { if (w->leader != nleader) {
Window cache_leader_old = win_get_leader(ps, w); xcb_window_t cache_leader_old = win_get_leader(ps, w);
w->leader = nleader; w->leader = nleader;
@ -946,7 +946,7 @@ static inline void win_set_leader(session_t *ps, win *w, Window nleader) {
// Update the old and new window group and active_leader if the window // Update the old and new window group and active_leader if the window
// could affect their state. // could affect their state.
Window cache_leader = win_get_leader(ps, w); xcb_window_t cache_leader = win_get_leader(ps, w);
if (win_is_focused_real(ps, w) && cache_leader_old != cache_leader) { if (win_is_focused_real(ps, w) && cache_leader_old != cache_leader) {
ps->active_leader = cache_leader; ps->active_leader = cache_leader;
@ -967,7 +967,7 @@ static inline void win_set_leader(session_t *ps, win *w, Window nleader) {
* Update leader of a window. * Update leader of a window.
*/ */
void win_update_leader(session_t *ps, win *w) { void win_update_leader(session_t *ps, win *w) {
Window leader = None; xcb_window_t leader = XCB_NONE;
// Read the leader properties // Read the leader properties
if (ps->o.detect_transient && !leader) if (ps->o.detect_transient && !leader)
@ -978,14 +978,14 @@ void win_update_leader(session_t *ps, win *w) {
win_set_leader(ps, w, leader); win_set_leader(ps, w, leader);
log_trace("(%#010lx): client %#010lx, leader %#010lx, cache %#010lx", log_trace("(%#010x): client %#010x, leader %#010x, cache %#010x",
w->id, w->client_win, w->leader, win_get_leader(ps, w)); w->id, w->client_win, w->leader, win_get_leader(ps, w));
} }
/** /**
* Internal function of win_get_leader(). * Internal function of win_get_leader().
*/ */
Window win_get_leader_raw(session_t *ps, win *w, int recursions) { xcb_window_t win_get_leader_raw(session_t *ps, win *w, int recursions) {
// Rebuild the cache if needed // Rebuild the cache if needed
if (!w->cache_leader && (w->client_win || w->leader)) { if (!w->cache_leader && (w->client_win || w->leader)) {
// Leader defaults to client window // Leader defaults to client window
@ -998,7 +998,7 @@ Window win_get_leader_raw(session_t *ps, win *w, int recursions) {
if (wp) { if (wp) {
// Dead loop? // Dead loop?
if (recursions > WIN_GET_LEADER_MAX_RECURSION) if (recursions > WIN_GET_LEADER_MAX_RECURSION)
return None; return XCB_NONE;
w->cache_leader = win_get_leader_raw(ps, wp, recursions + 1); w->cache_leader = win_get_leader_raw(ps, wp, recursions + 1);
} }
@ -1038,7 +1038,7 @@ bool win_get_class(session_t *ps, win *w) {
XFreeStringList(strlst); XFreeStringList(strlst);
log_trace("(%#010lx): client = %#010lx, " log_trace("(%#010x): client = %#010x, "
"instance = \"%s\", general = \"%s\"", "instance = \"%s\", general = \"%s\"",
w->id, w->client_win, w->class_instance, w->class_general); w->id, w->client_win, w->class_instance, w->class_general);
@ -1054,11 +1054,11 @@ static void
win_on_focus_change(session_t *ps, win *w) { win_on_focus_change(session_t *ps, win *w) {
// If window grouping detection is enabled // If window grouping detection is enabled
if (ps->o.track_leader) { if (ps->o.track_leader) {
Window leader = win_get_leader(ps, w); xcb_window_t leader = win_get_leader(ps, w);
// If the window gets focused, replace the old active_leader // If the window gets focused, replace the old active_leader
if (win_is_focused_real(ps, w) && leader != ps->active_leader) { if (win_is_focused_real(ps, w) && leader != ps->active_leader) {
Window active_leader_old = ps->active_leader; xcb_window_t active_leader_old = ps->active_leader;
ps->active_leader = leader; ps->active_leader = leader;
@ -1068,7 +1068,7 @@ win_on_focus_change(session_t *ps, win *w) {
// If the group get unfocused, remove it from active_leader // If the group get unfocused, remove it from active_leader
else if (!win_is_focused_real(ps, w) && leader && leader == ps->active_leader else if (!win_is_focused_real(ps, w) && leader && leader == ps->active_leader
&& !group_is_focused(ps, leader)) { && !group_is_focused(ps, leader)) {
ps->active_leader = None; ps->active_leader = XCB_NONE;
group_update_focused(ps, leader); group_update_focused(ps, leader);
} }
@ -1220,7 +1220,7 @@ void win_update_opacity_prop(session_t *ps, win *w) {
* Retrieve frame extents from a window. * Retrieve frame extents from a window.
*/ */
void void
win_update_frame_extents(session_t *ps, win *w, Window client) { win_update_frame_extents(session_t *ps, win *w, xcb_window_t client) {
winprop_t prop = wid_get_prop(ps, client, ps->atom_frame_extents, winprop_t prop = wid_get_prop(ps, client, ps->atom_frame_extents,
4L, XCB_ATOM_CARDINAL, 32); 4L, XCB_ATOM_CARDINAL, 32);
@ -1241,7 +1241,7 @@ win_update_frame_extents(session_t *ps, win *w, Window client) {
w->reg_ignore_valid = false; w->reg_ignore_valid = false;
} }
log_trace("(%#010lx): %d, %d, %d, %d", w->id, log_trace("(%#010x): %d, %d, %d, %d", w->id,
w->frame_extents.left, w->frame_extents.right, w->frame_extents.left, w->frame_extents.right,
w->frame_extents.top, w->frame_extents.bottom); w->frame_extents.top, w->frame_extents.bottom);

View File

@ -84,7 +84,7 @@ struct win {
// Core members // Core members
/// ID of the top-level frame window. /// ID of the top-level frame window.
Window id; xcb_window_t id;
/// Window attributes. /// Window attributes.
xcb_get_window_attributes_reply_t a; xcb_get_window_attributes_reply_t a;
xcb_get_geometry_reply_t g; xcb_get_geometry_reply_t g;
@ -146,7 +146,7 @@ struct win {
// Client window related members // Client window related members
/// ID of the top-level client window of the window. /// ID of the top-level client window of the window.
Window client_win; xcb_window_t client_win;
/// Type of the window. /// Type of the window.
wintype_t window_type; wintype_t window_type;
/// Whether it looks like a WM window. We consider a window WM window if /// Whether it looks like a WM window. We consider a window WM window if
@ -154,9 +154,9 @@ struct win {
/// redirected itself. /// redirected itself.
bool wmwin; bool wmwin;
/// Leader window ID of the window. /// Leader window ID of the window.
Window leader; xcb_window_t leader;
/// Cached topmost window ID of the window. /// Cached topmost window ID of the window.
Window cache_leader; xcb_window_t cache_leader;
// Focus-related members // Focus-related members
/// Whether the window is to be considered focused. /// Whether the window is to be considered focused.
@ -281,10 +281,10 @@ void win_on_factor_change(session_t *ps, win *w);
void calc_win_size(session_t *ps, win *w); void calc_win_size(session_t *ps, win *w);
void calc_shadow_geometry(session_t *ps, win *w); void calc_shadow_geometry(session_t *ps, win *w);
void win_upd_wintype(session_t *ps, win *w); void win_upd_wintype(session_t *ps, win *w);
void win_mark_client(session_t *ps, win *w, Window client); void win_mark_client(session_t *ps, win *w, xcb_window_t client);
void win_unmark_client(session_t *ps, win *w); void win_unmark_client(session_t *ps, win *w);
void win_recheck_client(session_t *ps, win *w); void win_recheck_client(session_t *ps, win *w);
Window win_get_leader_raw(session_t *ps, win *w, int recursions); xcb_window_t win_get_leader_raw(session_t *ps, win *w, int recursions);
bool win_get_class(session_t *ps, win *w); bool win_get_class(session_t *ps, win *w);
void win_calc_opacity(session_t *ps, win *w); void win_calc_opacity(session_t *ps, win *w);
void win_calc_dim(session_t *ps, win *w); void win_calc_dim(session_t *ps, win *w);
@ -332,8 +332,8 @@ region_t win_get_region_noframe_local_by_val(win *w);
* Retrieve frame extents from a window. * Retrieve frame extents from a window.
*/ */
void void
win_update_frame_extents(session_t *ps, win *w, Window client); win_update_frame_extents(session_t *ps, win *w, xcb_window_t client);
bool add_win(session_t *ps, Window id, Window prev); bool add_win(session_t *ps, xcb_window_t id, xcb_window_t prev);
/** /**
* Set fade callback of a window, and possibly execute the previous * Set fade callback of a window, and possibly execute the previous
@ -361,7 +361,7 @@ void win_ev_stop(session_t *ps, win *w);
* *
* This function updates w->cache_leader if necessary. * This function updates w->cache_leader if necessary.
*/ */
static inline Window static inline xcb_window_t
win_get_leader(session_t *ps, win *w) { win_get_leader(session_t *ps, win *w) {
return win_get_leader_raw(ps, w, 0); return win_get_leader_raw(ps, w, 0);
} }

39
src/x.c
View File

@ -35,7 +35,7 @@ wid_get_prop_adv(const session_t *ps, xcb_window_t w, xcb_atom_t atom, long offs
xcb_get_property(ps->c, 0, w, atom, rtype, offset, length), NULL); xcb_get_property(ps->c, 0, w, atom, rtype, offset, length), NULL);
if (r && xcb_get_property_value_length(r) && if (r && xcb_get_property_value_length(r) &&
(rtype == XCB_ATOM_ANY || r->type == rtype) && (rtype == XCB_GET_PROPERTY_TYPE_ANY || r->type == rtype) &&
(!rformat || r->format == rformat) && (!rformat || r->format == rformat) &&
(r->format == 8 || r->format == 16 || r->format == 32)) (r->format == 8 || r->format == 16 || r->format == 32))
{ {
@ -53,20 +53,20 @@ wid_get_prop_adv(const session_t *ps, xcb_window_t w, xcb_atom_t atom, long offs
return (winprop_t) { return (winprop_t) {
.ptr = NULL, .ptr = NULL,
.nitems = 0, .nitems = 0,
.type = AnyPropertyType, .type = XCB_GET_PROPERTY_TYPE_ANY,
.format = 0 .format = 0
}; };
} }
/** /**
* Get the value of a type-<code>Window</code> property of a window. * Get the value of a type-<code>xcb_window_t</code> property of a window.
* *
* @return the value if successful, 0 otherwise * @return the value if successful, 0 otherwise
*/ */
Window xcb_window_t
wid_get_prop_window(session_t *ps, Window wid, Atom aprop) { wid_get_prop_window(session_t *ps, xcb_window_t wid, xcb_atom_t aprop) {
// Get the attribute // Get the attribute
Window p = None; xcb_window_t p = XCB_NONE;
winprop_t prop = wid_get_prop(ps, wid, aprop, 1L, XCB_ATOM_WINDOW, 32); winprop_t prop = wid_get_prop(ps, wid, aprop, 1L, XCB_ATOM_WINDOW, 32);
// Return it // Return it
@ -82,9 +82,9 @@ wid_get_prop_window(session_t *ps, Window wid, Atom aprop) {
/** /**
* Get the value of a text property of a window. * Get the value of a text property of a window.
*/ */
bool wid_get_text_prop(session_t *ps, Window wid, Atom prop, bool wid_get_text_prop(session_t *ps, xcb_window_t wid, xcb_atom_t prop,
char ***pstrlst, int *pnstr) { char ***pstrlst, int *pnstr) {
XTextProperty text_prop = { NULL, None, 0, 0 }; XTextProperty text_prop = { NULL, XCB_NONE, 0, 0 };
if (!(XGetTextProperty(ps->dpy, wid, &text_prop, prop) && text_prop.value)) if (!(XGetTextProperty(ps->dpy, wid, &text_prop, prop) && text_prop.value))
return false; return false;
@ -204,7 +204,7 @@ x_create_picture_with_pictfmt(session_t *ps, int wid, int hei,
xcb_pixmap_t tmp_pixmap = x_create_pixmap(ps, depth, ps->root, wid, hei); xcb_pixmap_t tmp_pixmap = x_create_pixmap(ps, depth, ps->root, wid, hei);
if (!tmp_pixmap) if (!tmp_pixmap)
return None; return XCB_NONE;
xcb_render_picture_t picture = xcb_render_picture_t picture =
x_create_picture_with_pictfmt_and_pixmap(ps, pictfmt, tmp_pixmap, valuemask, attr); x_create_picture_with_pictfmt_and_pixmap(ps, pictfmt, tmp_pixmap, valuemask, attr);
@ -274,7 +274,7 @@ void x_set_picture_clip_region(session_t *ps, xcb_render_picture_t pict,
void x_clear_picture_clip_region(session_t *ps, xcb_render_picture_t pict) { void x_clear_picture_clip_region(session_t *ps, xcb_render_picture_t pict) {
xcb_render_change_picture_value_list_t v = { xcb_render_change_picture_value_list_t v = {
.clipmask = None .clipmask = XCB_NONE
}; };
xcb_generic_error_t *e = xcb_generic_error_t *e =
xcb_request_check(ps->c, xcb_render_change_picture(ps->c, pict, xcb_request_check(ps->c, xcb_render_change_picture(ps->c, pict,
@ -403,14 +403,19 @@ x_create_pixmap(session_t *ps, uint8_t depth, xcb_drawable_t drawable, uint16_t
* are better ways. * are better ways.
*/ */
bool bool
x_validate_pixmap(session_t *ps, xcb_pixmap_t pxmap) { x_validate_pixmap(session_t *ps, xcb_pixmap_t pixmap) {
if (!pxmap) return false; if (pixmap == XCB_NONE) {
return false;
}
Window rroot = None; auto r = xcb_get_geometry_reply(ps->c, xcb_get_geometry(ps->c, pixmap), NULL);
int rx = 0, ry = 0; if (!r) {
unsigned rwid = 0, rhei = 0, rborder = 0, rdepth = 0; return false;
return XGetGeometry(ps->dpy, pxmap, &rroot, &rx, &ry, }
&rwid, &rhei, &rborder, &rdepth) && rwid && rhei;
bool ret = r->width && r->height;
free(r);
return ret;
} }
/// Names of root window properties that could point to a pixmap of /// Names of root window properties that could point to a pixmap of
/// background. /// background.

View File

@ -79,17 +79,17 @@ wid_get_prop(const session_t *ps, xcb_window_t wid, xcb_atom_t atom, long length
} }
/** /**
* Get the value of a type-<code>Window</code> property of a window. * Get the value of a type-<code>xcb_window_t</code> property of a window.
* *
* @return the value if successful, 0 otherwise * @return the value if successful, 0 otherwise
*/ */
Window xcb_window_t
wid_get_prop_window(session_t *ps, Window wid, Atom aprop); wid_get_prop_window(session_t *ps, xcb_window_t wid, xcb_atom_t aprop);
/** /**
* Get the value of a text property of a window. * Get the value of a text property of a window.
*/ */
bool wid_get_text_prop(session_t *ps, Window wid, Atom prop, bool wid_get_text_prop(session_t *ps, xcb_window_t wid, xcb_atom_t prop,
char ***pstrlst, int *pnstr); char ***pstrlst, int *pnstr);
xcb_render_pictforminfo_t *x_get_pictform_for_visual(session_t *, xcb_visualid_t); xcb_render_pictforminfo_t *x_get_pictform_for_visual(session_t *, xcb_visualid_t);