diff options
author | Aki <please@ignore.pl> | 2021-08-26 18:36:56 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2021-08-26 18:36:56 +0200 |
commit | 85b0e5a78d218597a3d217905edeeea07e8ce13c (patch) | |
tree | 9de026d453f29ba7407e3a85544ecacfea9b52ee | |
parent | a0334d3350556b92b12d4f4e62bd7b91cee5d3f8 (diff) | |
download | clipfs-85b0e5a78d218597a3d217905edeeea07e8ce13c.zip clipfs-85b0e5a78d218597a3d217905edeeea07e8ce13c.tar.gz clipfs-85b0e5a78d218597a3d217905edeeea07e8ce13c.tar.bz2 |
Exported owner lookup to an utility function
-rw-r--r-- | clipfs.c | 21 |
1 files changed, 15 insertions, 6 deletions
@@ -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); |