summary refs log tree commit diff
path: root/menu.c
diff options
context:
space:
mode:
authorokan <okan>2011-05-05 15:32:24 +0000
committerokan <okan>2011-05-05 15:32:24 +0000
commitc62c0ee9dbc3603558da76d48379edc1c29688dc (patch)
tree292a0e83990af84afebdfdd4a41f225ed9fab036 /menu.c
parent349b3295b8791fd08fbf1307576fe8ecd2c3f374 (diff)
downloadcwm-c62c0ee9dbc3603558da76d48379edc1c29688dc.tar.gz
cwm-c62c0ee9dbc3603558da76d48379edc1c29688dc.tar.xz
cwm-c62c0ee9dbc3603558da76d48379edc1c29688dc.zip
make the menu window aware of xinerama info; this makes the menu stay
within the current screen, like other cwm window placements and
mutations (vmax/hmax/max) - from Sviatoslav Chagaev.

ok oga@
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/menu.c b/menu.c
index e757665..dd858d8 100644
--- a/menu.c
+++ b/menu.c
@@ -287,8 +287,10 @@ static void
 menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
     struct menu_q *resultq)
 {
-	struct menu	*mi;
-	int		 n, dy, xsave, ysave;
+	struct menu		*mi;
+	XineramaScreenInfo	*xine;
+	int			 xmin, xmax, ymin, ymax;
+	int			 n, dy, xsave, ysave;
 
 	if (mc->list) {
 		if (TAILQ_EMPTY(resultq) && mc->list) {
@@ -330,18 +332,33 @@ menu_draw(struct screen_ctx *sc, struct menu_ctx *mc, struct menu_q *menuq,
 		mc->num++;
 	}
 
+	xine = screen_find_xinerama(sc, mc->x, mc->y);
+	if (xine) {
+		xmin = xine->x_org;
+		xmax = xine->x_org + xine->width;
+		ymin = xine->y_org;
+		ymax = xine->y_org + xine->height;
+	} else {
+		xmin = ymin = 0;
+		xmax = sc->xmax;
+		ymax = sc->ymax;
+	}
+
 	xsave = mc->x;
 	ysave = mc->y;
-	if (mc->x < 0)
-		mc->x = 0;
-	else if (mc->x + mc->width >= sc->xmax)
-		mc->x = sc->xmax - mc->width;
 
-	if (mc->y + dy >= sc->ymax)
-		mc->y = sc->ymax - dy;
+	if (mc->x < xmin)
+		mc->x = xmin;
+	else if (mc->x + mc->width >= xmax)
+		mc->x = xmax - mc->width;
+
+	if (mc->y + dy >= ymax)
+		mc->y = ymax - dy;
 	/* never hide the top of the menu */
-        if (mc->y < 0)
-                mc->y = 0;
+	if (mc->y < ymin) {
+		mc->y = ymin;
+		dy = ymax - ymin;
+	}
 
 	if (mc->x != xsave || mc->y != ysave)
 		xu_ptr_setpos(sc->rootwin, mc->x, mc->y);