Skip to content

Commit

Permalink
Merge pull request #7 from psychon/more-xcb-conv
Browse files Browse the repository at this point in the history
More conversion to XCB
  • Loading branch information
yshui authored Sep 30, 2018
2 parents 70fb58b + 8848676 commit 290cdd2
Show file tree
Hide file tree
Showing 7 changed files with 205 additions and 113 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ MANDIR ?= $(PREFIX)/share/man/man1
APPDIR ?= $(PREFIX)/share/applications
ICODIR ?= $(PREFIX)/share/icons/hicolor/

PACKAGES = x11 x11-xcb xcb-renderutil xcb-render xcb-damage xcb-randr xcb-xfixes xfixes xcb-image xcomposite xext
PACKAGES = x11 x11-xcb xcb-renderutil xcb-render xcb-damage xcb-randr xcb-composite xcb-shape xcb-image xcb-xfixes xfixes xext
LIBS = -lm -lrt
INCS =

Expand All @@ -26,7 +26,7 @@ endif
# Enables support for --xinerama-shadow-crop
ifeq "$(NO_XINERAMA)" ""
CFG += -DCONFIG_XINERAMA
PACKAGES += xinerama
PACKAGES += xcb-xinerama
endif

# ==== libconfig ====
Expand Down
53 changes: 41 additions & 12 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,21 @@
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/extensions/Xcomposite.h>
#include <X11/extensions/shape.h>
#include <X11/extensions/Xfixes.h>
#include <X11/extensions/Xdbe.h>
#ifdef CONFIG_XSYNC
#include <X11/extensions/sync.h>
#endif

#ifdef CONFIG_XINERAMA
#include <X11/extensions/Xinerama.h>
#endif

#include <xcb/composite.h>
#include <xcb/render.h>
#include <xcb/damage.h>
#include <xcb/randr.h>
#include <xcb/shape.h>

#ifdef CONFIG_XINERAMA
#include <xcb/xinerama.h>
#endif

// Workarounds for missing definitions in very old versions of X headers,
// thanks to consolers for reporting
Expand Down Expand Up @@ -171,9 +172,6 @@
#endif

// === Constants ===
#if !(COMPOSITE_MAJOR > 0 || COMPOSITE_MINOR >= 2)
#error libXcomposite version unsupported
#endif

/// @brief Length of generic buffers.
#define BUF_LEN 80
Expand Down Expand Up @@ -596,7 +594,7 @@ typedef struct _options_t {
Window benchmark_wid;
/// A list of conditions of windows not to paint.
c2_lptr_t *paint_blacklist;
/// Whether to avoid using XCompositeNameWindowPixmap(), for debugging.
/// Whether to avoid using xcb_composite_name_window_pixmap(), for debugging.
bool no_name_pixmap;
/// Whether to work under synchronized mode for debugging.
bool synchronize;
Expand Down Expand Up @@ -979,7 +977,7 @@ typedef struct session {
/// Whether X Xinerama extension exists.
bool xinerama_exists;
/// Xinerama screen info.
XineramaScreenInfo *xinerama_scrs;
xcb_xinerama_query_screens_reply_t *xinerama_scrs;
/// Xinerama screen regions.
XserverRegion *xinerama_scr_regs;
/// Number of Xinerama screens.
Expand Down Expand Up @@ -1253,6 +1251,9 @@ extern session_t *ps_g;
static inline void
print_timestamp(session_t *ps);

void
ev_xcb_error(session_t *ps, xcb_generic_error_t *err);

#ifdef DEBUG_BACKTRACE

#include <execinfo.h>
Expand Down Expand Up @@ -1997,6 +1998,14 @@ set_ignore_next(session_t *ps) {
set_ignore(ps, NextRequest(ps->dpy));
}

/**
* Ignore X errors caused by given X request.
*/
static inline void
set_ignore_cookie(session_t *ps, xcb_void_cookie_t cookie) {
set_ignore(ps, cookie.sequence);
}

/**
* Check if a window is a fullscreen window.
*
Expand Down Expand Up @@ -2519,7 +2528,27 @@ wintype_arr_enable(bool arr[]) {
static inline void
free_pixmap(session_t *ps, Pixmap *p) {
if (*p) {
XFreePixmap(ps->dpy, *p);
xcb_connection_t *c = XGetXCBConnection(ps->dpy);
xcb_free_pixmap(c, *p);
*p = None;
}
}

/**
* Create a pixmap and check that creation succeeded.
*/
static inline xcb_pixmap_t
create_pixmap(session_t *ps, uint8_t depth, xcb_drawable_t drawable, uint16_t width, uint16_t height)
{
xcb_connection_t *c = XGetXCBConnection(ps->dpy);
xcb_pixmap_t pix = xcb_generate_id(c);
xcb_void_cookie_t cookie = xcb_create_pixmap_checked(c, depth, pix, drawable, width, height);
xcb_generic_error_t *err = xcb_request_check(c, cookie);
if (err == NULL)
return pix;

printf_err("Failed to create pixmap:");
ev_xcb_error(ps, err);
free(err);
return XCB_NONE;
}
Loading

0 comments on commit 290cdd2

Please sign in to comment.