From 96c4dd93ddc01df0e2c26193af6f425ae594748c Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Wed, 20 Nov 2024 14:42:05 +0100 Subject: Sync with upstream --- .clang-format | 11 ++-- ci/Dockerfile | 25 ++++++++ dpi.c | 5 +- i3lock.c | 165 +++++++++++++++++++++++++++++++----------------- meson/meson-dist-script | 3 +- randr.c | 6 +- travis/Dockerfile | 25 -------- unlock_indicator.c | 12 ++-- xcb.c | 3 +- 9 files changed, 156 insertions(+), 99 deletions(-) create mode 100644 ci/Dockerfile delete mode 100644 travis/Dockerfile diff --git a/.clang-format b/.clang-format index 6e49d83..2b8e0b3 100644 --- a/.clang-format +++ b/.clang-format @@ -1,11 +1,12 @@ -BasedOnStyle: google +AllowShortBlocksOnASingleLine: false +AllowShortFunctionsOnASingleLine: None AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false -AllowShortFunctionsOnASingleLine: None -AllowShortBlocksOnASingleLine: false AlwaysBreakBeforeMultilineStrings: false +BasedOnStyle: google +ColumnLimit: 0 IndentWidth: 4 +InsertBraces: true PointerBindsToType: false -ColumnLimit: 0 -SpaceBeforeParens: ControlStatements SortIncludes: false +SpaceBeforeParens: ControlStatements diff --git a/ci/Dockerfile b/ci/Dockerfile new file mode 100644 index 0000000..17dd297 --- /dev/null +++ b/ci/Dockerfile @@ -0,0 +1,25 @@ +# vim:ft=Dockerfile +FROM debian:sid + +RUN echo force-unsafe-io > /etc/dpkg/dpkg.cfg.d/docker-apt-speedup +# Paper over occasional network flakiness of some mirrors. +RUN echo 'APT::Acquire::Retries "5";' > /etc/apt/apt.conf.d/80retry + +# NOTE: I tried exclusively using gce_debian_mirror.storage.googleapis.com +# instead of httpredir.debian.org, but the results (Fetched 123 MB in 36s (3357 +# kB/s)) are not any better than httpredir.debian.org (Fetched 123 MB in 34s +# (3608 kB/s)). Hence, let’s stick with httpredir.debian.org (default) for now. + +# Install mk-build-deps (for installing the i3 build dependencies), +# clang (for building), +# lintian (for checking spelling errors), +# test suite dependencies (for running tests) +RUN apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + build-essential clang git meson libxcb-randr0-dev pkg-config libpam0g-dev \ + libcairo2-dev libxcb1-dev libxcb-dpms0-dev libxcb-image0-dev libxcb-util0-dev \ + libxcb-xrm-dev libev-dev libxcb-xinerama0-dev libxcb-xkb-dev libxkbcommon-dev \ + libxkbcommon-x11-dev && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /usr/src diff --git a/dpi.c b/dpi.c index 3cb08ee..0fdf88a 100644 --- a/dpi.c +++ b/dpi.c @@ -1,7 +1,7 @@ /* * vim:ts=4:sw=4:expandtab * - * i3 - an improved dynamic tiling window manager + * i3 - an improved tiling window manager * © 2009 Michael Stapelberg and contributors (see also: LICENSE) * */ @@ -103,7 +103,8 @@ int logical_px(const int logical) { * systems to 96 dpi in order to get the behavior they expect/are used to, * but since we can easily detect this case in code, let’s do it for them. */ - if ((dpi / 96.0) < 1.25) + if ((dpi / 96.0) < 1.25) { return logical; + } return ceil((dpi / 96.0) * logical); } diff --git a/i3lock.c b/i3lock.c index 3f8eb77..44a30f2 100644 --- a/i3lock.c +++ b/i3lock.c @@ -236,12 +236,13 @@ static void clear_password_memory(void) { /* A volatile pointer to the password buffer to prevent the compiler from * optimizing this out. */ volatile char *vpassword = password; - for (size_t c = 0; c < sizeof(password); c++) + for (size_t c = 0; c < sizeof(password); c++) { /* We store a non-random pattern which consists of the (irrelevant) * index plus (!) the value of the beep variable. This prevents the * compiler from optimizing the calls away, since the value of 'beep' * is not known at compile-time. */ vpassword[c] = c + (int)beep; + } #endif } @@ -253,7 +254,7 @@ ev_timer *start_timer(ev_timer *timer_obj, ev_tstamp timeout, ev_callback_t call } else { /* When there is no memory, we just don’t have a timeout. We cannot * exit() here, since that would effectively unlock the screen. */ - timer_obj = calloc(sizeof(struct ev_timer), 1); + timer_obj = calloc(1, sizeof(struct ev_timer)); if (timer_obj) { ev_timer_init(timer_obj, callback, timeout, 0.); ev_timer_start(main_loop, timer_obj); @@ -332,8 +333,9 @@ static void input_done(void) { #ifdef __OpenBSD__ struct passwd *pw; - if (!(pw = getpwuid(getuid()))) + if (!(pw = getpwuid(getuid()))) { errx(1, "unknown uid %u.", getuid()); + } if (auth_userokay(pw->pw_name, NULL, NULL, password) != 0) { DEBUG("successfully authenticated\n"); @@ -362,14 +364,16 @@ static void input_done(void) { /* reset the time elapsed counter */ i3lock_elapsed_time.start_time = time(NULL); #endif - if (debug_mode) + if (debug_mode) { fprintf(stderr, "Authentication failure\n"); + } auth_state = STATE_AUTH_WRONG; failed_attempts += 1; clear_input(); - if (unlock_indicator) + if (unlock_indicator) { redraw_screen(); + } /* Clear this state after 2 seconds (unless the user enters another * password during that time). */ @@ -393,11 +397,13 @@ static void redraw_timeout(EV_P_ ev_timer *w, int revents) { } static bool skip_without_validation(void) { - if (input_position != 0) + if (input_position != 0) { return false; + } - if (skip_repeated_empty_password || ignore_empty_password) + if (skip_repeated_empty_password || ignore_empty_password) { return true; + } return false; } @@ -450,8 +456,9 @@ static void handle_key_press(xcb_key_press_event_t *event) { case XKB_KEY_Return: case XKB_KEY_KP_Enter: case XKB_KEY_XF86ScreenSaver: - if ((ksym == XKB_KEY_j || ksym == XKB_KEY_m) && !ctrl) + if ((ksym == XKB_KEY_j || ksym == XKB_KEY_m) && !ctrl) { break; + } if (auth_state == STATE_AUTH_WRONG) { retry_verification = true; @@ -483,8 +490,9 @@ static void handle_key_press(xcb_key_press_event_t *event) { DEBUG("C-u pressed\n"); clear_input(); /* Also hide the unlock indicator */ - if (unlock_indicator) + if (unlock_indicator) { clear_indicator(); + } return; } break; @@ -499,8 +507,9 @@ static void handle_key_press(xcb_key_press_event_t *event) { case XKB_KEY_h: case XKB_KEY_BackSpace: - if (ksym == XKB_KEY_h && !ctrl) + if (ksym == XKB_KEY_h && !ctrl) { break; + } if (input_position == 0) { START_TIMER(clear_indicator_timeout, 1.0, clear_indicator_cb); @@ -522,8 +531,9 @@ static void handle_key_press(xcb_key_press_event_t *event) { return; } - if ((input_position + 8) >= (int)sizeof(password)) + if ((input_position + 8) >= (int)sizeof(password)) { return; + } #if 0 /* FIXME: handle all of these? */ @@ -536,8 +546,9 @@ static void handle_key_press(xcb_key_press_event_t *event) { printf("xcb_is_modifier_key = %d\n", xcb_is_modifier_key(sym)); #endif - if (n < 2) + if (n < 2) { return; + } /* store it in the password array as UTF-8 */ memcpy(password + input_position, buffer, n - 1); @@ -598,8 +609,9 @@ static void process_xkb_event(xcb_generic_event_t *gevent) { DEBUG("process_xkb_event for device %d\n", event->any.deviceID); - if (event->any.deviceID != xkb_x11_get_core_keyboard_device_id(conn)) + if (event->any.deviceID != xkb_x11_get_core_keyboard_device_id(conn)) { return; + } /* * XkbNewKkdNotify and XkbMapNotify together capture all sorts of keymap @@ -608,8 +620,9 @@ static void process_xkb_event(xcb_generic_event_t *gevent) { */ switch (event->any.xkbType) { case XCB_XKB_NEW_KEYBOARD_NOTIFY: - if (event->new_keyboard_notify.changed & XCB_XKB_NKN_DETAIL_KEYCODES) + if (event->new_keyboard_notify.changed & XCB_XKB_NKN_DETAIL_KEYCODES) { (void)load_keymap(); + } break; case XCB_XKB_MAP_NOTIFY: @@ -638,8 +651,9 @@ static void handle_screen_resize(void) { xcb_get_geometry_cookie_t geomc; xcb_get_geometry_reply_t *geom; geomc = xcb_get_geometry(conn, screen->root); - if ((geom = xcb_get_geometry_reply(conn, geomc, 0)) == NULL) + if ((geom = xcb_get_geometry_reply(conn, geomc, 0)) == NULL) { return; + } if (last_resolution[0] == geom->width && last_resolution[1] == geom->height) { @@ -667,8 +681,9 @@ static ssize_t read_raw_image_native(uint32_t *dest, FILE *src, size_t width, si for (size_t y = 0; y < height; y++) { size_t n = fread(&dest[y * pixstride], 1, width * 4, src); count += n; - if (n < (size_t)(width * 4)) + if (n < (size_t)(width * 4)) { break; + } } return count; @@ -684,15 +699,17 @@ struct raw_pixel_format { static ssize_t read_raw_image_fmt(uint32_t *dest, FILE *src, size_t width, size_t height, int pixstride, struct raw_pixel_format fmt) { unsigned char *buf = malloc(width * fmt.bpp); - if (buf == NULL) + if (buf == NULL) { return -1; + } ssize_t count = 0; for (size_t y = 0; y < height; y++) { size_t n = fread(buf, 1, width * fmt.bpp, src); count += n; - if (n < (size_t)(width * fmt.bpp)) + if (n < (size_t)(width * fmt.bpp)) { break; + } for (size_t x = 0; x < width; ++x) { int idx = x * fmt.bpp; @@ -763,18 +780,19 @@ static cairo_surface_t *read_raw_image(const char *image_path, const char *image } else { const struct raw_pixel_format *fmt = NULL; - if (strcmp(pixfmt, "rgb") == 0) + if (strcmp(pixfmt, "rgb") == 0) { fmt = &raw_fmt_rgb; - else if (strcmp(pixfmt, "rgbx") == 0) + } else if (strcmp(pixfmt, "rgbx") == 0) { fmt = &raw_fmt_rgbx; - else if (strcmp(pixfmt, "xrgb") == 0) + } else if (strcmp(pixfmt, "xrgb") == 0) { fmt = &raw_fmt_xrgb; - else if (strcmp(pixfmt, "bgr") == 0) + } else if (strcmp(pixfmt, "bgr") == 0) { fmt = &raw_fmt_bgr; - else if (strcmp(pixfmt, "bgrx") == 0) + } else if (strcmp(pixfmt, "bgrx") == 0) { fmt = &raw_fmt_bgrx; - else if (strcmp(pixfmt, "xbgr") == 0) + } else if (strcmp(pixfmt, "xbgr") == 0) { fmt = &raw_fmt_xbgr; + } if (fmt == NULL) { fprintf(stderr, "Unknown raw pixel format: %s\n", pixfmt); @@ -845,8 +863,9 @@ static bool verify_png_image(const char *image_path) { */ static int conv_callback(int num_msg, const struct pam_message **msg, struct pam_response **resp, void *appdata_ptr) { - if (num_msg == 0) + if (num_msg == 0) { return 1; + } /* PAM expects an array of responses, one for each message */ if ((*resp = calloc(num_msg, sizeof(struct pam_response))) == NULL) { @@ -856,8 +875,9 @@ static int conv_callback(int num_msg, const struct pam_message **msg, for (int c = 0; c < num_msg; c++) { if (msg[c]->msg_style != PAM_PROMPT_ECHO_OFF && - msg[c]->msg_style != PAM_PROMPT_ECHO_ON) + msg[c]->msg_style != PAM_PROMPT_ECHO_ON) { continue; + } /* return code is currently not used but should be set to zero */ resp[c]->resp_retcode = 0; @@ -912,15 +932,17 @@ static void maybe_close_sleep_lock_fd(void) { static void xcb_check_cb(EV_P_ ev_check *w, int revents) { xcb_generic_event_t *event; - if (xcb_connection_has_error(conn)) + if (xcb_connection_has_error(conn)) { errx(EXIT_FAILURE, "X11 connection broke, did your server terminate?"); + } while ((event = xcb_poll_for_event(conn)) != NULL) { if (event->response_type == 0) { xcb_generic_error_t *error = (xcb_generic_error_t *)event; - if (debug_mode) + if (debug_mode) { fprintf(stderr, "X11 Error received! sequence 0x%x, error_code = %d\n", error->sequence, error->error_code); + } free(event); continue; } @@ -945,8 +967,9 @@ static void xcb_check_cb(EV_P_ ev_check *w, int revents) { dont_fork = true; /* In the parent process, we exit */ - if (fork() != 0) + if (fork() != 0) { exit(0); + } ev_loop_fork(EV_DEFAULT); } @@ -983,8 +1006,9 @@ static void raise_loop(xcb_window_t window) { xcb_generic_event_t *event; int screens; - if (xcb_connection_has_error((conn = xcb_connect(NULL, &screens))) > 0) + if (xcb_connection_has_error((conn = xcb_connect(NULL, &screens))) > 0) { errx(EXIT_FAILURE, "Cannot open display"); + } /* We need to know about the window being obscured or getting destroyed. */ xcb_change_window_attributes(conn, window, XCB_CW_EVENT_MASK, @@ -1011,13 +1035,15 @@ static void raise_loop(xcb_window_t window) { break; case XCB_UNMAP_NOTIFY: DEBUG("UnmapNotify for 0x%08x\n", (((xcb_unmap_notify_event_t *)event)->window)); - if (((xcb_unmap_notify_event_t *)event)->window == window) + if (((xcb_unmap_notify_event_t *)event)->window == window) { exit(EXIT_SUCCESS); + } break; case XCB_DESTROY_NOTIFY: DEBUG("DestroyNotify for 0x%08x\n", (((xcb_destroy_notify_event_t *)event)->window)); - if (((xcb_destroy_notify_event_t *)event)->window == window) + if (((xcb_destroy_notify_event_t *)event)->window == window) { exit(EXIT_SUCCESS); + } break; default: DEBUG("Unhandled event type %d\n", type); @@ -1088,12 +1114,7 @@ int main(int argc, char *argv[]) { {"show-keyboard-layout", no_argument, NULL, 'k'}, {NULL, no_argument, NULL, 0}}; - if ((pw = getpwuid(getuid())) == NULL) - err(EXIT_FAILURE, "getpwuid() failed"); - if ((username = pw->pw_name) == NULL) - errx(EXIT_FAILURE, "pw->pw_name is NULL."); - if (getenv("WAYLAND_DISPLAY") != NULL) - errx(EXIT_FAILURE, "i3lock is a program for X11 and does not work on Wayland. Try https://github.com/swaywm/swaylock instead"); + int code = EXIT_FAILURE; #ifdef EXTRAS char *optstring = "hvnbDdELC:c:B:G:F:J:O:R:r:S:T:W:X:x:Y:y:Z:p:ui:teI:fk"; @@ -1121,11 +1142,13 @@ int main(int argc, char *argv[]) { char *arg = optarg; /* Skip # if present */ - if (arg[0] == '#') + if (arg[0] == '#') { arg++; + } - if (strlen(arg) != 6 || sscanf(arg, "%06[0-9a-fA-F]", color) != 1) + if (strlen(arg) != 6 || sscanf(arg, "%06[0-9a-fA-F]", color) != 1) { errx(EXIT_FAILURE, "color is invalid, it must be given in 3-byte hexadecimal format: rrggbb"); + } break; } @@ -1332,10 +1355,11 @@ int main(int argc, char *argv[]) { ignore_empty_password = true; break; case 0: - if (strcmp(longopts[longoptind].name, "debug") == 0) + if (strcmp(longopts[longoptind].name, "debug") == 0) { debug_mode = true; - else if (strcmp(longopts[longoptind].name, "raw") == 0) + } else if (strcmp(longopts[longoptind].name, "raw") == 0) { image_raw_format = strdup(optarg); + } break; case 'f': show_failed_attempts = true; @@ -1343,10 +1367,13 @@ int main(int argc, char *argv[]) { case 'k': show_keyboard_layout = true; break; + case 'h': + code = EXIT_SUCCESS; + /* fallthrough */ default: #ifdef EXTRAS errx( - EXIT_FAILURE, + code, "Syntax: i3lock-extended [-B color] [-b] [-C seconds] " "[-c color] [-D] [-d] [-E] [-e] [-F color] [-f] [-k]" "[-G color] [-h] [-I timeout] [-i image.png] [-J text] " @@ -1356,12 +1383,22 @@ int main(int argc, char *argv[]) { "[-x horizontal-alignment] [-Y vertical-alignment] " "[-y vertical-alignment] [-Z vertical-alignment]"); #else - errx(EXIT_FAILURE, "Syntax: i3lock [-v] [-n] [-b] [-d] [-c color] [-u] [-p win|default]" - " [-i image.png] [-t] [-e] [-I timeout] [-f] [-k]"); + errx(code, "Syntax: i3lock [-v] [-n] [-b] [-d] [-c color] [-u] [-p win|default]" + " [-i image.png] [-t] [-e] [-I timeout] [-f] [-k]"); #endif } } + if ((pw = getpwuid(getuid())) == NULL) { + err(EXIT_FAILURE, "getpwuid() failed"); + } + if ((username = pw->pw_name) == NULL) { + errx(EXIT_FAILURE, "pw->pw_name is NULL."); + } + if (getenv("WAYLAND_DISPLAY") != NULL) { + errx(EXIT_FAILURE, "i3lock is a program for X11 and does not work on Wayland. Try https://github.com/swaywm/swaylock instead"); + } + /* We need (relatively) random numbers for highlighting a random part of * the unlock indicator upon keypresses. */ srand(time(NULL)); @@ -1369,14 +1406,16 @@ int main(int argc, char *argv[]) { #ifndef __OpenBSD__ /* Initialize PAM */ #ifdef EXTRAS - if ((ret = pam_start("i3lock-extended", username, &conv, &pam_handle)) != PAM_SUCCESS) + if ((ret = pam_start("i3lock-extended", username, &conv, &pam_handle)) != PAM_SUCCESS) { #else - if ((ret = pam_start("i3lock", username, &conv, &pam_handle)) != PAM_SUCCESS) + if ((ret = pam_start("i3lock", username, &conv, &pam_handle)) != PAM_SUCCESS) { #endif errx(EXIT_FAILURE, "PAM: %s", pam_strerror(pam_handle, ret)); + } - if ((ret = pam_set_item(pam_handle, PAM_TTY, getenv("DISPLAY"))) != PAM_SUCCESS) + if ((ret = pam_set_item(pam_handle, PAM_TTY, getenv("DISPLAY"))) != PAM_SUCCESS) { errx(EXIT_FAILURE, "PAM: %s", pam_strerror(pam_handle, ret)); + } #endif /* Using mlock() as non-super-user seems only possible in Linux. @@ -1388,15 +1427,17 @@ int main(int argc, char *argv[]) { /* Lock the area where we store the password in memory, we don’t want it to * be swapped to disk. Since Linux 2.6.9, this does not require any * privileges, just enough bytes in the RLIMIT_MEMLOCK limit. */ - if (mlock(password, sizeof(password)) != 0) + if (mlock(password, sizeof(password)) != 0) { err(EXIT_FAILURE, "Could not lock page in memory, check RLIMIT_MEMLOCK"); + } #endif /* Double checking that connection is good and operatable with xcb */ int screennr; if ((conn = xcb_connect(NULL, &screennr)) == NULL || - xcb_connection_has_error(conn)) + xcb_connection_has_error(conn)) { errx(EXIT_FAILURE, "Could not connect to X11, maybe you need to set DISPLAY?"); + } if (xkb_x11_setup_xkb_extension(conn, XKB_X11_MIN_MAJOR_XKB_VERSION, @@ -1405,8 +1446,9 @@ int main(int argc, char *argv[]) { NULL, NULL, &xkb_base_event, - &xkb_base_error) != 1) + &xkb_base_error) != 1) { errx(EXIT_FAILURE, "Could not setup XKB extension."); + } static const xcb_xkb_map_part_t required_map_parts = (XCB_XKB_MAP_PART_KEY_TYPES | @@ -1433,17 +1475,21 @@ int main(int argc, char *argv[]) { 0); /* When we cannot initially load the keymap, we better exit */ - if (!load_keymap()) + if (!load_keymap()) { errx(EXIT_FAILURE, "Could not load keymap"); + } const char *locale = getenv("LC_ALL"); - if (!locale || !*locale) + if (!locale || !*locale) { locale = getenv("LC_CTYPE"); - if (!locale || !*locale) + } + if (!locale || !*locale) { locale = getenv("LANG"); + } if (!locale || !*locale) { - if (debug_mode) + if (debug_mode) { fprintf(stderr, "Can't detect your locale, fallback to C\n"); + } locale = "C"; } @@ -1532,16 +1578,17 @@ int main(int argc, char *argv[]) { /* Initialize the libev event loop. */ main_loop = EV_DEFAULT; - if (main_loop == NULL) + if (main_loop == NULL) { errx(EXIT_FAILURE, "Could not initialize libev. Bad LIBEV_FLAGS?"); + } /* Explicitly call the screen redraw in case "locking…" message was displayed */ auth_state = STATE_AUTH_IDLE; redraw_screen(); - struct ev_io *xcb_watcher = calloc(sizeof(struct ev_io), 1); - struct ev_check *xcb_check = calloc(sizeof(struct ev_check), 1); - struct ev_prepare *xcb_prepare = calloc(sizeof(struct ev_prepare), 1); + struct ev_io *xcb_watcher = calloc(1, sizeof(struct ev_io)); + struct ev_check *xcb_check = calloc(1, sizeof(struct ev_check)); + struct ev_prepare *xcb_prepare = calloc(1, sizeof(struct ev_prepare)); ev_io_init(xcb_watcher, xcb_got_event, xcb_get_file_descriptor(conn), EV_READ); ev_io_start(main_loop, xcb_watcher); diff --git a/meson/meson-dist-script b/meson/meson-dist-script index b112d2f..a6a1151 100755 --- a/meson/meson-dist-script +++ b/meson/meson-dist-script @@ -8,4 +8,5 @@ cd "${MESON_DIST_ROOT}" rm -rf \ .clang-format \ .editorconfig \ - travis + ci \ + .github diff --git a/randr.c b/randr.c index 4b1ea97..ef84c49 100644 --- a/randr.c +++ b/randr.c @@ -58,8 +58,9 @@ void randr_init(int *event_base, xcb_window_t root) { free(randr_version); - if (event_base != NULL) + if (event_base != NULL) { *event_base = extreply->first_event; + } xcb_randr_select_input(conn, root, XCB_RANDR_NOTIFY_MASK_SCREEN_CHANGE | @@ -81,8 +82,9 @@ void _xinerama_init(void) { cookie = xcb_xinerama_is_active(conn); reply = xcb_xinerama_is_active_reply(conn, cookie, NULL); - if (!reply) + if (!reply) { return; + } if (!reply->state) { free(reply); diff --git a/travis/Dockerfile b/travis/Dockerfile deleted file mode 100644 index 9dc8137..0000000 --- a/travis/Dockerfile +++ /dev/null @@ -1,25 +0,0 @@ -# vim:ft=Dockerfile -FROM debian:sid - -RUN echo force-unsafe-io > /etc/dpkg/dpkg.cfg.d/docker-apt-speedup -# Paper over occasional network flakiness of some mirrors. -RUN echo 'APT::Acquire::Retries "5";' > /etc/apt/apt.conf.d/80retry - -# NOTE: I tried exclusively using gce_debian_mirror.storage.googleapis.com -# instead of httpredir.debian.org, but the results (Fetched 123 MB in 36s (3357 -# kB/s)) are not any better than httpredir.debian.org (Fetched 123 MB in 34s -# (3608 kB/s)). Hence, let’s stick with httpredir.debian.org (default) for now. - -# Install mk-build-deps (for installing the i3 build dependencies), -# clang and clang-format-9 (for checking formatting and building with clang), -# lintian (for checking spelling errors), -# test suite dependencies (for running tests) -RUN apt-get update && \ - DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - build-essential clang git meson libxcb-randr0-dev pkg-config libpam0g-dev \ - libcairo2-dev libxcb1-dev libxcb-dpms0-dev libxcb-image0-dev libxcb-util0-dev \ - libxcb-xrm-dev libev-dev libxcb-xinerama0-dev libxcb-xkb-dev libxkbcommon-dev \ - libxkbcommon-x11-dev && \ - rm -rf /var/lib/apt/lists/* - -WORKDIR /usr/src diff --git a/unlock_indicator.c b/unlock_indicator.c index 7d620fd..33b9406 100644 --- a/unlock_indicator.c +++ b/unlock_indicator.c @@ -186,12 +186,14 @@ static void check_modifier_keys(void) { num_mods = xkb_keymap_num_mods(xkb_keymap); for (idx = 0; idx < num_mods; idx++) { - if (!xkb_state_mod_index_is_active(xkb_state, idx, XKB_STATE_MODS_EFFECTIVE)) + if (!xkb_state_mod_index_is_active(xkb_state, idx, XKB_STATE_MODS_EFFECTIVE)) { continue; + } mod_name = xkb_keymap_mod_get_name(xkb_keymap, idx); - if (mod_name == NULL) + if (mod_name == NULL) { continue; + } /* Replace certain xkb names with nicer, human-readable ones. */ if (strcmp(mod_name, XKB_MOD_NAME_CAPS) == 0) { @@ -218,8 +220,9 @@ void draw_image(xcb_pixmap_t bg_pixmap, uint32_t *resolution) { DEBUG("scaling_factor is %.f, physical diameter is %d px\n", scaling_factor, button_diameter_physical); - if (!vistype) + if (!vistype) { vistype = get_root_visual_type(screen); + } /* Initialize cairo: Create one in-memory surface to render the unlock * indicator on, create one XCB surface to actually draw (one or more, @@ -534,7 +537,8 @@ void redraw_screen(void) { void clear_indicator(void) { if (input_position == 0) { unlock_state = STATE_STARTED; - } else + } else { unlock_state = STATE_KEY_PRESSED; + } redraw_screen(); } diff --git a/xcb.c b/xcb.c index 2867a47..f0a784f 100644 --- a/xcb.c +++ b/xcb.c @@ -95,8 +95,9 @@ xcb_visualtype_t *get_root_visual_type(xcb_screen_t *screen) { for (visual_iter = xcb_depth_visuals_iterator(depth_iter.data); visual_iter.rem; xcb_visualtype_next(&visual_iter)) { - if (screen->root_visual != visual_iter.data->visual_id) + if (screen->root_visual != visual_iter.data->visual_id) { continue; + } visual_type = visual_iter.data; return visual_type; -- cgit v1.3