11 Commits
1.2 ... title

Author SHA1 Message Date
Dylan Araps
7e731ccb4c sowm: added titlebar feature 2020-02-20 19:28:09 +02:00
Dylan Araps
7821aac0d2 sowm: Fix Makefile 2020-02-20 18:41:45 +02:00
Dylan Araps
a1c80d9b23 sowm: Fix Makefile 2020-02-20 18:40:29 +02:00
Dylan Araps
0df345e1da sowm: Fix compiler warning 2020-02-20 18:37:19 +02:00
Dylan Araps
b5087acaac docs: update 2020-02-20 18:34:57 +02:00
Dylan Araps
e491a637fe sowm: Changes for easier patching 2020-02-20 16:08:47 +02:00
Dylan Araps
21a35be863 Merge branch 'master' of github.com:dylanaraps/sowm 2020-02-20 16:00:23 +02:00
Dylan Araps
5547cc3a51 sowm: Set minimum resize amount. 2020-02-20 15:59:48 +02:00
dylan
67d323458c Merge pull request #56 from noxgeek/patch-1
Add uninstall to Makefile
2020-02-16 20:02:40 +02:00
noxgeek
0004ff3e18 Add uninstall to Makefile 2020-02-16 18:39:15 +01:00
Dylan Araps
5cc5d25823 Makefile: GNUisms 2020-02-16 13:38:57 +02:00
5 changed files with 83 additions and 16 deletions

View File

@@ -9,11 +9,14 @@ all: config.h sowm
config.h:
cp config.def.h config.h
sowm: sowm.o
$(CC) $(LDFLAGS) -O3 -o $@ $+ -lX11
sowm:
$(CC) -O3 $(CFLAGS) -lX11 $(LDFLAGS) -o sowm sowm.c
install: all
install -Dm755 sowm $(DESTDIR)$(BINDIR)/sowm
uninstall:
rm -f $(DESTDIR)$(BINDIR)/sowm
clean:
rm -f sowm *.o

View File

