Skip to content

Commit

Permalink
Import composite and damage extensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
xinhaoyuan committed Sep 24, 2022
1 parent b7bac1d commit 9334dc7
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/apidoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ jobs:
libxcb-shape0-dev \
libxcb-util0-dev \
libxcb-xfixes0-dev \
libxcb-composite0-dev \
libxcb-damage0-dev \
libxcb-xinerama0-dev \
libxcb-xkb-dev \
libxcb-xrm-dev \
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ jobs:
libxcb-shape0-dev \
libxcb-util0-dev \
libxcb-xfixes0-dev \
libxcb-composite0-dev \
libxcb-damage0-dev \
libxcb-xinerama0-dev \
libxcb-xkb-dev \
libxcb-xrm-dev \
Expand Down
16 changes: 16 additions & 0 deletions awesome.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
#include <xcb/xtest.h>
#include <xcb/shape.h>
#include <xcb/xfixes.h>
#include <xcb/composite.h>
#include <xcb/damage.h>

#include <glib-unix.h>

Expand Down Expand Up @@ -725,6 +727,8 @@ main(int argc, char **argv)
xcb_prefetch_extension_data(globalconf.connection, &xcb_xinerama_id);
xcb_prefetch_extension_data(globalconf.connection, &xcb_shape_id);
xcb_prefetch_extension_data(globalconf.connection, &xcb_xfixes_id);
xcb_prefetch_extension_data(globalconf.connection, &xcb_composite_id);
xcb_prefetch_extension_data(globalconf.connection, &xcb_damage_id);

if (xcb_cursor_context_new(globalconf.connection, globalconf.screen, &globalconf.cursor_ctx) < 0)
fatal("Failed to initialize xcb-cursor");
Expand Down Expand Up @@ -793,6 +797,18 @@ main(int argc, char **argv)
xcb_discard_reply(globalconf.connection,
xcb_xfixes_query_version(globalconf.connection, 1, 0).sequence);

query = xcb_get_extension_data(globalconf.connection, &xcb_composite_id);
globalconf.have_composite = query && query->present;
if (globalconf.have_composite)
xcb_discard_reply(globalconf.connection,
xcb_composite_query_version(globalconf.connection, 0, 3).sequence);

query = xcb_get_extension_data(globalconf.connection, &xcb_damage_id);
globalconf.have_damage = query && query->present;
if (globalconf.have_damage)
xcb_discard_reply(globalconf.connection,
xcb_damage_query_version(globalconf.connection, 1, 0).sequence);

event_init();

/* Allocate the key symbols */
Expand Down
2 changes: 2 additions & 0 deletions awesomeConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ set(AWESOME_DEPENDENCIES
xcb-icccm
xcb-icccm>=0.3.8
xcb-xfixes
xcb-composite
xcb-damage
# NOTE: it's not clear what version is required, but 1.10 works at least.
# See https://github.com/awesomeWM/awesome/pull/149#issuecomment-94208356.
xcb-xkb
Expand Down
2 changes: 2 additions & 0 deletions docs/10-building-and-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ environment):
- [libxcb-keysyms >= 0.3.4](https://xcb.freedesktop.org/)
- [libxcb-icccm >= 0.3.8](https://xcb.freedesktop.org/)
- [libxcb-xfixes](https://xcb.freedesktop.org/)
- [libxcb-composite](https://xcb.freedesktop.org/)
- [libxcb-damage](https://xcb.freedesktop.org/)
- [xcb-util-xrm >= 1.0](https://github.com/Airblader/xcb-util-xrm)
- [libxkbcommon](http://xkbcommon.org/) with X11 support enabled
- [libstartup-notification >=
Expand Down
10 changes: 10 additions & 0 deletions event.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include <xcb/xcb_event.h>
#include <xcb/xkb.h>
#include <xcb/xfixes.h>
#include <xcb/damage.h>

#define DO_EVENT_HOOK_CALLBACK(type, xcbtype, xcbeventprefix, arraytype, match) \
static void \
Expand Down Expand Up @@ -1023,6 +1024,10 @@ event_handle_selectionclear(xcb_selection_clear_event_t *ev)
selection_handle_selectionclear(ev);
}

static void
event_handle_damage_notify(xcb_damage_notify_event_t *ev) {
}

/** \brief awesome xerror function.
* There's no way to check accesses to destroyed windows, thus those cases are
* ignored (especially on UnmapNotify's).
Expand Down Expand Up @@ -1143,6 +1148,7 @@ void event_handle(xcb_generic_event_t *event)
EXTENSION_EVENT(shape, XCB_SHAPE_NOTIFY, event_handle_shape_notify);
EXTENSION_EVENT(xkb, 0, event_handle_xkb_notify);
EXTENSION_EVENT(xfixes, XCB_XFIXES_SELECTION_NOTIFY, event_handle_xfixes_selection_notify);
EXTENSION_EVENT(damage, XCB_DAMAGE_NOTIFY, event_handle_damage_notify);
#undef EXTENSION_EVENT
}

Expand All @@ -1165,6 +1171,10 @@ void event_init(void)
reply = xcb_get_extension_data(globalconf.connection, &xcb_xfixes_id);
if (reply && reply->present)
globalconf.event_base_xfixes = reply->first_event;

reply = xcb_get_extension_data(globalconf.connection, &xcb_damage_id);
if (reply && reply->present)
globalconf.event_base_damage = reply->first_event;
}

// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
5 changes: 5 additions & 0 deletions globalconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ typedef struct
bool have_xkb;
/** Check for XFixes extension */
bool have_xfixes;
/** Check for Composite extension */
bool have_composite;
/** Check for Damage extenion */
bool have_damage;
/** Custom searchpaths are present, the runtime is tinted */
bool have_searchpaths;
/** When --no-argb is used in the modeline or command line */
Expand All @@ -134,6 +138,7 @@ typedef struct
uint8_t event_base_xkb;
uint8_t event_base_randr;
uint8_t event_base_xfixes;
uint8_t event_base_damage;
/** Clients list */
client_array_t clients;
/** Embedded windows */
Expand Down

0 comments on commit 9334dc7

Please sign in to comment.