Convert some Xlib constants to xcb

And remove some Xlib headers

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2018-11-04 18:54:04 +00:00
parent 471f6f90ff
commit 2b0b7435df
6 changed files with 31 additions and 34 deletions

View File

@ -1647,7 +1647,7 @@ c2_match_once(session_t *ps, win *w, const c2_ptr_t cond) {
bool bool
c2_match(session_t *ps, win *w, const c2_lptr_t *condlst, c2_match(session_t *ps, win *w, const c2_lptr_t *condlst,
const c2_lptr_t **cache, void **pdata) { const c2_lptr_t **cache, void **pdata) {
assert(IsViewable == w->a.map_state); assert(w->a.map_state == XCB_MAP_STATE_VIEWABLE);
// Check if the cached entry matches firstly // Check if the cached entry matches firstly
if (cache && *cache && c2_match_once(ps, w, (*cache)->ptr)) { if (cache && *cache && c2_match_once(ps, w, (*cache)->ptr)) {

View File

@ -1437,7 +1437,7 @@ glx_has_context(session_t *ps) {
*/ */
static inline bool static inline bool
win_is_focused_real(session_t *ps, const win *w) { win_is_focused_real(session_t *ps, const win *w) {
return IsViewable == w->a.map_state && ps->active_win == w; return w->a.map_state == XCB_MAP_STATE_VIEWABLE && ps->active_win == w;
} }
/** /**

View File

@ -986,7 +986,7 @@ long determine_evmask(session_t *ps, Window wid, win_evmode_t mode) {
// Check if it's a mapped frame window // Check if it's a mapped frame window
if (WIN_EVMODE_FRAME == mode if (WIN_EVMODE_FRAME == mode
|| ((w = find_win(ps, wid)) && IsViewable == w->a.map_state)) { || ((w = find_win(ps, wid)) && w->a.map_state == XCB_MAP_STATE_VIEWABLE)) {
evmask |= XCB_EVENT_MASK_PROPERTY_CHANGE; evmask |= XCB_EVENT_MASK_PROPERTY_CHANGE;
if (ps->o.track_focus && !ps->o.use_ewmh_active_win) if (ps->o.track_focus && !ps->o.use_ewmh_active_win)
evmask |= XCB_EVENT_MASK_FOCUS_CHANGE; evmask |= XCB_EVENT_MASK_FOCUS_CHANGE;
@ -994,7 +994,7 @@ long determine_evmask(session_t *ps, Window wid, win_evmode_t mode) {
// Check if it's a mapped client window // Check if it's a mapped client window
if (WIN_EVMODE_CLIENT == mode if (WIN_EVMODE_CLIENT == mode
|| ((w = find_toplevel(ps, wid)) && IsViewable == w->a.map_state)) { || ((w = find_toplevel(ps, wid)) && w->a.map_state == XCB_MAP_STATE_VIEWABLE)) {
if (ps->o.frame_opacity || ps->o.track_wdata || ps->track_atom_lst if (ps->o.frame_opacity || ps->o.track_wdata || ps->track_atom_lst
|| ps->o.detect_client_opacity) || ps->o.detect_client_opacity)
evmask |= XCB_EVENT_MASK_PROPERTY_CHANGE; evmask |= XCB_EVENT_MASK_PROPERTY_CHANGE;
@ -1215,7 +1215,7 @@ paint_preprocess(session_t *ps, win *list) {
const bool was_painted = w->to_paint; const bool was_painted = w->to_paint;
const opacity_t opacity_old = w->opacity; const opacity_t opacity_old = w->opacity;
// Restore flags from last paint if the window is being faded out // Restore flags from last paint if the window is being faded out
if (IsUnmapped == w->a.map_state) { if (w->a.map_state == XCB_MAP_STATE_UNMAPPED) {
win_set_shadow(ps, w, w->shadow_last); win_set_shadow(ps, w, w->shadow_last);
w->fade = w->fade_last; w->fade = w->fade_last;
win_set_invert_color(ps, w, w->invert_color_last); win_set_invert_color(ps, w, w->invert_color_last);
@ -1279,7 +1279,7 @@ paint_preprocess(session_t *ps, win *list) {
if (!w->ever_damaged if (!w->ever_damaged
|| w->g.x + w->g.width < 1 || w->g.y + w->g.height < 1 || w->g.x + w->g.width < 1 || w->g.y + w->g.height < 1
|| w->g.x >= ps->root_width || w->g.y >= ps->root_height || w->g.x >= ps->root_width || w->g.y >= ps->root_height
|| ((IsUnmapped == w->a.map_state || w->destroyed) && !w->paint.pixmap) || ((w->a.map_state == XCB_MAP_STATE_UNMAPPED || w->destroyed) && !w->paint.pixmap)
|| get_alpha_step(ps, w->opacity) == 0 || get_alpha_step(ps, w->opacity) == 0
|| w->paint_excluded) || w->paint_excluded)
to_paint = false; to_paint = false;
@ -2082,7 +2082,7 @@ paint_all(session_t *ps, region_t *region, const region_t *region_real, win * co
static void static void
repair_win(session_t *ps, win *w) { repair_win(session_t *ps, win *w) {
if (IsViewable != w->a.map_state) if (w->a.map_state != XCB_MAP_STATE_VIEWABLE)
return; return;
region_t parts; region_t parts;
@ -2149,12 +2149,12 @@ map_win(session_t *ps, Window id) {
// 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
if (!w || InputOnly == w->a._class if (!w || InputOnly == w->a._class
|| IsViewable == w->a.map_state) || w->a.map_state == XCB_MAP_STATE_VIEWABLE)
return; return;
assert(!win_is_focused_real(ps, w)); assert(!win_is_focused_real(ps, w));
w->a.map_state = IsViewable; w->a.map_state = XCB_MAP_STATE_VIEWABLE;
cxinerama_win_upd_scr(ps, w); cxinerama_win_upd_scr(ps, w);
@ -2255,14 +2255,14 @@ finish_unmap_win(session_t *ps, win **_w) {
static void static void
unmap_win(session_t *ps, win **_w) { unmap_win(session_t *ps, win **_w) {
win *w = *_w; win *w = *_w;
if (!w || IsUnmapped == w->a.map_state) return; if (!w || w->a.map_state == XCB_MAP_STATE_UNMAPPED) return;
if (w->destroyed) return; if (w->destroyed) return;
// Set focus out // Set focus out
win_set_focused(ps, w, false); win_set_focused(ps, w, false);
w->a.map_state = IsUnmapped; w->a.map_state = XCB_MAP_STATE_UNMAPPED;
// Fading out // Fading out
w->flags |= WFLAG_OPCT_CHANGE; w->flags |= WFLAG_OPCT_CHANGE;
@ -2669,7 +2669,7 @@ opts_init_track_focus(session_t *ps) {
if (!ps->o.use_ewmh_active_win) { if (!ps->o.use_ewmh_active_win) {
// Start listening to FocusChange events // Start listening to FocusChange events
for (win *w = ps->list; w; w = w->next) for (win *w = ps->list; w; w = w->next)
if (IsViewable == w->a.map_state) if (w->a.map_state == XCB_MAP_STATE_VIEWABLE)
xcb_change_window_attributes(ps->c, w->id, XCB_CW_EVENT_MASK, xcb_change_window_attributes(ps->c, w->id, XCB_CW_EVENT_MASK,
(const uint32_t[]) { determine_evmask(ps, w->id, WIN_EVMODE_FRAME) }); (const uint32_t[]) { determine_evmask(ps, w->id, WIN_EVMODE_FRAME) });
} }
@ -3114,7 +3114,7 @@ ev_damage_notify(session_t *ps, xcb_damage_notify_event_t *de) {
inline static void inline static void
ev_shape_notify(session_t *ps, xcb_shape_notify_event_t *ev) { ev_shape_notify(session_t *ps, xcb_shape_notify_event_t *ev) {
win *w = find_win(ps, ev->affected_window); win *w = find_win(ps, ev->affected_window);
if (!w || IsUnmapped == w->a.map_state) return; if (!w || w->a.map_state == XCB_MAP_STATE_UNMAPPED) return;
/* /*
* Empty bounding_shape may indicated an * Empty bounding_shape may indicated an
@ -5543,7 +5543,7 @@ session_destroy(session_t *ps) {
// Must be put here to avoid segfault // Must be put here to avoid segfault
next = w->next; next = w->next;
if (IsViewable == w->a.map_state && !w->destroyed) if (w->a.map_state == XCB_MAP_STATE_VIEWABLE && !w->destroyed)
win_ev_stop(ps, w); win_ev_stop(ps, w);
free_win_res(ps, w); free_win_res(ps, w);

View File

@ -2,7 +2,6 @@
// Copyright (c) 2011-2013, Christopher Jeffrey // Copyright (c) 2011-2013, Christopher Jeffrey
// Copyright (c) 2013 Richard Grenville <pyxlcy@gmail.com> // Copyright (c) 2013 Richard Grenville <pyxlcy@gmail.com>
#include <X11/Xlib.h>
#include <xcb/render.h> #include <xcb/render.h>
#include <xcb/damage.h> #include <xcb/damage.h>
#include <xcb/xcb_renderutil.h> #include <xcb/xcb_renderutil.h>
@ -318,7 +317,7 @@ void win_determine_mode(session_t *ps, win *w) {
void win_calc_opacity(session_t *ps, win *w) { void win_calc_opacity(session_t *ps, win *w) {
opacity_t opacity = OPAQUE; opacity_t opacity = OPAQUE;
if (w->destroyed || IsViewable != w->a.map_state) if (w->destroyed || w->a.map_state != XCB_MAP_STATE_VIEWABLE)
opacity = 0; opacity = 0;
else { else {
// Try obeying opacity property and window type opacity firstly // Try obeying opacity property and window type opacity firstly
@ -350,7 +349,7 @@ void win_calc_dim(session_t *ps, win *w) {
bool dim; bool dim;
// Make sure we do nothing if the window is unmapped / destroyed // Make sure we do nothing if the window is unmapped / destroyed
if (w->destroyed || IsViewable != w->a.map_state) if (w->destroyed || w->a.map_state != XCB_MAP_STATE_VIEWABLE)
return; return;
if (ps->o.inactive_dim && !(w->focused)) { if (ps->o.inactive_dim && !(w->focused)) {
@ -381,7 +380,7 @@ void win_determine_fade(session_t *ps, win *w) {
} }
// Ignore other possible causes of fading state changes after window // Ignore other possible causes of fading state changes after window
// gets unmapped // gets unmapped
else if (IsViewable != w->a.map_state) { else if (w->a.map_state != XCB_MAP_STATE_VIEWABLE) {
} else if (c2_match(ps, w, ps->o.fade_blacklist, &w->cache_fblst, NULL)) } else if (c2_match(ps, w, ps->o.fade_blacklist, &w->cache_fblst, NULL))
w->fade = false; w->fade = false;
else else
@ -454,7 +453,7 @@ void win_determine_shadow(session_t *ps, win *w) {
if (UNSET != w->shadow_force) if (UNSET != w->shadow_force)
shadow_new = w->shadow_force; shadow_new = w->shadow_force;
else if (IsViewable == w->a.map_state) else if (w->a.map_state == XCB_MAP_STATE_VIEWABLE)
shadow_new = (ps->o.wintype_shadow[w->window_type] && shadow_new = (ps->o.wintype_shadow[w->window_type] &&
!c2_match(ps, w, ps->o.shadow_blacklist, &w->cache_sblst, NULL) && !c2_match(ps, w, ps->o.shadow_blacklist, &w->cache_sblst, NULL) &&
!(ps->o.shadow_ignore_shaped && w->bounding_shaped && !(ps->o.shadow_ignore_shaped && w->bounding_shaped &&
@ -481,7 +480,7 @@ void win_determine_invert_color(session_t *ps, win *w) {
if (UNSET != w->invert_color_force) if (UNSET != w->invert_color_force)
invert_color_new = w->invert_color_force; invert_color_new = w->invert_color_force;
else if (IsViewable == w->a.map_state) else if (w->a.map_state == XCB_MAP_STATE_VIEWABLE)
invert_color_new = invert_color_new =
c2_match(ps, w, ps->o.invert_color_list, &w->cache_ivclst, NULL); c2_match(ps, w, ps->o.invert_color_list, &w->cache_ivclst, NULL);
@ -504,7 +503,7 @@ void win_set_blur_background(session_t *ps, win *w, bool blur_background_new) {
* Determine if a window should have background blurred. * Determine if a window should have background blurred.
*/ */
void win_determine_blur_background(session_t *ps, win *w) { void win_determine_blur_background(session_t *ps, win *w) {
if (IsViewable != w->a.map_state) if (w->a.map_state != XCB_MAP_STATE_VIEWABLE)
return; return;
bool blur_background_new = bool blur_background_new =
@ -518,7 +517,7 @@ void win_determine_blur_background(session_t *ps, win *w) {
* Update window opacity according to opacity rules. * Update window opacity according to opacity rules.
*/ */
void win_update_opacity_rule(session_t *ps, win *w) { void win_update_opacity_rule(session_t *ps, win *w) {
if (IsViewable != w->a.map_state) if (w->a.map_state != XCB_MAP_STATE_VIEWABLE)
return; return;
opacity_t opacity = OPAQUE; opacity_t opacity = OPAQUE;
@ -569,10 +568,10 @@ void win_on_factor_change(session_t *ps, win *w) {
win_determine_blur_background(ps, w); win_determine_blur_background(ps, w);
if (ps->o.opacity_rules) if (ps->o.opacity_rules)
win_update_opacity_rule(ps, w); win_update_opacity_rule(ps, w);
if (IsViewable == w->a.map_state && ps->o.paint_blacklist) if (w->a.map_state == XCB_MAP_STATE_VIEWABLE && ps->o.paint_blacklist)
w->paint_excluded = w->paint_excluded =
c2_match(ps, w, ps->o.paint_blacklist, &w->cache_pblst, NULL); c2_match(ps, w, ps->o.paint_blacklist, &w->cache_pblst, NULL);
if (IsViewable == w->a.map_state && ps->o.unredir_if_possible_blacklist) if (w->a.map_state == XCB_MAP_STATE_VIEWABLE && ps->o.unredir_if_possible_blacklist)
w->unredir_if_possible_excluded = c2_match( w->unredir_if_possible_excluded = c2_match(
ps, w, ps->o.unredir_if_possible_blacklist, &w->cache_uipblst, NULL); ps, w, ps->o.unredir_if_possible_blacklist, &w->cache_uipblst, NULL);
w->reg_ignore_valid = false; w->reg_ignore_valid = false;
@ -636,7 +635,7 @@ void win_mark_client(session_t *ps, win *w, Window 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
// called in map_win() // called in map_win()
if (IsViewable != w->a.map_state) if (w->a.map_state != XCB_MAP_STATE_VIEWABLE)
return; return;
xcb_change_window_attributes(ps->c, client, XCB_CW_EVENT_MASK, xcb_change_window_attributes(ps->c, client, XCB_CW_EVENT_MASK,
@ -844,9 +843,9 @@ bool add_win(session_t *ps, Window id, Window prev) {
xcb_get_geometry_cookie_t gcookie = xcb_get_geometry(ps->c, id); xcb_get_geometry_cookie_t gcookie = xcb_get_geometry(ps->c, id);
xcb_get_window_attributes_reply_t *a = xcb_get_window_attributes_reply(ps->c, acookie, NULL); xcb_get_window_attributes_reply_t *a = xcb_get_window_attributes_reply(ps->c, acookie, NULL);
xcb_get_geometry_reply_t *g = xcb_get_geometry_reply(ps->c, gcookie, NULL); xcb_get_geometry_reply_t *g = xcb_get_geometry_reply(ps->c, gcookie, NULL);
if (!a || IsUnviewable == a->map_state) { if (!a || a->map_state == XCB_MAP_STATE_UNVIEWABLE) {
// Failed to get window attributes probably means the window is gone // Failed to get window attributes probably means the window is gone
// already. IsUnviewable means the window is already reparented // already. Unviewable means the window is already reparented
// elsewhere. // elsewhere.
free(a); free(a);
free(g); free(g);
@ -867,8 +866,8 @@ bool add_win(session_t *ps, Window id, Window prev) {
// Delay window mapping // Delay window mapping
int map_state = new->a.map_state; int map_state = new->a.map_state;
assert(IsViewable == map_state || IsUnmapped == map_state); assert(map_state == XCB_MAP_STATE_VIEWABLE || map_state == XCB_MAP_STATE_UNMAPPED);
new->a.map_state = IsUnmapped; new->a.map_state = XCB_MAP_STATE_UNMAPPED;
if (InputOutput == new->a._class) { if (InputOutput == new->a._class) {
// Create Damage for window // Create Damage for window
@ -896,7 +895,7 @@ bool add_win(session_t *ps, Window id, Window prev) {
} }
#endif #endif
if (IsViewable == map_state) { if (map_state == XCB_MAP_STATE_VIEWABLE) {
map_win(ps, id); map_win(ps, id);
} }
@ -919,7 +918,7 @@ void win_update_focused(session_t *ps, win *w) {
|| (ps->o.mark_wmwin_focused && w->wmwin) || (ps->o.mark_wmwin_focused && w->wmwin)
|| (ps->o.mark_ovredir_focused && || (ps->o.mark_ovredir_focused &&
w->id == w->client_win && !w->wmwin) w->id == w->client_win && !w->wmwin)
|| (IsViewable == w->a.map_state && || (w->a.map_state == XCB_MAP_STATE_VIEWABLE &&
c2_match(ps, w, ps->o.focus_blacklist, &w->cache_fcblst, NULL))) c2_match(ps, w, ps->o.focus_blacklist, &w->cache_fcblst, NULL)))
w->focused = true; w->focused = true;
@ -1110,7 +1109,7 @@ win_on_focus_change(session_t *ps, win *w) {
void void
win_set_focused(session_t *ps, win *w, bool focused) { win_set_focused(session_t *ps, win *w, bool focused) {
// Unmapped windows will have their focused state reset on map // Unmapped windows will have their focused state reset on map
if (IsUnmapped == w->a.map_state) if (w->a.map_state == XCB_MAP_STATE_UNMAPPED)
return; return;
if (win_is_focused_real(ps, w) == focused) return; if (win_is_focused_real(ps, w) == focused) return;

View File

@ -3,7 +3,6 @@
// Copyright (c) 2013 Richard Grenville <pyxlcy@gmail.com> // Copyright (c) 2013 Richard Grenville <pyxlcy@gmail.com>
#pragma once #pragma once
#include <stdbool.h> #include <stdbool.h>
#include <X11/Xlib.h>
#include <xcb/damage.h> #include <xcb/damage.h>
// FIXME shouldn't need this // FIXME shouldn't need this

View File

@ -3,7 +3,6 @@
#pragma once #pragma once
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <X11/Xlib.h>
#include <xcb/xcb.h> #include <xcb/xcb.h>
#include <xcb/render.h> #include <xcb/render.h>
#include <xcb/xcb_renderutil.h> #include <xcb/xcb_renderutil.h>