/
index
/
herbe.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
inline
| side by side (parent:
b8e91b6
)
Add timeout functionality
author
Samuel Dudik
<redacted>
Thu, 30 Jul 2020 12:41:01 +0000
(14:41 +0200)
committer
Samuel Dudik
<redacted>
Thu, 30 Jul 2020 12:41:01 +0000
(14:41 +0200)
main.c
patch
|
blob
|
history
diff --git
a/main.c
b/main.c
index c64b98f916239a58ea38b9417537eb2c079a7643..4c29b15728133233b0e1bab5d99746d7cd6f5b6e 100644
(file)
--- a/
main.c
+++ b/
main.c
@@
-2,13
+2,28
@@
#include <X11/Xft/Xft.h>
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xft/Xft.h>
#include <stdio.h>
#include <stdlib.h>
+#include <signal.h>
+#include <unistd.h>
#include "config.h"
#include "config.h"
-int main(int argc, char *argv[])
+Display *display;
+Window window;
+
+void expire()
{
{
- Display *display = XOpenDisplay(NULL);
XEvent event;
XEvent event;
+ event.type = ButtonPress;
+ XSendEvent(display, window, 0, 0, &event);
+ XFlush(display);
+}
+
+int main(int argc, char *argv[])
+{
+ signal(SIGALRM, expire);
+ alarm(duration);
+
+ display = XOpenDisplay(NULL);
if (display == NULL)
{
if (display == NULL)
{
@@
-36,17
+51,18
@@
int main(int argc, char *argv[])
unsigned short x = pos_x;
unsigned short y = pos_y;
int height = font->ascent - font->descent + text_padding * 2;
unsigned short x = pos_x;
unsigned short y = pos_y;
int height = font->ascent - font->descent + text_padding * 2;
- switch (corner) {
- case down_right:
- y = window_height - height - border_size * 2 - pos_y;
- case top_right:
- x = window_width - width - border_size * 2 - pos_x;
- break;
- case down_left:
- y = window_height - height - border_size * 2 - pos_y;
+ switch (corner)
+ {
+ case down_right:
+ y = window_height - height - border_size * 2 - pos_y;
+ case top_right:
+ x = window_width - width - border_size * 2 - pos_x;
+ break;
+ case down_left:
+ y = window_height - height - border_size * 2 - pos_y;
}
}
-
Window
window = XCreateWindow(
+ window = XCreateWindow(
display, root, x,
y, width, height, border_size,
DefaultDepth(display, screen), CopyFromParent,
display, root, x,
y, width, height, border_size,
DefaultDepth(display, screen), CopyFromParent,
@@
-62,6
+78,8
@@
int main(int argc, char *argv[])
// TODO free xftcolor
// TODO free xftcolor
+ XEvent event;
+
while (1)
{
XNextEvent(display, &event);
while (1)
{
XNextEvent(display, &event);