From 7602bce929b882531cd387a4c174b4b1a81954b6 Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Mon, 24 Aug 2020 09:33:59 +0200 Subject: [PATCH] added fibonacci smart master size diff file --- README.md | 1 + fibonacci.c | 2 +- patches/dwm-fibonacci_smart_master_size.diff | 26 ++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 patches/dwm-fibonacci_smart_master_size.diff diff --git a/README.md b/README.md index 65a8b3a..02016b0 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ Patches - warp mouse to center of focussed window - scratchpads - zoom swap +- don't create empty space if master windows are smaller than alloted space (personal) -> This is multiple patches, depending on the layout (fibonacci, tile & deck are seperately listed in patches folder) Requirements diff --git a/fibonacci.c b/fibonacci.c index 99c370a..d79c0ca 100644 --- a/fibonacci.c +++ b/fibonacci.c @@ -46,7 +46,7 @@ fibonacci(Monitor *mon, int s) { if(i == 0) { unsigned int altw = WIDTH(c) * mon->wh / HEIGHT(c); /*use max window height but preserve aspect ratio */ - if( n==1 ){ + if(n == 1){ //if window has min aspect ratio (aka not infinitely adjustable to screen), center that window if ( c->mina > 0 && altw < c->mon->mw ){ nx = c->mon->mx + (c->mon->mw - altw ) / 2; diff --git a/patches/dwm-fibonacci_smart_master_size.diff b/patches/dwm-fibonacci_smart_master_size.diff new file mode 100644 index 0000000..49f045a --- /dev/null +++ b/patches/dwm-fibonacci_smart_master_size.diff @@ -0,0 +1,26 @@ +This patch automatically centers if only one window is open in fibonacci (and that window can't make use of the whole screen) +If there are multiple windows and the master window does not take up all it's alloted space, everything will be adjusted so no empty space is created. +--- fibonacci.c 2020-08-24 09:22:31.596464187 +0200 ++++ fibonacci.c 2020-08-24 09:22:16.013131432 +0200 +@@ -43,9 +45,18 @@ + } + if(i == 0) + { +- if(n != 1) +- nw = mon->ww * mon->mfact; +- ny = mon->wy; ++ unsigned int altw = WIDTH(c) * mon->wh / HEIGHT(c); /*use max window height but preserve aspect ratio */ ++ if(n == 1){ ++ //if window has min aspect ratio (aka not infinitely adjustable to screen), center that window ++ if ( c->mina > 0 && altw < c->mon->mw ){ ++ nx = c->mon->mx + (c->mon->mw - altw ) / 2; ++ } ++ } ++ else{ ++ nw = mon->ww *mon->mfact; ++ nw = c->mina > 0 && altw < nw ? altw : nw; ++ ny = mon->wy; ++ } + } + else if(i == 1) + nw = mon->ww - nw;