summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2021-08-26 18:38:11 +0200
committerAki <please@ignore.pl>2021-08-26 18:38:11 +0200
commit581a6c22f7deadf11b64f85e9e8e5b5b91978fa0 (patch)
treef6e8272897e3b3b460d0f3eac5fef55b75f8b996
parent85b0e5a78d218597a3d217905edeeea07e8ce13c (diff)
downloadclipfs-581a6c22f7deadf11b64f85e9e8e5b5b91978fa0.zip
clipfs-581a6c22f7deadf11b64f85e9e8e5b5b91978fa0.tar.gz
clipfs-581a6c22f7deadf11b64f85e9e8e5b5b91978fa0.tar.bz2
Switched to use raw get_property
-rw-r--r--Makefile4
-rw-r--r--clipfs.c21
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 <errno.h>
+#include <limits.h>
#include <stdint.h>
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fuse3/fuse.h>
#include <xcb/xcb.h>
-#include <xcb/xcb_icccm.h>
#include <xcb/xcb_util.h>
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);