Move get_colorpixel to libi3, use it everywhere else
This commit is contained in:
@ -137,7 +137,7 @@ static char *resolve_tilde(const char *path) {
|
||||
static int handle_expose() {
|
||||
/* re-draw the background */
|
||||
xcb_rectangle_t border = {0, 0, 300, (15*font_height) + 8};
|
||||
xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel(conn, "#000000"));
|
||||
xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel("#000000"));
|
||||
xcb_poly_fill_rectangle(conn, pixmap, pixmap_gc, 1, &border);
|
||||
|
||||
xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FONT, font_id);
|
||||
@ -146,7 +146,7 @@ static int handle_expose() {
|
||||
|
||||
if (current_step == STEP_WELCOME) {
|
||||
/* restore font color */
|
||||
xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel(conn, "#FFFFFF"));
|
||||
xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel("#FFFFFF"));
|
||||
|
||||
txt(10, 2, "You have not configured i3 yet.");
|
||||
txt(10, 3, "Do you want me to generate ~/.i3/config?");
|
||||
@ -154,16 +154,16 @@ static int handle_expose() {
|
||||
txt(85, 7, "No, I will use the defaults");
|
||||
|
||||
/* green */
|
||||
xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel(conn, "#00FF00"));
|
||||
xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel("#00FF00"));
|
||||
txt(25, 5, "<Enter>");
|
||||
|
||||
/* red */
|
||||
xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel(conn, "#FF0000"));
|
||||
xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel("#FF0000"));
|
||||
txt(31, 7, "<ESC>");
|
||||
}
|
||||
|
||||
if (current_step == STEP_GENERATE) {
|
||||
xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel(conn, "#FFFFFF"));
|
||||
xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel("#FFFFFF"));
|
||||
|
||||
txt(10, 2, "Please choose either:");
|
||||
txt(85, 4, "Win as default modifier");
|
||||
@ -185,13 +185,13 @@ static int handle_expose() {
|
||||
|
||||
/* green */
|
||||
uint32_t mask = XCB_GC_FOREGROUND | XCB_GC_FONT;
|
||||
uint32_t values[] = { get_colorpixel(conn, "#00FF00"), font_id };
|
||||
uint32_t values[] = { get_colorpixel("#00FF00"), font_id };
|
||||
xcb_change_gc(conn, pixmap_gc, mask, values);
|
||||
|
||||
txt(25, 9, "<Enter>");
|
||||
|
||||
/* red */
|
||||
xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel(conn, "#FF0000"));
|
||||
xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel("#FF0000"));
|
||||
txt(31, 10, "<ESC>");
|
||||
}
|
||||
|
||||
|
@ -32,26 +32,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];
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the mask for Mode_switch (to be used for looking up keysymbols by
|
||||
* keycode).
|
||||
|
@ -11,7 +11,6 @@
|
||||
extern unsigned int xcb_numlock_mask;
|
||||
|
||||
void xcb_change_gc_single(xcb_connection_t *conn, xcb_gcontext_t gc, uint32_t mask, uint32_t value);
|
||||
uint32_t get_colorpixel(xcb_connection_t *conn, char *hex);
|
||||
uint32_t get_mod_mask(xcb_connection_t *conn, uint32_t keycode);
|
||||
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);
|
||||
|
Reference in New Issue
Block a user