diff options
author | okan | 2015-06-26 15:21:58 +0000 |
---|---|---|
committer | okan | 2015-06-26 15:21:58 +0000 |
commit | 5cf1374cd905ac2fb2aff2baf0e178ff81d5a416 (patch) | |
tree | eb54dacb882ea36d4e9b92274a28f2ae5f29107b | |
parent | c6cf16dddd47bdca93eefcaa3c8dfa858c09e426 (diff) | |
download | cwm-5cf1374cd905ac2fb2aff2baf0e178ff81d5a416.tar.gz |
Replace screen region info gathering with XRandR equivalent of Xinerama
queries (currently act on XRandR events anyway). Fall-back mode without
XRandR is still what X provides. This removes -lXinerama.
Diffstat (limited to '')
-rw-r--r-- | Makefile | 4 | ||||
-rw-r--r-- | calmwm.h | 3 | ||||
-rw-r--r-- | screen.c | 45 |
3 files changed, 31 insertions, 21 deletions
@@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.20 2013/05/19 23:38:20 okan Exp $ +# $OpenBSD: Makefile,v 1.21 2015/06/26 15:21:58 okan Exp $ .include <bsd.xconf.mk> @@ -13,7 +13,7 @@ CPPFLAGS+= -I${X11BASE}/include -I${X11BASE}/include/freetype2 -I${.CURDIR} CFLAGS+= -Wall LDADD+= -L${X11BASE}/lib -lXft -lXrender -lX11 -lxcb -lXau -lXdmcp \ - -lfontconfig -lexpat -lfreetype -lz -lXinerama -lXrandr -lXext + -lfontconfig -lexpat -lfreetype -lz -lXrandr -lXext MANDIR= ${X11BASE}/man/man MAN= cwm.1 cwmrc.5 @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: calmwm.h,v 1.292 2015/06/09 13:02:15 okan Exp $ + * $OpenBSD: calmwm.h,v 1.293 2015/06/26 15:21:58 okan Exp $ */ #ifndef _CALMWM_H_ @@ -28,7 +28,6 @@ #include <X11/Xproto.h> #include <X11/Xutil.h> #include <X11/cursorfont.h> -#include <X11/extensions/Xinerama.h> #include <X11/extensions/Xrandr.h> #include <X11/keysym.h> @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: screen.c,v 1.71 2015/01/19 14:54:16 okan Exp $ + * $OpenBSD: screen.c,v 1.72 2015/06/26 15:21:58 okan Exp $ */ #include <sys/types.h> @@ -152,9 +152,8 @@ screen_find_xinerama(struct screen_ctx *sc, int x, int y, int flags) void screen_update_geometry(struct screen_ctx *sc) { - XineramaScreenInfo *info = NULL; struct region_ctx *region; - int info_num = 0, i; + int i; sc->view.x = 0; sc->view.y = 0; @@ -166,25 +165,37 @@ screen_update_geometry(struct screen_ctx *sc) sc->work.w = sc->view.w - (sc->gap.left + sc->gap.right); sc->work.h = sc->view.h - (sc->gap.top + sc->gap.bottom); - /* RandR event may have a CTRC added or removed. */ - if (XineramaIsActive(X_Dpy)) - info = XineramaQueryScreens(X_Dpy, &info_num); - while ((region = TAILQ_FIRST(&sc->regionq)) != NULL) { TAILQ_REMOVE(&sc->regionq, region, entry); free(region); } - for (i = 0; i < info_num; i++) { - region = xmalloc(sizeof(*region)); - region->num = i; - region->area.x = info[i].x_org; - region->area.y = info[i].y_org; - region->area.w = info[i].width; - region->area.h = info[i].height; - TAILQ_INSERT_TAIL(&sc->regionq, region, entry); + + if (HasRandr) { + XRRScreenResources *sr; + XRRCrtcInfo *ci; + + sr = XRRGetScreenResources(X_Dpy, sc->rootwin); + for (i = 0, ci = NULL; i < sr->ncrtc; i++) { + ci = XRRGetCrtcInfo(X_Dpy, sr, sr->crtcs[i]); + if (ci == NULL) + continue; + if (ci->noutput == 0) { + XRRFreeCrtcInfo(ci); + continue; + } + + region = xmalloc(sizeof(*region)); + region->num = i; + region->area.x = ci->x; + region->area.y = ci->y; + region->area.w = ci->width; + region->area.h = ci->height; + TAILQ_INSERT_TAIL(&sc->regionq, region, entry); + + XRRFreeCrtcInfo(ci); + } + XRRFreeScreenResources(sr); } - if (info) - XFree(info); xu_ewmh_net_desktop_geometry(sc); xu_ewmh_net_workarea(sc); |