mirror of
https://github.com/dylanaraps/sowm.git
synced 2025-08-02 05:01:59 -07:00
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
f201a467ea |
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) -lX11 $(LDFLAGS) -o sowm sowm.c
|
$(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,8 +2,6 @@
|
|||||||
#define CONFIG_H
|
#define CONFIG_H
|
||||||
|
|
||||||
#define MOD Mod4Mask
|
#define MOD Mod4Mask
|
||||||
#define TH 90
|
|
||||||
#define TC 255 + (255<<8) + (255<<16)
|
|
||||||
|
|
||||||
const char* menu[] = {"dmenu_run", 0};
|
const char* menu[] = {"dmenu_run", 0};
|
||||||
const char* term[] = {"st", 0};
|
const char* term[] = {"st", 0};
|
||||||
|
59
sowm.c
59
sowm.c
@@ -1,14 +1,12 @@
|
|||||||
// sowm - An itsy bitsy floating window manager.
|
// sowm - An itsy bitsy floating window manager.
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
|
||||||
#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 <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "sowm.h"
|
#include "sowm.h"
|
||||||
|
|
||||||
@@ -33,27 +31,6 @@ static void (*events[LASTEvent])(XEvent *e) = {
|
|||||||
|
|
||||||
#include "config.h"
|
#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) {
|
void win_focus(client *c) {
|
||||||
cur = c;
|
cur = c;
|
||||||
XSetInputFocus(d, cur->w, RevertToParent, CurrentTime);
|
XSetInputFocus(d, cur->w, RevertToParent, CurrentTime);
|
||||||
@@ -74,11 +51,6 @@ void notify_enter(XEvent *e) {
|
|||||||
void notify_motion(XEvent *e) {
|
void notify_motion(XEvent *e) {
|
||||||
if (!mouse.subwindow || cur->f) return;
|
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));
|
while(XCheckTypedEvent(d, MotionNotify, e));
|
||||||
|
|
||||||
int xd = e->xbutton.x_root - mouse.x_root;
|
int xd = e->xbutton.x_root - mouse.x_root;
|
||||||
@@ -89,11 +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 (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) {
|
void key_press(XEvent *e) {
|
||||||
@@ -150,7 +117,6 @@ void win_del(Window w) {
|
|||||||
if (x->next) x->next->prev = x->prev;
|
if (x->next) x->next->prev = x->prev;
|
||||||
if (x->prev) x->prev->next = x->next;
|
if (x->prev) x->prev->next = x->next;
|
||||||
|
|
||||||
title_del(x);
|
|
||||||
free(x);
|
free(x);
|
||||||
ws_save(ws);
|
ws_save(ws);
|
||||||
}
|
}
|
||||||
@@ -164,8 +130,6 @@ void win_center(const Arg arg) {
|
|||||||
|
|
||||||
win_size(cur->w, &(int){0}, &(int){0}, &ww, &wh);
|
win_size(cur->w, &(int){0}, &(int){0}, &ww, &wh);
|
||||||
XMoveWindow(d, cur->w, (sw - ww) / 2, (sh - wh) / 2);
|
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) {
|
void win_fs(const Arg arg) {
|
||||||
@@ -174,12 +138,9 @@ void win_fs(const Arg arg) {
|
|||||||
if ((cur->f = cur->f ? 0 : 1)) {
|
if ((cur->f = cur->f ? 0 : 1)) {
|
||||||
win_size(cur->w, &cur->wx, &cur->wy, &cur->ww, &cur->wh);
|
win_size(cur->w, &cur->wx, &cur->wy, &cur->ww, &cur->wh);
|
||||||
XMoveResizeWindow(d, cur->w, 0, 0, sw, sh);
|
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);
|
XMoveResizeWindow(d, cur->w, cur->wx, cur->wy, cur->ww, cur->wh);
|
||||||
title_add(cur);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +156,6 @@ void win_to_ws(const Arg arg) {
|
|||||||
ws_sel(tmp);
|
ws_sel(tmp);
|
||||||
win_del(cur->w);
|
win_del(cur->w);
|
||||||
XUnmapWindow(d, cur->w);
|
XUnmapWindow(d, cur->w);
|
||||||
title_del(cur);
|
|
||||||
ws_save(tmp);
|
ws_save(tmp);
|
||||||
|
|
||||||
if (list) win_focus(list);
|
if (list) win_focus(list);
|
||||||
@@ -205,10 +165,6 @@ void win_prev(const Arg arg) {
|
|||||||
if (!cur) return;
|
if (!cur) return;
|
||||||
|
|
||||||
XRaiseWindow(d, cur->prev->w);
|
XRaiseWindow(d, cur->prev->w);
|
||||||
|
|
||||||
if (cur->prev->t)
|
|
||||||
XRaiseWindow(d, cur->prev->t);
|
|
||||||
|
|
||||||
win_focus(cur->prev);
|
win_focus(cur->prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,10 +172,6 @@ void win_next(const Arg arg) {
|
|||||||
if (!cur) return;
|
if (!cur) return;
|
||||||
|
|
||||||
XRaiseWindow(d, cur->next->w);
|
XRaiseWindow(d, cur->next->w);
|
||||||
|
|
||||||
if (cur->next->t)
|
|
||||||
XRaiseWindow(d, cur->next->t);
|
|
||||||
|
|
||||||
win_focus(cur->next);
|
win_focus(cur->next);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,17 +183,11 @@ void ws_go(const Arg arg) {
|
|||||||
ws_save(ws);
|
ws_save(ws);
|
||||||
ws_sel(arg.i);
|
ws_sel(arg.i);
|
||||||
|
|
||||||
for win {
|
for win XMapWindow(d, c->w);
|
||||||
XMapWindow(d, c->w);
|
|
||||||
title_add(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
ws_sel(tmp);
|
ws_sel(tmp);
|
||||||
|
|
||||||
for win {
|
for win XUnmapWindow(d, c->w);
|
||||||
XUnmapWindow(d, c->w);
|
|
||||||
title_del(c);
|
|
||||||
}
|
|
||||||
|
|
||||||
ws_sel(arg.i);
|
ws_sel(arg.i);
|
||||||
|
|
||||||
@@ -273,7 +219,6 @@ void map_request(XEvent *e) {
|
|||||||
|
|
||||||
XMapWindow(d, w);
|
XMapWindow(d, w);
|
||||||
win_focus(list->prev);
|
win_focus(list->prev);
|
||||||
title_add(cur);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void run(const Arg arg) {
|
void run(const Arg arg) {
|
||||||
|
4
sowm.h
4
sowm.h
@@ -30,7 +30,7 @@ typedef struct client {
|
|||||||
struct client *next, *prev;
|
struct client *next, *prev;
|
||||||
int f, wx, wy;
|
int f, wx, wy;
|
||||||
unsigned int ww, wh;
|
unsigned int ww, wh;
|
||||||
Window w, t;
|
Window w;
|
||||||
} client;
|
} client;
|
||||||
|
|
||||||
void button_press(XEvent *e);
|
void button_press(XEvent *e);
|
||||||
@@ -43,8 +43,6 @@ void notify_destroy(XEvent *e);
|
|||||||
void notify_enter(XEvent *e);
|
void notify_enter(XEvent *e);
|
||||||
void notify_motion(XEvent *e);
|
void notify_motion(XEvent *e);
|
||||||
void run(const Arg arg);
|
void run(const Arg arg);
|
||||||
void title_add(client *c);
|
|
||||||
void title_del(client *c);
|
|
||||||
void win_add(Window w);
|
void win_add(Window w);
|
||||||
void win_center(const Arg arg);
|
void win_center(const Arg arg);
|
||||||
void win_del(Window w);
|
void win_del(Window w);
|
||||||
|
Reference in New Issue
Block a user