Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

sowm: Fixed Borders #91

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config.def.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 "#00FF00"
#define BORDER_WIDTH 1

const char* menu[] = {"dmenu_run", 0};
const char* term[] = {"st", 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 All @@ -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);
Expand All @@ -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);
}
Expand Down Expand Up @@ -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});

Expand Down Expand Up @@ -263,10 +274,9 @@ int main(void) {
signal(SIGCHLD, SIG_IGN);
XSetErrorHandler(xerror);

Unixsys marked this conversation as resolved.
Show resolved Hide resolved
int s = DefaultScreen(d);
Copy link

@viyoriya viyoriya Jul 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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