remove support for NOLIBCAIRO, cairo-xcb is widespread by now

pull/1/head
Michael Stapelberg 2012-10-26 20:42:26 +02:00
parent fe4f4a8674
commit fba88476dd
4 changed files with 5 additions and 46 deletions

View File

@ -11,14 +11,8 @@ CFLAGS += -std=c99
CFLAGS += -pipe CFLAGS += -pipe
CFLAGS += -Wall CFLAGS += -Wall
CPPFLAGS += -D_GNU_SOURCE CPPFLAGS += -D_GNU_SOURCE
CFLAGS += $(shell pkg-config --cflags xcb-dpms xcb-xinerama xkbcommon xkbfile x11 x11-xcb) CFLAGS += $(shell pkg-config --cflags cairo xcb-dpms xcb-xinerama xkbcommon xkbfile x11 x11-xcb)
LIBS += $(shell pkg-config --libs xcb-dpms xcb-xinerama xcb-image xkbcommon xkbfile x11 x11-xcb) LIBS += $(shell pkg-config --libs cairo xcb-dpms xcb-xinerama xcb-image xkbcommon xkbfile x11 x11-xcb)
ifndef NOLIBCAIRO
CFLAGS += $(shell pkg-config --cflags cairo)
LIBS += $(shell pkg-config --libs cairo)
else
CPPFLAGS += -DNOLIBCAIRO
endif
LIBS += -lpam LIBS += -lpam
LIBS += -lev LIBS += -lev

8
README
View File

@ -33,9 +33,5 @@ Requirements
Running i3lock Running i3lock
------------- -------------
Simply invoke the 'i3lock' command. To get out of it, enter your password. Simply invoke the 'i3lock' command. To get out of it, enter your password and
press enter.
Building i3lock
-------------
If you don't want to build against libcairo run "make NOLIBCAIRO=y", without
libcairo displaying images is not possible.

View File

