main.c
changeset 328 083f1f3e1e93
parent 326 73efaa15a635
child 329 cea0c98495bc
equal deleted inserted replaced
327:96d09fd98e89 328:083f1f3e1e93
    58 				manage(wins[i], &wa);
    58 				manage(wins[i], &wa);
    59 		}
    59 		}
    60 	}
    60 	}
    61 	if(wins)
    61 	if(wins)
    62 		XFree(wins);
    62 		XFree(wins);
    63 }
       
    64 
       
    65 static int
       
    66 winprop(Window w, Atom a, Atom t, long l, unsigned char **prop)
       
    67 {
       
    68 	int status, format;
       
    69 	unsigned long res, extra;
       
    70 	Atom real;
       
    71 
       
    72 	status = XGetWindowProperty(dpy, w, a, 0L, l, False, t, &real, &format,
       
    73 			&res, &extra, prop);
       
    74 
       
    75 	if(status != Success || *prop == 0) {
       
    76 		return 0;
       
    77 	}
       
    78 	if(res == 0) {
       
    79 		free((void *) *prop);
       
    80 	}
       
    81 	return res;
       
    82 }
    63 }
    83 
    64 
    84 /*
    65 /*
    85  * Startup Error handler to check if another window manager
    66  * Startup Error handler to check if another window manager
    86  * is already running.
    67  * is already running.
   109 Window root, barwin;
    90 Window root, barwin;
   110 
    91 
   111 int
    92 int
   112 getproto(Window w)
    93 getproto(Window w)
   113 {
    94 {
   114 	int protos = 0;
    95 	int status, format, protos = 0;
   115 	int i;
    96 	int i;
   116 	long res;
    97 	unsigned long extra, res;
   117 	Atom *protocols;
    98 	Atom *protocols, real;
   118 
    99 
   119 	res = winprop(w, wmatom[WMProtocols], XA_ATOM, 20L,
   100 	status = XGetWindowProperty(dpy, w, wmatom[WMProtocols], 0L, 20L,
   120 			((unsigned char **)&protocols));
   101 			False, XA_ATOM, &real, &format, &res, &extra, (unsigned char **)&protocols);
   121 	if(res <= 0) {
   102 	if(status != Success || protocols == 0)
   122 		return protos;
   103 		return protos;
   123 	}
       
   124 	for(i = 0; i < res; i++) {
   104 	for(i = 0; i < res; i++) {
   125 		if(protocols[i] == wmatom[WMDelete])
   105 		if(protocols[i] == wmatom[WMDelete])
   126 			protos |= PROTODELWIN;
   106 			protos |= PROTODELWIN;
   127 	}
   107 	}
   128 	free((char *) protocols);
   108 	free(protocols);
   129 	return protos;
   109 	return protos;
   130 }
   110 }
   131 
   111 
   132 void
   112 void
   133 sendevent(Window w, Atom a, long value)
   113 sendevent(Window w, Atom a, long value)