From 4fb7c984551a88ab7423cd9728d3e7022287b4d2 Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Sat, 26 Nov 2016 15:42:48 +0100 Subject: [PATCH] build: Optional X extensions --- cmake/build/options.cmake | 8 +++++--- cmake/build/summary.cmake | 2 ++ include/config.hpp.cmake | 8 +++++--- include/x11/composite.hpp | 10 ++++++++++ include/x11/connection.hpp | 34 ++++++++++++++++++++++++++-------- include/x11/damage.hpp | 3 ++- include/x11/draw.hpp | 4 ++-- include/x11/randr.hpp | 3 ++- include/x11/render.hpp | 3 ++- include/x11/sync.hpp | 10 ++++++++++ include/x11/types.hpp | 38 ++++++++++++++++++++++++++++++-------- src/CMakeLists.txt | 6 ++++++ src/x11/connection.cpp | 17 ++++++++++++++--- src/x11/draw.cpp | 8 ++++---- src/x11/tray.cpp | 15 +++++++++++++++ 15 files changed, 135 insertions(+), 34 deletions(-) create mode 100644 include/x11/composite.hpp create mode 100644 include/x11/sync.hpp diff --git a/cmake/build/options.cmake b/cmake/build/options.cmake index 4ba46652..32ade002 100644 --- a/cmake/build/options.cmake +++ b/cmake/build/options.cmake @@ -51,9 +51,11 @@ option(ENABLE_I3 "Enable i3 support" ON) option(ENABLE_MPD "Enable mpd support" ON) option(ENABLE_NETWORK "Enable network support" ON) -option(ENABLE_RANDR_EXT "Enable RandR X extension" ON) -option(ENABLE_RENDER_EXT "Enable Render X extension" OFF) -option(ENABLE_DAMAGE_EXT "Enable Damage X extension" OFF) +option(ENABLE_RANDR_EXT "Enable RandR X extension" ON) +option(ENABLE_RENDER_EXT "Enable Render X extension" OFF) +option(ENABLE_DAMAGE_EXT "Enable Damage X extension" OFF) +option(ENABLE_SYNC_EXT "Enable Sync X extension" OFF) +option(ENABLE_COMPOSITE_EXT "Enable Sync X extension" OFF) # }}} # Set cache vars {{{ diff --git a/cmake/build/summary.cmake b/cmake/build/summary.cmake index 755a27f2..965d247b 100644 --- a/cmake/build/summary.cmake +++ b/cmake/build/summary.cmake @@ -58,4 +58,6 @@ message(STATUS "--------------------------") colored_option(STATUS " Enable X RandR ${ENABLE_RANDR_EXT}" ENABLE_RANDR_EXT "32;1" "37;2") colored_option(STATUS " Enable X Render ${ENABLE_RENDER_EXT}" ENABLE_RENDER_EXT "32;1" "37;2") colored_option(STATUS " Enable X Damage ${ENABLE_DAMAGE_EXT}" ENABLE_DAMAGE_EXT "32;1" "37;2") +colored_option(STATUS " Enable X Sync ${ENABLE_SYNC_EXT}" ENABLE_SYNC_EXT "32;1" "37;2") +colored_option(STATUS " Enable X Composite ${ENABLE_COMPOSITE_EXT}" ENABLE_COMPOSITE_EXT "32;1" "37;2") message(STATUS "--------------------------") diff --git a/include/config.hpp.cmake b/include/config.hpp.cmake index 03cf8361..22a61da7 100644 --- a/include/config.hpp.cmake +++ b/include/config.hpp.cmake @@ -17,9 +17,11 @@ #cmakedefine01 ENABLE_NETWORK #cmakedefine01 ENABLE_I3 -#cmakedefine ENABLE_RANDR_EXT -#cmakedefine ENABLE_RENDER_EXT -#cmakedefine ENABLE_DAMAGE_EXT +#cmakedefine01 ENABLE_RANDR_EXT +#cmakedefine01 ENABLE_RENDER_EXT +#cmakedefine01 ENABLE_DAMAGE_EXT +#cmakedefine01 ENABLE_SYNC_EXT +#cmakedefine01 ENABLE_COMPOSITE_EXT #cmakedefine DEBUG_LOGGER #cmakedefine VERBOSE_TRACELOG diff --git a/include/x11/composite.hpp b/include/x11/composite.hpp new file mode 100644 index 00000000..67b4ab44 --- /dev/null +++ b/include/x11/composite.hpp @@ -0,0 +1,10 @@ +#pragma once + +#include "config.hpp" + +#if not ENABLE_COMPOSITE_EXT +#error "X Composite extension is disabled..." +#endif + +#include +#include diff --git a/include/x11/connection.hpp b/include/x11/connection.hpp index 1a55167a..aec3a685 100644 --- a/include/x11/connection.hpp +++ b/include/x11/connection.hpp @@ -10,33 +10,51 @@ #include "common.hpp" #include "x11/types.hpp" -#ifdef ENABLE_DAMAGE_EXT +#if ENABLE_DAMAGE_EXT #include "x11/damage.hpp" #endif -#ifdef ENABLE_RENDER_EXT +#if ENABLE_RENDER_EXT #include "x11/render.hpp" #endif -#ifdef ENABLE_RANDR_EXT +#if ENABLE_RANDR_EXT #include "x11/randr.hpp" #endif +#if ENABLE_SYNC_EXT +#include "x11/sync.hpp" +#endif +#if ENABLE_COMPOSITE_EXT +#include "x11/composite.hpp" +#endif POLYBAR_NS using xpp_connection = xpp::connection< -#ifdef ENABLE_DAMAGE_EXT +#if ENABLE_DAMAGE_EXT xpp::damage::extension #endif -#ifdef ENABLE_RANDR_EXT -#ifdef ENABLE_DAMAGE_EXT +#if ENABLE_RANDR_EXT +#if ENABLE_DAMAGE_EXT , #endif xpp::randr::extension #endif -#ifdef ENABLE_RENDER_EXT -#ifdef ENABLE_RANDR_EXT +#if ENABLE_RENDER_EXT +#if (ENABLE_RANDR_EXT || ENABLE_DAMAGE_EXT) , #endif xpp::render::extension +#endif +#if ENABLE_SYNC_EXT +#if (ENABLE_RANDR_EXT || ENABLE_DAMAGE_EXT || ENABLE_RENDER_EXT) + , +#endif + xpp::sync::extension +#endif +#if ENABLE_COMPOSITE_EXT +#if (ENABLE_RANDR_EXT || ENABLE_DAMAGE_EXT || ENABLE_RENDER_EXT || ENABLE_SYNC_EXT) + , +#endif + xpp::composite::extension #endif >; diff --git a/include/x11/damage.hpp b/include/x11/damage.hpp index 4e643ef6..f51037b4 100644 --- a/include/x11/damage.hpp +++ b/include/x11/damage.hpp @@ -2,8 +2,9 @@ #include "config.hpp" -#ifndef ENABLE_DAMAGE_EXT +#if not ENABLE_DAMAGE_EXT #error "X Damage extension is disabled..." #endif +#include #include diff --git a/include/x11/draw.hpp b/include/x11/draw.hpp index b2bb1311..05f4650f 100644 --- a/include/x11/draw.hpp +++ b/include/x11/draw.hpp @@ -9,8 +9,8 @@ POLYBAR_NS class connection; namespace draw_util { - void fill(connection& conn, xcb_drawable_t d, xcb_gcontext_t g, const xcb_rectangle_t rect); - void fill(connection& conn, xcb_drawable_t d, xcb_gcontext_t g, int16_t x, int16_t y, uint16_t w, uint16_t h); + void fill(xcb_connection_t* c, xcb_drawable_t d, xcb_gcontext_t g, const xcb_rectangle_t rect); + void fill(xcb_connection_t* c, xcb_drawable_t d, xcb_gcontext_t g, int16_t x, int16_t y, uint16_t w, uint16_t h); xcb_void_cookie_t xcb_poly_text_16_patched( xcb_connection_t* conn, xcb_drawable_t d, xcb_gcontext_t gc, int16_t x, int16_t y, uint8_t len, uint16_t* str); diff --git a/include/x11/randr.hpp b/include/x11/randr.hpp index 56445387..7587f361 100644 --- a/include/x11/randr.hpp +++ b/include/x11/randr.hpp @@ -2,10 +2,11 @@ #include "config.hpp" -#ifndef ENABLE_RANDR_EXT +#if not ENABLE_RANDR_EXT #error "X RandR extension is disabled..." #endif +#include #include #include diff --git a/include/x11/render.hpp b/include/x11/render.hpp index 134569c3..fdd064d9 100644 --- a/include/x11/render.hpp +++ b/include/x11/render.hpp @@ -2,8 +2,9 @@ #include "config.hpp" -#ifndef ENABLE_RENDER_EXT +#if not ENABLE_RENDER_EXT #error "X Render extension is disabled..." #endif +#include #include diff --git a/include/x11/sync.hpp b/include/x11/sync.hpp new file mode 100644 index 00000000..d77c827c --- /dev/null +++ b/include/x11/sync.hpp @@ -0,0 +1,10 @@ +#pragma once + +#include "config.hpp" + +#if not ENABLE_SYNC_EXT +#error "X Sync extension is disabled..." +#endif + +#include +#include diff --git a/include/x11/types.hpp b/include/x11/types.hpp index e427acb1..9c7a8489 100644 --- a/include/x11/types.hpp +++ b/include/x11/types.hpp @@ -4,21 +4,31 @@ // fwd namespace xpp { -#ifdef ENABLE_DAMAGE_EXT +#if ENABLE_DAMAGE_EXT namespace damage { class extension; } #endif -#ifdef ENABLE_RANDR_EXT +#if ENABLE_RANDR_EXT namespace randr { class extension; } #endif -#ifdef ENABLE_RENDER_EXT +#if ENABLE_SYNC_EXT + namespace sync { + class extension; + } +#endif +#if ENABLE_RENDER_EXT namespace render { class extension; } #endif +#if ENABLE_COMPOSITE_EXT + namespace composite { + class extension; + } +#endif } #include @@ -38,20 +48,32 @@ using font = xpp::font; using cursor = xpp::cursor; using registry = xpp::event::registry; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 29b3ae3a..fc0fdd01 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -62,6 +62,12 @@ endif() if(ENABLE_DAMAGE_EXT) set(XCB_PROTOS "${XCB_PROTOS}" damage) endif() +if(ENABLE_SYNC_EXT) + set(XCB_PROTOS "${XCB_PROTOS}" sync) +endif() +if(ENABLE_COMPOSITE_EXT) + set(XCB_PROTOS "${XCB_PROTOS}" composite) +endif() add_subdirectory(${PROJECT_SOURCE_DIR}/lib/xpp ${PROJECT_BINARY_DIR}/lib/xpp) set(APP_LIBRARIES ${APP_LIBRARIES} ${XPP_LIBRARIES}) set(APP_INCLUDE_DIRS ${APP_INCLUDE_DIRS} ${XPP_INCLUDE_DIRS}) diff --git a/src/x11/connection.cpp b/src/x11/connection.cpp index 2c8475bd..c84faf91 100644 --- a/src/x11/connection.cpp +++ b/src/x11/connection.cpp @@ -53,22 +53,33 @@ void connection::query_extensions() { return; } -#ifdef ENABLE_DAMAGE_EXT +#if ENABLE_DAMAGE_EXT damage().query_version(XCB_DAMAGE_MAJOR_VERSION, XCB_DAMAGE_MINOR_VERSION); if (!extension()->present) throw application_error("Missing X extension: Damage"); #endif -#ifdef ENABLE_RENDER_EXT +#if ENABLE_RENDER_EXT render().query_version(XCB_RENDER_MAJOR_VERSION, XCB_RENDER_MINOR_VERSION); if (!extension()->present) throw application_error("Missing X extension: Render"); #endif -#ifdef ENABLE_RANDR_EXT +#if ENABLE_RANDR_EXT randr().query_version(XCB_RANDR_MAJOR_VERSION, XCB_RANDR_MINOR_VERSION); if (!extension()->present) { throw application_error("Missing X extension: RandR"); } #endif +#if ENABLE_SYNC_EXT + if (!extension()->present) { + throw application_error("Missing X extension: Sync"); + } +#endif +#if ENABLE_COMPOSITE_EXT + composite().query_version(XCB_COMPOSITE_MAJOR_VERSION, XCB_COMPOSITE_MINOR_VERSION); + if (!extension()->present) { + throw application_error("Missing X extension: RandR"); + } +#endif s_extensions_loaded = true; } diff --git a/src/x11/draw.cpp b/src/x11/draw.cpp index 1f20f50e..25e1a120 100644 --- a/src/x11/draw.cpp +++ b/src/x11/draw.cpp @@ -11,15 +11,15 @@ namespace draw_util { /** * Fill region of drawable with color defined by gcontext */ - void fill(connection& conn, xcb_drawable_t d, xcb_gcontext_t g, const xcb_rectangle_t rect) { - conn.poly_fill_rectangle(d, g, 1, &rect); + void fill(xcb_connection_t* c, xcb_drawable_t d, xcb_gcontext_t g, const xcb_rectangle_t rect) { + xcb_poly_fill_rectangle(c, d, g, 1, &rect); } /** * Fill region of drawable with color defined by gcontext */ - void fill(connection& conn, xcb_drawable_t d, xcb_gcontext_t g, int16_t x, int16_t y, uint16_t w, uint16_t h) { - fill(conn, d, g, {x, y, w, h}); + void fill(xcb_connection_t* c, xcb_drawable_t d, xcb_gcontext_t g, int16_t x, int16_t y, uint16_t w, uint16_t h) { + fill(c, d, g, {x, y, w, h}); } /** diff --git a/src/x11/tray.cpp b/src/x11/tray.cpp index f9758e09..5c749246 100644 --- a/src/x11/tray.cpp +++ b/src/x11/tray.cpp @@ -22,6 +22,21 @@ #include "x11/xembed.hpp" #include "x11/xutils.hpp" +// ==================================================================================================== +// +// TODO: 32-bit visual +// +// _NET_SYSTEM_TRAY_VISUAL visual_id VISUALID/32 +// +// The property should be set by the tray manager to indicate the preferred visual for icon windows. +// +// To avoid ambiguity about the colormap to use this visual must either be the default visual for +// the screen or it must be a TrueColor visual. If this property is set to a visual with an alpha +// channel, the tray manager must use the Composite extension to composite the icon against the +// background using PictOpOver. +// +// ==================================================================================================== + POLYBAR_NS // implementation : tray_client {{{