summaryrefslogtreecommitdiff
path: root/app/cwm/calmwm.c
diff options
context:
space:
mode:
authorOkan Demirmen <okan@cvs.openbsd.org>2011-06-24 05:58:52 +0000
committerOkan Demirmen <okan@cvs.openbsd.org>2011-06-24 05:58:52 +0000
commitd10d97e09692b1883ed731a00b7b37f21b2d996e (patch)
treef3f97be01eb69bd71eb5aa5c9b66c0e32f3ce692 /app/cwm/calmwm.c
parentaac887da536ed5fc828ce2071d5e8a7edcba4597 (diff)
replace the non-working check to see if another wm is running with a
method that actually works. checking for icccm compliant wm's should also be done first, but that's another diff (noted by oga). ok oga@
Diffstat (limited to 'app/cwm/calmwm.c')
-rw-r--r--app/cwm/calmwm.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/app/cwm/calmwm.c b/app/cwm/calmwm.c
index f8ab1c14b..577ac8c33 100644
--- a/app/cwm/calmwm.c
+++ b/app/cwm/calmwm.c
@@ -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.c,v 1.54 2011/05/11 13:53:51 okan Exp $
+ * $OpenBSD: calmwm.c,v 1.55 2011/06/24 05:58:51 okan Exp $
*/
#include <sys/param.h>
@@ -45,12 +45,12 @@ struct screen_ctx_q Screenq = TAILQ_HEAD_INITIALIZER(Screenq);
struct client_ctx_q Clientq = TAILQ_HEAD_INITIALIZER(Clientq);
int HasXinerama, HasRandr, Randr_ev;
-int Starting;
struct conf Conf;
static void sigchld_cb(int);
static void dpy_init(const char *);
static int x_errorhandler(Display *, XErrorEvent *);
+static int x_wmerrorhandler(Display *, XErrorEvent *);
static void x_setup(void);
static void x_setupscreen(struct screen_ctx *, u_int);
static void x_teardown(void);
@@ -80,14 +80,12 @@ main(int argc, char **argv)
if (signal(SIGCHLD, sigchld_cb) == SIG_ERR)
err(1, "signal");
- Starting = 1;
dpy_init(display_name);
bzero(&Conf, sizeof(Conf));
conf_setup(&Conf, conf_file);
xu_getatoms();
x_setup();
- Starting = 0;
xev_loop();
@@ -101,10 +99,15 @@ dpy_init(const char *dpyname)
{
int i;
+ XSetErrorHandler(x_errorhandler);
+
if ((X_Dpy = XOpenDisplay(dpyname)) == NULL)
errx(1, "unable to open display \"%s\"",
XDisplayName(dpyname));
+ XSetErrorHandler(x_wmerrorhandler);
+ XSelectInput(X_Dpy, DefaultRootWindow(X_Dpy), SubstructureRedirectMask);
+ XSync(X_Dpy, False);
XSetErrorHandler(x_errorhandler);
HasRandr = XRRQueryExtension(X_Dpy, &Randr_ev, &i);
@@ -212,27 +215,25 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
}
static int
+x_wmerrorhandler(Display *dpy, XErrorEvent *e)
+{
+ errx(1, "root window unavailable - perhaps another wm is running?");
+
+ return (0);
+}
+static int
x_errorhandler(Display *dpy, XErrorEvent *e)
{
-#ifdef DEBUG
- {
- char msg[80], number[80], req[80];
+#if DEBUG
+ char msg[80], number[80], req[80];
- XGetErrorText(X_Dpy, e->error_code, msg, sizeof(msg));
- snprintf(number, sizeof(number), "%d", e->request_code);
- XGetErrorDatabaseText(X_Dpy, "XRequest", number,
- "<unknown>", req, sizeof(req));
+ XGetErrorText(X_Dpy, e->error_code, msg, sizeof(msg));
+ snprintf(number, sizeof(number), "%d", e->request_code);
+ XGetErrorDatabaseText(X_Dpy, "XRequest", number,
+ "<unknown>", req, sizeof(req));
- warnx("%s(0x%x): %s", req, (u_int)e->resourceid, msg);
- }
+ warnx("%s(0x%x): %s", req, (u_int)e->resourceid, msg);
#endif
-
- if (Starting &&
- e->error_code == BadAccess &&
- e->request_code == X_GrabKey)
- errx(1, "root window unavailable - perhaps another "
- "wm is running?");
-
return (0);
}