#include <X11/XKBlib.h>
#include <X11/extensions/XKBfile.h>
#include <xkbcommon/xkbcommon.h>
-
-
-#ifndef NOLIBCAIRO
#include <cairo.h>
#include <cairo/cairo-xcb.h>
-#endif
#include "i3lock.h"
#include "xcb.h"
static struct xkb_context *xkb_context;
static struct xkb_keymap *xkb_keymap;
-#ifndef NOLIBCAIRO
cairo_surface_t *img = NULL;
bool tile = false;
-#endif
/* isutf, u8_dec © 2005 Jeff Bezanson, public domain */
#define isutf(c) (((c) & 0xC0) != 0x80)
free(geom);
-#ifndef NOLIBCAIRO
redraw_screen();
-#endif
uint32_t mask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
xcb_configure_window(conn, win, mask, last_resolution);
int main(int argc, char *argv[]) {
char *username;
-#ifndef NOLIBCAIRO
char *image_path = NULL;
-#endif
int ret;
struct pam_conv conv = {conv_callback, NULL};
int curs_choice = CURS_NONE;
{"debug", no_argument, NULL, 0},
{"help", no_argument, NULL, 'h'},
{"no-unlock-indicator", no_argument, NULL, 'u'},
-#ifndef NOLIBCAIRO
{"image", required_argument, NULL, 'i'},
{"tiling", no_argument, NULL, 't'},
-#endif
{NULL, no_argument, NULL, 0}
};
if ((username = getenv("USER")) == NULL)
errx(1, "USER environment variable not set, please set it.\n");
- while ((o = getopt_long(argc, argv, "hvnbdc:p:u"
-#ifndef NOLIBCAIRO
- "i:t"
-#endif
- , longopts, &optind)) != -1) {
+ while ((o = getopt_long(argc, argv, "hvnbdc:p:ui:t", longopts, &optind)) != -1) {
switch (o) {
case 'v':
errx(EXIT_SUCCESS, "version " VERSION " © 2010-2012 Michael Stapelberg");
case 'u':
unlock_indicator = false;
break;
-#ifndef NOLIBCAIRO
case 'i':
image_path = strdup(optarg);
break;
case 't':
tile = true;
break;
-#endif
case 'p':
if (!strcmp(optarg, "win")) {
curs_choice = CURS_WIN;
break;
default:
errx(1, "Syntax: i3lock [-v] [-n] [-b] [-d] [-c color] [-u] [-p win|default]"
-#ifndef NOLIBCAIRO
" [-i image.png] [-t]"
-#else
- " (compiled with NOLIBCAIRO)"
-#endif
);
}
}
xcb_change_window_attributes(conn, screen->root, XCB_CW_EVENT_MASK,
(uint32_t[]){ XCB_EVENT_MASK_STRUCTURE_NOTIFY });
-#ifndef NOLIBCAIRO
if (image_path) {
/* Create a pixmap to render on, fill it with the background color */
img = cairo_image_surface_create_from_png(image_path);
img = NULL;
}
}
-#endif
/* Pixmap on which the image is rendered to (if any) */
xcb_pixmap_t bg_pixmap = draw_image(last_resolution);
#include <math.h>
#include <xcb/xcb.h>
#include <ev.h>
-
-#ifndef NOLIBCAIRO
#include <cairo.h>
#include <cairo/cairo-xcb.h>
-#endif
#include "xcb.h"
#include "unlock_indicator.h"
/* Whether the unlock indicator is enabled (defaults to true). */
extern bool unlock_indicator;
-#ifndef NOLIBCAIRO
/* A Cairo surface containing the specified image (-i), if any. */
extern cairo_surface_t *img;
-#endif
/* Whether the image should be tiled. */
extern bool tile;
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);
cairo_surface_destroy(output);
cairo_destroy(ctx);
cairo_destroy(xcb_ctx);
-#endif
return bg_pixmap;
}