ryudo/xevents.c

54 lines
1.2 KiB
C
Raw Normal View History

2019-12-02 18:23:00 +00:00
/*
* Original code posted to comp.sources.x (see printevent.c).
* Modifications by Russ Cox <rsc@swtch.com>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <X11/Intrinsic.h>
#include "printevent.h"
2021-02-26 19:50:23 +00:00
int main(int argc, char** argv) {
2021-02-26 18:01:22 +00:00
int screen;
Display* dpy;
Window window;
XEvent event;
if (!(dpy = XOpenDisplay(""))) {
printf("Failed to open display...\n");
exit(1);
}
screen = DefaultScreen(dpy);
window = XCreateSimpleWindow(
dpy,
RootWindow(dpy, screen),
100,
100,
300,
200,
2,
BlackPixel(dpy, screen),
WhitePixel(dpy, screen));
2019-12-02 18:23:00 +00:00
2021-02-26 18:01:22 +00:00
XSelectInput(
dpy,
window,
KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
EnterWindowMask | LeaveWindowMask | PointerMotionMask |
PointerMotionHintMask | Button1MotionMask | Button2MotionMask |
Button3MotionMask | Button4MotionMask | Button5MotionMask |
ButtonMotionMask | KeymapStateMask | ExposureMask | VisibilityChangeMask |
StructureNotifyMask | SubstructureNotifyMask | SubstructureRedirectMask |
FocusChangeMask | PropertyChangeMask | ColormapChangeMask |
OwnerGrabButtonMask);
XMapWindow(dpy, window);
for (;;) {
XNextEvent(dpy, &event);
printevent(&event);
}
}