diff options
Diffstat (limited to 'unlock_indicator.c')
| -rw-r--r-- | unlock_indicator.c | 81 |
1 files changed, 73 insertions, 8 deletions
diff --git a/unlock_indicator.c b/unlock_indicator.c index d6237ed..3d98a5f 100644 --- a/unlock_indicator.c +++ b/unlock_indicator.c | |||
| @@ -1,11 +1,30 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * vim:ts=4:sw=4:expandtab | 2 | * This file is part of i3lock-extended |
| 3 | * Copyright (C) 2020 Simeon Simeonov | ||
| 4 | |||
| 5 | * i3lock-extended is free software: you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation, either version 3 of the License, or | ||
| 8 | * (at your option) any later version. | ||
| 9 | |||
| 10 | * i3lock-extended is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | |||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 17 | */ | ||
| 18 | |||
| 19 | /* This file includes software copyrighted by Michael Stapelberg and | ||
| 20 | * distributed under the following license: See LICENSE for more information | ||
| 3 | * | 21 | * |
| 4 | * © 2010 Michael Stapelberg | 22 | * © 2010 Michael Stapelberg |
| 5 | * | 23 | * |
| 6 | * See LICENSE for licensing information | 24 | * See LICENSE for licensing information |
| 7 | * | 25 | * |
| 8 | */ | 26 | */ |
| 27 | |||
| 9 | #include <stdbool.h> | 28 | #include <stdbool.h> |
| 10 | #include <stdlib.h> | 29 | #include <stdlib.h> |
| 11 | #include <stdio.h> | 30 | #include <stdio.h> |
| @@ -22,17 +41,36 @@ | |||
| 22 | #include "randr.h" | 41 | #include "randr.h" |
| 23 | #include "dpi.h" | 42 | #include "dpi.h" |
| 24 | 43 | ||
| 44 | #ifdef EXTRAS | ||
| 45 | #include "extras.h" | ||
| 46 | #endif | ||
| 47 | |||
| 25 | #define BUTTON_RADIUS 90 | 48 | #define BUTTON_RADIUS 90 |
| 26 | #define BUTTON_SPACE (BUTTON_RADIUS + 5) | 49 | #define BUTTON_SPACE (BUTTON_RADIUS + 5) |
| 27 | #define BUTTON_CENTER (BUTTON_RADIUS + 5) | 50 | #define BUTTON_CENTER (BUTTON_RADIUS + 5) |
| 28 | #define BUTTON_DIAMETER (2 * BUTTON_SPACE) | 51 | #define BUTTON_DIAMETER (2 * BUTTON_SPACE) |
| 29 | 52 | ||
| 30 | /******************************************************************************* | 53 | /****************************************************************************** |
| 31 | * Variables defined in i3lock.c. | 54 | * Variables defined in i3lock.c. |
| 32 | ******************************************************************************/ | 55 | *****************************************************************************/ |
| 33 | 56 | ||
| 34 | extern bool debug_mode; | 57 | extern bool debug_mode; |
| 35 | 58 | ||
| 59 | #ifdef EXTRAS | ||
| 60 | /* timekeeping */ | ||
| 61 | time_t now; | ||
| 62 | struct tm *brokentime; | ||
| 63 | /* enable the digital clock */ | ||
| 64 | extern bool digital_clock; | ||
| 65 | extern bool led_clock; | ||
| 66 | extern bool elapsed_time; | ||
| 67 | extern i3lock_digital_clock_t i3lock_digital_clock; | ||
| 68 | extern i3lock_elapsed_time_t i3lock_elapsed_time; | ||
| 69 | extern i3lock_led_clock_t i3lock_led_clock; | ||
| 70 | /* display text */ | ||
| 71 | extern char *display_text; | ||
| 72 | #endif | ||
| 73 | |||
| 36 | /* The current position in the input buffer. Useful to determine if any | 74 | /* The current position in the input buffer. Useful to determine if any |
| 37 | * characters of the password have already been entered or not. */ | 75 | * characters of the password have already been entered or not. */ |
| 38 | extern int input_position; | 76 | extern int input_position; |
| @@ -62,16 +100,16 @@ extern bool show_failed_attempts; | |||
| 62 | /* Number of failed unlock attempts. */ | 100 | /* Number of failed unlock attempts. */ |
| 63 | extern int failed_attempts; | 101 | extern int failed_attempts; |
| 64 | 102 | ||
| 65 | /******************************************************************************* | 103 | /****************************************************************************** |
| 66 | * Variables defined in xcb.c. | 104 | * Variables defined in xcb.c. |
| 67 | ******************************************************************************/ | 105 | *****************************************************************************/ |
| 68 | 106 | ||
| 69 | /* The root screen, to determine the DPI. */ | 107 | /* The root screen, to determine the DPI. */ |
| 70 | extern xcb_screen_t *screen; | 108 | extern xcb_screen_t *screen; |
| 71 | 109 | ||
| 72 | /******************************************************************************* | 110 | /****************************************************************************** |
| 73 | * Local variables. | 111 | * Local variables. |
| 74 | ******************************************************************************/ | 112 | *****************************************************************************/ |
| 75 | 113 | ||
| 76 | /* Cache the screen’s visual, necessary for creating a Cairo context. */ | 114 | /* Cache the screen’s visual, necessary for creating a Cairo context. */ |
| 77 | static xcb_visualtype_t *vistype; | 115 | static xcb_visualtype_t *vistype; |
| @@ -304,7 +342,34 @@ xcb_pixmap_t draw_image(uint32_t *resolution) { | |||
| 304 | cairo_stroke(ctx); | 342 | cairo_stroke(ctx); |
| 305 | } | 343 | } |
| 306 | } | 344 | } |
| 307 | 345 | #ifdef EXTRAS | |
| 346 | now = time(NULL); | ||
| 347 | brokentime = localtime(&now); | ||
| 348 | if (led_clock) { | ||
| 349 | i3lock_draw_led_clock(xcb_ctx, | ||
| 350 | &i3lock_led_clock, | ||
| 351 | resolution, | ||
| 352 | brokentime); | ||
| 353 | } | ||
| 354 | if (digital_clock) { | ||
| 355 | i3lock_draw_digital_clock(xcb_ctx, | ||
| 356 | &i3lock_digital_clock, | ||
| 357 | resolution, | ||
| 358 | brokentime); | ||
| 359 | } | ||
| 360 | /* elapsed time or display text */ | ||
| 361 | if (elapsed_time) { | ||
| 362 | i3lock_draw_elapsed_time(xcb_ctx, | ||
| 363 | &i3lock_elapsed_time, | ||
| 364 | resolution, | ||
| 365 | &now); | ||
| 366 | } else if (display_text != NULL) { | ||
| 367 | i3lock_draw_string(xcb_ctx, | ||
| 368 | display_text, | ||
| 369 | &i3lock_elapsed_time, | ||
| 370 | resolution); | ||
| 371 | } | ||
| 372 | #endif | ||
| 308 | if (xr_screens > 0) { | 373 | if (xr_screens > 0) { |
| 309 | /* Composite the unlock indicator in the middle of each screen. */ | 374 | /* Composite the unlock indicator in the middle of each screen. */ |
| 310 | for (int screen = 0; screen < xr_screens; screen++) { | 375 | for (int screen = 0; screen < xr_screens; screen++) { |
