[hackers] [st] Inline clipboard functions || Devin J. Pohly

From: <git_AT_suckless.org>
Date: Fri, 9 Mar 2018 15:37:37 +0100 (CET)

commit 428f01969aaf48ffa2983746c0a397bcc8946799
Author: Devin J. Pohly <djpohly_AT_gmail.com>
AuthorDate: Tue Oct 17 15:43:32 2017 -0500
Commit: Devin J. Pohly <djpohly_AT_gmail.com>
CommitDate: Sun Feb 25 21:53:24 2018 -0600

    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_AT_gmail.com>

diff --git a/win.h b/win.h
index b7022ec..beb458d 100644
--- a/win.h
+++ b/win.h
_AT_@ -10,11 +10,9 @@ void drawregion(int, int, int, int);
 
 void xbell(void);
 void xclipcopy(void);
-void xclippaste(void);
 void xhints(void);
 void xloadcols(void);
 int xsetcolorname(int, const char *);
 void xsettitle(char *);
 void xsetpointermotion(int);
-void xselpaste(void);
 void xsetsel(char *, Time);
diff --git a/x.c b/x.c
index cb8c351..46356fe 100644
--- a/x.c
+++ b/x.c
_AT_@ -210,19 +210,33 @@ static char *opt_title = NULL;
 void
 clipcopy(const Arg *dummy)
 {
- xclipcopy();
+ Atom clipboard;
+
+ if (sel.clipboard != NULL)
+ free(sel.clipboard);
+
+ if (sel.primary != NULL) {
+ sel.clipboard = xstrdup(sel.primary);
+ clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0);
+ XSetSelectionOwner(xw.dpy, clipboard, xw.win, CurrentTime);
+ }
 }
 
 void
 clippaste(const Arg *dummy)
 {
- xclippaste();
+ Atom clipboard;
+
+ clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0);
+ XConvertSelection(xw.dpy, clipboard, xsel.xtarget, clipboard,
+ xw.win, CurrentTime);
 }
 
 void
 selpaste(const Arg *dummy)
 {
- xselpaste();
+ XConvertSelection(xw.dpy, XA_PRIMARY, xsel.xtarget, XA_PRIMARY,
+ xw.win, CurrentTime);
 }
 
 void
_AT_@ -519,35 +533,9 @@ selnotify(XEvent *e)
 }
 
 void
-xselpaste(void)
-{
- XConvertSelection(xw.dpy, XA_PRIMARY, xsel.xtarget, XA_PRIMARY,
- xw.win, CurrentTime);
-}
-
-void
 xclipcopy(void)
 {
- Atom clipboard;
-
- if (sel.clipboard != NULL)
- free(sel.clipboard);
-
- if (sel.primary != NULL) {
- sel.clipboard = xstrdup(sel.primary);
- clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0);
- XSetSelectionOwner(xw.dpy, clipboard, xw.win, CurrentTime);
- }
-}
-
-void
-xclippaste(void)
-{
- Atom clipboard;
-
- clipboard = XInternAtom(xw.dpy, "CLIPBOARD", 0);
- XConvertSelection(xw.dpy, clipboard, xsel.xtarget, clipboard,
- xw.win, CurrentTime);
+ clipcopy(NULL);
 }
 
 void
_AT_@ -634,7 +622,7 @@ brelease(XEvent *e)
         }
 
         if (e->xbutton.button == Button2) {
- xselpaste();
+ selpaste(NULL);
         } else if (e->xbutton.button == Button1) {
                 if (sel.mode == SEL_READY) {
                         getbuttoninfo(e);
Received on Fri Mar 09 2018 - 15:37:37 CET

This archive was generated by hypermail 2.3.0 : Fri Mar 09 2018 - 15:49:27 CET