Move get_colorpixel to libi3, use it everywhere else
This commit is contained in:
@ -3,6 +3,8 @@ TOPDIR=..
|
||||
|
||||
include $(TOPDIR)/common.mk
|
||||
|
||||
CPPFLAGS += -I$(TOPDIR)/include
|
||||
|
||||
# Depend on the object files of all source-files in src/*.c and on all header files
|
||||
FILES=$(patsubst %.c,%.o,$(wildcard *.c))
|
||||
HEADERS=$(wildcard *.h)
|
||||
@ -14,9 +16,12 @@ HEADERS=$(wildcard *.h)
|
||||
|
||||
all: i3-nagbar
|
||||
|
||||
i3-nagbar: ${FILES}
|
||||
i3-nagbar: $(TOPDIR)/libi3/libi3.a ${FILES}
|
||||
echo "[i3-nagbar] LINK i3-nagbar"
|
||||
$(CC) $(LDFLAGS) -o $@ ${FILES} $(LIBS)
|
||||
$(CC) $(LDFLAGS) -o $@ $(filter-out libi3/libi3.a,$^) $(LIBS)
|
||||
|
||||
$(TOPDIR)/libi3/%.a: $(TOPDIR)/libi3/*.c
|
||||
$(MAKE) -C $(TOPDIR)/libi3
|
||||
|
||||
install: all
|
||||
echo "[i3-nagbar] INSTALL"
|
||||
|
@ -18,7 +18,6 @@ while (0)
|
||||
|
||||
extern xcb_window_t root;
|
||||
|
||||
uint32_t get_colorpixel(xcb_connection_t *conn, char *hex);
|
||||
xcb_window_t open_input_window(xcb_connection_t *conn, uint32_t width, uint32_t height);
|
||||
int get_font_id(xcb_connection_t *conn, char *pattern, int *font_height);
|
||||
void xcb_change_gc_single(xcb_connection_t *conn, xcb_gcontext_t gc, uint32_t mask, uint32_t value);
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <xcb/xcb_aux.h>
|
||||
#include <xcb/xcb_event.h>
|
||||
|
||||
#include "libi3.h"
|
||||
#include "i3-nagbar.h"
|
||||
|
||||
typedef struct {
|
||||
@ -287,18 +288,18 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
if (bar_type == TYPE_ERROR) {
|
||||
/* Red theme for error messages */
|
||||
color_button_background = get_colorpixel(conn, "#680a0a");
|
||||
color_background = get_colorpixel(conn, "#900000");
|
||||
color_text = get_colorpixel(conn, "#ffffff");
|
||||
color_border = get_colorpixel(conn, "#d92424");
|
||||
color_border_bottom = get_colorpixel(conn, "#470909");
|
||||
color_button_background = get_colorpixel("#680a0a");
|
||||
color_background = get_colorpixel("#900000");
|
||||
color_text = get_colorpixel("#ffffff");
|
||||
color_border = get_colorpixel("#d92424");
|
||||
color_border_bottom = get_colorpixel("#470909");
|
||||
} else {
|
||||
/* Yellowish theme for warnings */
|
||||
color_button_background = get_colorpixel(conn, "#ffc100");
|
||||
color_background = get_colorpixel(conn, "#ffa8000");
|
||||
color_text = get_colorpixel(conn, "#000000");
|
||||
color_border = get_colorpixel(conn, "#ab7100");
|
||||
color_border_bottom = get_colorpixel(conn, "#ab7100");
|
||||
color_button_background = get_colorpixel("#ffc100");
|
||||
color_background = get_colorpixel("#ffa8000");
|
||||
color_text = get_colorpixel("#000000");
|
||||
color_border = get_colorpixel("#ab7100");
|
||||
color_border_bottom = get_colorpixel("#ab7100");
|
||||
}
|
||||
|
||||
uint32_t font_id = get_font_id(conn, pattern, &font_height);
|
||||
|
@ -28,26 +28,6 @@ void xcb_change_gc_single(xcb_connection_t *conn, xcb_gcontext_t gc, uint32_t ma
|
||||
xcb_change_gc(conn, gc, mask, &value);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the colorpixel to use for the given hex color (think of HTML).
|
||||
*
|
||||
* The hex_color has to start with #, for example #FF00FF.
|
||||
*
|
||||
* NOTE that get_colorpixel() does _NOT_ check the given color code for validity.
|
||||
* This has to be done by the caller.
|
||||
*
|
||||
*/
|
||||
uint32_t get_colorpixel(xcb_connection_t *conn, char *hex) {
|
||||
char strgroups[3][3] = {{hex[1], hex[2], '\0'},
|
||||
{hex[3], hex[4], '\0'},
|
||||
{hex[5], hex[6], '\0'}};
|
||||
uint32_t rgb16[3] = {(strtol(strgroups[0], NULL, 16)),
|
||||
(strtol(strgroups[1], NULL, 16)),
|
||||
(strtol(strgroups[2], NULL, 16))};
|
||||
|
||||
return (rgb16[0] << 16) + (rgb16[1] << 8) + rgb16[2];
|
||||
}
|
||||
|
||||
/*
|
||||
* Opens the window we use for input/output and maps it
|
||||
*
|
||||
|
Reference in New Issue
Block a user