@@ -9,7 +9,8 @@ An itsy bitsy floating window manager (*220~ sloc / 24kb compiled!*).
- Window centering.
- Mix of mouse and keyboard workflow.
- Focus with cursor.
- Rounded corners (*[through patch](https://github.com/dylanaraps/sowm-patches)*)
- Rounded corners (*[through patch](https://github.com/dylanaraps/sowm/pull/58)*)
- Titlebars (*[through patch](https://github.com/dylanaraps/sowm/pull/57)*)
<a href="https://user-images.githubusercontent.com/6799467/66687814-8cd9f800-ec73-11e9-97b8-6ae77876bd1b.jpg"><img src="https://user-images.githubusercontent.com/6799467/66687814-8cd9f800-ec73-11e9-97b8-6ae77876bd1b.jpg" width="43%" align="right"></a>
@@ -23,7 +24,7 @@ An itsy bitsy floating window manager (*220~ sloc / 24kb compiled!*).
<br>
Patches available here: https://github.com/dylanaraps/sowm-patches
Patches available here: https://github.com/dylanaraps/sowm/pulls
## Default Keybindings

View File

@@ -2,6 +2,8 @@
#define CONFIG_H
#define MOD Mod4Mask
#define TH 90
#define TC 255 + (255<<8) + (255<<16)
const char* menu[] = {"dmenu_run", 0};
const char* term[] = {"st", 0};

75
sowm.c
View File

@@ -1,12 +1,14 @@
// sowm - An itsy bitsy floating window manager.
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/XF86keysym.h>
#include <X11/keysym.h>
#include <X11/XKBlib.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
#include <string.h>
#include "sowm.h"
@@ -16,6 +18,7 @@ static unsigned int ww, wh;
static Display *d;
static XButtonEvent mouse;
static Window root;
static void (*events[LASTEvent])(XEvent *e) = {
[ButtonPress] = button_press,
@@ -30,6 +33,27 @@ static void (*events[LASTEvent])(XEvent *e) = {
#include "config.h"
void title_add(client *c) {
if (c->t) return;
XClassHint cl;
XGetClassHint(d, c->w, &cl);
if (!strcmp(cl.res_name, "no-title")) return;
win_size(c->w, &wx, &wy, &ww, &wh);
c->t = XCreateSimpleWindow(d, root, wx, wy - TH, ww, TH, 0, TC, TC);
XMapWindow(d, c->t);
}
void title_del(client *c) {
if (!c->t) return;
XUnmapWindow(d, c->t);
XDestroyWindow(d, c->t);
c->t = 0;
}
void win_focus(client *c) {
cur = c;
XSetInputFocus(d, cur->w, RevertToParent, CurrentTime);
@@ -50,6 +74,11 @@ void notify_enter(XEvent *e) {
void notify_motion(XEvent *e) {
if (!mouse.subwindow || cur->f) return;
if (mouse.subwindow == cur->t) {
mouse.subwindow = cur->w;
win_size(cur->w, &wx, &wy, &ww, &wh);
}
while(XCheckTypedEvent(d, MotionNotify, e));
int xd = e->xbutton.x_root - mouse.x_root;
@@ -58,8 +87,13 @@ void notify_motion(XEvent *e) {
XMoveResizeWindow(d, mouse.subwindow,
wx + (mouse.button == 1 ? xd : 0),
wy + (mouse.button == 1 ? yd : 0),
ww + (mouse.button == 3 ? xd : 0),
wh + (mouse.button == 3 ? yd : 0));
MAX(1, ww + (mouse.button == 3 ? xd : 0)),
MAX(1, wh + (mouse.button == 3 ? yd : 0)));
if (cur->t) XMoveResizeWindow(d, cur->t,
wx + (mouse.button == 1 ? xd : 0),
wy + (mouse.button == 1 ? yd : 0) - TH,
MAX(1, ww + (mouse.button == 3 ? xd : 0)), TH);
}
void key_press(XEvent *e) {
@@ -116,6 +150,7 @@ void win_del(Window w) {
if (x->next) x->next->prev = x->prev;
if (x->prev) x->prev->next = x->next;
title_del(x);
free(x);
ws_save(ws);
}
@@ -129,6 +164,8 @@ void win_center(const Arg arg) {
win_size(cur->w, &(int){0}, &(int){0}, &ww, &wh);
XMoveWindow(d, cur->w, (sw - ww) / 2, (sh - wh) / 2);
if (cur->t) XMoveWindow(d, cur->t, (sw - ww) / 2, (sh - wh - TH * 2) / 2);
}
void win_fs(const Arg arg) {
@@ -137,9 +174,13 @@ void win_fs(const Arg arg) {
if ((cur->f = cur->f ? 0 : 1)) {
win_size(cur->w, &cur->wx, &cur->wy, &cur->ww, &cur->wh);
XMoveResizeWindow(d, cur->w, 0, 0, sw, sh);
XRaiseWindow(d, cur->w);
title_del(cur);
} else
} else {
XMoveResizeWindow(d, cur->w, cur->wx, cur->wy, cur->ww, cur->wh);
title_add(cur);
}
}
void win_to_ws(const Arg arg) {
@@ -154,6 +195,7 @@ void win_to_ws(const Arg arg) {
ws_sel(tmp);
win_del(cur->w);
XUnmapWindow(d, cur->w);
title_del(cur);
ws_save(tmp);
if (list) win_focus(list);
@@ -163,6 +205,10 @@ void win_prev(const Arg arg) {
if (!cur) return;
XRaiseWindow(d, cur->prev->w);
if (cur->prev->t)
XRaiseWindow(d, cur->prev->t);
win_focus(cur->prev);
}
@@ -170,6 +216,10 @@ void win_next(const Arg arg) {
if (!cur) return;
XRaiseWindow(d, cur->next->w);
if (cur->next->t)
XRaiseWindow(d, cur->next->t);
win_focus(cur->next);
}
@@ -181,11 +231,17 @@ void ws_go(const Arg arg) {
ws_save(ws);
ws_sel(arg.i);
for win XMapWindow(d, c->w);
for win {
XMapWindow(d, c->w);
title_add(c);
}
ws_sel(tmp);
for win XUnmapWindow(d, c->w);
for win {
XUnmapWindow(d, c->w);
title_del(c);
}
ws_sel(arg.i);
@@ -217,6 +273,7 @@ void map_request(XEvent *e) {
XMapWindow(d, w);
win_focus(list->prev);
title_add(cur);
}
void run(const Arg arg) {
@@ -261,10 +318,10 @@ int main(void) {
signal(SIGCHLD, SIG_IGN);
XSetErrorHandler(xerror);
int s = DefaultScreen(d);
Window root = RootWindow(d, s);
sw = XDisplayWidth(d, s);
sh = XDisplayHeight(d, s);
int s = DefaultScreen(d);
root = RootWindow(d, s);
sw = XDisplayWidth(d, s);
sh = XDisplayHeight(d, s);
XSelectInput(d, root, SubstructureRedirectMask);
XDefineCursor(d, root, XCreateFontCursor(d, 68));

10
sowm.h
View File

@@ -3,6 +3,7 @@
#define win (client *t=0, *c=list; c && t!=list->prev; t=c, c=c->next)
#define ws_save(W) ws_list[W] = list
#define ws_sel(W) list = ws_list[ws = W]
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define win_size(W, gx, gy, gw, gh) \
XGetGeometry(d, W, &(Window){0}, gx, gy, gw, gh, \
@@ -12,7 +13,7 @@
#define mod_clean(mask) (mask & ~(numlock|LockMask) & \
(ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
typedef union {
typedef struct {
const char** com;
const int i;
const Window w;
@@ -29,7 +30,7 @@ typedef struct client {
struct client *next, *prev;
int f, wx, wy;
unsigned int ww, wh;
Window w;
Window w, t;
} client;
void button_press(XEvent *e);
@@ -42,6 +43,8 @@ void notify_destroy(XEvent *e);
void notify_enter(XEvent *e);
void notify_motion(XEvent *e);
void run(const Arg arg);
void title_add(client *c);
void title_del(client *c);
void win_add(Window w);
void win_center(const Arg arg);
void win_del(Window w);
@@ -52,4 +55,5 @@ void win_prev(const Arg arg);
void win_next(const Arg arg);
void win_to_ws(const Arg arg);
void ws_go(const Arg arg);
int xerror() { return 0; }
static int xerror() { return 0; }