mirror of
https://github.com/mintycube/dwm.git
synced 2024-10-22 14:05:45 +02:00
Adding maximize patch
This commit is contained in:
parent
853c64fbb7
commit
2de0c0e307
@ -13,6 +13,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
|
||||
|
||||
### Changelog:
|
||||
|
||||
2019-10-04 - Added maximize patch
|
||||
|
||||
2019-10-03 - Added onlyquitonempty and switchcol patches
|
||||
|
||||
2019-10-02 - Added restartsig, emptyview, focusurgent and focusadjacenttag patches
|
||||
@ -133,6 +135,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
|
||||
- it is also possible to spawn new windows (e.g. a terminal) that end up getting focus while the previous window remains in fullscreen
|
||||
- this patch ensures that in such scenarios the previous window loses fullscreen
|
||||
|
||||
- [maximize](https://dwm.suckless.org/patches/maximize/)
|
||||
- adds helper functions for maximizing, horizontally and vertically, floating windows using keybindings
|
||||
|
||||
- monitorrules
|
||||
- adds rules per monitor, e.g. have default layouts per monitor
|
||||
- the use case for this is if the second monitor is vertical (i.e. rotated) then you may want to use a different default layout for this monitor than what is used for the main monitor (for example normal vertical split for main monitor and horizontal split for the second)
|
||||
|
@ -391,6 +391,13 @@ static Key keys[] = {
|
||||
#endif // FLEXTILE_DELUXE_LAYOUT
|
||||
{ MODKEY, XK_space, setlayout, {0} },
|
||||
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
|
||||
#if MAXIMIZE_PATCH
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_h, togglehorizontalmax, {0} },
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_l, togglehorizontalmax, {0} },
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_j, toggleverticalmax, {0} },
|
||||
{ MODKEY|ControlMask|ShiftMask, XK_k, toggleverticalmax, {0} },
|
||||
{ MODKEY|ControlMask, XK_m, togglemaximize, {0} },
|
||||
#endif // MAXIMIZE_PATCH
|
||||
#if UNFLOATVISIBLE_PATCH
|
||||
{ MODKEY|Mod4Mask, XK_space, unfloatvisible, {0} },
|
||||
{ MODKEY|ShiftMask, XK_t, unfloatvisible, {.v = &layouts[0]} },
|
||||
|
7
dwm.c
7
dwm.c
@ -140,6 +140,9 @@ struct Client {
|
||||
int bw, oldbw;
|
||||
unsigned int tags;
|
||||
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
|
||||
#if MAXIMIZE_PATCH
|
||||
int ismax, wasfloating;
|
||||
#endif // MAXIMIZE_PATCH
|
||||
#if AUTORESIZE_PATCH
|
||||
int needresize;
|
||||
#endif // AUTORESIZE_PATCH
|
||||
@ -1748,6 +1751,10 @@ manage(Window w, XWindowAttributes *wa)
|
||||
|
||||
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
|
||||
grabbuttons(c, 0);
|
||||
#if MAXIMIZE_PATCH
|
||||
c->wasfloating = 0;
|
||||
c->ismax = 0;
|
||||
#endif // MAXIMIZE_PATCH
|
||||
if (!c->isfloating)
|
||||
c->isfloating = c->oldstate = trans != None || c->isfixed;
|
||||
if (c->isfloating)
|
||||
|
@ -52,6 +52,10 @@
|
||||
#include "holdbar.c"
|
||||
#endif
|
||||
|
||||
#if MAXIMIZE_PATCH
|
||||
#include "maximize.c"
|
||||
#endif
|
||||
|
||||
#if PERTAG_PATCH
|
||||
#include "pertag.c"
|
||||
#endif
|
||||
|
@ -52,6 +52,10 @@
|
||||
#include "holdbar.h"
|
||||
#endif
|
||||
|
||||
#if MAXIMIZE_PATCH
|
||||
#include "maximize.h"
|
||||
#endif
|
||||
|
||||
#if PERTAG_PATCH
|
||||
#include "pertag.h"
|
||||
#endif
|
||||
|
45
patch/maximize.c
Normal file
45
patch/maximize.c
Normal file
@ -0,0 +1,45 @@
|
||||
void
|
||||
maximize(int x, int y, int w, int h) {
|
||||
XEvent ev;
|
||||
|
||||
if(!selmon->sel || selmon->sel->isfixed)
|
||||
return;
|
||||
XRaiseWindow(dpy, selmon->sel->win);
|
||||
if(!selmon->sel->ismax) {
|
||||
if(!selmon->lt[selmon->sellt]->arrange || selmon->sel->isfloating)
|
||||
selmon->sel->wasfloating = True;
|
||||
else {
|
||||
togglefloating(NULL);
|
||||
selmon->sel->wasfloating = False;
|
||||
}
|
||||
selmon->sel->oldx = selmon->sel->x;
|
||||
selmon->sel->oldy = selmon->sel->y;
|
||||
selmon->sel->oldw = selmon->sel->w;
|
||||
selmon->sel->oldh = selmon->sel->h;
|
||||
resize(selmon->sel, x, y, w, h, True);
|
||||
selmon->sel->ismax = True;
|
||||
}
|
||||
else {
|
||||
resize(selmon->sel, selmon->sel->oldx, selmon->sel->oldy, selmon->sel->oldw, selmon->sel->oldh, True);
|
||||
if(!selmon->sel->wasfloating)
|
||||
togglefloating(NULL);
|
||||
selmon->sel->ismax = False;
|
||||
}
|
||||
drawbar(selmon);
|
||||
while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
|
||||
}
|
||||
|
||||
void
|
||||
togglemaximize(const Arg *arg) {
|
||||
maximize(selmon->wx, selmon->wy, selmon->ww - 2 * borderpx, selmon->wh - 2 * borderpx);
|
||||
}
|
||||
|
||||
void
|
||||
toggleverticalmax(const Arg *arg) {
|
||||
maximize(selmon->sel->x, selmon->wy, selmon->sel->w, selmon->wh - 2 * borderpx);
|
||||
}
|
||||
|
||||
void
|
||||
togglehorizontalmax(const Arg *arg) {
|
||||
maximize(selmon->wx, selmon->sel->y, selmon->ww - 2 * borderpx, selmon->sel->h);
|
||||
}
|
4
patch/maximize.h
Normal file
4
patch/maximize.h
Normal file
@ -0,0 +1,4 @@
|
||||
static void maximize(int x, int y, int w, int h);
|
||||
static void togglemaximize(const Arg *arg);
|
||||
static void toggleverticalmax(const Arg *arg);
|
||||
static void togglehorizontalmax(const Arg *arg);
|
@ -189,6 +189,12 @@
|
||||
*/
|
||||
#define LOSEFULLSCREEN_PATCH 0
|
||||
|
||||
/* This patch adds helper functions for maximizing, horizontally and vertically, floating
|
||||
* windows using keybindings.
|
||||
* https://dwm.suckless.org/patches/maximize/
|
||||
*/
|
||||
#define MAXIMIZE_PATCH 0
|
||||
|
||||
/* Adds rules per monitor, e.g. have default layouts per monitor.
|
||||
* The use case for this is if the second monitor is vertical (i.e. rotated) then
|
||||
* you may want to use a different default layout for this monitor than what is
|
||||
|
Loading…
Reference in New Issue
Block a user