summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2021-08-26 18:36:56 +0200
committerAki <please@ignore.pl>2021-08-26 18:36:56 +0200
commit85b0e5a78d218597a3d217905edeeea07e8ce13c (patch)
tree9de026d453f29ba7407e3a85544ecacfea9b52ee
parenta0334d3350556b92b12d4f4e62bd7b91cee5d3f8 (diff)
downloadclipfs-85b0e5a78d218597a3d217905edeeea07e8ce13c.zip
clipfs-85b0e5a78d218597a3d217905edeeea07e8ce13c.tar.gz
clipfs-85b0e5a78d218597a3d217905edeeea07e8ce13c.tar.bz2
Exported owner lookup to an utility function
-rw-r--r--clipfs.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/clipfs.c b/clipfs.c
index 488b57e..48f27e8 100644
--- a/clipfs.c
+++ b/clipfs.c
@@ -18,6 +18,7 @@ struct selection
};
int get_selection_index(const char *);
+xcb_window_t find_owner(int);
void update_selection(int);
xcb_atom_t get_atom(xcb_connection_t *, const char *);
int clip_getattr(const char *, struct stat *, struct fuse_file_info *);
@@ -69,15 +70,23 @@ int get_selection_index(const char * path)
}
+xcb_window_t find_owner(const int i)
+{
+ xcb_get_selection_owner_cookie_t cookie = xcb_get_selection_owner(c, x[i].atom);
+ xcb_get_selection_owner_reply_t * reply = xcb_get_selection_owner_reply(c, cookie, NULL);
+ xcb_window_t owner = XCB_WINDOW_NONE;
+ if (reply)
+ owner = reply->owner;
+ free(reply);
+ return owner;
+}
+
+
void update_selection(const int i)
{
xcb_atom_t TARGET_PROPERTY = get_atom(c, "_TARGET_SELECTION");
- xcb_atom_t UTF8_STRING = get_atom(c, "UTF8_STRING"); // TODO: Actually, focus on "rawest" format at first.
- xcb_get_selection_owner_cookie_t owner_cookie = xcb_get_selection_owner(c, x[i].atom);
- xcb_get_selection_owner_reply_t * owner = xcb_get_selection_owner_reply(c, owner_cookie, NULL);
- xcb_window_t owner_window = owner->owner;
- free(owner);
- if (XCB_WINDOW_NONE == owner_window)
+ xcb_atom_t UTF8_STRING = get_atom(c, "UTF8_STRING"); // TODO: Look into ways to support various TARGETS.
+ if (XCB_WINDOW_NONE == find_owner(i))
return;
xcb_convert_selection(c, w, x[i].atom, UTF8_STRING, TARGET_PROPERTY, XCB_CURRENT_TIME);
xcb_flush(c);