On Tue, 11 Mar 2008 23:05:56 +0100
"Anselm R. Garbe" <[EMAIL PROTECTED]> wrote:

> On Fri, Mar 07, 2008 at 12:02:31PM +0100, Szabolcs Nagy wrote:
> > On 3/7/08, pancake <[EMAIL PROTECTED]> wrote:
> > > * If we change these #defines to integer variables we will be able to 
> > > write
> > > external
> > > commands to swap master and slave area between two monitors, join both
> > > areas, manage
> > > setmwfact or creating mixed layouts. And everything without touching the
> > > core :)
> > 
> > +togglebar
> 
> I agree on having the defines being assigned to specific
> variables/I pushed a change accordingly some minutes ago.

Yeah! nice!

I have reimplemented the togglebar and setmwfact for current 4.8.
My config is attached too, it should work on mostly common configurations.

Obviously the mwfact plugin doesn't works well with multiple screens.

patches are attached.

Im not very proud of these codes, but they work and show how
to change the master/tile/bar variables.
 
> However, the defines are useful as they are, because they are
> allowed to depend on bh and s{x,y,w,h} which are initialized
> before the assignments (otherwise things like int mw = sw; in
> config.h won't work, because sw is not initialized in the global
> scope already due to DisplayWidth() depending on dpy).

Yeah this is good :) we can ignore hardcoding the resolution if
we only use one monitor using:

#define SCRT sw*3/5
#define SCRW sw
#define SCRH sh

What do you think about the addition of a third area for "static"
applications that can be used for a third monitor or a second one
with a default dwm configuration in the first monitor. This would
be a sample configuration.

  screen 1      screen 2
+-----------+ +-----+-----+
|      |    | |     |     |
|      |----| |-----|-----|
|      |    | |     |     |
+------+----+ +-----+-----+

We can define a toggle to switch between the screen 1 and two with a
"zoom" key to move applications between static area and master one.

This way we can also enhace the layout configuration with a single
monitor with three areas in this way:

+-----------+
|     |     |  M = Master
|  M  |  T  |  T = Tiled
+-----|     |  S = Static
|  S  |     |
+-----+-----+

The simplest way I can imagine for this is by specifying a tag into a frame area
to make it visible in some place of the screen.

Maybe this is too many changes for 4.7 - 4.8 but I maybe good for single
and multiple screens.

--pancake
/* See LICENSE file for copyright and license details. */

/* appearance */
#define BORDERPX		6
#define FONT			"-*-terminus-medium-r-normal-*-14-*-*-*-*-*-*-*"
#define NORMBGCOLOR		"#cccccc"
#define NORMFGCOLOR		"#000000"
#define NORMBORDERCOLOR		"#172"
//"#cccccc"
#define SELBORDERCOLOR		"#cccccc"
//"#0066ff"
#define SELBGCOLOR		"#172" 
//"#0066ff"
#define SELFGCOLOR		"#ffffff"

#define SCRT sw*3/5
#define SCRW sw
#define SCRH sh

/* bar position */
#define BX 0
#define BY 0
#define BW MW

/* window area, including floating windows */
#define WX 0
#define WY bh
#define WW sw
#define WH sh - bh

/* master area */
#define MX WX
#define MY bh
#define MW SCRT
#define MH SCRH - bh

/* tile area, might be on a different screen */
// TX=MW
#define TX MW
#define TY 0
#define TW SCRW-SCRT
#define TH SCRH

/* monocle area, might be restricted to a specific screen */
#define MOX MX
#define MOY MY
#define MOW SCRW-8
#define MOH MH

/* tagging */
const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };

Rule rules[] = {
	/* class:instance:title substr	tags ref	isfloating */
	{ "Firefox",			tags[8],	False },
	{ "Gimp",			NULL,		True },
	{ "MPlayer",			NULL,		True },
	{ "Acroread",			NULL,		True },
};

/* layout(s) */
#define RESIZEHINTS		False	/* False - respect size hints in tiled resizals */
#define SNAP			32	/* snap pixel */

Layout layouts[] = {
	/* symbol		function	isfloating */
	{ "[]=",		tilev,		False },
	{ "[]|",		tileh,		False }, /* first entry is default */
	{ "[M]",		monocle,	True },
};
	//{ "><>",		floating,	True },

#include "mwfact.c"
#include "togglebar.c"

/* key definitions */
#define MODKEY			Mod1Mask
Key keys[] = {
	/* modifier			key		function	argument */
#if ANSELM_OFFICE
	{ MODKEY,			XK_p,		spawn,
		"exec dmenu_run -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' -sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"' -x 0 -y 0 -w 1280" },
#else
	{ MODKEY,			XK_p,		spawn,
		"exec dmenu_run -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' -sb '"SELBGCOLOR"' -sf '"SELFGCOLOR"'" },
#endif
	{ MODKEY|ShiftMask,		XK_Return,	spawn, "exec Eterm" },
	{ MODKEY,			XK_j,		focusnext,	NULL },
	{ MODKEY,			XK_k,		focusprev,	NULL },
	{ MODKEY,			XK_r,		reapply,	NULL },
	{ MODKEY,			XK_Return,	zoom,		NULL },
	{ MODKEY,			XK_Tab,		viewprevtag,	NULL },
	{ MODKEY,			XK_m,		setlayout,	"[M]" },
	{ MODKEY,			XK_f,		setlayout,	"><>" },
	{ MODKEY,			XK_t,		setlayout,	"[]=" },
	{ MODKEY,			XK_v,		setlayout,	"[]|" },
	{ MODKEY,			XK_h,		setmwfact,	"-64" },
	{ MODKEY,			XK_l,		setmwfact,	"+64" },
	{ MODKEY,			XK_b,		togglebar,	NULL },
	{ MODKEY|ShiftMask,		XK_space,	togglefloating,	NULL },
	{ MODKEY|ShiftMask,		XK_c,		killclient,	NULL },
	{ MODKEY,			XK_0,		view,		NULL },
	{ MODKEY,			XK_1,		view,		tags[0] },
	{ MODKEY,			XK_2,		view,		tags[1] },
	{ MODKEY,			XK_3,		view,		tags[2] },
	{ MODKEY,			XK_4,		view,		tags[3] },
	{ MODKEY,			XK_5,		view,		tags[4] },
	{ MODKEY,			XK_6,		view,		tags[5] },
	{ MODKEY,			XK_7,		view,		tags[6] },
	{ MODKEY,			XK_8,		view,		tags[7] },
	{ MODKEY,			XK_9,		view,		tags[8] },
	{ MODKEY|ControlMask,		XK_1,		toggleview,	tags[0] },
	{ MODKEY|ControlMask,		XK_2,		toggleview,	tags[1] },
	{ MODKEY|ControlMask,		XK_3,		toggleview,	tags[2] },
	{ MODKEY|ControlMask,		XK_4,		toggleview,	tags[3] },
	{ MODKEY|ControlMask,		XK_5,		toggleview,	tags[4] },
	{ MODKEY|ControlMask,		XK_6,		toggleview,	tags[5] },
	{ MODKEY|ControlMask,		XK_7,		toggleview,	tags[6] },
	{ MODKEY|ControlMask,		XK_8,		toggleview,	tags[7] },
	{ MODKEY|ControlMask,		XK_9,		toggleview,	tags[8] },
	{ MODKEY|ShiftMask,		XK_0,		tag,		NULL },
	{ MODKEY|ShiftMask,		XK_1,		tag,		tags[0] },
	{ MODKEY|ShiftMask,		XK_2,		tag,		tags[1] },
	{ MODKEY|ShiftMask,		XK_3,		tag,		tags[2] },
	{ MODKEY|ShiftMask,		XK_4,		tag,		tags[3] },
	{ MODKEY|ShiftMask,		XK_5,		tag,		tags[4] },
	{ MODKEY|ShiftMask,		XK_6,		tag,		tags[5] },
	{ MODKEY|ShiftMask,		XK_7,		tag,		tags[6] },
	{ MODKEY|ShiftMask,		XK_8,		tag,		tags[7] },
	{ MODKEY|ShiftMask,		XK_9,		tag,		tags[8] },
	{ MODKEY|ControlMask|ShiftMask,	XK_1,		toggletag,	tags[0] },
	{ MODKEY|ControlMask|ShiftMask,	XK_2,		toggletag,	tags[1] },
	{ MODKEY|ControlMask|ShiftMask,	XK_3,		toggletag,	tags[2] },
	{ MODKEY|ControlMask|ShiftMask,	XK_4,		toggletag,	tags[3] },
	{ MODKEY|ControlMask|ShiftMask,	XK_5,		toggletag,	tags[4] },
	{ MODKEY|ControlMask|ShiftMask,	XK_6,		toggletag,	tags[5] },
	{ MODKEY|ControlMask|ShiftMask,	XK_7,		toggletag,	tags[6] },
	{ MODKEY|ControlMask|ShiftMask,	XK_8,		toggletag,	tags[7] },
	{ MODKEY|ControlMask|ShiftMask,	XK_9,		toggletag,	tags[8] },
	{ MODKEY|ShiftMask,		XK_q,		quit,		NULL },
};
void setmwfact(const char *str)
{
	int a = atoi(str);
	if (a > 0) {
		if (mw+a>ww)
			return;
	} else {
		if (mw < a)
			return;
	}
	if (bw != ww && bw == mw) {
		bw += a;
		XMoveResizeWindow(dpy, barwin, bx, by, bw, bh);
		drawbar();
	}
	mw += a;
	tx += a;
	tw -= a;
	arrange();
}
void togglebar(const char* arg)
{
	if (bx==0) {
		bx = ww; // out of screen
		moy = my = wy = 0;
		mh += bh;
		mh += bh;
		if (bw != mw) th += bh;
	} else {
		moy = my = wy = bh;
		mh -= bh;
		mh -= bh;
		if (bw != mw) th -= bh;
		bx = 0;
	}
	// XXX must be done in drawbar ?
	XMoveResizeWindow(dpy, barwin, bx, by, bw, bh);
	drawbar();
	arrange();
}

Reply via email to