mirror of
https://github.com/dylanaraps/sowm.git
synced 2025-08-03 13:42:04 -07:00
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
6b8a169b9d |
2
Makefile
2
Makefile
@@ -10,7 +10,7 @@ config.h:
|
|||||||
cp config.def.h config.h
|
cp config.def.h config.h
|
||||||
|
|
||||||
sowm:
|
sowm:
|
||||||
$(CC) -O3 $(CFLAGS) -o sowm sowm.c -lX11 -lXext $(LDFLAGS)
|
$(CC) -O3 $(CFLAGS) -o sowm sowm.c -lX11 $(LDFLAGS)
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
install -Dm755 sowm $(DESTDIR)$(BINDIR)/sowm
|
install -Dm755 sowm $(DESTDIR)$(BINDIR)/sowm
|
||||||
|
@@ -2,7 +2,6 @@
|
|||||||
#define CONFIG_H
|
#define CONFIG_H
|
||||||
|
|
||||||
#define MOD Mod4Mask
|
#define MOD Mod4Mask
|
||||||
#define ROUND_CORNERS 20
|
|
||||||
|
|
||||||
const char* menu[] = {"dmenu_run", 0};
|
const char* menu[] = {"dmenu_run", 0};
|
||||||
const char* term[] = {"st", 0};
|
const char* term[] = {"st", 0};
|
||||||
|
57
sowm.c
57
sowm.c
@@ -4,7 +4,6 @@
|
|||||||
#include <X11/XF86keysym.h>
|
#include <X11/XF86keysym.h>
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
#include <X11/XKBlib.h>
|
#include <X11/XKBlib.h>
|
||||||
#include <X11/extensions/shape.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -62,9 +61,6 @@ void notify_motion(XEvent *e) {
|
|||||||
wy + (mouse.button == 1 ? yd : 0),
|
wy + (mouse.button == 1 ? yd : 0),
|
||||||
MAX(1, ww + (mouse.button == 3 ? xd : 0)),
|
MAX(1, ww + (mouse.button == 3 ? xd : 0)),
|
||||||
MAX(1, wh + (mouse.button == 3 ? yd : 0)));
|
MAX(1, wh + (mouse.button == 3 ? yd : 0)));
|
||||||
|
|
||||||
if (mouse.button == 3)
|
|
||||||
win_round_corners(mouse.subwindow, ROUND_CORNERS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void key_press(XEvent *e) {
|
void key_press(XEvent *e) {
|
||||||
@@ -146,41 +142,6 @@ void win_fs(const Arg arg) {
|
|||||||
} else {
|
} else {
|
||||||
XMoveResizeWindow(d, cur->w, cur->wx, cur->wy, cur->ww, cur->wh);
|
XMoveResizeWindow(d, cur->w, cur->wx, cur->wy, cur->ww, cur->wh);
|
||||||
}
|
}
|
||||||
|
|
||||||
win_round_corners(cur->w, cur->f ? 0 : ROUND_CORNERS);
|
|
||||||
}
|
|
||||||
|
|
||||||
void win_round_corners(Window w, int rad) {
|
|
||||||
unsigned int ww, wh, dia = 2 * rad;
|
|
||||||
|
|
||||||
win_size(w, &(int){1}, &(int){1}, &ww, &wh);
|
|
||||||
|
|
||||||
if (ww < dia || wh < dia) return;
|
|
||||||
|
|
||||||
Pixmap mask = XCreatePixmap(d, w, ww, wh, 1);
|
|
||||||
|
|
||||||
if (!mask) return;
|
|
||||||
|
|
||||||
XGCValues xgcv;
|
|
||||||
GC shape_gc = XCreateGC(d, mask, 0, &xgcv);
|
|
||||||
|
|
||||||
if (!shape_gc) {
|
|
||||||
XFreePixmap(d, mask);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
XSetForeground(d, shape_gc, 0);
|
|
||||||
XFillRectangle(d, mask, shape_gc, 0, 0, ww, wh);
|
|
||||||
XSetForeground(d, shape_gc, 1);
|
|
||||||
XFillArc(d, mask, shape_gc, 0, 0, dia, dia, 0, 23040);
|
|
||||||
XFillArc(d, mask, shape_gc, ww-dia-1, 0, dia, dia, 0, 23040);
|
|
||||||
XFillArc(d, mask, shape_gc, 0, wh-dia-1, dia, dia, 0, 23040);
|
|
||||||
XFillArc(d, mask, shape_gc, ww-dia-1, wh-dia-1, dia, dia, 0, 23040);
|
|
||||||
XFillRectangle(d, mask, shape_gc, rad, 0, ww-dia, wh);
|
|
||||||
XFillRectangle(d, mask, shape_gc, 0, rad, ww, wh-dia);
|
|
||||||
XShapeCombineMask(d, w, ShapeBounding, 0, 0, mask, ShapeSet);
|
|
||||||
XFreePixmap(d, mask);
|
|
||||||
XFreeGC(d, shape_gc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void win_to_ws(const Arg arg) {
|
void win_to_ws(const Arg arg) {
|
||||||
@@ -244,8 +205,6 @@ void configure_request(XEvent *e) {
|
|||||||
.sibling = ev->above,
|
.sibling = ev->above,
|
||||||
.stack_mode = ev->detail
|
.stack_mode = ev->detail
|
||||||
});
|
});
|
||||||
|
|
||||||
win_round_corners(ev->window, ROUND_CORNERS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void map_request(XEvent *e) {
|
void map_request(XEvent *e) {
|
||||||
@@ -258,7 +217,6 @@ void map_request(XEvent *e) {
|
|||||||
|
|
||||||
if (wx + wy == 0) win_center((Arg){0});
|
if (wx + wy == 0) win_center((Arg){0});
|
||||||
|
|
||||||
win_round_corners(w, ROUND_CORNERS);
|
|
||||||
XMapWindow(d, w);
|
XMapWindow(d, w);
|
||||||
win_focus(list->prev);
|
win_focus(list->prev);
|
||||||
}
|
}
|
||||||
@@ -297,6 +255,20 @@ void input_grab(Window root) {
|
|||||||
XFreeModifiermap(modmap);
|
XFreeModifiermap(modmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void win_init(void) {
|
||||||
|
Window *child;
|
||||||
|
unsigned int i, n_child;
|
||||||
|
|
||||||
|
XQueryTree(d, RootWindow(d, DefaultScreen(d)),
|
||||||
|
&(Window){0}, &(Window){0}, &child, &n_child);
|
||||||
|
|
||||||
|
for (i = 0; i < n_child; i++) {
|
||||||
|
XSelectInput(d, child[i], StructureNotifyMask|EnterWindowMask);
|
||||||
|
XMapWindow(d, child[i]);
|
||||||
|
win_add(child[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
|
|
||||||
@@ -313,6 +285,7 @@ int main(void) {
|
|||||||
XSelectInput(d, root, SubstructureRedirectMask);
|
XSelectInput(d, root, SubstructureRedirectMask);
|
||||||
XDefineCursor(d, root, XCreateFontCursor(d, 68));
|
XDefineCursor(d, root, XCreateFontCursor(d, 68));
|
||||||
input_grab(root);
|
input_grab(root);
|
||||||
|
win_init();
|
||||||
|
|
||||||
while (1 && !XNextEvent(d, &ev))
|
while (1 && !XNextEvent(d, &ev))
|
||||||
if (events[ev.type]) events[ev.type](&ev);
|
if (events[ev.type]) events[ev.type](&ev);
|
||||||
|
2
sowm.h
2
sowm.h
@@ -51,7 +51,7 @@ void win_focus(client *c);
|
|||||||
void win_kill(const Arg arg);
|
void win_kill(const Arg arg);
|
||||||
void win_prev(const Arg arg);
|
void win_prev(const Arg arg);
|
||||||
void win_next(const Arg arg);
|
void win_next(const Arg arg);
|
||||||
void win_round_corners(Window w, int rad);
|
void win_init(void);
|
||||||
void win_to_ws(const Arg arg);
|
void win_to_ws(const Arg arg);
|
||||||
void ws_go(const Arg arg);
|
void ws_go(const Arg arg);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user