diff --git a/config.def.h b/config.def.h index cae2009..4f022f7 100644 --- a/config.def.h +++ b/config.def.h @@ -2,6 +2,8 @@ #define CONFIG_H #define MOD Mod4Mask +#define BORDER_COLOR "#00FF00" +#define BORDER_WIDTH 1 const char* menu[] = {"dmenu_run", 0}; const char* term[] = {"st", 0}; diff --git a/sowm.c b/sowm.c index b4a39dd..2a25c57 100644 --- a/sowm.c +++ b/sowm.c @@ -14,6 +14,7 @@ static client *list = {0}, *ws_list[10] = {0}, *cur; static int ws = 1, sw, sh, wx, wy, numlock = 0; static unsigned int ww, wh; +static int s; static Display *d; static XButtonEvent mouse; static Window root; @@ -31,6 +32,12 @@ static void (*events[LASTEvent])(XEvent *e) = { #include "config.h" +unsigned long getcolor(const char *col) { + Colormap m = DefaultColormap(d, s); + XColor c; + return (!XAllocNamedColor(d, m, col, &c, &c))?0:c.pixel; +} + void win_focus(client *c) { cur = c; XSetInputFocus(d, cur->w, RevertToParent, CurrentTime); @@ -44,6 +51,7 @@ void notify_destroy(XEvent *e) { void notify_enter(XEvent *e) { while(XCheckTypedEvent(d, EnterNotify, e)); + while(XCheckTypedWindowEvent(d, mouse.subwindow, MotionNotify, e)); for win if (c->w == e->xcrossing.window) win_focus(c); } @@ -214,6 +222,9 @@ void map_request(XEvent *e) { win_size(w, &wx, &wy, &ww, &wh); win_add(w); cur = list->prev; + XSetWindowBorder(d, w, getcolor(BORDER_COLOR)); + XConfigureWindow(d, w, CWBorderWidth, &(XWindowChanges){.border_width = BORDER_WIDTH}); + if (wx + wy == 0) win_center((Arg){0}); @@ -263,10 +274,9 @@ int main(void) { signal(SIGCHLD, SIG_IGN); XSetErrorHandler(xerror); - int s = DefaultScreen(d); root = RootWindow(d, s); - sw = XDisplayWidth(d, s); - sh = XDisplayHeight(d, s); + sw = XDisplayWidth(d, s) - (2*BORDER_WIDTH); + sh = XDisplayHeight(d, s) - (2*BORDER_WIDTH); XSelectInput(d, root, SubstructureRedirectMask); XDefineCursor(d, root, XCreateFontCursor(d, 68)); diff --git a/sowm.h b/sowm.h index 455ed93..08af907 100644 --- a/sowm.h +++ b/sowm.h @@ -33,6 +33,7 @@ typedef struct client { Window w; } client; +unsigned long getcolor(const char *col); void button_press(XEvent *e); void button_release(XEvent *e); void configure_request(XEvent *e);