about summary refs log tree commit diff
path: root/screen.c
diff options
context:
space:
mode:
authorokan <okan>2012-12-19 15:21:34 +0000
committerokan <okan>2012-12-19 15:21:34 +0000
commitf77166194f4586cb19abcb7951ca05e356ac74e1 (patch)
tree304227f75a0b05af3f544be74a6ce47b3fae676e /screen.c
parent878eb6bf050c6b55104e12c17b9644c2625bace0 (diff)
parentdc1e3a88438dc732349154bca610dbe813d2fc04 (diff)
downloadcwm-f77166194f4586cb19abcb7951ca05e356ac74e1.tar.gz
cwm-f77166194f4586cb19abcb7951ca05e356ac74e1.tar.xz
cwm-f77166194f4586cb19abcb7951ca05e356ac74e1.zip
cvsimport
Diffstat (limited to 'screen.c')
-rw-r--r--screen.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/screen.c b/screen.c
index c723378..92ff9a4 100644
--- a/screen.c
+++ b/screen.c
@@ -32,6 +32,63 @@
 
 static void	 screen_init_xinerama(struct screen_ctx *);
 
+void
+screen_init(struct screen_ctx *sc, u_int which)
+{
+	Window			*wins, w0, w1;
+	XWindowAttributes	 winattr;
+	XSetWindowAttributes	 rootattr;
+	u_int			 nwins, i;
+
+	sc->which = which;
+	sc->visual = DefaultVisual(X_Dpy, sc->which);
+	sc->colormap = DefaultColormap(X_Dpy, sc->which);
+	sc->rootwin = RootWindow(X_Dpy, sc->which);
+
+	xu_ewmh_net_supported(sc);
+	xu_ewmh_net_supported_wm_check(sc);
+
+	conf_gap(&Conf, sc);
+
+	screen_update_geometry(sc);
+
+	conf_color(&Conf, sc);
+
+	group_init(sc);
+	conf_font(&Conf, sc);
+
+	TAILQ_INIT(&sc->mruq);
+
+	menu_init(sc);
+
+	rootattr.cursor = Cursor_normal;
+	rootattr.event_mask = SubstructureRedirectMask|SubstructureNotifyMask|
+	    PropertyChangeMask|EnterWindowMask|LeaveWindowMask|
+	    ColormapChangeMask|BUTTONMASK;
+
+	XChangeWindowAttributes(X_Dpy, sc->rootwin,
+	    CWEventMask|CWCursor, &rootattr);
+
+	/* Deal with existing clients. */
+	XQueryTree(X_Dpy, sc->rootwin, &w0, &w1, &wins, &nwins);
+
+	for (i = 0; i < nwins; i++) {
+		XGetWindowAttributes(X_Dpy, wins[i], &winattr);
+		if (winattr.override_redirect ||
+		    winattr.map_state != IsViewable)
+			continue;
+		(void)client_new(wins[i], sc, winattr.map_state != IsUnmapped);
+	}
+	XFree(wins);
+
+	screen_updatestackingorder(sc);
+
+	if (HasRandr)
+		XRRSelectInput(X_Dpy, sc->rootwin, RRScreenChangeNotifyMask);
+
+	XSync(X_Dpy, False);
+}
+
 struct screen_ctx *
 screen_fromroot(Window rootwin)
 {