#include <xcb/dpms.h>
#include <xcb/xcb_keysyms.h>
#include <err.h>
-#include <cairo.h>
-#include <cairo/cairo-xcb.h>
#include <assert.h>
#include <security/pam_appl.h>
/* FIXME: can we get rid of this header? */
#include <getopt.h>
#include <string.h>
+#ifndef NOLIBCAIRO
+#include <cairo.h>
+#include <cairo/cairo-xcb.h>
+#endif
+
#include "keysym2ucs.h"
#include "ucs2_to_utf8.h"
#include "xcb.h"
static xcb_connection_t *conn;
static xcb_key_symbols_t *symbols;
-static cairo_surface_t *img = NULL;
-static cairo_t *ctx = NULL;
static xcb_screen_t *scr;
static pam_handle_t *pam_handle;
static int input_position = 0;
static int modeswitchmask;
static int numlockmask;
static bool beep = false;
+
+#ifndef NOLIBCAIRO
+static cairo_surface_t *img = NULL;
+static cairo_t *ctx = NULL;
static bool tile = false;
+#endif
static void input_done() {
if (input_position == 0)
*
*/
static void handle_expose_event() {
+#ifndef NOLIBCAIRO
if (!ctx)
return;
/* otherwise, just paint the image */
cairo_paint(ctx);
}
-
+#endif
xcb_flush(conn);
}
bool dpms = false;
char color[7] = "ffffff";
char *username;
+#ifndef NOLIBCAIRO
char *image_path = NULL;
+#endif
int ret;
struct pam_conv conv = {conv_callback, NULL};
int screen;
{"nofork", no_argument, NULL, 'n'},
{"beep", no_argument, NULL, 'b'},
{"dpms", no_argument, NULL, 'd'},
- {"image", required_argument, NULL, 'i'},
{"color", required_argument, NULL, 'c'},
- {"tiling", no_argument, NULL, 't'},
{"pointer", required_argument, NULL , 'p'},
+#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, "vnbdi:c:tp:", longopts, &optind)) != -1) {
+ while ((o = getopt_long(argc, argv, "vnbdc:p:"
+#ifndef NOLIBCAIRO
+ "i:t"
+#endif
+ , longopts, &optind)) != -1) {
switch (o) {
case 'v':
errx(EXIT_SUCCESS, "version " VERSION " © 2010 Michael Stapelberg\n");
case 'd':
dpms = true;
break;
- case 'i':
- image_path = strdup(optarg);
- break;
case 'c': {
char *arg = optarg;
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, "i3lock: Unknown option. Syntax: i3lock [-v] [-n] [-b] [-d] [-i image.png] [-c color] [-t] [-p win|default]\n");
+ errx(1, "i3lock: Unknown option. Syntax: i3lock [-v] [-n] [-b] [-d] [-c color] [-p win|default]"
+#ifndef NOLIBCAIRO
+ " [-i image.png] [-t]"
+#endif
+ "\n");
}
}
grab_pointer_and_keyboard(conn, scr, cursor);
- if (image_path)
- img = cairo_image_surface_create_from_png(image_path);
-
symbols = xcb_key_symbols_alloc(conn);
modeswitchmask = get_mod_mask(conn, symbols, XK_Mode_switch);
numlockmask = get_mod_mask(conn, symbols, XK_Num_Lock);
+#ifndef NOLIBCAIRO
+ if (image_path)
+ img = cairo_image_surface_create_from_png(image_path);
if (img) {
/* Initialize cairo */
handle_expose_event();
}
+#endif
if (dpms)
dpms_turn_off_screen(conn);