changeset: 2561:895eeae5f462
user: Kris Maglione <kris_AT_suckless.org>
date: Thu Oct 22 07:07:10 2009 -0400
files: cmd/Makefile cmd/wmii9menu.c
description:
Restrict wmii9menu to logical Xinerama screen. Closes issue #142.
diff -r 588aa236c05d -r 895eeae5f462 cmd/Makefile
--- a/cmd/Makefile Wed Oct 21 14:22:45 2009 -0400
+++ b/cmd/Makefile Thu Oct 22 07:07:10 2009 -0400
@@ -24,10 +24,10 @@
wmiir.out: $(OWMIIR)
$(LINK) $@ $(STATIC) $(OWMIIR)
-wmii/x11.o wmii/map.o: dall
+wmii/x11.o wmii/xext.o wmii/geom.o wmii/map.o: dall
true
-O9MENU=wmii9menu.o clientutil.o wmii/x11.o wmii/map.o $(OFILES) $(LIBIXP)
+O9MENU=wmii9menu.o clientutil.o wmii/x11.o wmii/xext.o wmii/geom.o wmii/map.o $(OFILES) $(LIBIXP)
wmii9menu.out: $(O9MENU)
- $(LINK) $@ $(O9MENU) $$(pkg-config --libs $(X11PACKAGES)) -lXext -lbio
+ $(LINK) $@ $(O9MENU) $$(pkg-config --libs $(X11PACKAGES) xrandr xinerama) -lXext -lbio
diff -r 588aa236c05d -r 895eeae5f462 cmd/wmii9menu.c
--- a/cmd/wmii9menu.c Wed Oct 21 14:22:45 2009 -0400
+++ b/cmd/wmii9menu.c Thu Oct 22 07:07:10 2009 -0400
@@ -85,6 +85,33 @@
{ 0, }
};
+/* xext.c */
+void xext_init(void);
+Rectangle* xinerama_screens(int*);
+/* geom.c */
+bool rect_haspoint_p(Point, Rectangle);
+
+Cursor cursor[1];
+Visual* render_visual;
+
+void init_screens(void);
+void
+init_screens(void) {
+ Rectangle *rects;
+ Point p;
+ int i, n;
+
+ rects = xinerama_screens(&n);
+ p = querypointer(&scr.root);
+ for(i=0; i < n; i++) {
+ if(rect_haspoint_p(p, rects[i]))
+ break;
+ }
+ if(i == n)
+ i = 0;
+ scr.rect = rects[i];
+}
+
/* main --- crack arguments, set up X stuff, run the main menu loop */
int
@@ -115,6 +142,8 @@
usage();
initdisplay();
+ xext_init();
+ init_screens();
create_window();
numitems = argc;
@@ -258,16 +287,12 @@
p = querypointer(&scr.root);
p.x -= wide / 2;
- if(p.x < 0)
- p.x = 0;
- else if(p.x + wide > Dx(scr.rect))
- p.x = Dx(scr.rect) - wide;
+ p.x = max(p.x, scr.rect.min.x);
+ p.x = min(p.x, scr.rect.max.x - wide);
p.y -= cur * high + high / 2;
- if(p.y < 0)
- p.y = 0;
- else if(p.y + h > Dy(scr.rect))
- p.y = Dy(scr.rect) - h;
+ p.y = max(p.y, scr.rect.min.y);
+ p.y = min(p.y, scr.rect.max.y - h);
reshapewin(menuwin, rectaddpt(r, p));
Received on Thu Oct 22 2009 - 11:07:57 UTC
This archive was generated by hypermail 2.2.0 : Thu Oct 22 2009 - 11:12:06 UTC