sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

dwm-maximize_vert_horz-6.1.diff (2532B)


      1 Author: Jan Christoph Ebersbach <jceb@e-jc.de>
      2 URL: http://dwm.suckless.org/patches/historical/moveresize
      3 These patches provide helper functions for moving and resizing floating windows
      4 using keybindings.
      5 
      6 Index: dwm/dwm.c
      7 ===================================================================
      8 --- dwm/dwm.c.orig	2014-02-09 15:24:12.552116979 +0100
      9 +++ dwm/dwm.c	2014-02-09 15:24:12.548116979 +0100
     10 @@ -91,7 +91,7 @@
     11  	int basew, baseh, incw, inch, maxw, maxh, minw, minh;
     12  	int bw, oldbw;
     13  	unsigned int tags;
     14 -	Bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
     15 +	Bool ismax, wasfloating, isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
     16  	Client *next;
     17  	Client *snext;
     18  	Monitor *mon;
     19 @@ -1047,6 +1047,8 @@
     20  	updatewmhints(c);
     21  	XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
     22  	grabbuttons(c, False);
     23 +	c->wasfloating = False;
     24 +	c->ismax = False;
     25  	if(!c->isfloating)
     26  		c->isfloating = c->oldstate = trans != None || c->isfixed;
     27  	if(c->isfloating)
     28 Index: dwm/maximize.c
     29 ===================================================================
     30 --- /dev/null	1970-01-01 00:00:00.000000000 +0000
     31 +++ dwm/maximize.c	2014-02-09 15:24:12.548116979 +0100
     32 @@ -0,0 +1,45 @@
     33 +void
     34 +maximize(int x, int y, int w, int h) {
     35 +	XEvent ev;
     36 +
     37 +	if(!selmon->sel || selmon->sel->isfixed)
     38 +		return;
     39 +	XRaiseWindow(dpy, selmon->sel->win);
     40 +	if(!selmon->sel->ismax) {
     41 +		if(!selmon->lt[selmon->sellt]->arrange || selmon->sel->isfloating)
     42 +			selmon->sel->wasfloating = True;
     43 +		else {
     44 +			togglefloating(NULL);
     45 +			selmon->sel->wasfloating = False;
     46 +		}
     47 +		selmon->sel->oldx = selmon->sel->x;
     48 +		selmon->sel->oldy = selmon->sel->y;
     49 +		selmon->sel->oldw = selmon->sel->w;
     50 +		selmon->sel->oldh = selmon->sel->h;
     51 +		resize(selmon->sel, x, y, w, h, True);
     52 +		selmon->sel->ismax = True;
     53 +	}
     54 +	else {
     55 +		resize(selmon->sel, selmon->sel->oldx, selmon->sel->oldy, selmon->sel->oldw, selmon->sel->oldh, True);
     56 +		if(!selmon->sel->wasfloating)
     57 +			togglefloating(NULL);
     58 +		selmon->sel->ismax = False;
     59 +	}
     60 +	drawbar(selmon);
     61 +	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
     62 +}
     63 +
     64 +void
     65 +togglemaximize(const Arg *arg) {
     66 +	maximize(selmon->wx, selmon->wy, selmon->ww - 2 * borderpx, selmon->wh - 2 * borderpx);
     67 +}
     68 +
     69 +void
     70 +toggleverticalmax(const Arg *arg) {
     71 +	maximize(selmon->sel->x, selmon->wy, selmon->sel->w, selmon->wh - 2 * borderpx);
     72 +}
     73 +
     74 +void
     75 +togglehorizontalmax(const Arg *arg) {
     76 +	maximize(selmon->wx, selmon->sel->y, selmon->ww - 2 * borderpx, selmon->sel->h);
     77 +}