@ -25,12 +25,8 @@
#include <X11/XKBlib.h> #include <X11/XKBlib.h>
#include <X11/extensions/XKBfile.h> #include <X11/extensions/XKBfile.h>
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>
#ifndef NOLIBCAIRO
#include <cairo.h> #include <cairo.h>
#include <cairo/cairo-xcb.h> #include <cairo/cairo-xcb.h>
#endif
#include "i3lock.h" #include "i3lock.h"
#include "xcb.h" #include "xcb.h"
@ -62,10 +58,8 @@ static struct xkb_state *xkb_state;
static struct xkb_context *xkb_context; static struct xkb_context *xkb_context;
static struct xkb_keymap *xkb_keymap; static struct xkb_keymap *xkb_keymap;
#ifndef NOLIBCAIRO
cairo_surface_t *img = NULL; cairo_surface_t *img = NULL;
bool tile = false; bool tile = false;
#endif
/* isutf, u8_dec © 2005 Jeff Bezanson, public domain */ /* isutf, u8_dec © 2005 Jeff Bezanson, public domain */
#define isutf(c) (((c) & 0xC0) != 0x80) #define isutf(c) (((c) & 0xC0) != 0x80)
@ -377,9 +371,7 @@ void handle_screen_resize(void) {
free(geom); free(geom);
#ifndef NOLIBCAIRO
redraw_screen(); redraw_screen();
#endif
uint32_t mask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT; uint32_t mask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
xcb_configure_window(conn, win, mask, last_resolution); xcb_configure_window(conn, win, mask, last_resolution);
@ -504,9 +496,7 @@ static void xcb_check_cb(EV_P_ ev_check *w, int revents) {
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
char *username; char *username;
#ifndef NOLIBCAIRO
char *image_path = NULL; char *image_path = NULL;
#endif
int ret; int ret;
struct pam_conv conv = {conv_callback, NULL}; struct pam_conv conv = {conv_callback, NULL};
int curs_choice = CURS_NONE; int curs_choice = CURS_NONE;
@ -522,21 +512,15 @@ int main(int argc, char *argv[]) {
{"debug", no_argument, NULL, 0}, {"debug", no_argument, NULL, 0},
{"help", no_argument, NULL, 'h'}, {"help", no_argument, NULL, 'h'},
{"no-unlock-indicator", no_argument, NULL, 'u'}, {"no-unlock-indicator", no_argument, NULL, 'u'},
#ifndef NOLIBCAIRO
{"image", required_argument, NULL, 'i'}, {"image", required_argument, NULL, 'i'},
{"tiling", no_argument, NULL, 't'}, {"tiling", no_argument, NULL, 't'},
#endif
{NULL, no_argument, NULL, 0} {NULL, no_argument, NULL, 0}
}; };
if ((username = getenv("USER")) == NULL) if ((username = getenv("USER")) == NULL)
errx(1, "USER environment variable not set, please set it.\n"); errx(1, "USER environment variable not set, please set it.\n");
while ((o = getopt_long(argc, argv, "hvnbdc:p:u" while ((o = getopt_long(argc, argv, "hvnbdc:p:ui:t", longopts, &optind)) != -1) {
#ifndef NOLIBCAIRO
"i:t"
#endif
, longopts, &optind)) != -1) {
switch (o) { switch (o) {
case 'v': case 'v':
errx(EXIT_SUCCESS, "version " VERSION " © 2010-2012 Michael Stapelberg"); errx(EXIT_SUCCESS, "version " VERSION " © 2010-2012 Michael Stapelberg");
@ -564,14 +548,12 @@ int main(int argc, char *argv[]) {
case 'u': case 'u':
unlock_indicator = false; unlock_indicator = false;
break; break;
#ifndef NOLIBCAIRO
case 'i': case 'i':
image_path = strdup(optarg); image_path = strdup(optarg);
break; break;
case 't': case 't':
tile = true; tile = true;
break; break;
#endif
case 'p': case 'p':
if (!strcmp(optarg, "win")) { if (!strcmp(optarg, "win")) {
curs_choice = CURS_WIN; curs_choice = CURS_WIN;
@ -587,11 +569,7 @@ int main(int argc, char *argv[]) {
break; break;
default: default:
errx(1, "Syntax: i3lock [-v] [-n] [-b] [-d] [-c color] [-u] [-p win|default]" errx(1, "Syntax: i3lock [-v] [-n] [-b] [-d] [-c color] [-u] [-p win|default]"
#ifndef NOLIBCAIRO
" [-i image.png] [-t]" " [-i image.png] [-t]"
#else
" (compiled with NOLIBCAIRO)"
#endif
); );
} }
} }
@ -655,7 +633,6 @@ int main(int argc, char *argv[]) {
xcb_change_window_attributes(conn, screen->root, XCB_CW_EVENT_MASK, xcb_change_window_attributes(conn, screen->root, XCB_CW_EVENT_MASK,
(uint32_t[]){ XCB_EVENT_MASK_STRUCTURE_NOTIFY }); (uint32_t[]){ XCB_EVENT_MASK_STRUCTURE_NOTIFY });
#ifndef NOLIBCAIRO
if (image_path) { if (image_path) {
/* Create a pixmap to render on, fill it with the background color */ /* Create a pixmap to render on, fill it with the background color */
img = cairo_image_surface_create_from_png(image_path); img = cairo_image_surface_create_from_png(image_path);
@ -666,7 +643,6 @@ int main(int argc, char *argv[]) {
img = NULL; img = NULL;
} }
} }
#endif
/* Pixmap on which the image is rendered to (if any) */ /* Pixmap on which the image is rendered to (if any) */
xcb_pixmap_t bg_pixmap = draw_image(last_resolution); xcb_pixmap_t bg_pixmap = draw_image(last_resolution);

View File

@ -11,11 +11,8 @@
#include <math.h> #include <math.h>
#include <xcb/xcb.h> #include <xcb/xcb.h>
#include <ev.h> #include <ev.h>
#ifndef NOLIBCAIRO
#include <cairo.h> #include <cairo.h>
#include <cairo/cairo-xcb.h> #include <cairo/cairo-xcb.h>
#endif
#include "xcb.h" #include "xcb.h"
#include "unlock_indicator.h" #include "unlock_indicator.h"
@ -46,10 +43,8 @@ extern uint32_t last_resolution[2];
/* Whether the unlock indicator is enabled (defaults to true). */ /* Whether the unlock indicator is enabled (defaults to true). */
extern bool unlock_indicator; extern bool unlock_indicator;
#ifndef NOLIBCAIRO
/* A Cairo surface containing the specified image (-i), if any. */ /* A Cairo surface containing the specified image (-i), if any. */
extern cairo_surface_t *img; extern cairo_surface_t *img;
#endif
/* Whether the image should be tiled. */ /* Whether the image should be tiled. */
extern bool tile; extern bool tile;
@ -78,7 +73,6 @@ pam_state_t pam_state;
xcb_pixmap_t draw_image(uint32_t *resolution) { xcb_pixmap_t draw_image(uint32_t *resolution) {
xcb_pixmap_t bg_pixmap = XCB_NONE; xcb_pixmap_t bg_pixmap = XCB_NONE;
#ifndef NOLIBCAIRO
if (!vistype) if (!vistype)
vistype = get_root_visual_type(screen); vistype = get_root_visual_type(screen);
bg_pixmap = create_bg_pixmap(conn, screen, resolution, color); bg_pixmap = create_bg_pixmap(conn, screen, resolution, color);
@ -263,7 +257,6 @@ xcb_pixmap_t draw_image(uint32_t *resolution) {
cairo_surface_destroy(output); cairo_surface_destroy(output);
cairo_destroy(ctx); cairo_destroy(ctx);
cairo_destroy(xcb_ctx); cairo_destroy(xcb_ctx);
#endif
return bg_pixmap; return bg_pixmap;
} }