From 581a6c22f7deadf11b64f85e9e8e5b5b91978fa0 Mon Sep 17 00:00:00 2001 From: Aki Date: Thu, 26 Aug 2021 18:38:11 +0200 Subject: Switched to use raw get_property --- Makefile | 4 ++-- clipfs.c | 21 +++++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index b2650af..163233a 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CFLAGS += -Wall -Wextra -Wpedantic CFLAGS += -DFUSE_USE_VERSION=31 -CFLAGS += `pkg-config --cflags fuse3 xcb xcb-util xcb-icccm` -LDLIBS += `pkg-config --libs fuse3 xcb xcb-util xcb-icccm` +CFLAGS += `pkg-config --cflags fuse3 xcb xcb-util` +LDLIBS += `pkg-config --libs fuse3 xcb xcb-util` all: clipfs diff --git a/clipfs.c b/clipfs.c index 48f27e8..236a36e 100644 --- a/clipfs.c +++ b/clipfs.c @@ -1,12 +1,11 @@ #include +#include #include -#include #include #include #include #include -#include #include struct selection @@ -91,7 +90,7 @@ void update_selection(const int i) xcb_convert_selection(c, w, x[i].atom, UTF8_STRING, TARGET_PROPERTY, XCB_CURRENT_TIME); xcb_flush(c); xcb_generic_event_t * e; - int done = 0; // TODO: Look into continuous notifications and keeping the data somewhere? + int done = 0; // TODO: Look into continuous notifications. while (!done) { e = xcb_wait_for_event(c); @@ -104,18 +103,20 @@ void update_selection(const int i) xcb_selection_notify_event_t * n = (xcb_selection_notify_event_t *) e; if (x[i].atom == n->selection && XCB_NONE != n->property) { - xcb_icccm_get_text_property_reply_t prop; - xcb_get_property_cookie_t cookie = xcb_icccm_get_text_property(c, n->requestor, n->property); - if (xcb_icccm_get_text_property_reply(c, cookie, &prop, NULL)) + xcb_get_property_cookie_t pcookie = xcb_get_property( + c, 0, w, TARGET_PROPERTY, XCB_ATOM_ANY, 0, UINT32_MAX); + xcb_get_property_reply_t * reply = xcb_get_property_reply(c, pcookie, NULL); + if (reply) { - x[i].data = realloc(x[i].data, prop.name_len); + const int len = xcb_get_property_value_length(reply); + x[i].data = realloc(x[i].data, len); if (NULL == x[i].data) x[i].len = 0; - x[i].len = prop.name_len; - memcpy(x[i].data, prop.name, prop.name_len); - xcb_icccm_get_text_property_reply_wipe(&prop); + x[i].len = len; + memcpy(x[i].data, xcb_get_property_value(reply), len); xcb_delete_property(c, n->requestor, n->property); done = 1; + free(reply); } } free(e); -- cgit v1.1