aboutsummaryrefslogtreecommitdiff
path: root/x.c
diff options
context:
space:
mode:
Diffstat (limited to 'x.c')
-rw-r--r--x.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/x.c b/x.c
index e3e5451..9f506b1 100644
--- a/x.c
+++ b/x.c
@@ -94,6 +94,9 @@ typedef struct {
94 94
95typedef struct { 95typedef struct {
96 Atom xtarget; 96 Atom xtarget;
97 char *primary, *clipboard;
98 struct timespec tclick1;
99 struct timespec tclick2;
97} XSelection; 100} XSelection;
98 101
99/* Font structure */ 102/* Font structure */
@@ -234,11 +237,11 @@ clipcopy(const Arg *dummy)
234{ 237{
235 Atom clipboard; 238 Atom clipboard;
236 239
237 if (sel.clipboard != NULL) 240 if (xsel.clipboard != NULL)
238 free(sel.clipboard); 241 free(xsel.clipboard);
239 242
240 if (sel.primary != NULL) { 243 if (xsel.primary != NULL) {
241 sel.clipboard = xstrdup(sel.primary); 244 xsel.clipboard = xstrdup(xsel.primary);
242 clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0); 245 clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0);
243 XSetSelectionOwner(xw.dpy, clipboard, xw.win, CurrentTime); 246 XSetSelectionOwner(xw.dpy, clipboard, xw.win, CurrentTime);
244 } 247 }
@@ -427,9 +430,9 @@ bpress(XEvent *e)
427 * If the user clicks below predefined timeouts specific 430 * If the user clicks below predefined timeouts specific
428 * snapping behaviour is exposed. 431 * snapping behaviour is exposed.
429 */ 432 */
430 if (TIMEDIFF(now, sel.tclick2) <= tripleclicktimeout) { 433 if (TIMEDIFF(now, xsel.tclick2) <= tripleclicktimeout) {
431 sel.snap = SNAP_LINE; 434 sel.snap = SNAP_LINE;
432 } else if (TIMEDIFF(now, sel.tclick1) <= doubleclicktimeout) { 435 } else if (TIMEDIFF(now, xsel.tclick1) <= doubleclicktimeout) {
433 sel.snap = SNAP_WORD; 436 sel.snap = SNAP_WORD;
434 } else { 437 } else {
435 sel.snap = 0; 438 sel.snap = 0;
@@ -439,8 +442,8 @@ bpress(XEvent *e)
439 if (sel.snap != 0) 442 if (sel.snap != 0)
440 sel.mode = SEL_READY; 443 sel.mode = SEL_READY;
441 tsetdirt(sel.nb.y, sel.ne.y); 444 tsetdirt(sel.nb.y, sel.ne.y);
442 sel.tclick2 = sel.tclick1; 445 xsel.tclick2 = xsel.tclick1;
443 sel.tclick1 = now; 446 xsel.tclick1 = now;
444 } 447 }
445} 448}
446 449
@@ -594,9 +597,9 @@ selrequest(XEvent *e)
594 */ 597 */
595 clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0); 598 clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0);
596 if (xsre->selection == XA_PRIMARY) { 599 if (xsre->selection == XA_PRIMARY) {
597 seltext = sel.primary; 600 seltext = xsel.primary;
598 } else if (xsre->selection == clipboard) { 601 } else if (xsre->selection == clipboard) {
599 seltext = sel.clipboard; 602 seltext = xsel.clipboard;
600 } else { 603 } else {
601 fprintf(stderr, 604 fprintf(stderr,
602 "Unhandled clipboard selection 0x%lx\n", 605 "Unhandled clipboard selection 0x%lx\n",
@@ -620,8 +623,8 @@ selrequest(XEvent *e)
620void 623void
621setsel(char *str, Time t) 624setsel(char *str, Time t)
622{ 625{
623 free(sel.primary); 626 free(xsel.primary);
624 sel.primary = str; 627 xsel.primary = str;
625 628
626 XSetSelectionOwner(xw.dpy, XA_PRIMARY, xw.win, t); 629 XSetSelectionOwner(xw.dpy, XA_PRIMARY, xw.win, t);
627 if (XGetSelectionOwner(xw.dpy, XA_PRIMARY) != xw.win) 630 if (XGetSelectionOwner(xw.dpy, XA_PRIMARY) != xw.win)
@@ -1127,6 +1130,10 @@ xinit(void)
1127 xhints(); 1130 xhints();
1128 XSync(xw.dpy, False); 1131 XSync(xw.dpy, False);
1129 1132
1133 clock_gettime(CLOCK_MONOTONIC, &xsel.tclick1);
1134 clock_gettime(CLOCK_MONOTONIC, &xsel.tclick2);
1135 xsel.primary = NULL;
1136 xsel.clipboard = NULL;
1130 xsel.xtarget = XInternAtom(xw.dpy, "UTF8_STRING", 0); 1137 xsel.xtarget = XInternAtom(xw.dpy, "UTF8_STRING", 0);
1131 if (xsel.xtarget == None) 1138 if (xsel.xtarget == None)
1132 xsel.xtarget = XA_STRING; 1139 xsel.xtarget = XA_STRING;