Add an option to specify 'corner'
This commit is contained in:
parent
45c030065a
commit
ba24eb9d58
2 changed files with 37 additions and 17 deletions
21
config.h
21
config.h
|
@ -1,13 +1,16 @@
|
||||||
unsigned long background_color = 0xFFFFFF;
|
const static char *background_color = "#FFFFFF";
|
||||||
unsigned long border_color = 0xFF0000;
|
const static char *border_color = "#FF0000";
|
||||||
|
|
||||||
const static char *font_style = "Inconsolata:style=Medium:size=13";
|
const static char *font_style = "Inconsolata:style=Medium:size=13";
|
||||||
const static char *font_color = "#000000";
|
const static char *font_color = "#00FF00";
|
||||||
|
|
||||||
const static unsigned int width = 325;
|
const static unsigned short width = 325;
|
||||||
const static unsigned int height = 50;
|
const static unsigned short height = 50;
|
||||||
const static unsigned int border_size = 5;
|
const static unsigned short border_size = 5;
|
||||||
const static unsigned int pos_x = 1920 - width - border_size - 30;
|
const static unsigned short pos_x = 50;
|
||||||
const static unsigned int pos_y = 50;
|
const static unsigned short pos_y = 50;
|
||||||
|
|
||||||
const static int duration = 5;
|
enum corners { top_left, top_right, down_right, down_left };
|
||||||
|
enum corners corner = top_right;
|
||||||
|
|
||||||
|
const static short duration = 5;
|
||||||
|
|
33
main.c
33
main.c
|
@ -20,27 +20,41 @@ int main(int argc, char *argv[])
|
||||||
int screen = DefaultScreen(display);
|
int screen = DefaultScreen(display);
|
||||||
|
|
||||||
int window_width = DisplayWidth(display, screen);
|
int window_width = DisplayWidth(display, screen);
|
||||||
int widnow_height = DisplayHeight(display, screen);
|
int window_height = DisplayHeight(display, screen);
|
||||||
|
|
||||||
|
XftColor color;
|
||||||
|
|
||||||
Window root = RootWindow(display, screen);
|
Window root = RootWindow(display, screen);
|
||||||
XSetWindowAttributes attributes;
|
XSetWindowAttributes attributes;
|
||||||
attributes.override_redirect = True;
|
attributes.override_redirect = True;
|
||||||
attributes.background_pixel = background_color;
|
XftColorAllocName(display, DefaultVisual(display, screen), DefaultColormap(display, screen), background_color, &color);
|
||||||
attributes.border_pixel = border_color;
|
attributes.background_pixel = color.pixel;
|
||||||
|
XftColorAllocName(display, DefaultVisual(display, screen), DefaultColormap(display, screen), border_color, &color);
|
||||||
|
attributes.border_pixel = color.pixel;
|
||||||
|
|
||||||
XftColor color;
|
|
||||||
char *status = "Ahoj volam sa samko netahaj mi stolicku lebo ta ujebem ty hovafoooooo";
|
|
||||||
XftFont *font = XftFontOpenName(display, screen, font_style);
|
XftFont *font = XftFontOpenName(display, screen, font_style);
|
||||||
|
|
||||||
|
unsigned short x = pos_x;
|
||||||
|
unsigned short y = pos_y;
|
||||||
|
switch (corner) {
|
||||||
|
case down_right:
|
||||||
|
y = window_height - height + 5;
|
||||||
|
case top_right:
|
||||||
|
x = window_width - width - border_size * 2 - pos_x;
|
||||||
|
break;
|
||||||
|
case down_left:
|
||||||
|
y = window_height - height + 5;
|
||||||
|
}
|
||||||
|
|
||||||
Window window = XCreateWindow(
|
Window window = XCreateWindow(
|
||||||
display, root, pos_x,
|
display, root, x,
|
||||||
pos_y, width, font->ascent + 10 + border_size, border_size,
|
y, width, font->ascent + 10 + border_size, border_size,
|
||||||
DefaultDepth(display, screen), CopyFromParent,
|
DefaultDepth(display, screen), CopyFromParent,
|
||||||
DefaultVisual(display, screen),
|
DefaultVisual(display, screen),
|
||||||
CWOverrideRedirect | CWBackPixel | CWBorderPixel, &attributes);
|
CWOverrideRedirect | CWBackPixel | CWBorderPixel, &attributes);
|
||||||
|
|
||||||
XftDraw *draw = XftDrawCreate(display, window, DefaultVisual(display, screen), DefaultColormap(display, screen));
|
XftDraw *draw = XftDrawCreate(display, window, DefaultVisual(display, screen), DefaultColormap(display, screen));
|
||||||
XftColorAllocName(display, DefaultVisual(display, screen), DefaultColormap(display, screen), "#000000", &color);
|
XftColorAllocName(display, DefaultVisual(display, screen), DefaultColormap(display, screen), font_color, &color);
|
||||||
|
|
||||||
XMapWindow(display, window);
|
XMapWindow(display, window);
|
||||||
|
|
||||||
|
@ -49,4 +63,7 @@ int main(int argc, char *argv[])
|
||||||
XNextEvent(display, &event);
|
XNextEvent(display, &event);
|
||||||
|
|
||||||
sleep(duration);
|
sleep(duration);
|
||||||
|
|
||||||
|
XCloseDisplay(display);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue