aboutsummaryrefslogtreecommitdiff
path: root/monsterwm.c
diff options
context:
space:
mode:
authorIvan Kanakarakis <ivan.kanak@gmail.com>2012-01-06 14:32:27 +0200
committerIvan Kanakarakis <ivan.kanak@gmail.com>2012-01-06 14:32:27 +0200
commit1365372d03320cc0d8be16a6a812a504bd85435d (patch)
treef9dccd9fc34ca78d1c15731e1039c267f8a81e6e /monsterwm.c
parent524d9a7b82121ce0a996b9ac20e149d818c06f88 (diff)
generalize deletewindow() to sendevent() function
Diffstat (limited to 'monsterwm.c')
-rw-r--r--monsterwm.c29
1 files 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; i<nchildren; i++) deletewindow(children[i]);
+ for (unsigned int i = 0; i<nchildren; i++) sendevent(children[i], WM_DELETE_WINDOW);
if (children) XFree(children);
XSync(dis, False);
XSetInputFocus(dis, PointerRoot, RevertToPointerRoot, CurrentTime);
@@ -242,17 +242,6 @@ void configurerequest(XEvent *e) {
tile();
}
-void deletewindow(Window w) {
- 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[WM_DELETE_WINDOW];
- ev.xclient.data.l[1] = CurrentTime;
- XSendEvent(dis, w, False, NoEventMask, &ev);
-}
-
void desktopinfo(void) {
Bool urgent = False;
int cd = current_desktop, n=0, d=0;
@@ -322,7 +311,7 @@ void keypress(XEvent *e) {
void killclient() {
if (!current) return;
- deletewindow(current->win);
+ 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);