From: Michael D. Lowis Date: Fri, 24 May 2019 00:58:14 +0000 (-0400) Subject: removed yet more stuff X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=f8d7b183815e423aa55649260b15bc91073c3c10;p=proto%2Fwindowlab.git removed yet more stuff --- diff --git a/client.c b/client.c index fd13966..2b241b8 100644 --- a/client.c +++ b/client.c @@ -173,20 +173,11 @@ void remove_client(Client *c, int mode) void redraw(Client *c) { - XDrawLine(dsply, c->frame, border_gc, 0, BARHEIGHT() - DEF_BORDERWIDTH + DEF_BORDERWIDTH / 2, c->width, BARHEIGHT() - DEF_BORDERWIDTH + DEF_BORDERWIDTH / 2); - // clear text part of bar - if (c == focused_client) - { - XFillRectangle(dsply, c->frame, active_gc, 0, 0, c->width - (BARHEIGHT() - DEF_BORDERWIDTH), BARHEIGHT() - DEF_BORDERWIDTH); - } - else - { - XFillRectangle(dsply, c->frame, inactive_gc, 0, 0, c->width - (BARHEIGHT() - DEF_BORDERWIDTH), BARHEIGHT() - DEF_BORDERWIDTH); - } + int barwidth = BARHEIGHT() - DEF_BORDERWIDTH; + XDrawLine(dsply, c->frame, border_gc, 0, barwidth + DEF_BORDERWIDTH/2, c->width, barwidth + DEF_BORDERWIDTH/2); + XFillRectangle(dsply, c->frame, active_gc, 0, 0, c->width, barwidth); if (!c->trans && c->name != NULL) - { XftDrawString8(c->xftdraw, &xft_detail, xftfont, SPACE, SPACE + xftfont->ascent, (unsigned char *)c->name, strlen(c->name)); - } } /* Window gravity is a mess to explain, but we don't need to do much diff --git a/main.c b/main.c index dfa2e2e..58c44d3 100644 --- a/main.c +++ b/main.c @@ -26,7 +26,6 @@ Display *dsply = NULL; Window root; int screen; -XFontStruct *font = NULL; XftFont *xftfont = NULL; XftColor xft_detail; GC string_gc, border_gc, text_gc, active_gc, depressed_gc, inactive_gc, selected_gc, empty_gc; @@ -51,14 +50,6 @@ static void setup_display(void); int main(int argc, char **argv) { - struct sigaction act; - act.sa_handler = sig_handler; - act.sa_flags = 0; - sigaction(SIGTERM, &act, NULL); - sigaction(SIGINT, &act, NULL); - sigaction(SIGHUP, &act, NULL); - sigaction(SIGCHLD, &act, NULL); - setup_display(); scan_wins(); do_event_loop(); diff --git a/misc.c b/misc.c index 1d57fee..f0bbf79 100644 --- a/misc.c +++ b/misc.c @@ -25,12 +25,9 @@ #include #include "windowlab.h" -static void quit_nicely(void); - void err(const char *fmt, ...) { va_list argp; - fprintf(stderr, "windowlab: "); va_start(argp, fmt); vfprintf(stderr, fmt, argp); @@ -38,67 +35,6 @@ void err(const char *fmt, ...) fprintf(stderr, "\n"); } -void fork_exec(char *cmd) -{ - char *envshell, *envshellname; - pid_t pid = fork(); - - switch (pid) - { - case 0: - setsid(); - envshell = getenv("SHELL"); - if (envshell == NULL) - { - envshell = "/bin/sh"; - } - envshellname = strrchr(envshell, '/'); - if (envshellname == NULL) - { - envshellname = envshell; - } - else - { - /* move to the character after the slash */ - envshellname++; - } - execlp(envshell, envshellname, "-c", cmd, NULL); - err("exec failed, cleaning up child"); - exit(1); - break; - case -1: - err("can't fork"); - break; - } -} - -void sig_handler(int signal) -{ - pid_t pid; - int status; - - switch (signal) - { - case SIGINT: - case SIGTERM: - quit_nicely(); - break; - case SIGCHLD: - while ((pid = waitpid(-1, &status, WNOHANG)) != 0) - { - if ((pid == -1) && (errno != EINTR)) - { - break; - } - else - { - continue; - } - } - break; - } -} - int handle_xerror(Display *dsply, XErrorEvent *e) { Client *c = find_client(e->resourceid, WINDOW); @@ -241,41 +177,3 @@ void copy_dims(Rect *sourcedims, Rect *destdims) destdims->height = sourcedims->height; } -/* We use XQueryTree here to preserve the window stacking order, - * since the order in our linked list is different. */ - -static void quit_nicely(void) -{ - unsigned int nwins, i; - Window dummyw1, dummyw2, *wins; - Client *c; - - XQueryTree(dsply, root, &dummyw1, &dummyw2, &wins, &nwins); - for (i = 0; i < nwins; i++) - { - c = find_client(wins[i], FRAME); - if (c != NULL) - { - remove_client(c, REMAP); - } - } - XFree(wins); - - if (font) - { - XFreeFont(dsply, font); - } - if (xftfont) - { - XftFontClose(dsply, xftfont); - } - XFreeCursor(dsply, resize_curs); - XFreeGC(dsply, border_gc); - XFreeGC(dsply, text_gc); - - XInstallColormap(dsply, DefaultColormap(dsply, screen)); - XSetInputFocus(dsply, PointerRoot, RevertToNone, CurrentTime); - - XCloseDisplay(dsply); - exit(0); -}