Just cosmetics... ;)
This commit is contained in:
parent
b6528efc13
commit
00aa8cd38b
1 changed files with 7 additions and 7 deletions
14
Xtimer.c
14
Xtimer.c
|
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
* xtimer is a program that executes a givin program after a given time if no
|
* Xtimer is a program that executes a givin command or program after a given
|
||||||
* X11 keybord or mouse input happend in the given time.
|
* time if no X11 keybord or mouse input happend in the given time.
|
||||||
*
|
*
|
||||||
* Author: Johannes Findeisen <you@hanez.org> - 2025
|
* Author: Johannes Findeisen <you@hanez.org> - 2025
|
||||||
* License: Apache-2.0 (see LICENSE)
|
* License: Apache-2.0 (see LICENSE)
|
||||||
|
|
@ -8,11 +8,11 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <limits.h> // For INT_MAX and INT_MIN
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/extensions/XInput2.h>
|
#include <X11/extensions/XInput2.h>
|
||||||
#include <time.h>
|
|
||||||
#include <limits.h> // For INT_MAX and INT_MIN
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
@ -65,7 +65,7 @@ INT_MAX);
|
||||||
XISetMask(mask, XI_KeyRelease);
|
XISetMask(mask, XI_KeyRelease);
|
||||||
XISetMask(mask, XI_ButtonPress);
|
XISetMask(mask, XI_ButtonPress);
|
||||||
XISetMask(mask, XI_ButtonRelease);
|
XISetMask(mask, XI_ButtonRelease);
|
||||||
XISetMask(mask, XI_Motion); // Listen for mouse motion events
|
XISetMask(mask, XI_Motion); // Listen for mouse motion events
|
||||||
|
|
||||||
if (XISelectEvents(display, root, &evmask, 1) != Success) {
|
if (XISelectEvents(display, root, &evmask, 1) != Success) {
|
||||||
fprintf(stderr, "Error: Unable to select input events.\n");
|
fprintf(stderr, "Error: Unable to select input events.\n");
|
||||||
|
|
@ -91,7 +91,7 @@ INT_MAX);
|
||||||
XNextEvent(display, &event);
|
XNextEvent(display, &event);
|
||||||
|
|
||||||
if (event.xcookie.type == GenericEvent &&
|
if (event.xcookie.type == GenericEvent &&
|
||||||
event.xcookie.extension == opcode && // Use the opcode obtained earlier
|
event.xcookie.extension == opcode && // Use the opcode obtained earlier
|
||||||
XGetEventData(display, &event.xcookie)) {
|
XGetEventData(display, &event.xcookie)) {
|
||||||
XIDeviceEvent *xi_event = (XIDeviceEvent *)event.xcookie.data;
|
XIDeviceEvent *xi_event = (XIDeviceEvent *)event.xcookie.data;
|
||||||
if (xi_event->evtype == XI_KeyPress ||
|
if (xi_event->evtype == XI_KeyPress ||
|
||||||
|
|
@ -105,7 +105,7 @@ INT_MAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sleep briefly to reduce CPU usage
|
// Sleep briefly to reduce CPU usage
|
||||||
usleep(10000); // 10 milliseconds
|
usleep(10000); // 10 milliseconds
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the X display
|
// Close the X display
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue