about summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2013-12-13 22:39:13 +0000
committerokan <okan>2013-12-13 22:39:13 +0000
commit75b69c0b04001523eb3ad64cbb1d9f1843b41c67 (patch)
tree00e3b3b5ae0b3d55a901a3bb47d8bd2b6e8254ec
parentddb67559f63d6187921a0796f43d4c8cae6707a9 (diff)
parentf98f4615c0bf2fbf3f6229ccb9cb46284f3dd18a (diff)
downloadcwm-75b69c0b04001523eb3ad64cbb1d9f1843b41c67.tar.gz
cwm-75b69c0b04001523eb3ad64cbb1d9f1843b41c67.tar.xz
cwm-75b69c0b04001523eb3ad64cbb1d9f1843b41c67.zip
cvsimport
-rw-r--r--calmwm.h6
-rw-r--r--client.c12
-rw-r--r--kbfunc.c8
-rw-r--r--menu.c2
-rw-r--r--mousefunc.c8
-rw-r--r--screen.c16
6 files changed, 35 insertions, 17 deletions
diff --git a/calmwm.h b/calmwm.h
index 94aea5d..9b32ed3 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -92,6 +92,9 @@ size_t strlcat(char *, const char *, size_t);
 #define CWM_TILE_HORIZ 		0x0001
 #define CWM_TILE_VERT 		0x0002
 
+#define CWM_GAP			0x0001
+#define CWM_NOGAP		0x0002
+
 union arg {
 	char	*c;
 	int	 i;
@@ -442,7 +445,8 @@ void			 search_match_text(struct menu_q *, struct menu_q *,
 			     char *);
 void			 search_print_client(struct menu *, int);
 
-struct geom		 screen_find_xinerama(struct screen_ctx *, int, int);
+struct geom		 screen_find_xinerama(struct screen_ctx *,
+    			     int, int, int);
 struct screen_ctx	*screen_fromroot(Window);
 void			 screen_init(int);
 void			 screen_update_geometry(struct screen_ctx *);
diff --git a/client.c b/client.c
index a2b6322..e61975d 100644
--- a/client.c
+++ b/client.c
@@ -261,7 +261,7 @@ client_maximize(struct client_ctx *cc)
 	 */
 	xine = screen_find_xinerama(sc,
 	    cc->geom.x + cc->geom.w / 2,
-	    cc->geom.y + cc->geom.h / 2);
+	    cc->geom.y + cc->geom.h / 2, CWM_GAP);
 
 	cc->geom = xine;
 	cc->bwidth = 0;
@@ -302,7 +302,7 @@ client_vmaximize(struct client_ctx *cc)
 
 	xine = screen_find_xinerama(sc,
 	    cc->geom.x + cc->geom.w / 2,
-	    cc->geom.y + cc->geom.h / 2);
+	    cc->geom.y + cc->geom.h / 2, CWM_GAP);
 
 	cc->geom.y = xine.y;
 	cc->geom.h = xine.h - (cc->bwidth * 2);
@@ -343,7 +343,7 @@ client_hmaximize(struct client_ctx *cc)
 
 	xine = screen_find_xinerama(sc,
 	    cc->geom.x + cc->geom.w / 2,
-	    cc->geom.y + cc->geom.h / 2);
+	    cc->geom.y + cc->geom.h / 2, CWM_GAP);
 
 	cc->geom.x = xine.x;
 	cc->geom.w = xine.w - (cc->bwidth * 2);
@@ -691,7 +691,7 @@ client_placecalc(struct client_ctx *cc)
 		int			 xmouse, ymouse;
 
 		xu_ptr_getpos(sc->rootwin, &xmouse, &ymouse);
-		xine = screen_find_xinerama(sc, xmouse, ymouse);
+		xine = screen_find_xinerama(sc, xmouse, ymouse, CWM_GAP);
 		xine.w += xine.x;
 		xine.h += xine.y;
 		xmouse = MAX(xmouse, xine.x) - cc->geom.w / 2;
@@ -906,7 +906,7 @@ client_htile(struct client_ctx *cc)
 
 	xine = screen_find_xinerama(sc,
 	    cc->geom.x + cc->geom.w / 2,
-	    cc->geom.y + cc->geom.h / 2);
+	    cc->geom.y + cc->geom.h / 2, CWM_GAP);
 
 	if (cc->flags & CLIENT_VMAXIMIZED ||
 	    cc->geom.h + (cc->bwidth * 2) >= xine.h)
@@ -965,7 +965,7 @@ client_vtile(struct client_ctx *cc)
 
 	xine = screen_find_xinerama(sc,
 	    cc->geom.x + cc->geom.w / 2,
-	    cc->geom.y + cc->geom.h / 2);
+	    cc->geom.y + cc->geom.h / 2, CWM_GAP);
 
 	if (cc->flags & CLIENT_HMAXIMIZED ||
 	    cc->geom.w + (cc->bwidth * 2) >= xine.w)
