aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@gmail.com>2017-10-17 15:43:32 -0500
committerDevin J. Pohly <djpohly@gmail.com>2018-02-25 21:53:24 -0600
commit428f01969aaf48ffa2983746c0a397bcc8946799 (patch)
tree5ad1ccfaf6ac0599498b0d7795fe7002b365d19f
parent65976c1a29f2945c3cfb6af74cd6440cf193021d (diff)
downloadst-patched-428f01969aaf48ffa2983746c0a397bcc8946799.tar.bz2
st-patched-428f01969aaf48ffa2983746c0a397bcc8946799.tar.xz
st-patched-428f01969aaf48ffa2983746c0a397bcc8946799.zip
Inline clipboard functions
No need to keep a function that only calls another function in the same file. Signed-off-by: Devin J. Pohly <djpohly@gmail.com>
-rw-r--r--win.h2
-rw-r--r--x.c50
2 files changed, 19 insertions, 33 deletions
diff --git a/win.h b/win.h
index b7022ec..beb458d 100644
--- a/win.h
+++ b/win.h
@@ -10,11 +10,9 @@ void drawregion(int, int, int, int);
10 10
11void xbell(void); 11void xbell(void);
12void xclipcopy(void); 12void xclipcopy(void);
13void xclippaste(void);
14void xhints(void); 13void xhints(void);
15void xloadcols(void); 14void xloadcols(void);
16int xsetcolorname(int, const char *); 15int xsetcolorname(int, const char *);
17void xsettitle(char *); 16void xsettitle(char *);
18void xsetpointermotion(int); 17void xsetpointermotion(int);
19void xselpaste(void);
20void xsetsel(char *, Time); 18void xsetsel(char *, Time);
diff --git a/x.c b/x.c
index cb8c351..46356fe 100644
--- a/x.c
+++ b/x.c
@@ -210,19 +210,33 @@ static char *opt_title = NULL;
210void 210void
211clipcopy(const Arg *dummy) 211clipcopy(const Arg *dummy)
212{ 212{
213 xclipcopy(); 213 Atom clipboard;
214
215 if (sel.clipboard != NULL)
216 free(sel.clipboard);
217
218 if (sel.primary != NULL) {
219 sel.clipboard = xstrdup(sel.primary);
220 clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0);
221 XSetSelectionOwner(xw.dpy, clipboard, xw.win, CurrentTime);
222 }
214} 223}
215 224
216void 225void
217clippaste(const Arg *dummy) 226clippaste(const Arg *dummy)
218{ 227{
219 xclippaste(); 228 Atom clipboard;
229
230 clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0);
231 XConvertSelection(xw.dpy, clipboard, xsel.xtarget, clipboard,
232 xw.win, CurrentTime);
220} 233}
221 234
222void 235void
223selpaste(const Arg *dummy) 236selpaste(const Arg *dummy)
224{ 237{
225 xselpaste(); 238 XConvertSelection(xw.dpy, XA_PRIMARY, xsel.xtarget, XA_PRIMARY,
239 xw.win, CurrentTime);
226} 240}
227 241
228void 242void
@@ -519,35 +533,9 @@ selnotify(XEvent *e)
519} 533}
520 534
521void 535void
522xselpaste(void)
523{
524 XConvertSelection(xw.dpy, XA_PRIMARY, xsel.xtarget, XA_PRIMARY,
525 xw.win, CurrentTime);
526}
527
528void
529xclipcopy(void) 536xclipcopy(void)
530{ 537{
531 Atom clipboard; 538 clipcopy(NULL);
532
533 if (sel.clipboard != NULL)
534 free(sel.clipboard);
535
536 if (sel.primary != NULL) {
537 sel.clipboard = xstrdup(sel.primary);
538 clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0);
539 XSetSelectionOwner(xw.dpy, clipboard, xw.win, CurrentTime);
540 }
541}
542
543void
544xclippaste(void)
545{
546 Atom clipboard;
547
548 clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0);
549 XConvertSelection(xw.dpy, clipboard, xsel.xtarget, clipboard,
550 xw.win, CurrentTime);
551} 539}
552 540
553void 541void
@@ -634,7 +622,7 @@ brelease(XEvent *e)
634 } 622 }
635 623
636 if (e->xbutton.button == Button2) { 624 if (e->xbutton.button == Button2) {
637 xselpaste(); 625 selpaste(NULL);
638 } else if (e->xbutton.button == Button1) { 626 } else if (e->xbutton.button == Button1) {
639 if (sel.mode == SEL_READY) { 627 if (sel.mode == SEL_READY) {
640 getbuttoninfo(e); 628 getbuttoninfo(e);