Add timeout functionality
This commit is contained in:
parent
b8e91b6164
commit
db1e571082
1 changed files with 29 additions and 11 deletions
26
main.c
26
main.c
|
@ -2,13 +2,28 @@
|
||||||
#include <X11/Xft/Xft.h>
|
#include <X11/Xft/Xft.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
Display *display;
|
||||||
|
Window window;
|
||||||
|
|
||||||
|
void expire()
|
||||||
|
{
|
||||||
|
XEvent event;
|
||||||
|
event.type = ButtonPress;
|
||||||
|
XSendEvent(display, window, 0, 0, &event);
|
||||||
|
XFlush(display);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
Display *display = XOpenDisplay(NULL);
|
signal(SIGALRM, expire);
|
||||||
XEvent event;
|
alarm(duration);
|
||||||
|
|
||||||
|
display = XOpenDisplay(NULL);
|
||||||
|
|
||||||
if (display == NULL)
|
if (display == NULL)
|
||||||
{
|
{
|
||||||
|
@ -36,7 +51,8 @@ int main(int argc, char *argv[])
|
||||||
unsigned short x = pos_x;
|
unsigned short x = pos_x;
|
||||||
unsigned short y = pos_y;
|
unsigned short y = pos_y;
|
||||||
int height = font->ascent - font->descent + text_padding * 2;
|
int height = font->ascent - font->descent + text_padding * 2;
|
||||||
switch (corner) {
|
switch (corner)
|
||||||
|
{
|
||||||
case down_right:
|
case down_right:
|
||||||
y = window_height - height - border_size * 2 - pos_y;
|
y = window_height - height - border_size * 2 - pos_y;
|
||||||
case top_right:
|
case top_right:
|
||||||
|
@ -46,7 +62,7 @@ int main(int argc, char *argv[])
|
||||||
y = window_height - height - border_size * 2 - pos_y;
|
y = window_height - height - border_size * 2 - pos_y;
|
||||||
}
|
}
|
||||||
|
|
||||||
Window window = XCreateWindow(
|
window = XCreateWindow(
|
||||||
display, root, x,
|
display, root, x,
|
||||||
y, width, height, border_size,
|
y, width, height, border_size,
|
||||||
DefaultDepth(display, screen), CopyFromParent,
|
DefaultDepth(display, screen), CopyFromParent,
|
||||||
|
@ -62,6 +78,8 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
// TODO free xftcolor
|
// TODO free xftcolor
|
||||||
|
|
||||||
|
XEvent event;
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
XNextEvent(display, &event);
|
XNextEvent(display, &event);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue