diff options
| author | Anselm R. Garbe <garbeam@wmii.de> | 2006-07-11 18:19:01 +0200 |
|---|---|---|
| committer | Anselm R. Garbe <garbeam@wmii.de> | 2006-07-11 18:19:01 +0200 |
| commit | b1669b5c48f71c9a7a919dbf09a1af527c62f69a (patch) | |
| tree | f94f1018357afe5abef9cde46a80d16a9676010f | |
| parent | added bar event timer (diff) | |
| download | dwm-b1669b5c48f71c9a7a919dbf09a1af527c62f69a.tar.gz dwm-b1669b5c48f71c9a7a919dbf09a1af527c62f69a.zip | |
removed unnecessary sel stuff
| -rw-r--r-- | Makefile | 10 | ||||
| -rw-r--r-- | gridsel.c | 47 | ||||
| -rw-r--r-- | util.c | 38 | ||||
| -rw-r--r-- | util.h | 2 |
4 files changed, 2 insertions, 95 deletions
| @@ -7,12 +7,10 @@ WMSRC = bar.c client.c cmd.c draw.c event.c key.c util.c wm.c | |||
| 7 | WMOBJ = ${WMSRC:.c=.o} | 7 | WMOBJ = ${WMSRC:.c=.o} |
| 8 | MENSRC = menu.c draw.c util.c | 8 | MENSRC = menu.c draw.c util.c |
| 9 | MENOBJ = ${MENSRC:.c=.o} | 9 | MENOBJ = ${MENSRC:.c=.o} |
| 10 | SELSRC = gridsel.c util.c | ||
| 11 | SELOBJ = ${SELSRC:.c=.o} | ||
| 12 | MAN1 = gridwm.1 gridmenu.1 | 10 | MAN1 = gridwm.1 gridmenu.1 |
| 13 | BIN = gridwm gridmenu gridsel | 11 | BIN = gridwm gridmenu |
| 14 | 12 | ||
| 15 | all: config gridwm gridmenu gridsel | 13 | all: config gridwm gridmenu |
| 16 | @echo finished | 14 | @echo finished |
| 17 | 15 | ||
| 18 | config: | 16 | config: |
| @@ -36,10 +34,6 @@ gridwm: ${WMOBJ} | |||
| 36 | @echo LD $@ | 34 | @echo LD $@ |
| 37 | @${CC} -o $@ ${WMOBJ} ${LDFLAGS} | 35 | @${CC} -o $@ ${WMOBJ} ${LDFLAGS} |
| 38 | 36 | ||
| 39 | gridsel: ${SELOBJ} | ||
| 40 | @echo LD $@ | ||
| 41 | @${CC} -o $@ ${SELOBJ} ${LDFLAGS} | ||
| 42 | |||
| 43 | clean: | 37 | clean: |
| 44 | rm -f gridwm gridmenu *.o core | 38 | rm -f gridwm gridmenu *.o core |
| 45 | 39 | ||
diff --git a/gridsel.c b/gridsel.c deleted file mode 100644 index c76105e..0000000 --- a/gridsel.c +++ /dev/null | |||
| @@ -1,47 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com> | ||
| 3 | * See LICENSE file for license details. | ||
| 4 | */ | ||
| 5 | |||
| 6 | #include <stdlib.h> | ||
| 7 | #include <stdio.h> | ||
| 8 | #include <string.h> | ||
| 9 | |||
| 10 | #include <util.h> | ||
| 11 | |||
| 12 | static char version[] = "gridsel - " VERSION ", (C)opyright MMVI Anselm R. Garbe\n"; | ||
| 13 | |||
| 14 | static void | ||
| 15 | usage() | ||
| 16 | { | ||
| 17 | fprintf(stderr, "%s\n", "usage: gridsel [-v]\n"); | ||
| 18 | exit(1); | ||
| 19 | } | ||
| 20 | |||
| 21 | int | ||
| 22 | main(int argc, char **argv) | ||
| 23 | { | ||
| 24 | unsigned char *data; | ||
| 25 | unsigned long i, offset, len, remain; | ||
| 26 | |||
| 27 | /* command line args */ | ||
| 28 | if(argc > 1) { | ||
| 29 | if(!strncmp(argv[1], "-v", 3)) { | ||
| 30 | fprintf(stdout, "%s", version); | ||
| 31 | exit(0); | ||
| 32 | } else | ||
| 33 | usage(); | ||
| 34 | } | ||
| 35 | len = offset = remain = 0; | ||
| 36 | do { | ||
| 37 | data = getselection(offset, &len, &remain); | ||
| 38 | for(i = 0; i < len; i++) | ||
| 39 | putchar(data[i]); | ||
| 40 | offset += len; | ||
| 41 | free(data); | ||
| 42 | } | ||
| 43 | while(remain); | ||
| 44 | if(offset) | ||
| 45 | putchar('\n'); | ||
| 46 | return 0; | ||
| 47 | } | ||
| @@ -10,7 +10,6 @@ | |||
| 10 | #include <sys/types.h> | 10 | #include <sys/types.h> |
| 11 | #include <sys/wait.h> | 11 | #include <sys/wait.h> |
| 12 | #include <unistd.h> | 12 | #include <unistd.h> |
| 13 | #include <X11/Xatom.h> | ||
| 14 | 13 | ||
| 15 | #include "util.h" | 14 | #include "util.h" |
| 16 | 15 | ||
| @@ -139,40 +138,3 @@ pipe_spawn(char *buf, unsigned int len, Display *dpy, char *argv[]) | |||
| 139 | } | 138 | } |
| 140 | wait(0); | 139 | wait(0); |
| 141 | } | 140 | } |
| 142 | |||
| 143 | |||
| 144 | unsigned char * | ||
| 145 | getselection(unsigned long offset, unsigned long *len, unsigned long *remain) | ||
| 146 | { | ||
| 147 | Display *dpy; | ||
| 148 | Atom xa_clip_string; | ||
| 149 | Window w; | ||
| 150 | XEvent ev; | ||
| 151 | Atom typeret; | ||
| 152 | int format; | ||
| 153 | unsigned char *data; | ||
| 154 | unsigned char *result = NULL; | ||
| 155 | |||
| 156 | dpy = XOpenDisplay(0); | ||
| 157 | if(!dpy) | ||
| 158 | return NULL; | ||
| 159 | xa_clip_string = XInternAtom(dpy, "_SEL_STRING", False); | ||
| 160 | w = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 10, 10, 200, 200, | ||
| 161 | 1, CopyFromParent, CopyFromParent); | ||
| 162 | XConvertSelection(dpy, XA_PRIMARY, XA_STRING, xa_clip_string, | ||
| 163 | w, CurrentTime); | ||
| 164 | XFlush(dpy); | ||
| 165 | XNextEvent(dpy, &ev); | ||
| 166 | if(ev.type == SelectionNotify && ev.xselection.property != None) { | ||
| 167 | XGetWindowProperty(dpy, w, ev.xselection.property, offset, 4096L, False, | ||
| 168 | AnyPropertyType, &typeret, &format, len, remain, &data); | ||
| 169 | if(*len) { | ||
| 170 | result = emalloc(sizeof(unsigned char) * *len); | ||
| 171 | memcpy(result, data, *len); | ||
| 172 | } | ||
| 173 | XDeleteProperty(dpy, w, ev.xselection.property); | ||
| 174 | } | ||
| 175 | XDestroyWindow(dpy, w); | ||
| 176 | XCloseDisplay(dpy); | ||
| 177 | return result; | ||
| 178 | } | ||
| @@ -18,7 +18,5 @@ extern void failed_assert(char *a, char *file, int line); | |||
| 18 | extern void pipe_spawn(char *buf, unsigned int len, Display *dpy, char *argv[]); | 18 | extern void pipe_spawn(char *buf, unsigned int len, Display *dpy, char *argv[]); |
| 19 | extern void spawn(Display *dpy, char *argv[]); | 19 | extern void spawn(Display *dpy, char *argv[]); |
| 20 | extern void swap(void **p1, void **p2); | 20 | extern void swap(void **p1, void **p2); |
| 21 | extern unsigned char *getselection(unsigned long offset, unsigned long *len, | ||
| 22 | unsigned long *remain); | ||
| 23 | extern unsigned int tokenize(char **result, unsigned int reslen, | 21 | extern unsigned int tokenize(char **result, unsigned int reslen, |
| 24 | char *str, char delim); | 22 | char *str, char delim); |
