Skip to content

Commit

Permalink
PATCH: Fixed Borders
Browse files Browse the repository at this point in the history
  • Loading branch information
ttr3dp committed Jan 26, 2021
1 parent 9a508a7 commit 92dae1a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#define CONFIG_H

#define MOD Mod4Mask
#define BORDER_COLOR "#6D9E3F"
#define BORDER_WIDTH 3

#define TERM "st"
const char* menu[] = {"dmrun", 0};
Expand Down
16 changes: 13 additions & 3 deletions sowm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -45,6 +46,12 @@ void win_move(const Arg arg) {
MAX(10, wh + (r ? m == 'n' ? -arg.i : m == 's' ? arg.i : 0 : 0)));
}

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);
Expand All @@ -58,6 +65,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);
}
Expand Down Expand Up @@ -228,6 +236,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});

Expand Down Expand Up @@ -288,10 +299,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));
Expand Down
1 change: 1 addition & 0 deletions sowm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 92dae1a

Please sign in to comment.