readded wm_atom's again, necessary to not kill complete apps when sending kill to a popup

This commit is contained in:
Anselm R. Garbe 2006-07-11 16:15:01 +02:00
parent 874228cf1a
commit 4f13adf6fd
3 changed files with 78 additions and 1 deletions

View File

@ -100,6 +100,7 @@ create_client(Window w, XWindowAttributes *wa)
c->rect.width = wa->width;
c->rect.height = wa->height;
XSetWindowBorderWidth(blz.dpy, c->win, 0);
c->proto = win_proto(c->win);
XGetTransientForHint(blz.dpy, c->win, &c->trans);
if(!XGetWMNormalHints(blz.dpy, c->win, &c->size, &msize) || !c->size.flags)
c->size.flags = PSize;
@ -240,9 +241,27 @@ configure_client(Client *c)
XSync(blz.dpy, False);
}
static void
send_client_message(Window w, Atom a, long value)
{
XEvent e;
e.type = ClientMessage;
e.xclient.window = w;
e.xclient.message_type = a;
e.xclient.format = 32;
e.xclient.data.l[0] = value;
e.xclient.data.l[1] = CurrentTime;
XSendEvent(blz.dpy, w, False, NoEventMask, &e);
XSync(blz.dpy, False);
}
void
kill_client(Client * c)
{
if(c->proto & WM_PROTOCOL_DELWIN)
send_client_message(c->win, wm_atom[WMProtocols], wm_atom[WMDelete]);
else
XKillClient(blz.dpy, c->win);
}
@ -251,6 +270,10 @@ prop_client(Client *c, XPropertyEvent *e)
{
long msize;
if(e->atom == wm_atom[WMProtocols]) {
c->proto = win_proto(c->win);
return;
}
switch (e->atom) {
case XA_WM_TRANSIENT_FOR:
XGetTransientForHint(blz.dpy, c->win, &c->trans);

View File

@ -63,9 +63,53 @@ scan_wins()
XFree(wins);
}
static int
win_property(Window w, Atom a, Atom t, long l, unsigned char **prop)
{
Atom real;
int format;
unsigned long res, extra;
int status;
status = XGetWindowProperty(blz.dpy, w, a, 0L, l, False, t, &real, &format,
&res, &extra, prop);
if(status != Success || *prop == 0) {
return 0;
}
if(res == 0) {
free((void *) *prop);
}
return res;
}
int
win_proto(Window w)
{
Atom *protocols;
long res;
int protos = 0;
int i;
res = win_property(w, wm_atom[WMProtocols], XA_ATOM, 20L,
((unsigned char **) &protocols));
if(res <= 0) {
return protos;
}
for(i = 0; i < res; i++) {
if(protocols[i] == wm_atom[WMDelete])
protos |= WM_PROTOCOL_DELWIN;
}
free((char *) protocols);
return protos;
}
static void
init_atoms()
{
wm_atom[WMProtocols] = XInternAtom(blz.dpy, "WM_PROTOCOLS", False);
wm_atom[WMDelete] = XInternAtom(blz.dpy, "WM_DELETE_WINDOW", False);
net_atom[NetSupported] = XInternAtom(blz.dpy, "_NET_SUPPORTED", False);
net_atom[NetWMName] = XInternAtom(blz.dpy, "_NET_WM_NAME", False);
tags_atom = XInternAtom(blz.dpy, "_WIN_TAGS", False);

View File

@ -11,6 +11,13 @@
#include <ixp.h>
#include <blitz.h>
/* WM atoms */
enum {
WMProtocols,
WMDelete,
WMLast
};
/* NET atoms */
enum {
NetSupported,
@ -94,6 +101,7 @@ struct Client {
char props[512];
unsigned short id;
unsigned int border;
int proto;
Bool floating;
Bool fixedsize;
Window win;
@ -180,6 +188,7 @@ unsigned int num_screens;
Blitz blz;
GC xorgc;
char *user;
Atom wm_atom[WMLast];
Atom net_atom[NetLast];
Atom tags_atom;
Cursor cursor[CurLast];
@ -315,3 +324,4 @@ unsigned int newcolw_of_view(View *v);
/* wm.c */
int wmii_error_handler(Display *dpy, XErrorEvent *error);
int win_proto(Window w);