removed unnecessary sel stuff
b1669b5c
4 file(s) · +2 −95
| 7 | 7 | WMOBJ = ${WMSRC:.c=.o} |
|
| 8 | 8 | MENSRC = menu.c draw.c util.c |
|
| 9 | 9 | MENOBJ = ${MENSRC:.c=.o} |
|
| 10 | - | SELSRC = gridsel.c util.c |
|
| 11 | - | SELOBJ = ${SELSRC:.c=.o} |
|
| 12 | 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 | 14 | @echo finished |
|
| 17 | 15 | ||
| 18 | 16 | config: |
|
| 35 | 33 | gridwm: ${WMOBJ} |
|
| 36 | 34 | @echo LD $@ |
|
| 37 | 35 | @${CC} -o $@ ${WMOBJ} ${LDFLAGS} |
|
| 38 | - | ||
| 39 | - | gridsel: ${SELOBJ} |
|
| 40 | - | @echo LD $@ |
|
| 41 | - | @${CC} -o $@ ${SELOBJ} ${LDFLAGS} |
|
| 42 | 36 | ||
| 43 | 37 | clean: |
|
| 44 | 38 | rm -f gridwm gridmenu *.o core |
|
| 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 | 10 | #include <sys/types.h> |
|
| 11 | 11 | #include <sys/wait.h> |
|
| 12 | 12 | #include <unistd.h> |
|
| 13 | - | #include <X11/Xatom.h> |
|
| 14 | 13 | ||
| 15 | 14 | #include "util.h" |
|
| 16 | 15 | ||
| 139 | 138 | } |
|
| 140 | 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 | 18 | extern void pipe_spawn(char *buf, unsigned int len, Display *dpy, char *argv[]); |
|
| 19 | 19 | extern void spawn(Display *dpy, char *argv[]); |
|
| 20 | 20 | extern void swap(void **p1, void **p2); |
|
| 21 | - | extern unsigned char *getselection(unsigned long offset, unsigned long *len, |
|
| 22 | - | unsigned long *remain); |
|
| 23 | 21 | extern unsigned int tokenize(char **result, unsigned int reslen, |
|
| 24 | 22 | char *str, char delim); |