[hackers] [st][PATCH 07/23] Move selection functions into x.c

From: Devin J. Pohly <djpohly_AT_gmail.com>
Date: Sun, 24 Sep 2017 16:11:29 -0500

---
 st.c  | 35 +----------------------------------
 st.h  |  1 -
 win.h |  5 +++--
 x.c   | 27 +++++++++++++++++++++++----
 4 files changed, 27 insertions(+), 41 deletions(-)
diff --git a/st.c b/st.c
index 306aa69..559ce73 100644
--- a/st.c
+++ b/st.c
_AT_@ -118,10 +118,7 @@ typedef struct {
 } Key;
 
 /* function definitions used in config.h */
-static void clipcopy(const Arg *);
-static void clippaste(const Arg *);
 static void numlock(const Arg *);
-static void selpaste(const Arg *);
 static void printsel(const Arg *);
 static void printscreen(const Arg *) ;
 static void toggleprinter(const Arg *);
_AT_@ -408,18 +405,6 @@ base64dec(const char *src)
 	return result;
 }
 
-void
-selinit(void)
-{
-	clock_gettime(CLOCK_MONOTONIC, &sel.tclick1);
-	clock_gettime(CLOCK_MONOTONIC, &sel.tclick2);
-	sel.mode = SEL_IDLE;
-	sel.snap = 0;
-	sel.ob.x = -1;
-	sel.primary = NULL;
-	sel.clipboard = NULL;
-}
-
 int
 x2col(int x)
 {
_AT_@ -622,24 +607,6 @@ getsel(void)
 	return str;
 }
 
-void
-selpaste(const Arg *dummy)
-{
-	xselpaste();
-}
-
-void
-clipcopy(const Arg *dummy)
-{
-	xclipcopy();
-}
-
-void
-clippaste(const Arg *dummy)
-{
-	xclippaste();
-}
-
 void
 selclear(void)
 {
_AT_@ -1866,7 +1833,7 @@ strhandle(void)
 				dec = base64dec(strescseq.args[2]);
 				if (dec) {
 					xsetsel(dec, CurrentTime);
-					clipcopy(NULL);
+					xclipcopy();
 				} else {
 					fprintf(stderr, "erresc: invalid base64\n");
 				}
diff --git a/st.h b/st.h
index ed7fa52..1a8bc5c 100644
--- a/st.h
+++ b/st.h
_AT_@ -204,7 +204,6 @@ char *kmap(KeySym, uint);
 void cresize(int, int);
 void selclear(void);
 
-void selinit(void);
 void selnormalize(void);
 int selected(int, int);
 char *getsel(void);
diff --git a/win.h b/win.h
index bf7481f..1d5e664 100644
--- a/win.h
+++ b/win.h
_AT_@ -8,17 +8,18 @@
 void draw(void);
 void drawregion(int, int, int, int);
 
+void clipcopy(const Arg *);
+void clippaste(const Arg *);
 void iso14755(const Arg *);
+void selpaste(const Arg *);
 void xbell(void);
 void xclipcopy(void);
-void xclippaste(void);
 void xloadcols(void);
 int xsetcolorname(int, const char *);
 void xsetenv(void);
 void xsettitle(char *);
 void xsetpointermotion(int);
 void xresize(int, int);
-void xselpaste(void);
 void xsetsel(char *, Time);
 void zoom(const Arg *);
 void zoomabs(const Arg *);
diff --git a/x.c b/x.c
index 9049fa9..6f8d4bc 100644
--- a/x.c
+++ b/x.c
_AT_@ -114,6 +114,7 @@ static void selclear_(XEvent *);
 static void selrequest(XEvent *);
 
 static void selcopy(Time);
+static void selinit(void);
 static void getbuttoninfo(XEvent *);
 static void mousereport(XEvent *);
 static void usage(void);
_AT_@ -413,7 +414,7 @@ selnotify(XEvent *e)
 }
 
 void
-xselpaste(void)
+selpaste(const Arg *dummy)
 {
 	XConvertSelection(xw.dpy, XA_PRIMARY, xsel.xtarget, XA_PRIMARY,
 			xw.win, CurrentTime);
_AT_@ -451,7 +452,7 @@ zoomreset(const Arg *arg)
 }
 
 void
-xclipcopy(void)
+clipcopy(const Arg *dummy)
 {
 	Atom clipboard;
 
_AT_@ -466,7 +467,13 @@ xclipcopy(void)
 }
 
 void
-xclippaste(void)
+xclipcopy()
+{
+	clipcopy(NULL);
+}
+
+void
+clippaste(const Arg *dummy)
 {
 	Atom clipboard;
 
_AT_@ -559,7 +566,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);
_AT_@ -1024,6 +1031,18 @@ xinit(void)
 		xsel.xtarget = XA_STRING;
 }
 
+void
+selinit(void)
+{
+	clock_gettime(CLOCK_MONOTONIC, &sel.tclick1);
+	clock_gettime(CLOCK_MONOTONIC, &sel.tclick2);
+	sel.mode = SEL_IDLE;
+	sel.snap = 0;
+	sel.ob.x = -1;
+	sel.primary = NULL;
+	sel.clipboard = NULL;
+}
+
 int
 xmakeglyphfontspecs(XftGlyphFontSpec *specs, const Glyph *glyphs, int len, int x, int y)
 {
-- 
2.14.1
Received on Sun Sep 24 2017 - 23:11:29 CEST

This archive was generated by hypermail 2.3.0 : Sun Sep 24 2017 - 23:24:56 CEST