X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=unlock_indicator.c;h=ab4d56ed6f4e3cd47b895932d2293ec528a9b71c;hb=fba88476dd346be871b932c3f7626dba21de2e95;hp=bd61881cc8dc1c7061b28010edc4d30fbbeea0f0;hpb=5e14ad0605efbd4bd593bb24c2d9b53074a620d2;p=i3%2Fi3lock diff --git a/unlock_indicator.c b/unlock_indicator.c index bd61881..ab4d56e 100644 --- a/unlock_indicator.c +++ b/unlock_indicator.c @@ -10,13 +10,9 @@ #include #include #include -#include #include - -#ifndef NOLIBCAIRO #include #include -#endif #include "xcb.h" #include "unlock_indicator.h" @@ -49,6 +45,7 @@ extern bool unlock_indicator; /* A Cairo surface containing the specified image (-i), if any. */ extern cairo_surface_t *img; + /* Whether the image should be tiled. */ extern bool tile; /* The background color to use (in hex). */ @@ -76,7 +73,6 @@ pam_state_t pam_state; xcb_pixmap_t draw_image(uint32_t *resolution) { xcb_pixmap_t bg_pixmap = XCB_NONE; -#ifndef NOLIBCAIRO if (!vistype) vistype = get_root_visual_type(screen); bg_pixmap = create_bg_pixmap(conn, screen, resolution, color); @@ -110,7 +106,7 @@ xcb_pixmap_t draw_image(uint32_t *resolution) { uint32_t rgb16[3] = {(strtol(strgroups[0], NULL, 16)), (strtol(strgroups[1], NULL, 16)), (strtol(strgroups[2], NULL, 16))}; - cairo_set_source_rgb(xcb_ctx, rgb16[0], rgb16[1], rgb16[2]); + cairo_set_source_rgb(xcb_ctx, rgb16[0] / 255.0, rgb16[1] / 255.0, rgb16[2] / 255.0); cairo_rectangle(xcb_ctx, 0, 0, resolution[0], resolution[1]); cairo_fill(xcb_ctx); } @@ -261,7 +257,6 @@ xcb_pixmap_t draw_image(uint32_t *resolution) { cairo_surface_destroy(output); cairo_destroy(ctx); cairo_destroy(xcb_ctx); -#endif return bg_pixmap; } @@ -269,12 +264,12 @@ xcb_pixmap_t draw_image(uint32_t *resolution) { * Calls draw_image on a new pixmap and swaps that with the current pixmap * */ -void redraw_screen() { +void redraw_screen(void) { xcb_pixmap_t bg_pixmap = draw_image(last_resolution); xcb_change_window_attributes(conn, win, XCB_CW_BACK_PIXMAP, (uint32_t[1]){ bg_pixmap }); /* XXX: Possible optimization: Only update the area in the middle of the * screen instead of the whole screen. */ - xcb_clear_area(conn, 0, win, 0, 0, screen->width_in_pixels, screen->height_in_pixels); + xcb_clear_area(conn, 0, win, 0, 0, last_resolution[0], last_resolution[1]); xcb_free_pixmap(conn, bg_pixmap); xcb_flush(conn); } @@ -300,7 +295,7 @@ static void clear_indicator(EV_P_ ev_timer *w, int revents) { * after an unsuccessful authentication attempt. * */ -void start_clear_indicator_timeout() { +void start_clear_indicator_timeout(void) { if (clear_indicator_timeout) { ev_timer_stop(main_loop, clear_indicator_timeout); ev_timer_set(clear_indicator_timeout, 1.0, 0.); @@ -319,7 +314,7 @@ void start_clear_indicator_timeout() { * Stops the clear_indicator timeout. * */ -void stop_clear_indicator_timeout() { +void stop_clear_indicator_timeout(void) { if (clear_indicator_timeout) { ev_timer_stop(main_loop, clear_indicator_timeout); free(clear_indicator_timeout);