kill window by pressing alt+q
This commit is contained in:
parent
3baf563d0a
commit
fd01561ddc
1 changed files with 8 additions and 1 deletions
7
wm.c
7
wm.c
|
@ -1,6 +1,7 @@
|
|||
// Taken from https://github.com/mackstann/tinywm
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/keysym.h>
|
||||
|
||||
#define MODMASK Mod1Mask
|
||||
|
||||
|
@ -18,6 +19,7 @@ int main() {
|
|||
if(!(dpy = XOpenDisplay(0x0))) return 1;
|
||||
|
||||
XGrabKey(dpy, XKeysymToKeycode(dpy, XStringToKeysym("F1")), MODMASK, DefaultRootWindow(dpy), True, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(dpy, XKeysymToKeycode(dpy, XStringToKeysym("Q")), MODMASK, DefaultRootWindow(dpy), True, GrabModeAsync, GrabModeAsync);
|
||||
XGrabButton(dpy, 1, MODMASK, DefaultRootWindow(dpy), True, ButtonPressMask|ButtonReleaseMask|PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None);
|
||||
XGrabButton(dpy, 3, MODMASK, DefaultRootWindow(dpy), True, ButtonPressMask|ButtonReleaseMask|PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None);
|
||||
|
||||
|
@ -27,7 +29,12 @@ int main() {
|
|||
XNextEvent(dpy, &ev);
|
||||
|
||||
if (ev.type == KeyPress && ev.xkey.subwindow != None) {
|
||||
KeySym keysym = XkbKeycodeToKeysym(dpy, ev.xkey.keycode, 0, 0);
|
||||
if (keysym == XK_q) {
|
||||
XKillClient(dpy, ev.xkey.subwindow);
|
||||
} else {
|
||||
XRaiseWindow(dpy, ev.xkey.subwindow);
|
||||
}
|
||||
} else if (ev.type == ButtonPress && ev.xbutton.subwindow != None) {
|
||||
XGetWindowAttributes(dpy, ev.xbutton.subwindow, &attr);
|
||||
start = ev.xbutton;
|
||||
|
|
Reference in a new issue