static xcb_gcontext_t pixmap_gc;
static xcb_rectangle_t rect = { 0, 0, 600, 20 };
static i3Font font;
-static char *prompt = "Please do not run this program.";
+static char *prompt;
static button_t *buttons;
static int buttoncnt;
xcb_poly_fill_rectangle(conn, pixmap, pixmap_gc, 1, &rect);
/* restore font color */
- uint32_t values[3];
- values[0] = color_text;
- values[1] = color_background;
- xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND | XCB_GC_BACKGROUND, values);
- xcb_image_text_8(conn, strlen(prompt), pixmap, pixmap_gc, 4 + 4/* X */,
- font.height + 2 + 4 /* Y = baseline of font */, prompt);
+ set_font_colors(pixmap_gc, color_text, color_background);
+ draw_text(prompt, strlen(prompt), false, pixmap, pixmap_gc,
+ 4 + 4, 4 + 4, rect.width - 4 - 4);
/* render close button */
int line_width = 4;
int w = 20;
int y = rect.width;
+ uint32_t values[3];
values[0] = color_button_background;
values[1] = line_width;
xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND | XCB_GC_LINE_WIDTH, values);
};
xcb_poly_line(conn, XCB_COORD_MODE_ORIGIN, pixmap, pixmap_gc, 5, points);
- values[0] = color_text;
- values[1] = color_button_background;
- values[2] = 1;
- xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND | XCB_GC_BACKGROUND | XCB_GC_LINE_WIDTH, values);
- xcb_image_text_8(conn, strlen("x"), pixmap, pixmap_gc, y - w - line_width + (w / 2) - 4/* X */,
- font.height + 2 + 4 - 1/* Y = baseline of font */, "X");
+ values[0] = 1;
+ set_font_colors(pixmap_gc, color_text, color_button_background);
+ draw_text("X", 1, false, pixmap, pixmap_gc, y - w - line_width + w / 2 - 4,
+ 4 + 4 - 1, rect.width - y + w + line_width - w / 2 + 4);
y -= w;
y -= 20;
values[0] = color_text;
values[1] = color_button_background;
- xcb_change_gc(conn, pixmap_gc, XCB_GC_FOREGROUND | XCB_GC_BACKGROUND, values);
- xcb_image_text_8(conn, strlen(buttons[c].label), pixmap, pixmap_gc, y - w - line_width + 6/* X */,
- font.height + 2 + 3/* Y = baseline of font */, buttons[c].label);
+ set_font_colors(pixmap_gc, color_text, color_button_background);
+ draw_text(buttons[c].label, strlen(buttons[c].label), false, pixmap, pixmap_gc,
+ y - w - line_width + 6, 4 + 3, rect.width - y + w + line_width - 6);
y -= w;
}
}
int main(int argc, char *argv[]) {
- char *pattern = "-misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1";
+ char *pattern = strdup("-misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1");
int o, option_index = 0;
enum { TYPE_ERROR = 0, TYPE_WARNING = 1 } bar_type = TYPE_ERROR;
char *options_string = "b:f:m:t:vh";
+ prompt = strdup("Please do not run this program.");
+
while ((o = getopt_long(argc, argv, options_string, long_options, &option_index)) != -1) {
switch (o) {
case 'v':
pattern = strdup(optarg);
break;
case 'm':
+ FREE(prompt);
prompt = strdup(optarg);
break;
case 't':
}
font = load_font(pattern, true);
+ set_font(&font);
/* Open an input window */
win = xcb_generate_id(conn);
xcb_create_pixmap(conn, root_screen->root_depth, pixmap, win, 500, font.height + 8);
xcb_create_gc(conn, pixmap_gc, pixmap, 0, 0);
- /* Create graphics context */
- xcb_change_gc(conn, pixmap_gc, XCB_GC_FONT, (uint32_t[]){ font.id });
-
/* Grab the keyboard to get all input */
xcb_flush(conn);
xcb_create_pixmap(conn, root_screen->root_depth, pixmap, win, rect.width, rect.height);
xcb_create_gc(conn, pixmap_gc, pixmap, 0, 0);
-
- /* Create graphics context */
- xcb_change_gc(conn, pixmap_gc, XCB_GC_FONT, (uint32_t[]){ font.id });
break;
}
}