Adding aspectresize patch

This commit is contained in:
bakkeby 2020-08-27 07:34:21 +02:00
parent 376b48e4d2
commit b3d336322e
8 changed files with 49 additions and 0 deletions

View File

@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog: ### Changelog:
2020-08-27 - Added aspectresize patch
2020-08-25 - Unified tag icon handling while adding support for different icons per monitor. Added alttagsdecoration patch. 2020-08-25 - Unified tag icon handling while adding support for different icons per monitor. Added alttagsdecoration patch.
2020-08-22 - Added logic to auto-hide bars if nothing is drawn on them (e.g. for standalone bars that only show certain clients). Added clientindicators patch and unified indicator code. Simplified Pango integration by settling on common function signatures. 2020-08-22 - Added logic to auto-hide bars if nothing is drawn on them (e.g. for standalone bars that only show certain clients). Added clientindicators patch and unified indicator code. Simplified Pango integration by settling on common function signatures.
@ -170,6 +172,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- [alwaysfullscreen](https://dwm.suckless.org/patches/alwaysfullscreen/) - [alwaysfullscreen](https://dwm.suckless.org/patches/alwaysfullscreen/)
- prevents the focus to drift from the active fullscreen client when using focusstack\(\) - prevents the focus to drift from the active fullscreen client when using focusstack\(\)
- [aspectresize](https://dwm.suckless.org/patches/aspectresize/)
- allows windows to be resized with its aspect ratio remaining constant
- [attachabove](https://dwm.suckless.org/patches/attachabove/) - [attachabove](https://dwm.suckless.org/patches/attachabove/)
- new windows are placed above selected client - new windows are placed above selected client

View File

@ -945,6 +945,10 @@ static Key keys[] = {
{ MODKEY|ShiftMask, XK_l, setcfact, {.f = -0.25} }, { MODKEY|ShiftMask, XK_l, setcfact, {.f = -0.25} },
{ MODKEY|ShiftMask, XK_o, setcfact, {0} }, { MODKEY|ShiftMask, XK_o, setcfact, {0} },
#endif // CFACTS_PATCH #endif // CFACTS_PATCH
#if ASPECTRESIZE_PATCH
{ MODKEY|ControlMask|ShiftMask, XK_e, aspectresize, {.i = +24} },
{ MODKEY|ControlMask|ShiftMask, XK_r, aspectresize, {.i = -24} },
#endif // ASPECTRESIZE_PATCH
#if MOVERESIZE_PATCH #if MOVERESIZE_PATCH
{ MODKEY|Mod4Mask, XK_Down, moveresize, {.v = "0x 25y 0w 0h" } }, { MODKEY|Mod4Mask, XK_Down, moveresize, {.v = "0x 25y 0w 0h" } },
{ MODKEY|Mod4Mask, XK_Up, moveresize, {.v = "0x -25y 0w 0h" } }, { MODKEY|Mod4Mask, XK_Up, moveresize, {.v = "0x -25y 0w 0h" } },

4
dwm.c
View File

@ -63,6 +63,10 @@
#endif // SPAWNCMD_PATCH #endif // SPAWNCMD_PATCH
/* macros */ /* macros */
#define Button6 6
#define Button7 7
#define Button8 8
#define Button9 9
#define NUMTAGS 9 #define NUMTAGS 9
#define BARRULES 20 #define BARRULES 20
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)

24
patch/aspectresize.c Normal file
View File

@ -0,0 +1,24 @@
void
aspectresize(const Arg *arg)
{
/* only floating windows can be moved */
Client *c;
c = selmon->sel;
float ratio;
int w, h,nw, nh;
if (!c || !arg)
return;
if (selmon->lt[selmon->sellt]->arrange && !c->isfloating)
return;
ratio = (float)c->w / (float)c->h;
h = arg->i;
w = (int)(ratio * h);
nw = c->w + w;
nh = c->h + h;
XRaiseWindow(dpy, c->win);
resize(c, c->x, c->y, nw, nh, True);
}

1
patch/aspectresize.h Normal file
View File

@ -0,0 +1 @@
static void aspectresize(const Arg *arg);

View File

@ -82,6 +82,9 @@
#endif #endif
/* Other patches */ /* Other patches */
#if ASPECTRESIZE_PATCH
#include "aspectresize.c"
#endif
#if ATTACHABOVE_PATCH || ATTACHASIDE_PATCH || ATTACHBELOW_PATCH || ATTACHBOTTOM_PATCH #if ATTACHABOVE_PATCH || ATTACHASIDE_PATCH || ATTACHBELOW_PATCH || ATTACHBOTTOM_PATCH
#include "attachx.c" #include "attachx.c"
#endif #endif

View File

@ -79,6 +79,9 @@
#endif #endif
/* Other patches */ /* Other patches */
#if ASPECTRESIZE_PATCH
#include "aspectresize.h"
#endif
#if ATTACHABOVE_PATCH || ATTACHASIDE_PATCH || ATTACHBELOW_PATCH || ATTACHBOTTOM_PATCH #if ATTACHABOVE_PATCH || ATTACHASIDE_PATCH || ATTACHBELOW_PATCH || ATTACHBOTTOM_PATCH
#include "attachx.h" #include "attachx.h"
#endif #endif

View File

@ -299,6 +299,11 @@
* Other patches * Other patches
*/ */
/* This patch allows windows to be resized with its aspect ratio remaining constant.
* https://dwm.suckless.org/patches/aspectresize/
*/
#define ASPECTRESIZE_PATCH 0
/* This patch prevents the focus to drift from the active fullscreen client when /* This patch prevents the focus to drift from the active fullscreen client when
* using focusstack(). * using focusstack().
* https://dwm.suckless.org/patches/alwaysfullscreen/ * https://dwm.suckless.org/patches/alwaysfullscreen/