mirror of
https://github.com/dylanaraps/sowm.git
synced 2025-08-03 05:32:02 -07:00
Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
41ad0ff832 | ||
|
abb9445bfb | ||
|
2928148534 | ||
|
f19fd045a8 | ||
|
d271e266e6 | ||
|
cd37b0ad39 | ||
|
69499117c2 | ||
|
1866f5ff02 | ||
|
70dda04916 | ||
|
5668ad1259 | ||
|
c4e64e27b7 | ||
|
a20543402c |
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
sowm
|
||||||
|
sowm.o
|
||||||
|
config.h
|
9
Makefile
9
Makefile
@@ -1,4 +1,4 @@
|
|||||||
CFLAGS+= -std=c99 -Wall -Wno-deprecated-declarations -pedantic
|
CFLAGS+= -std=c99 -Wall -Wextra -pedantic -Wno-deprecated-declarations
|
||||||
LDADD+= -lX11
|
LDADD+= -lX11
|
||||||
LDFLAGS=
|
LDFLAGS=
|
||||||
PREFIX?= /usr
|
PREFIX?= /usr
|
||||||
@@ -6,10 +6,13 @@ BINDIR?= $(PREFIX)/bin
|
|||||||
|
|
||||||
CC ?= gcc
|
CC ?= gcc
|
||||||
|
|
||||||
all: sowm
|
all: config.h sowm
|
||||||
|
|
||||||
|
config.h:
|
||||||
|
cp config.def.h config.h
|
||||||
|
|
||||||
sowm: sowm.o
|
sowm: sowm.o
|
||||||
$(CC) $(LDFLAGS) -Os -o $@ $+ $(LDADD)
|
$(CC) $(LDFLAGS) -O3 -o $@ $+ $(LDADD)
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
install -Dm 755 sowm $(DESTDIR)$(BINDIR)/sowm
|
install -Dm 755 sowm $(DESTDIR)$(BINDIR)/sowm
|
||||||
|
@@ -62,7 +62,7 @@ An itsy bitsy floating window manager (*270~ sloc / 24kb compiled!*).
|
|||||||
|
|
||||||
## Installation
|
## 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`.
|
2) Run `make` to build `sowm`.
|
||||||
3) Copy it to your path or run `make install`.
|
3) Copy it to your path or run `make install`.
|
||||||
- `DESTDIR` and `PREFIX` are supported.
|
- `DESTDIR` and `PREFIX` are supported.
|
||||||
|
@@ -15,7 +15,7 @@ const char* colors[] = {"bud", "/home/goldie/Pictures/Wallpapers", 0};
|
|||||||
|
|
||||||
static struct key keys[] = {
|
static struct key keys[] = {
|
||||||
{MOD, XK_q, win_kill, {0}},
|
{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}},
|
{MOD, XK_f, win_fs, {0}},
|
||||||
{Mod1Mask, XK_Tab, win_next, {0}},
|
{Mod1Mask, XK_Tab, win_next, {0}},
|
||||||
|
|
23
patches/sowm-normal-kill.patch
Normal file
23
patches/sowm-normal-kill.patch
Normal 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
@@ -3,16 +3,16 @@ index 2549d3a..04c2222 100644
|
|||||||
--- a/Makefile
|
--- a/Makefile
|
||||||
+++ b/Makefile
|
+++ b/Makefile
|
||||||
@@ -1,5 +1,5 @@
|
@@ -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
|
||||||
+LDADD+= -lX11 -lXext
|
+LDADD+= -lX11 -lXext
|
||||||
LDFLAGS=
|
LDFLAGS=
|
||||||
PREFIX?= /usr
|
PREFIX?= /usr
|
||||||
BINDIR?= $(PREFIX)/bin
|
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
|
index 864c9a7..1525894 100644
|
||||||
--- a/config.h
|
--- a/config.def.h
|
||||||
+++ b/config.h
|
+++ b/config.def.h
|
||||||
@@ -2,6 +2,7 @@
|
@@ -2,6 +2,7 @@
|
||||||
#define CONFIG_H
|
#define CONFIG_H
|
||||||
|
|
||||||
@@ -41,15 +41,16 @@ index b9e8867..4c0b3fa 100644
|
|||||||
static void win_to_ws(const Arg arg);
|
static void win_to_ws(const Arg arg);
|
||||||
static void ws_go(const Arg arg);
|
static void ws_go(const Arg arg);
|
||||||
static void ws_save(int i);
|
static void ws_save(int i);
|
||||||
@@ -183,6 +185,8 @@ void notify_motion(XEvent *e) {
|
@@ -179,6 +179,9 @@ void notify_motion(XEvent *e) {
|
||||||
attr.width + (mouse.button==3 ? xd : 0),
|
attr.y + (mouse.button == 1 ? yd : 0),
|
||||||
attr.height + (mouse.button==3 ? yd : 0));
|
attr.width + (mouse.button == 3 ? xd : 0),
|
||||||
|
attr.height + (mouse.button == 3 ? yd : 0));
|
||||||
+ win_round_corners(mouse.subwindow, ROUND_CORNERS);
|
|
||||||
+
|
+
|
||||||
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() {
|
@@ -367,9 +367,58 @@ void win_fs() {
|
||||||
|
|
||||||
} else
|
} else
|
||||||
@@ -109,8 +110,8 @@ index b9e8867..4c0b3fa 100644
|
|||||||
/*
|
/*
|
||||||
This function simply moves the focused window to
|
This function simply moves the focused window to
|
||||||
the desired desktop.
|
the desired desktop.
|
||||||
@@ -510,6 +510,7 @@ void map_request(XEvent *e) {
|
@@ -511,6 +511,7 @@ void map_request(XEvent *e) {
|
||||||
EnterWindowMask|FocusChangeMask);
|
|
||||||
win_center((Arg){.i = w});
|
win_center((Arg){.i = w});
|
||||||
XMapWindow(d, w);
|
XMapWindow(d, w);
|
||||||
+ win_round_corners(w, ROUND_CORNERS);
|
+ win_round_corners(w, ROUND_CORNERS);
|
||||||
|
53
sowm.c
53
sowm.c
@@ -23,6 +23,7 @@
|
|||||||
typedef union {
|
typedef union {
|
||||||
const char** com;
|
const char** com;
|
||||||
const int i;
|
const int i;
|
||||||
|
const Window w;
|
||||||
} Arg;
|
} Arg;
|
||||||
|
|
||||||
struct key {
|
struct key {
|
||||||
@@ -66,7 +67,7 @@ static void ws_sel(int i);
|
|||||||
|
|
||||||
static client *list = {0};
|
static client *list = {0};
|
||||||
static desktop ws_list[10];
|
static desktop ws_list[10];
|
||||||
static int ws = 1, sh, sw, s, j;
|
static int ws = 1, sh, sw, s;
|
||||||
|
|
||||||
static Display *d;
|
static Display *d;
|
||||||
static Window root, cur;
|
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.
|
the same value can be used as a variable directly afterwards.
|
||||||
*/
|
*/
|
||||||
Window win_current() {
|
Window win_current() {
|
||||||
XGetInputFocus(d, &cur, &j);
|
XGetInputFocus(d, &cur, (int[]){1});
|
||||||
return cur;
|
return cur;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,26 +164,21 @@ void notify_enter(XEvent *e) {
|
|||||||
There's no use in computing each and every event as we
|
There's no use in computing each and every event as we
|
||||||
only really care about the newest one.
|
only really care about the newest one.
|
||||||
|
|
||||||
The window is then moved or resized and finally its
|
The window is then moved or resized.
|
||||||
fullscreen value is reset to '0' (False).
|
|
||||||
*/
|
*/
|
||||||
void notify_motion(XEvent *e) {
|
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 xd = e->xbutton.x_root - mouse.x_root;
|
int yd = e->xbutton.y_root - mouse.y_root;
|
||||||
int yd = e->xbutton.y_root - mouse.y_root;
|
|
||||||
|
|
||||||
while(XCheckTypedEvent(d, MotionNotify, e));
|
while(XCheckTypedEvent(d, MotionNotify, e));
|
||||||
|
|
||||||
XMoveResizeWindow(d, mouse.subwindow,
|
XMoveResizeWindow(d, mouse.subwindow,
|
||||||
attr.x + (mouse.button==1 ? xd : 0),
|
attr.x + (mouse.button == 1 ? xd : 0),
|
||||||
attr.y + (mouse.button==1 ? yd : 0),
|
attr.y + (mouse.button == 1 ? yd : 0),
|
||||||
attr.width + (mouse.button==3 ? xd : 0),
|
attr.width + (mouse.button == 3 ? xd : 0),
|
||||||
attr.height + (mouse.button==3 ? yd : 0));
|
attr.height + (mouse.button == 3 ? yd : 0));
|
||||||
|
|
||||||
for WIN if (c->w == mouse.subwindow) c->f = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -193,7 +189,7 @@ void notify_motion(XEvent *e) {
|
|||||||
void key_grab() {
|
void key_grab() {
|
||||||
KeyCode code;
|
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)))
|
if ((code = XKeysymToKeycode(d, keys[i].keysym)))
|
||||||
XGrabKey(d, code, keys[i].mod, root,
|
XGrabKey(d, code, keys[i].mod, root,
|
||||||
True, GrabModeAsync, GrabModeAsync);
|
True, GrabModeAsync, GrabModeAsync);
|
||||||
@@ -214,7 +210,7 @@ void key_grab() {
|
|||||||
void key_press(XEvent *e) {
|
void key_press(XEvent *e) {
|
||||||
KeySym keysym = XKeycodeToKeysym(d, e->xkey.keycode, 0);
|
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)
|
if (keys[i].keysym == keysym && keys[i].mod == e->xkey.state)
|
||||||
keys[i].function(keys[i].arg);
|
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
|
On a mouse button release we simply unset the 'mouse' global
|
||||||
as all of this mouse pointer nonsense is done.
|
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() {
|
void button_release() {
|
||||||
|
client *c;
|
||||||
|
|
||||||
|
for WIN if (c->w == mouse.subwindow) c->f = 0;
|
||||||
|
|
||||||
mouse.subwindow = None;
|
mouse.subwindow = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -258,8 +261,7 @@ void win_add(Window w) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
if (!list) {
|
if (!list) {
|
||||||
c->next = 0;
|
c->next = c->prev = 0;
|
||||||
c->prev = 0;
|
|
||||||
c->w = w;
|
c->w = w;
|
||||||
list = c;
|
list = c;
|
||||||
|
|
||||||
@@ -335,7 +337,7 @@ void win_kill() {
|
|||||||
currently focused window.
|
currently focused window.
|
||||||
*/
|
*/
|
||||||
void win_center(const Arg arg) {
|
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);
|
XGetWindowAttributes(d, w, &attr);
|
||||||
|
|
||||||
@@ -468,7 +470,7 @@ void ws_save(int i) {
|
|||||||
*/
|
*/
|
||||||
void ws_sel(int i) {
|
void ws_sel(int i) {
|
||||||
list = ws_list[i].list;
|
list = ws_list[i].list;
|
||||||
ws = i;
|
ws = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -508,6 +510,7 @@ void map_request(XEvent *e) {
|
|||||||
|
|
||||||
XSelectInput(d, w, PropertyChangeMask|StructureNotifyMask|
|
XSelectInput(d, w, PropertyChangeMask|StructureNotifyMask|
|
||||||
EnterWindowMask|FocusChangeMask);
|
EnterWindowMask|FocusChangeMask);
|
||||||
|
|
||||||
win_center((Arg){.i = w});
|
win_center((Arg){.i = w});
|
||||||
XMapWindow(d, w);
|
XMapWindow(d, w);
|
||||||
FOC(w);
|
FOC(w);
|
||||||
@@ -535,9 +538,7 @@ void run(const Arg arg) {
|
|||||||
The only errors which are handled are failed memory
|
The only errors which are handled are failed memory
|
||||||
allocations or a failure to open the display on start.
|
allocations or a failure to open the display on start.
|
||||||
*/
|
*/
|
||||||
int xerror(Display *d, XErrorEvent *e) {
|
int xerror() { return 0; }
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Initialize the window manager by registering all
|
Initialize the window manager by registering all
|
||||||
|
Reference in New Issue
Block a user