|
@ -16,8 +16,6 @@ |
|
|
#include <xcb/dpms.h> |
|
|
#include <xcb/dpms.h> |
|
|
#include <xcb/xcb_keysyms.h> |
|
|
#include <xcb/xcb_keysyms.h> |
|
|
#include <err.h> |
|
|
#include <err.h> |
|
|
#include <cairo.h> |
|
|
|
|
|
#include <cairo/cairo-xcb.h> |
|
|
|
|
|
#include <assert.h> |
|
|
#include <assert.h> |
|
|
#include <security/pam_appl.h> |
|
|
#include <security/pam_appl.h> |
|
|
/* FIXME: can we get rid of this header? */ |
|
|
/* FIXME: can we get rid of this header? */ |
|
@ -25,6 +23,11 @@ |
|
|
#include <getopt.h> |
|
|
#include <getopt.h> |
|
|
#include <string.h> |
|
|
#include <string.h> |
|
|
|
|
|
|
|
|
|
|
|
#ifndef NOLIBCAIRO |
|
|
|
|
|
#include <cairo.h> |
|
|
|
|
|
#include <cairo/cairo-xcb.h> |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
#include "keysym2ucs.h" |
|
|
#include "keysym2ucs.h" |
|
|
#include "ucs2_to_utf8.h" |
|
|
#include "ucs2_to_utf8.h" |
|
|
#include "xcb.h" |
|
|
#include "xcb.h" |
|
@ -32,8 +35,6 @@ |
|
|
|
|
|
|
|
|
static xcb_connection_t *conn; |
|
|
static xcb_connection_t *conn; |
|
|
static xcb_key_symbols_t *symbols; |
|
|
static xcb_key_symbols_t *symbols; |
|
|
static cairo_surface_t *img = NULL; |
|
|
|
|
|
static cairo_t *ctx = NULL; |
|
|
|
|
|
static xcb_screen_t *scr; |
|
|
static xcb_screen_t *scr; |
|
|
static pam_handle_t *pam_handle; |
|
|
static pam_handle_t *pam_handle; |
|
|
static int input_position = 0; |
|
|
static int input_position = 0; |
|
@ -43,7 +44,12 @@ static bool modeswitch_active = false; |
|
|
static int modeswitchmask; |
|
|
static int modeswitchmask; |
|
|
static int numlockmask; |
|
|
static int numlockmask; |
|
|
static bool beep = false; |
|
|
static bool beep = false; |
|
|
|
|
|
|
|
|
|
|
|
#ifndef NOLIBCAIRO |
|
|
|
|
|
static cairo_surface_t *img = NULL; |
|
|
|
|
|
static cairo_t *ctx = NULL; |
|
|
static bool tile = false; |
|
|
static bool tile = false; |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
static void input_done() { |
|
|
static void input_done() { |
|
|
if (input_position == 0) |
|
|
if (input_position == 0) |
|
@ -67,6 +73,7 @@ static void input_done() { |
|
|
* |
|
|
* |
|
|
*/ |
|
|
*/ |
|
|
static void handle_expose_event() { |
|
|
static void handle_expose_event() { |
|
|
|
|
|
#ifndef NOLIBCAIRO |
|
|
if (!ctx) |
|
|
if (!ctx) |
|
|
return; |
|
|
return; |
|
|
|
|
|
|
|
@ -82,7 +89,7 @@ static void handle_expose_event() { |
|
|
/* otherwise, just paint the image */ |
|
|
/* otherwise, just paint the image */ |
|
|
cairo_paint(ctx); |
|
|
cairo_paint(ctx); |
|
|
} |
|
|
} |
|
|
|
|
|
#endif |
|
|
xcb_flush(conn); |
|
|
xcb_flush(conn); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -238,7 +245,9 @@ int main(int argc, char *argv[]) { |
|
|
bool dpms = false; |
|
|
bool dpms = false; |
|
|
char color[7] = "ffffff"; |
|
|
char color[7] = "ffffff"; |
|
|
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 screen; |
|
|
int screen; |
|
@ -254,17 +263,23 @@ int main(int argc, char *argv[]) { |
|
|
{"nofork", no_argument, NULL, 'n'}, |
|
|
{"nofork", no_argument, NULL, 'n'}, |
|
|
{"beep", no_argument, NULL, 'b'}, |
|
|
{"beep", no_argument, NULL, 'b'}, |
|
|
{"dpms", no_argument, NULL, 'd'}, |
|
|
{"dpms", no_argument, NULL, 'd'}, |
|
|
{"image", required_argument, NULL, 'i'}, |
|
|
|
|
|
{"color", required_argument, NULL, 'c'}, |
|
|
{"color", required_argument, NULL, 'c'}, |
|
|
{"tiling", no_argument, NULL, 't'}, |
|
|
|
|
|
{"pointer", required_argument, NULL , 'p'}, |
|
|
{"pointer", required_argument, NULL , 'p'}, |
|
|
|
|
|
#ifndef NOLIBCAIRO |
|
|
|
|
|
{"image", required_argument, NULL, 'i'}, |
|
|
|
|
|
{"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, "vnbdi:c:tp:", longopts, &optind)) != -1) { |
|
|
while ((o = getopt_long(argc, argv, "vnbdc:p:" |
|
|
|
|
|
#ifndef NOLIBCAIRO |
|
|
|
|
|
"i:t" |
|
|
|
|
|
#endif |
|
|
|
|
|
, longopts, &optind)) != -1) { |
|
|
switch (o) { |
|
|
switch (o) { |
|
|
case 'v': |
|
|
case 'v': |
|
|
errx(EXIT_SUCCESS, "version " VERSION " © 2010 Michael Stapelberg\n"); |
|
|
errx(EXIT_SUCCESS, "version " VERSION " © 2010 Michael Stapelberg\n"); |
|
@ -277,9 +292,6 @@ int main(int argc, char *argv[]) { |
|
|
case 'd': |
|
|
case 'd': |
|
|
dpms = true; |
|
|
dpms = true; |
|
|
break; |
|
|
break; |
|
|
case 'i': |
|
|
|
|
|
image_path = strdup(optarg); |
|
|
|
|
|
break; |
|
|
|
|
|
case 'c': { |
|
|
case 'c': { |
|
|
char *arg = optarg; |
|
|
char *arg = optarg; |
|
|
|
|
|
|
|
@ -292,9 +304,14 @@ int main(int argc, char *argv[]) { |
|
|
|
|
|
|
|
|
break; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
#ifndef NOLIBCAIRO |
|
|
|
|
|
case 'i': |
|
|
|
|
|
image_path = strdup(optarg); |
|
|
|
|
|
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; |
|
@ -304,7 +321,11 @@ int main(int argc, char *argv[]) { |
|
|
} |
|
|
} |
|
|
break; |
|
|
break; |
|
|
default: |
|
|
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"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -345,13 +366,13 @@ int main(int argc, char *argv[]) { |
|
|
|
|
|
|
|
|
grab_pointer_and_keyboard(conn, scr, cursor); |
|
|
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); |
|
|
symbols = xcb_key_symbols_alloc(conn); |
|
|
modeswitchmask = get_mod_mask(conn, symbols, XK_Mode_switch); |
|
|
modeswitchmask = get_mod_mask(conn, symbols, XK_Mode_switch); |
|
|
numlockmask = get_mod_mask(conn, symbols, XK_Num_Lock); |
|
|
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) { |
|
|
if (img) { |
|
|
/* Initialize cairo */ |
|
|
/* Initialize cairo */ |
|
@ -364,6 +385,7 @@ int main(int argc, char *argv[]) { |
|
|
|
|
|
|
|
|
handle_expose_event(); |
|
|
handle_expose_event(); |
|
|
} |
|
|
} |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
if (dpms) |
|
|
if (dpms) |
|
|
dpms_turn_off_screen(conn); |
|
|
dpms_turn_off_screen(conn); |
|
|