2 #include <X11/Xft/Xft.h>
8 int main(int argc
, char *argv
[])
10 Display
*display
= XOpenDisplay(NULL
);
15 fprintf(stderr
, "Cannot open display\n");
19 int screen
= DefaultScreen(display
);
21 int window_width
= DisplayWidth(display
, screen
);
22 int window_height
= DisplayHeight(display
, screen
);
26 Window root
= RootWindow(display
, screen
);
27 XSetWindowAttributes attributes
;
28 attributes
.override_redirect
= True
;
29 XftColorAllocName(display
, DefaultVisual(display
, screen
), DefaultColormap(display
, screen
), background_color
, &color
);
30 attributes
.background_pixel
= color
.pixel
;
31 XftColorAllocName(display
, DefaultVisual(display
, screen
), DefaultColormap(display
, screen
), border_color
, &color
);
32 attributes
.border_pixel
= color
.pixel
;
34 XftFont
*font
= XftFontOpenName(display
, screen
, font_style
);
36 unsigned short x
= pos_x
;
37 unsigned short y
= pos_y
;
38 int height
= font
->ascent
- font
->descent
+ text_padding
* 2;
41 y
= window_height
- height
- border_size
* 2 - pos_y
;
43 x
= window_width
- width
- border_size
* 2 - pos_x
;
46 y
= window_height
- height
- border_size
* 2 - pos_y
;
49 Window window
= XCreateWindow(
51 y
, width
, height
, border_size
,
52 DefaultDepth(display
, screen
), CopyFromParent
,
53 DefaultVisual(display
, screen
),
54 CWOverrideRedirect
| CWBackPixel
| CWBorderPixel
, &attributes
);
56 XftDraw
*draw
= XftDrawCreate(display
, window
, DefaultVisual(display
, screen
), DefaultColormap(display
, screen
));
57 XftColorAllocName(display
, DefaultVisual(display
, screen
), DefaultColormap(display
, screen
), font_color
, &color
);
59 XSelectInput(display
, window
, ExposureMask
| ButtonPress
);
61 XMapWindow(display
, window
);
67 XNextEvent(display
, &event
);
69 if (event
.type
== Expose
)
71 XClearWindow(display
, window
);
72 XftDrawString8(draw
, &color
, font
, text_padding
, height
- text_padding
, (XftChar8
*)argv
[1], strlen(argv
[1]));
74 if (event
.type
== ButtonPress
)
78 XCloseDisplay(display
);