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
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;
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();
#include <sys/wait.h>
#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);
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);
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);
-}