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