diff --git a/libs/arg.c b/libs/arg.c index 46532c5..b327e6c 100644 --- a/libs/arg.c +++ b/libs/arg.c @@ -159,17 +159,7 @@ void moveend(Arg *arg) { } void paste(Arg *arg) { - int clipboard; - - if (arg->i == 1) { - clipboard = XA_PRIMARY; - } else { - clipboard = clip; - } - - XConvertSelection(dpy, clipboard, utf8, utf8, win, CurrentTime); - - return; + paste_x11(arg->i); } void viewhist(Arg *arg) { diff --git a/libs/define.c b/libs/define.c index 41a3056..79610cd 100644 --- a/libs/define.c +++ b/libs/define.c @@ -1,17 +1,10 @@ /* See LICENSE file for copyright and license details. */ -// declare various macros -#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) -#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) #define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \ && MAX(0, MIN((y)+(h),(r).y_org+(r).height) - MAX((y),(r).y_org))) #define LENGTH(X) (sizeof X / sizeof X[0]) #define TEXTW(X) (drw_font_getwidth(drw, (X), False) + lrpad) #define TEXTWM(X) (drw_font_getwidth(drw, (X), True) + lrpad) - -// number #define NUMBERSMAXDIGITS 100 #define NUMBERSBUFSIZE (NUMBERSMAXDIGITS * 2) + 1 - -// item #define MAXITEMLENGTH 1024 diff --git a/libs/x11/clipboard.c b/libs/x11/clipboard.c index f6e59ed..f8df003 100644 --- a/libs/x11/clipboard.c +++ b/libs/x11/clipboard.c @@ -17,3 +17,11 @@ void pastesel_x11(void) { // draw the menu drawmenu(); } + +int paste_x11(int sel) { + if (XConvertSelection(dpy, sel ? XA_PRIMARY : clip, utf8, utf8, win, CurrentTime)) { + return 0; + } else { + return 1; + } +} diff --git a/libs/x11/clipboard.h b/libs/x11/clipboard.h index 43622ee..cc9a895 100644 --- a/libs/x11/clipboard.h +++ b/libs/x11/clipboard.h @@ -1,3 +1,4 @@ /* See LICENSE file for copyright and license details. */ static void pastesel_x11(void); +static int paste_x11(int sel); diff --git a/libs/x11/def.h b/libs/x11/def.h new file mode 100644 index 0000000..da9391b --- /dev/null +++ b/libs/x11/def.h @@ -0,0 +1,4 @@ +/* See LICENSE file for copyright and license details. */ + +#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) +#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) diff --git a/libs/event.c b/libs/x11/event.c similarity index 100% rename from libs/event.c rename to libs/x11/event.c diff --git a/libs/event.h b/libs/x11/event.h similarity index 100% rename from libs/event.h rename to libs/x11/event.h diff --git a/libs/x11/inc.c b/libs/x11/inc.c index c4ef14e..38bfa1e 100644 --- a/libs/x11/inc.c +++ b/libs/x11/inc.c @@ -1,4 +1,5 @@ /* See LICENSE file for copyright and license details. */ + #include "xim.c" #include "key.c" #include "mouse.c" @@ -6,6 +7,7 @@ #include "xrdb.c" #include "client.h" #include "client.c" +#include "event.c" #include "init.c" #include "focus.c" #include "clipboard.c" diff --git a/libs/x11/inc.h b/libs/x11/inc.h index 8f718b3..aa11b19 100644 --- a/libs/x11/inc.h +++ b/libs/x11/inc.h @@ -1,7 +1,9 @@ /* See LICENSE file for copyright and license details. */ #include "lib.h" +#include "def.h" #include "init.h" +#include "event.h" #include "xrdb.h" #include "xim.h" #include "key.h" diff --git a/spmenu.c b/spmenu.c index 085633e..327a27c 100644 --- a/spmenu.c +++ b/spmenu.c @@ -245,8 +245,6 @@ static char *fonts[] = { font }; #include "libs/history.c" #include "libs/arg.c" #include "libs/stream.c" -#include "libs/event.h" -#include "libs/event.c" int is_selected(size_t index) { for (int i = 0; i < sel_size; i++) {