diff options
-rw-r--r-- | conf.h | 1 | ||||
-rw-r--r-- | data.h | 7 | ||||
-rw-r--r-- | events.c | 33 | ||||
-rw-r--r-- | manage.c | 2 |
4 files changed, 42 insertions, 1 deletions
@@ -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 */ @@ -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; @@ -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"); @@ -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); } |