summaryrefslogtreecommitdiff
path: root/i3lock.c
diff options
context:
space:
mode:
authorknolax <1339802534.kk@gmail.com>2017-07-17 12:15:58 -0400
committerknolax <1339802534.kk@gmail.com>2017-07-17 12:15:58 -0400
commit6fc239fdb0cfc9add7b683d83260dc19b9de3284 (patch)
tree1d59eaa97235ef2133e56427d5f8ec097440d280 /i3lock.c
parente1a0ee458f32fe5e61ed23fc71fd08af501998b7 (diff)
functional implementation of images for auth indicator state
Diffstat (limited to 'i3lock.c')
-rw-r--r--i3lock.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/i3lock.c b/i3lock.c
index 826d27e..988c32e 100644
--- a/i3lock.c
+++ b/i3lock.c
@@ -86,7 +86,8 @@ static uint8_t xkb_base_event;
static uint8_t xkb_base_error;
cairo_surface_t *img = NULL; // image buffer to background image
-cairo_surface_t **auth_images = NULL; // array of image buffers to background image;
+cairo_surface_t *auth_images[5]; // array of image buffers to background image;
+bool use_auth_images = false;
bool tile = false;
bool ignore_empty_password = false;
bool skip_repeated_empty_password = false;
@@ -836,8 +837,8 @@ int main(int argc, char *argv[]) {
{"help", no_argument, NULL, 'h'},
{"no-unlock-indicator", no_argument, NULL, 'u'},
{"image", required_argument, NULL, 'i'},
- {"auth-image-indicator", required_argument, NULL, 'a'},
- {"keypress-image-indicator", required_argument, NULL, 'k'},
+ {"auth-image-dir", required_argument, NULL, 'a'},
+ {"keypress-image-dir", required_argument, NULL, 'k'},
{"tiling", no_argument, NULL, 't'},
{"ignore-empty-password", no_argument, NULL, 'e'},
{"inactivity-timeout", required_argument, NULL, 'I'},
@@ -849,7 +850,7 @@ int main(int argc, char *argv[]) {
if ((username = pw->pw_name) == NULL)
errx(EXIT_FAILURE, "pw->pw_name is NULL.\n");
- char *optstring = "hvnbdc:p:ui:teI:f";
+ char *optstring = "hvnbdc:p:ui:a:k:teI:f";
while ((o = getopt_long(argc, argv, optstring, longopts, &optind)) != -1) {
switch (o) {
case 'v':
@@ -915,7 +916,7 @@ int main(int argc, char *argv[]) {
break;
default:
errx(EXIT_FAILURE, "Syntax: i3lock [-v] [-n] [-b] [-d] [-c color] [-u] [-p win|default]"
- " [-i image.png] [-t] [-e] [-I timeout] [-f]");
+ " [-i image.png] [-a auth-image-dir] [-k keypress-image-dir] [-t] [-e] [-I timeout] [-f]");
}
}
@@ -1029,24 +1030,23 @@ int main(int argc, char *argv[]) {
//auth_image_path/{0-4}.png are required, corresponding to their auth_state_t states
//otherwise auth_images is set to null
if (auth_image_path) {
- //allocates 5 cairo_surface_t * to auth_images
- auth_images = calloc(sizeof(cairo_surface_t *) * 5);
+ use_auth_images = true;
int auth_image_counter = 0; // counter to loop through the states
- char * auth_img_path_buffer; // string to store the pathes of each image as it loads
- while (auth_image_counter < STATE_I3LOCK_LOCK_FAILED) {
- //allocates string of exactly 5chars larger tan auth_image_path, since $auth_image_counter.png is 5 chars;
- auth_img_path_buffer = calloc(strlen(auth_image_path) + 5);
- sprintf(auth_img_path_buffer,"%s%d%s",auth_image_path,auth_image_counter,".png");
+ char * auth_image_path_buffer; // string to store the pathes of each image as it loads
+ while (auth_image_counter <= STATE_I3LOCK_LOCK_FAILED) {
+ //allocates string of exactly 5chars larger tan auth_image_path, since /$auth_image_counter.png is 5 chars;
+ auth_image_path_buffer = calloc(strlen(auth_image_path) + 6,sizeof(char));
+ sprintf(auth_image_path_buffer,"%s%s%d%s",auth_image_path,"/",auth_image_counter,".png");
/* Create a pixmap to render on, fill it with the background color */
auth_images[auth_image_counter] = cairo_image_surface_create_from_png(auth_image_path_buffer);
/* In case loading failed, we just pretend no -i was specified. */
- if (cairo_surface_status(img) != CAIRO_STATUS_SUCCESS) {
+ if (cairo_surface_status(auth_images[auth_image_counter]) != CAIRO_STATUS_SUCCESS) {
fprintf(stderr, "Could not load image \"%s\": %s\n",
- image_path_buffer, cairo_status_to_string(cairo_surface_status(auth_images[auth_image_counter])));
- free(auth_images);
- auth_images = NULL;
+ auth_image_path_buffer, cairo_status_to_string(cairo_surface_status(auth_images[auth_image_counter])));
+ use_auth_images = false;
}
free(auth_image_path_buffer);
+ auth_image_counter++;
}
free(auth_image_path);
}