12 Commits
0.1 ... 0.2

Author SHA1 Message Date
Dylan Araps
41ad0ff832 patches: rebase 2019-10-16 08:32:46 +03:00
Dylan Araps
abb9445bfb patches: rebase 2019-10-16 08:31:27 +03:00
Dylan Araps
2928148534 patches: rebase 2019-10-16 08:29:58 +03:00
Dylan Araps
f19fd045a8 sowm: resize optimization 2019-10-15 23:44:04 +03:00
Dylan Araps
d271e266e6 patches: Added normal kill. 2019-10-15 20:03:50 +03:00
Dylan Araps
cd37b0ad39 patches: Added normal kill. 2019-10-15 20:01:41 +03:00
Dylan Araps
69499117c2 patches: rebase 2019-10-15 19:50:26 +03:00
Dylan Araps
1866f5ff02 patches: rebase 2019-10-15 19:49:30 +03:00
Dylan Araps
70dda04916 patches: rebase 2019-10-15 19:48:44 +03:00
Dylan Araps
5668ad1259 sowm: fixed all compiler warnings. 2019-10-15 19:45:24 +03:00
Dylan Araps
c4e64e27b7 docs: update 2019-10-15 17:33:40 +03:00
Dylan Araps
a20543402c sowm: provide config.def.h instead 2019-10-15 17:12:10 +03:00
7 changed files with 75 additions and 44 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
sowm
sowm.o
config.h

View File

@@ -1,4 +1,4 @@
CFLAGS+= -std=c99 -Wall -Wno-deprecated-declarations -pedantic
CFLAGS+= -std=c99 -Wall -Wextra -pedantic -Wno-deprecated-declarations
LDADD+= -lX11
LDFLAGS=
PREFIX?= /usr
@@ -6,10 +6,13 @@ BINDIR?= $(PREFIX)/bin
CC ?= gcc
all: sowm
all: config.h sowm
config.h:
cp config.def.h config.h
sowm: sowm.o
$(CC) $(LDFLAGS) -Os -o $@ $+ $(LDADD)
$(CC) $(LDFLAGS) -O3 -o $@ $+ $(LDADD)
install: all
install -Dm 755 sowm $(DESTDIR)$(BINDIR)/sowm

View File

@@ -62,7 +62,7 @@ An itsy bitsy floating window manager (*270~ sloc / 24kb compiled!*).
## Installation
1) Modify `config.h` to suit your needs.
1) Copy `config.def.h` to `config.h` and modify it to suit your needs.
2) Run `make` to build `sowm`.
3) Copy it to your path or run `make install`.
- `DESTDIR` and `PREFIX` are supported.

View File

