Merge pull request #34 from SeungheonOh/master

README.md: Instruction for applying multiple patches/Patch: Wheel for window resizing.
This commit is contained in:
dylan 2019-12-15 09:26:46 +00:00 committed by GitHub
commit aaabcb8049
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 13 deletions

View File

@ -65,8 +65,8 @@ An itsy bitsy floating window manager (*220~ sloc / 24kb compiled!*).
2) Run `make` to build `sowm`.
3) Copy it to your path or run `make install`.
- `DESTDIR` and `PREFIX` are supported.
4) (Optional) Apply patch with `git apply patches/patch-name`
- In case of applying multiple patches, it has to be done **manually**.
## Thanks

View File

@ -1,5 +1,5 @@
diff --git a/sowm.c b/sowm.c
index bc14c4e..83ed0fb 100644
index bc14c4e..4ae3a8f 100644
--- a/sowm.c
+++ b/sowm.c
@@ -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, \
&(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) {
+ XClearWindow(d, RootWindow(d, DefaultScreen(d)));
@ -48,7 +48,7 @@ index bc14c4e..83ed0fb 100644
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) {
@ -73,10 +73,10 @@ index bc14c4e..83ed0fb 100644
+ cur = list->prev;
+
+ XMoveResizeWindow(d, cur->w,
+ mouse.x_root,
+ mouse.y_root,
+ abs(e->xbutton.x_root - mouse.x_root),
+ abs(e->xbutton.y_root - mouse.y_root));
+ e->xbutton.x_root > mouse.x_root ? mouse.x_root : e->xbutton.x_root,
+ e->xbutton.y_root > mouse.y_root ? mouse.y_root : e->xbutton.y_root,
+ ABS(mouse.x_root - e->xbutton.x_root),
+ ABS(mouse.y_root - e->xbutton.y_root));
+
+ XMapWindow(d, WaitingWindow);
+ win_focus(list->prev);
@ -84,18 +84,19 @@ index bc14c4e..83ed0fb 100644
+ WaitingWindow = 0;
+
+ } else if(!mouse.subwindow && cur) {
+
+ XMoveResizeWindow(d, cur->w,
+ mouse.x_root,
+ mouse.y_root,
+ abs(e->xbutton.x_root - mouse.x_root),
+ abs(e->xbutton.y_root - mouse.y_root));
+ e->xbutton.x_root > mouse.x_root ? mouse.x_root : e->xbutton.x_root,
+ e->xbutton.y_root > mouse.y_root ? mouse.y_root : e->xbutton.y_root,
+ ABS(mouse.x_root - e->xbutton.x_root),
+ ABS(mouse.y_root - e->xbutton.y_root));
+
+ mouse.subwindow = 0;
+ }
}
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) {

View 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);