diff --git a/kbfunc.c b/kbfunc.c
index cac97fe..9529e74 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -56,6 +56,7 @@ void
 kbfunc_client_moveresize(struct client_ctx *cc, union arg *arg)
 {
 	struct screen_ctx	*sc = cc->sc;
+	struct geom		 xine;
 	int			 x, y, flags, amt;
 	u_int			 mx, my;
 
@@ -99,12 +100,15 @@ kbfunc_client_moveresize(struct client_ctx *cc, union arg *arg)
 		if (cc->geom.y > sc->view.h - 1)
 			cc->geom.y = sc->view.h - 1;
 
+		xine = screen_find_xinerama(sc,
+		    cc->geom.x + cc->geom.w / 2,
+		    cc->geom.y + cc->geom.h / 2, CWM_GAP);
 		cc->geom.x += client_snapcalc(cc->geom.x,
 		    cc->geom.x + cc->geom.w + (cc->bwidth * 2),
-		    sc->work.x, sc->work.x + sc->work.w, sc->snapdist);
+		    xine.x, xine.x + xine.w, sc->snapdist);
 		cc->geom.y += client_snapcalc(cc->geom.y,
 		    cc->geom.y + cc->geom.h + (cc->bwidth * 2),
-		    sc->work.y, sc->work.y + sc->work.h, sc->snapdist);
+		    xine.y, xine.y + xine.h, sc->snapdist);
 
 		client_move(cc);
 		xu_ptr_getpos(cc->win, &x, &y);
diff --git a/menu.c b/menu.c
index af9eda1..78dde0a 100644
--- a/menu.c
+++ b/menu.c
@@ -380,7 +380,7 @@ menu_draw(struct menu_ctx *mc, struct menu_q *menuq, struct menu_q *resultq)
 		mc->num++;
 	}
 
-	xine = screen_find_xinerama(sc, mc->x, mc->y);
+	xine = screen_find_xinerama(sc, mc->x, mc->y, CWM_GAP);
 	xine.w += xine.x;
 	xine.h += xine.y;
 
diff --git a/mousefunc.c b/mousefunc.c
index f4bbae1..9fc2248 100644
--- a/mousefunc.c
+++ b/mousefunc.c
@@ -125,6 +125,7 @@ mousefunc_client_move(struct client_ctx *cc, void *arg)
 	XEvent			 ev;
 	Time			 ltime = 0;
 	struct screen_ctx	*sc = cc->sc;
+	struct geom		 xine;
 	int			 px, py;
 
 	client_raise(cc);
@@ -145,12 +146,15 @@ mousefunc_client_move(struct client_ctx *cc, void *arg)
 			cc->geom.x = ev.xmotion.x_root - px - cc->bwidth;
 			cc->geom.y = ev.xmotion.y_root - py - cc->bwidth;
 
+			xine = screen_find_xinerama(sc,
+			    cc->geom.x + cc->geom.w / 2,
+			    cc->geom.y + cc->geom.h / 2, CWM_GAP);
 			cc->geom.x += client_snapcalc(cc->geom.x,
 			    cc->geom.x + cc->geom.w + (cc->bwidth * 2),
-			    sc->work.x, sc->work.x + sc->work.w, sc->snapdist);
+			    xine.x, xine.x + xine.w, sc->snapdist);
 			cc->geom.y += client_snapcalc(cc->geom.y,
 			    cc->geom.y + cc->geom.h + (cc->bwidth * 2),
-			    sc->work.y, sc->work.y + sc->work.h, sc->snapdist);
+			    xine.y, xine.y + xine.h, sc->snapdist);
 
 			/* don't move more than 60 times / second */
 			if ((ev.xmotion.time - ltime) > (1000 / 60)) {
diff --git a/screen.c b/screen.c
index e006374..0e2c0a1 100644
--- a/screen.c
+++ b/screen.c
@@ -126,7 +126,7 @@ screen_updatestackingorder(struct screen_ctx *sc)
  * Find which xinerama screen the coordinates (x,y) is on.
  */
 struct geom
-screen_find_xinerama(struct screen_ctx *sc, int x, int y)
+screen_find_xinerama(struct screen_ctx *sc, int x, int y, int flags)
 {
 	XineramaScreenInfo	*info;
 	struct geom		 geom;
@@ -141,13 +141,19 @@ screen_find_xinerama(struct screen_ctx *sc, int x, int y)
 		info = &sc->xinerama[i];
 		if (x >= info->x_org && x < info->x_org + info->width &&
 		    y >= info->y_org && y < info->y_org + info->height) {
-			geom.x = info->x_org + sc->gap.left;
-			geom.y = info->y_org + sc->gap.top;
-			geom.w = info->width - (sc->gap.left + sc->gap.right);
-			geom.h = info->height - (sc->gap.top + sc->gap.bottom);
+			geom.x = info->x_org;
+			geom.y = info->y_org;
+			geom.w = info->width;
+			geom.h = info->height;
 			break;
 		}
 	}
+	if (flags & CWM_GAP) {
+		geom.x += sc->gap.left;
+		geom.y += sc->gap.top;
+		geom.w -= (sc->gap.left + sc->gap.right);
+		geom.h -= (sc->gap.top + sc->gap.bottom);
+	}
 	return (geom);
 }