[hackers] wmii: new tip (= 1777)

From: Anselm R. Garbe <arg_AT_suckless.org>
Date: Thu, 08 Feb 2007 03:30:03 +0100

changeset: 1777:9761eb2391f4
tag: tip
user: Kris Maglione <jg_AT_suckless.org>
date: Wed Feb 07 21:26:02 2007 -0500
files: main.c
description:
Fixed last commit

changeset: 1776:73109b3da3a6
user: Kris Maglione <jg_AT_suckless.org>
date: Wed Feb 07 21:23:50 2007 -0500
files: main.c
description:
Removed the startup_error_handler

diff -r fafd2716d4fd -r 9761eb2391f4 main.c
--- a/main.c Wed Feb 07 12:45:00 2007 -0500
+++ b/main.c Wed Feb 07 21:26:02 2007 -0500
@@ -19,7 +19,7 @@
 #include <X11/Xatom.h>
 #include <X11/Xproto.h>
 
-static int other_wm_running;
+Bool check_other_wm;
 static int (*x_error_handler) (Display *, XErrorEvent *);
 static char version[] = "wmiiwm - " VERSION ", (C)opyright MMIV-MMVI Anselm R. Garbe\n";
 
@@ -154,6 +154,8 @@ init_screen(WMScreen *screen) {
  */
 int
 wmii_error_handler(Display *dpy, XErrorEvent *error) {
+ if(check_other_wm)
+ ixp_eprint("wmiiwm: another window manager is already running\n");
         if(error->error_code == BadWindow
                         || (error->request_code == X_SetInputFocus
                                 && error->error_code == BadMatch)
@@ -173,16 +175,6 @@ wmii_error_handler(Display *dpy, XErrorE
         return x_error_handler(blz.dpy, error); /* calls exit() */
 }
 
-/*
- * Startup Error handler to check if another window manager
- * is already running.
- */
-static int
-startup_error_handler(Display * dpy, XErrorEvent * error) {
- other_wm_running = 1;
- return -1;
-}
-
 static void
 cleanup() {
         Client *c;
@@ -230,6 +222,7 @@ main(int argc, char *argv[]) {
                 usage();
 
         setlocale(LC_CTYPE, "");
+ starting = True;
 
         blz.dpy = XOpenDisplay(0);
         if(!blz.dpy)
@@ -237,14 +230,11 @@ main(int argc, char *argv[]) {
         blz.screen = DefaultScreen(blz.dpy);
         blz.root = RootWindow(blz.dpy, blz.screen);
 
- /* check if another WM is already running */
- other_wm_running = 0;
- XSetErrorHandler(startup_error_handler);
- /* this causes an error if some other WM is running */
+ check_other_wm = True;
+ x_error_handler = XSetErrorHandler(wmii_error_handler);
         XSelectInput(blz.dpy, blz.root, SubstructureRedirectMask | EnterWindowMask);
         XSync(blz.dpy, False);
- if(other_wm_running)
- ixp_eprint("wmiiwm: another window manager is already running\n");
+ check_other_wm = False;
 
         /* Check namespace permissions */
         if(!strncmp(address, "unix!", 5)) {
@@ -267,8 +257,6 @@ main(int argc, char *argv[]) {
                 free(namespace);
         }
 
- XSetErrorHandler(0);
- x_error_handler = XSetErrorHandler(wmii_error_handler);
         errstr = nil;
         i = ixp_create_sock(address, &errstr);
         if(i < 0)
@@ -366,7 +354,6 @@ main(int argc, char *argv[]) {
 
         screen = &screens[0];
 
- starting = True;
         scan_wins();
         update_views();
         starting = False;
Received on Thu Feb 08 2007 - 03:30:03 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:54:58 UTC