@@ -15,7 +15,7 @@ const char* colors[] = {"bud", "/home/goldie/Pictures/Wallpapers", 0};
static struct key keys[] = {
{MOD, XK_q, win_kill, {0}},
{MOD, XK_c, win_center, {.i = 0}},
{MOD, XK_c, win_center, {.w = 0}},
{MOD, XK_f, win_fs, {0}},
{Mod1Mask, XK_Tab, win_next, {0}},

View File

@@ -0,0 +1,23 @@
diff --git a/sowm.c b/sowm.c
index 0d74d4b..ff70968 100644
--- a/sowm.c
+++ b/sowm.c
@@ -326,7 +326,17 @@ void win_del(Window w) {
"Shoot first and don't ask questions later?.."
*/
void win_kill() {
- if (win_current() != root) XKillClient(d, cur);
+ if (win_current() == root) return;
+
+ XEvent ev = { .type = ClientMessage };
+
+ ev.xclient.window = cur;
+ ev.xclient.format = 32;
+ ev.xclient.message_type = XInternAtom(d, "WM_PROTOCOLS", True);
+ ev.xclient.data.l[0] = XInternAtom(d, "WM_DELETE_WINDOW", True);
+ ev.xclient.data.l[1] = CurrentTime;
+
+ XSendEvent(d, cur, False, NoEventMask, &ev);
}
/*

View File

@@ -3,16 +3,16 @@ index 2549d3a..04c2222 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
CFLAGS+= -std=c99 -Wall -Wno-deprecated-declarations -pedantic
CFLAGS+= -std=c99 -Wall -Wextra -pedantic -Wno-deprecated-declarations
-LDADD+= -lX11
+LDADD+= -lX11 -lXext
LDFLAGS=
PREFIX?= /usr
BINDIR?= $(PREFIX)/bin
diff --git a/config.h b/config.h
diff --git a/config.def.h b/config.def.h
index 864c9a7..1525894 100644
--- a/config.h
+++ b/config.h
--- a/config.def.h
+++ b/config.def.h
@@ -2,6 +2,7 @@
#define CONFIG_H
@@ -41,15 +41,16 @@ index b9e8867..4c0b3fa 100644
static void win_to_ws(const Arg arg);
static void ws_go(const Arg arg);
static void ws_save(int i);
@@ -183,6 +185,8 @@ void notify_motion(XEvent *e) {
attr.width + (mouse.button==3 ? xd : 0),
attr.height + (mouse.button==3 ? yd : 0));
+ win_round_corners(mouse.subwindow, ROUND_CORNERS);
@@ -179,6 +179,9 @@ void notify_motion(XEvent *e) {
attr.y + (mouse.button == 1 ? yd : 0),
attr.width + (mouse.button == 3 ? xd : 0),
attr.height + (mouse.button == 3 ? yd : 0));
+
for WIN if (c->w == mouse.subwindow) c->f = 0;
}
+ if (mouse.button == 3)
+ win_round_corners(mouse.subwindow, ROUND_CORNERS);
}
/*
@@ -367,9 +367,58 @@ void win_fs() {
} else
@@ -109,8 +110,8 @@ index b9e8867..4c0b3fa 100644
/*
This function simply moves the focused window to
the desired desktop.
@@ -510,6 +510,7 @@ void map_request(XEvent *e) {
EnterWindowMask|FocusChangeMask);
@@ -511,6 +511,7 @@ void map_request(XEvent *e) {
win_center((Arg){.i = w});
XMapWindow(d, w);
+ win_round_corners(w, ROUND_CORNERS);

53
sowm.c
View File

@@ -23,6 +23,7 @@
typedef union {
const char** com;
const int i;
const Window w;
} Arg;
struct key {
@@ -66,7 +67,7 @@ static void ws_sel(int i);
static client *list = {0};
static desktop ws_list[10];
static int ws = 1, sh, sw, s, j;
static int ws = 1, sh, sw, s;
static Display *d;
static Window root, cur;
@@ -110,7 +111,7 @@ static void (*events[LASTEvent])(XEvent *e) = {
the same value can be used as a variable directly afterwards.
*/
Window win_current() {
XGetInputFocus(d, &cur, &j);
XGetInputFocus(d, &cur, (int[]){1});
return cur;
}
@@ -163,26 +164,21 @@ void notify_enter(XEvent *e) {
There's no use in computing each and every event as we
only really care about the newest one.
The window is then moved or resized and finally its
fullscreen value is reset to '0' (False).
The window is then moved or resized.
*/
void notify_motion(XEvent *e) {
client *c;
if (mouse.subwindow == None) return;
if (mouse.subwindow != None) {
int xd = e->xbutton.x_root - mouse.x_root;
int yd = e->xbutton.y_root - mouse.y_root;
int xd = e->xbutton.x_root - mouse.x_root;
int yd = e->xbutton.y_root - mouse.y_root;
while(XCheckTypedEvent(d, MotionNotify, e));
while(XCheckTypedEvent(d, MotionNotify, e));
XMoveResizeWindow(d, mouse.subwindow,
attr.x + (mouse.button==1 ? xd : 0),
attr.y + (mouse.button==1 ? yd : 0),
attr.width + (mouse.button==3 ? xd : 0),
attr.height + (mouse.button==3 ? yd : 0));
for WIN if (c->w == mouse.subwindow) c->f = 0;
}
XMoveResizeWindow(d, mouse.subwindow,
attr.x + (mouse.button == 1 ? xd : 0),
attr.y + (mouse.button == 1 ? yd : 0),
attr.width + (mouse.button == 3 ? xd : 0),
attr.height + (mouse.button == 3 ? yd : 0));
}
/*
@@ -193,7 +189,7 @@ void notify_motion(XEvent *e) {
void key_grab() {
KeyCode code;
for (int i=0; i < sizeof(keys)/sizeof(*keys); ++i)
for (unsigned int i=0; i < sizeof(keys)/sizeof(*keys); ++i)
if ((code = XKeysymToKeycode(d, keys[i].keysym)))
XGrabKey(d, code, keys[i].mod, root,
True, GrabModeAsync, GrabModeAsync);
@@ -214,7 +210,7 @@ void key_grab() {
void key_press(XEvent *e) {
KeySym keysym = XKeycodeToKeysym(d, e->xkey.keycode, 0);
for (int i=0; i < sizeof(keys)/sizeof(*keys); ++i)
for (unsigned int i=0; i < sizeof(keys)/sizeof(*keys); ++i)
if (keys[i].keysym == keysym && keys[i].mod == e->xkey.state)
keys[i].function(keys[i].arg);
}
@@ -239,8 +235,15 @@ void button_press(XEvent *e) {
/*
On a mouse button release we simply unset the 'mouse' global
as all of this mouse pointer nonsense is done.
We also reset the current window's fullscreen state as it is
no longer at 0,0+[screen_width]X[screen_height].
*/
void button_release() {
client *c;
for WIN if (c->w == mouse.subwindow) c->f = 0;
mouse.subwindow = None;
}
@@ -258,8 +261,7 @@ void win_add(Window w) {
exit(1);
if (!list) {
c->next = 0;
c->prev = 0;
c->next = c->prev = 0;
c->w = w;
list = c;
@@ -335,7 +337,7 @@ void win_kill() {
currently focused window.
*/
void win_center(const Arg arg) {
Window w = arg.i ? arg.i : win_current();
Window w = arg.w ? arg.w : win_current();
XGetWindowAttributes(d, w, &attr);
@@ -468,7 +470,7 @@ void ws_save(int i) {
*/
void ws_sel(int i) {
list = ws_list[i].list;
ws = i;
ws = i;
}
/*
@@ -508,6 +510,7 @@ void map_request(XEvent *e) {
XSelectInput(d, w, PropertyChangeMask|StructureNotifyMask|
EnterWindowMask|FocusChangeMask);
win_center((Arg){.i = w});
XMapWindow(d, w);
FOC(w);
@@ -535,9 +538,7 @@ void run(const Arg arg) {
The only errors which are handled are failed memory
allocations or a failure to open the display on start.
*/
int xerror(Display *d, XErrorEvent *e) {
return 0;
}
int xerror() { return 0; }
/*
Initialize the window manager by registering all