diff options
-rw-r--r-- | clipfs.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -53,7 +53,7 @@ int main(int argc, char ** argv) c, XCB_COPY_FROM_PARENT, w, s->root, 0, 0, 1, 1, 0, XCB_COPY_FROM_PARENT, s->root_visual, mask, values); xcb_flush(c); x[0].atom = get_atom(c, "PRIMARY"); - x[1].atom = get_atom(c, "PRIMARY"); // TODO: This is intentional until update can recognize missing selection. + x[1].atom = get_atom(c, "SECONDARY"); x[2].atom = get_atom(c, "CLIPBOARD"); fuse_main(argc, argv, &clip_ops, NULL); xcb_disconnect(c); @@ -73,7 +73,12 @@ 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. - // TODO-maybe: Look for the selection owner 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) + return; xcb_convert_selection(c, w, x[i].atom, UTF8_STRING, TARGET_PROPERTY, XCB_CURRENT_TIME); xcb_flush(c); xcb_generic_event_t * e; |