|
@ -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); |
|
|