mirror of
https://github.com/dylanaraps/sowm.git
synced 2025-05-19 09:30:24 -07:00
Merge pull request #34 from SeungheonOh/master
README.md: Instruction for applying multiple patches/Patch: Wheel for window resizing.
This commit is contained in:
commit
aaabcb8049
@ -65,8 +65,8 @@ An itsy bitsy floating window manager (*220~ sloc / 24kb compiled!*).
|
|||||||
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.
|
||||||
|
|
||||||
4) (Optional) Apply patch with `git apply patches/patch-name`
|
4) (Optional) Apply patch with `git apply patches/patch-name`
|
||||||
|
- In case of applying multiple patches, it has to be done **manually**.
|
||||||
|
|
||||||
|
|
||||||
## Thanks
|
## Thanks
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
diff --git a/sowm.c b/sowm.c
|
diff --git a/sowm.c b/sowm.c
|
||||||
index bc14c4e..83ed0fb 100644
|
index bc14c4e..4ae3a8f 100644
|
||||||
--- a/sowm.c
|
--- a/sowm.c
|
||||||
+++ b/sowm.c
|
+++ b/sowm.c
|
||||||
@@ -65,6 +65,9 @@ static void (*events[LASTEvent])(XEvent *e) = {
|
@@ -65,6 +65,9 @@ static void (*events[LASTEvent])(XEvent *e) = {
|
||||||
@ -16,7 +16,7 @@ index bc14c4e..83ed0fb 100644
|
|||||||
XGetGeometry(d, W, &(Window){0}, gx, gy, gw, gh, \
|
XGetGeometry(d, W, &(Window){0}, gx, gy, gw, gh, \
|
||||||
&(unsigned int){0}, &(unsigned int){0})
|
&(unsigned int){0}, &(unsigned int){0})
|
||||||
|
|
||||||
+#define abs(a) a < 0 ? -a : a
|
+#define ABS(N) (((N)<0)?-(N):(N))
|
||||||
+
|
+
|
||||||
+void draw_outline(int x1, int y1, int x2, int y2) {
|
+void draw_outline(int x1, int y1, int x2, int y2) {
|
||||||
+ XClearWindow(d, RootWindow(d, DefaultScreen(d)));
|
+ XClearWindow(d, RootWindow(d, DefaultScreen(d)));
|
||||||
@ -48,7 +48,7 @@ index bc14c4e..83ed0fb 100644
|
|||||||
|
|
||||||
while(XCheckTypedEvent(d, MotionNotify, e));
|
while(XCheckTypedEvent(d, MotionNotify, e));
|
||||||
|
|
||||||
@@ -116,15 +139,42 @@ void key_press(XEvent *e) {
|
@@ -116,15 +139,43 @@ void key_press(XEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void button_press(XEvent *e) {
|
void button_press(XEvent *e) {
|
||||||
@ -73,10 +73,10 @@ index bc14c4e..83ed0fb 100644
|
|||||||
+ cur = list->prev;
|
+ cur = list->prev;
|
||||||
+
|
+
|
||||||
+ XMoveResizeWindow(d, cur->w,
|
+ XMoveResizeWindow(d, cur->w,
|
||||||
+ mouse.x_root,
|
+ e->xbutton.x_root > mouse.x_root ? mouse.x_root : e->xbutton.x_root,
|
||||||
+ mouse.y_root,
|
+ e->xbutton.y_root > mouse.y_root ? mouse.y_root : e->xbutton.y_root,
|
||||||
+ abs(e->xbutton.x_root - mouse.x_root),
|
+ ABS(mouse.x_root - e->xbutton.x_root),
|
||||||
+ abs(e->xbutton.y_root - mouse.y_root));
|
+ ABS(mouse.y_root - e->xbutton.y_root));
|
||||||
+
|
+
|
||||||
+ XMapWindow(d, WaitingWindow);
|
+ XMapWindow(d, WaitingWindow);
|
||||||
+ win_focus(list->prev);
|
+ win_focus(list->prev);
|
||||||
@ -84,18 +84,19 @@ index bc14c4e..83ed0fb 100644
|
|||||||
+ WaitingWindow = 0;
|
+ WaitingWindow = 0;
|
||||||
+
|
+
|
||||||
+ } else if(!mouse.subwindow && cur) {
|
+ } else if(!mouse.subwindow && cur) {
|
||||||
|
+
|
||||||
+ XMoveResizeWindow(d, cur->w,
|
+ XMoveResizeWindow(d, cur->w,
|
||||||
+ mouse.x_root,
|
+ e->xbutton.x_root > mouse.x_root ? mouse.x_root : e->xbutton.x_root,
|
||||||
+ mouse.y_root,
|
+ e->xbutton.y_root > mouse.y_root ? mouse.y_root : e->xbutton.y_root,
|
||||||
+ abs(e->xbutton.x_root - mouse.x_root),
|
+ ABS(mouse.x_root - e->xbutton.x_root),
|
||||||
+ abs(e->xbutton.y_root - mouse.y_root));
|
+ ABS(mouse.y_root - e->xbutton.y_root));
|
||||||
+
|
+
|
||||||
+ mouse.subwindow = 0;
|
+ mouse.subwindow = 0;
|
||||||
+ }
|
+ }
|
||||||
}
|
}
|
||||||
|
|
||||||
void win_add(Window w) {
|
void win_add(Window w) {
|
||||||
@@ -244,17 +294,7 @@ void configure_request(XEvent *e) {
|
@@ -244,17 +295,7 @@ void configure_request(XEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void map_request(XEvent *e) {
|
void map_request(XEvent *e) {
|
||||||
|
43
patches/sowm-wheelresize.patch
Normal file
43
patches/sowm-wheelresize.patch
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
diff --git a/config.def.h b/config.def.h
|
||||||
|
index aaaf38d..5a95d71 100644
|
||||||
|
--- a/config.def.h
|
||||||
|
+++ b/config.def.h
|
||||||
|
@@ -2,6 +2,7 @@
|
||||||
|
#define CONFIG_H
|
||||||
|
|
||||||
|
#define MOD Mod4Mask
|
||||||
|
+#define WheelResizeStep 5
|
||||||
|
|
||||||
|
const char* menu[] = {"dmenu_run", 0};
|
||||||
|
const char* term[] = {"st", 0};
|
||||||
|
diff --git a/sowm.c b/sowm.c
|
||||||
|
index bc14c4e..3b95c28 100644
|
||||||
|
--- a/sowm.c
|
||||||
|
+++ b/sowm.c
|
||||||
|
@@ -120,6 +120,17 @@ void button_press(XEvent *e) {
|
||||||
|
|
||||||
|
win_size(e->xbutton.subwindow, &wx, &wy, &ww, &wh);
|
||||||
|
XRaiseWindow(d, e->xbutton.subwindow);
|
||||||
|
+
|
||||||
|
+ int sd = 0;
|
||||||
|
+ if(e->xbutton.button == Button4) sd = WheelResizeStep;
|
||||||
|
+ else if(e->xbutton.button == Button5) sd = -WheelResizeStep;
|
||||||
|
+
|
||||||
|
+ XMoveResizeWindow(d, e->xbutton.subwindow,
|
||||||
|
+ wx - sd,
|
||||||
|
+ wy - sd,
|
||||||
|
+ ww + sd*2,
|
||||||
|
+ wh + sd*2);
|
||||||
|
+
|
||||||
|
mouse = e->xbutton;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -285,7 +296,7 @@ int main(void) {
|
||||||
|
XGrabKey(d, XKeysymToKeycode(d, keys[i].keysym), keys[i].mod,
|
||||||
|
root, True, GrabModeAsync, GrabModeAsync);
|
||||||
|
|
||||||
|
- for (int i=1; i<4; i+=2)
|
||||||
|
+ for (int i=1; i<6; i++)
|
||||||
|
XGrabButton(d, i, MOD, root, True,
|
||||||
|
ButtonPressMask|ButtonReleaseMask|PointerMotionMask,
|
||||||
|
GrabModeAsync, GrabModeAsync, 0, 0);
|
Loading…
x
Reference in New Issue
Block a user