2 #include <X11/Xft/Xft.h>
16 event
.type
= ButtonPress
;
17 XSendEvent(display
, window
, 0, 0, &event
);
21 int main(int argc
, char *argv
[])
25 fprintf(stderr
, "Usage: herbe message\n");
29 signal(SIGALRM
, expire
);
32 display
= XOpenDisplay(NULL
);
36 fprintf(stderr
, "Cannot open display\n");
40 int screen
= DefaultScreen(display
);
41 Visual
*visual
= DefaultVisual(display
, screen
);
42 Colormap colormap
= DefaultColormap(display
, screen
);
44 int window_width
= DisplayWidth(display
, screen
);
45 int window_height
= DisplayHeight(display
, screen
);
49 XSetWindowAttributes attributes
;
50 attributes
.override_redirect
= True
;
51 XftColorAllocName(display
, visual
, colormap
, background_color
, &color
);
52 attributes
.background_pixel
= color
.pixel
;
53 XftColorAllocName(display
, visual
, colormap
, border_color
, &color
);
54 attributes
.border_pixel
= color
.pixel
;
56 XftFont
*font
= XftFontOpenName(display
, screen
, font_pattern
);
58 unsigned short x
= pos_x
;
59 unsigned short y
= pos_y
;
60 unsigned short height
= font
->ascent
- font
->descent
+ padding
* 2;
65 y
= window_height
- height
- border_size
* 2 - pos_y
;
67 x
= window_width
- width
- border_size
* 2 - pos_x
;
70 y
= window_height
- height
- border_size
* 2 - pos_y
;
73 window
= XCreateWindow(
74 display
, RootWindow(display
, screen
), x
,
75 y
, width
, height
, border_size
,
76 DefaultDepth(display
, screen
), CopyFromParent
,
78 CWOverrideRedirect
| CWBackPixel
| CWBorderPixel
, &attributes
);
80 XftDraw
*draw
= XftDrawCreate(display
, window
, visual
, colormap
);
81 XftColorAllocName(display
, visual
, colormap
, font_color
, &color
);
83 XSelectInput(display
, window
, ExposureMask
| ButtonPress
);
85 XMapWindow(display
, window
);
91 XNextEvent(display
, &event
);
93 if (event
.type
== Expose
)
95 XClearWindow(display
, window
);
96 XftDrawStringUtf8(draw
, &color
, font
, padding
, height
- padding
, (XftChar8
*)argv
[1], strlen(argv
[1]));
98 if (event
.type
== ButtonPress
)
102 XftDrawDestroy(draw
);
103 XftColorFree(display
, visual
, colormap
, &color
);
104 XftFontClose(display
, font
);
106 XCloseDisplay(display
);