summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--conf.h1
-rw-r--r--data.h7
-rw-r--r--events.c33
-rw-r--r--manage.c2
4 files changed, 42 insertions, 1 deletions
diff --git a/conf.h b/conf.h
index 8976e68..6c48664 100644
--- a/conf.h
+++ b/conf.h
@@ -26,6 +26,7 @@
#define KEY_NEXTWINDOW 'n'
#define KEY_LASTWINDOW 't' /* key to toggle between the current window and the last visitted one */
#define KEY_TOGGLEBAR 'w' /* key to toggle the display of the program bar */
+#define KEY_DELETE 'k' /* delete a window SHIFT+key will Destroy the window */
#define TERM_PROG "xterm" /* command to boot an xterm */
#define EMACS_PROG "emacs" /* command to boot emacs */
diff --git a/data.h b/data.h
index 18fc6c8..af88705 100644
--- a/data.h
+++ b/data.h
@@ -62,6 +62,13 @@ extern int num_screens;
extern Display *dpy;
extern Atom rp_restart;
+extern Atom wm_state;
+extern Atom wm_change_state;
+extern Atom wm_protocols;
+extern Atom wm_delete;
+extern Atom wm_take_focus;
+extern Atom wm_colormaps;
+
/* Set to 1 to indicate that the WM should exit at it's earliest
convenience. */
extern int exit_signal;
diff --git a/events.c b/events.c
index 1d2d8f5..5b12536 100644
--- a/events.c
+++ b/events.c
@@ -174,6 +174,33 @@ configure_request (XConfigureRequestEvent *e)
}
}
+void
+delete_window ()
+{
+ XEvent ev;
+ int status;
+
+ if (rp_current_window == NULL) return;
+
+ ev.xclient.type = ClientMessage;
+ ev.xclient.window = rp_current_window->w;
+ ev.xclient.message_type = wm_protocols;
+ ev.xclient.format = 32;
+ ev.xclient.data.l[0] = wm_delete;
+ ev.xclient.data.l[1] = CurrentTime;
+
+ status = XSendEvent(dpy, rp_current_window->w, False, 0, &ev);
+ if (status == 0) fprintf(stderr, "ratpoison: XSendEvent failed\n");
+}
+
+void
+kill_window ()
+{
+ if (rp_current_window == NULL) return;
+
+ XKillClient(dpy, rp_current_window->w);
+}
+
static void
client_msg (XClientMessageEvent *ev)
{
@@ -233,6 +260,10 @@ handle_key (screen_info *s)
case KEY_LASTWINDOW:
last_window ();
break;
+ case KEY_DELETE:
+ if (ev.xkey.state & ShiftMask) kill_window ();
+ else delete_window ();
+ break;
default:
fprintf (stderr, "Unknown key command %c", (char)XKeycodeToKeysym(dpy, ev.xkey.keycode, 0));
break;
@@ -317,7 +348,7 @@ delegate_event (XEvent *ev)
case UnmapNotify:
unmap_notify (ev);
printf ("UnmapNotify\n");
- break;
+ break;
case MotionNotify:
printf ("MotionNotify\n");
diff --git a/manage.c b/manage.c
index c547d5c..7f2e6f5 100644
--- a/manage.c
+++ b/manage.c
@@ -52,6 +52,8 @@ grab_keys (screen_info *s)
GrabModeAsync, GrabModeAsync);
XGrabKey(dpy, XKeysymToKeycode (dpy, KEY_LASTWINDOW ), AnyModifier, s->key_window, True,
GrabModeAsync, GrabModeAsync);
+ XGrabKey(dpy, XKeysymToKeycode (dpy, KEY_DELETE ), AnyModifier, s->key_window, True,
+ GrabModeAsync, GrabModeAsync);
XGrabKey(dpy, XKeysymToKeycode (dpy, KEY_PREFIX ), AnyModifier, s->key_window, True,
GrabModeAsync, GrabModeAsync);
}