2 #include <X11/Xft/Xft.h>
16 event
.type
= ButtonPress
;
17 XSendEvent(display
, window
, 0, 0, &event
);
21 int main(int argc
, char *argv
[])
24 fprintf(stderr
, "Usage: herbe message\n");
28 signal(SIGALRM
, expire
);
31 display
= XOpenDisplay(NULL
);
35 fprintf(stderr
, "Cannot open display\n");
39 int screen
= DefaultScreen(display
);
41 int window_width
= DisplayWidth(display
, screen
);
42 int window_height
= DisplayHeight(display
, screen
);
46 Window root
= RootWindow(display
, screen
);
47 XSetWindowAttributes attributes
;
48 attributes
.override_redirect
= True
;
49 XftColorAllocName(display
, DefaultVisual(display
, screen
), DefaultColormap(display
, screen
), background_color
, &color
);
50 attributes
.background_pixel
= color
.pixel
;
51 XftColorAllocName(display
, DefaultVisual(display
, screen
), DefaultColormap(display
, screen
), border_color
, &color
);
52 attributes
.border_pixel
= color
.pixel
;
54 XftFont
*font
= XftFontOpenName(display
, screen
, font_style
);
56 unsigned short x
= pos_x
;
57 unsigned short y
= pos_y
;
58 int height
= font
->ascent
- font
->descent
+ text_padding
* 2;
62 y
= window_height
- height
- border_size
* 2 - pos_y
;
64 x
= window_width
- width
- border_size
* 2 - pos_x
;
67 y
= window_height
- height
- border_size
* 2 - pos_y
;
70 window
= XCreateWindow(
72 y
, width
, height
, border_size
,
73 DefaultDepth(display
, screen
), CopyFromParent
,
74 DefaultVisual(display
, screen
),
75 CWOverrideRedirect
| CWBackPixel
| CWBorderPixel
, &attributes
);
77 XftDraw
*draw
= XftDrawCreate(display
, window
, DefaultVisual(display
, screen
), DefaultColormap(display
, screen
));
78 XftColorAllocName(display
, DefaultVisual(display
, screen
), DefaultColormap(display
, screen
), font_color
, &color
);
80 XSelectInput(display
, window
, ExposureMask
| ButtonPress
);
82 XMapWindow(display
, window
);
88 XNextEvent(display
, &event
);
90 if (event
.type
== Expose
)
92 XClearWindow(display
, window
);
93 XftDrawStringUtf8(draw
, &color
, font
, text_padding
, height
- text_padding
, (XftChar8
*)argv
[1], strlen(argv
[1]));
95 if (event
.type
== ButtonPress
)
100 XftColorFree(display
, DefaultVisual(display
, screen
), DefaultColormap(display
, screen
), &color
);
101 XftFontClose(display
, font
);
103 XCloseDisplay(display
);