about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAnselm R Garbe <garbeam@gmail.com>2008-07-16 18:33:51 +0100
committerAnselm R Garbe <garbeam@gmail.com>2008-07-16 18:33:51 +0100
commitc86ed46a1bbba0635a76d05ebeb839c7fec7f7fc (patch)
tree57f5b1346e66a9fd6501ed28ebf5d7c1ea8b3d36
parent9086f98068693d22321be2bdc6779e7be7e751c7 (diff)
downloaddwm-c86ed46a1bbba0635a76d05ebeb839c7fec7f7fc.tar.gz
got rid of compile time xidx configuration, querying mouse pointer instead
-rw-r--r--config.def.h4
-rw-r--r--dwm.c45
2 files changed, 29 insertions, 20 deletions
diff --git a/config.def.h b/config.def.h
index d408e70..eaf773d 100644
--- a/config.def.h
+++ b/config.def.h
@@ -13,10 +13,6 @@ static uint snap                    = 32;       /* snap pixel */
 static Bool showbar                 = True;     /* False means no bar */
 static Bool topbar                  = True;     /* False means bottom bar */
 
-#ifdef XINERAMA
-static uint xidx                    = 0;        /* Xinerama screen index to use */
-#endif
-
 /* tagging */
 static const char tags[][MAXTAGLEN] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
 
diff --git a/dwm.c b/dwm.c
index 29157de..f8a6ed5 100644
--- a/dwm.c
+++ b/dwm.c
@@ -44,16 +44,17 @@
 #endif
 
 /* macros */
-#define MAX(a, b)       ((a) > (b) ? (a) : (b))
-#define MIN(a, b)       ((a) < (b) ? (a) : (b))
-#define BUTTONMASK      (ButtonPressMask|ButtonReleaseMask)
-#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask))
-#define LENGTH(x)       (sizeof x / sizeof x[0])
-#define MAXTAGLEN       16
-#define MOUSEMASK       (BUTTONMASK|PointerMotionMask)
-#define TAGMASK         ((int)((1LL << LENGTH(tags)) - 1))
-#define TEXTW(x)        (textnw(x, strlen(x)) + dc.font.height)
-#define ISVISIBLE(x)    (x->tags & tagset[seltags])
+#define BUTTONMASK              (ButtonPressMask|ButtonReleaseMask)
+#define CLEANMASK(mask)         (mask & ~(numlockmask|LockMask))
+#define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH))
+#define ISVISIBLE(x)            (x->tags & tagset[seltags])
+#define LENGTH(x)               (sizeof x / sizeof x[0])
+#define MAX(a, b)               ((a) > (b) ? (a) : (b))
+#define MIN(a, b)               ((a) < (b) ? (a) : (b))
+#define MAXTAGLEN               16
+#define MOUSEMASK               (BUTTONMASK|PointerMotionMask)
+#define TAGMASK                 ((int)((1LL << LENGTH(tags)) - 1))
+#define TEXTW(x)                (textnw(x, strlen(x)) + dc.font.height)
 
 /* enums */
 enum { CurNormal, CurResize, CurMove, CurLast };        /* cursor */
@@ -974,7 +975,7 @@ monocle(void) {
 
 void
 movemouse(const Arg *arg) {
-	int x1, y1, ocx, ocy, di, nx, ny;
+	int x, y, ocx, ocy, di, nx, ny;
 	unsigned int dui;
 	Client *c;
 	Window dummy;
@@ -988,7 +989,7 @@ movemouse(const Arg *arg) {
 	if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
 	None, cursor[CurMove], CurrentTime) != GrabSuccess)
 		return;
-	XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
+	XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui);
 	for(;;) {
 		XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
 		switch (ev.type) {
@@ -1002,8 +1003,8 @@ movemouse(const Arg *arg) {
 			break;
 		case MotionNotify:
 			XSync(dpy, False);
-			nx = ocx + (ev.xmotion.x - x1);
-			ny = ocy + (ev.xmotion.y - y1);
+			nx = ocx + (ev.xmotion.x - x);
+			ny = ocy + (ev.xmotion.y - y);
 			if(snap && nx >= wx && nx <= wx + ww
 			        && ny >= wy && ny <= wy + wh) {
 				if(abs(wx - nx) < snap)
@@ -1557,12 +1558,24 @@ updatebar(void) {
 void
 updategeom(void) {
 #ifdef XINERAMA
-	int i;
+	int n;
+	unsigned int xidx = 0;
 	XineramaScreenInfo *info = NULL;
 
 	/* window area geometry */
 	if(XineramaIsActive(dpy)) {
-		info = XineramaQueryScreens(dpy, &i);
+		info = XineramaQueryScreens(dpy, &n);
+		if(n > 1) {
+			int di, i, x, y;
+			unsigned int dui;
+			Window dummy;
+			if(XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui))
+				for(i = 0; i < n; i++)
+					if(INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height)) {
+						xidx = i;
+						break;
+					}
+		}
 		wx = info[xidx].x_org;
 		wy = showbar && topbar ?  info[xidx].y_org + bh : info[xidx].y_org;
 		ww = info[xidx].width;
#cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
.TH DWM 1 dwm-0.0
.SH NAME
dwm \- dynamic window manager
.SH SYNOPSIS
.B dwm
.RB [ \-v ]
.SH DESCRIPTION
.SS Overview
.B dwm
is a dynamic window manager for X11.
.SS Options
.TP
.B \-v
prints version information to stdout, then exits.
.SS Status text
.B dwm
reads from stdin to display status text if provided.
.SS Default Key Bindings
.TP 16
.I Key	
.I Action
.TP
.B Mod1-Return
Zoom
.B window
to the 
.B master
track
.TP
.B Mod1-k
Focus previous
.B window
.TP
.B Mod1-j
Focus next
.B window
.TP
.B Mod1-m
Maximize current
.B window
.TP
.B Mod1-[0..n]
Focus
.B nth
tag
.TP
.B Mod1-space
(Re-)arrange
.B all
windows tiled
.TP
.B Mod1-Shift-space
(Re-)arrange
.B all
windows floating
.TP
.B Mod1-Shift-[0..n]
Apply
.B nth
tag to current
.B window
.TP
.B Mod1-Shift-q
Quit
.B dwm
.TP
.B Mod1-Shift-Return
Start
.B terminal
.TP
.B Mod1-Shift-w
Start
.B web browser
.TP
.B Mod1-Shift-l
Lock
.B screen
.TP
.B Control-[0..n]
Append
.B nth
tag to cureent
.B window
.SS Default Mouse Bindings
.TP
.B Mod1-Button1
Moves current
.B window
while dragging
.TP
.B Mod1-Button2
Lowers current
.B window
.TP
.B Mod1-Button3
Resizes current
.B window
while dragging