herbe

[fork] notifications
Log | Files | Refs | README | LICENSE

commit e81696c2d38ddc11927d70680358512ece552880
parent 025055056c399aeb6b0115bda0ab4105e1dbf78b
Author: Samuel Dudik <samuel.dudik@gmail.com>
Date:   Wed,  5 Aug 2020 20:51:53 +0200

Small refactoring

Diffstat:
Mconfig.h | 23+++++++++++------------
Mherbe.c | 18++++++------------
Mmakefile | 5++---
3 files changed, 19 insertions(+), 27 deletions(-)

diff --git a/config.h b/config.h @@ -1,16 +1,16 @@ -const static char *background_color = "#3e3e3e"; -const static char *border_color = "#ececec"; -const static char *font_color = "#ececec"; -const static char *font_pattern = "Inconsolata:style=Medium:size=13"; -const static unsigned line_spacing = 5; -const static unsigned int padding = 15; +static const char *background_color = "#3e3e3e"; +static const char *border_color = "#ececec"; +static const char *font_color = "#ececec"; +static const char *font_pattern = "Inconsolata:style=Medium:size=13"; +static const unsigned line_spacing = 5; +static const unsigned int padding = 15; -const static unsigned int width = 400; -const static unsigned int border_size = 2; -const static unsigned int pos_x = 30; -const static unsigned int pos_y = 50; +static const unsigned int width = 400; +static const unsigned int border_size = 2; +static const unsigned int pos_x = 30; +static const unsigned int pos_y = 50; enum corners { TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, BOTTOM_RIGHT }; enum corners corner = TOP_RIGHT; -const static unsigned int duration = 5; /* in seconds */ -\ No newline at end of file +static const unsigned int duration = 15; /* in seconds */ diff --git a/herbe.c b/herbe.c @@ -72,7 +72,7 @@ int main(int argc, char *argv[]) while (info.width < max_text_width) { eol++; - XftTextExtentsUtf8(display, font, body + eols[num_of_lines - 1], eol, &info); + XftTextExtentsUtf8(display, font, (FcChar8 *)body + eols[num_of_lines - 1], eol, &info); } --eol; @@ -114,16 +114,11 @@ int main(int argc, char *argv[]) unsigned int text_height = font->ascent - font->descent; unsigned int height = (num_of_lines - 2) * line_spacing + (num_of_lines - 1) * text_height + 2 * padding; - switch (corner) - { - case BOTTOM_RIGHT: - y = screen_height - height - border_size * 2 - pos_y; - case TOP_RIGHT: + if (corner == TOP_RIGHT || corner == BOTTOM_RIGHT) x = screen_width - width - border_size * 2 - pos_x; - break; - case BOTTOM_LEFT: + + if (corner == BOTTOM_LEFT || corner == BOTTOM_RIGHT) y = screen_height - height - border_size * 2 - pos_y; - } window = XCreateWindow(display, RootWindow(display, screen), x, y, width, height, border_size, DefaultDepth(display, screen), CopyFromParent, visual, CWOverrideRedirect | CWBackPixel | CWBorderPixel, &attributes); @@ -145,7 +140,7 @@ int main(int argc, char *argv[]) { XClearWindow(display, window); for (int i = 1; i < num_of_lines; i++) - XftDrawStringUtf8(draw, &color, font, padding, line_spacing * (i - 1) + text_height * i + padding, body + eols[i - 1], eols[i] - eols[i - 1]); + XftDrawStringUtf8(draw, &color, font, padding, line_spacing * (i - 1) + text_height * i + padding, (FcChar8 *)body + eols[i - 1], eols[i] - eols[i - 1]); } if (event.type == ButtonPress) break; @@ -158,4 +153,4 @@ int main(int argc, char *argv[]) XCloseDisplay(display); return EXIT_SUCCESS; -} -\ No newline at end of file +} diff --git a/makefile b/makefile @@ -1,5 +1,5 @@ default: - gcc herbe.c -lX11 -lXft -I/usr/include/freetype2 -lm -o herbe + gcc herbe.c -Wall -Wextra -Werror -pedantic -lX11 -lXft -I/usr/include/freetype2 -lm -o herbe install: default cp herbe /usr/local/bin @@ -8,4 +8,4 @@ uninstall: rm /usr/local/bin/herbe clean: - rm -f herbe -\ No newline at end of file + rm -f herbe