From 1365372d03320cc0d8be16a6a812a504bd85435d Mon Sep 17 00:00:00 2001 From: Ivan Kanakarakis Date: Fri, 6 Jan 2012 14:32:27 +0200 Subject: generalize deletewindow() to sendevent() function --- monsterwm.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/monsterwm.c b/monsterwm.c index 495b91b..a292847 100644 --- a/monsterwm.c +++ b/monsterwm.c @@ -62,7 +62,6 @@ static void cleanup(void); static void client_to_desktop(const Arg *arg); static void clientmessage(XEvent *e); static void configurerequest(XEvent *e); -static void deletewindow(Window w); static void desktopinfo(void); static void destroynotify(XEvent *e); static void die(const char* errstr, ...); @@ -87,6 +86,7 @@ static void rotate_desktop(const Arg *arg); static void run(void); static void save_desktop(int i); static void select_desktop(int i); +static void sendevent(Window w, int atom); static void setfullscreen(client *c, Bool fullscreen); static void setup(void); static void sigchld(); @@ -184,7 +184,7 @@ void cleanup(void) { XUngrabKey(dis, AnyKey, AnyModifier, root); XQueryTree(dis, root, &root_return, &parent_return, &children, &nchildren); - for (unsigned int i = 0; iwin); + sendevent(current->win, WM_DELETE_WINDOW); removeclient(current); } @@ -544,6 +533,18 @@ void select_desktop(int i) { current_desktop = i; } +void sendevent(Window w, int atom) { + if (atom >= WM_COUNT) return; + XEvent ev; + ev.type = ClientMessage; + ev.xclient.window = w; + ev.xclient.message_type = wmatoms[WM_PROTOCOLS]; + ev.xclient.format = 32; + ev.xclient.data.l[0] = wmatoms[atom]; + ev.xclient.data.l[1] = CurrentTime; + XSendEvent(dis, w, False, NoEventMask, &ev); +} + void setfullscreen(client *c, Bool fullscreen) { XChangeProperty(dis, c->win, netatoms[NET_WM_STATE], XA_ATOM, 32, PropModeReplace, (unsigned char*) ((c->isfullscreen = fullscreen) ? &netatoms[NET_FULLSCREEN] : 0), fullscreen); -- cgit v1.3.1