summaryrefslogtreecommitdiff
path: root/i3lock.c
diff options
context:
space:
mode:
authoreplanet <emeric.planet@gmail.com>2016-09-28 03:39:52 +0200
committerMichael Stapelberg <stapelberg@users.noreply.github.com>2016-09-27 18:39:52 -0700
commit1c97a8484723b7db6c96c3b7bfa4c86c26f47b5a (patch)
tree0b25192dc3cd1d9fb0151d58174755292cd891f5 /i3lock.c
parentfd2215b0f08991f0f710533b122a182438ff2237 (diff)
Displaying locking message when grabbing the pointer/keyboard. (#88)
Display "locking…" message when grabbing the pointer/keyboard, after at least 250 ms of unfruitful attempts. If grabbing eventually fails, application will not fork and return 1.
Diffstat (limited to 'i3lock.c')
-rw-r--r--i3lock.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/i3lock.c b/i3lock.c
index 6778e5e..06531e6 100644
--- a/i3lock.c
+++ b/i3lock.c
@@ -977,10 +977,16 @@ int main(int argc, char *argv[]) {
/* Pixmap on which the image is rendered to (if any) */
xcb_pixmap_t bg_pixmap = draw_image(last_resolution);
- /* open the fullscreen window, already with the correct pixmap in place */
+ /* Open the fullscreen window, already with the correct pixmap in place */
win = open_fullscreen_window(conn, screen, color, bg_pixmap);
xcb_free_pixmap(conn, bg_pixmap);
+ cursor = create_cursor(conn, screen, win, curs_choice);
+
+ /* Display the "locking…" message while trying to grab the pointer/keyboard. */
+ pam_state = STATE_PAM_LOCK;
+ grab_pointer_and_keyboard(conn, screen, cursor);
+
pid_t pid = fork();
/* The pid == -1 case is intentionally ignored here:
* While the child process is useful for preventing other windows from
@@ -993,9 +999,6 @@ int main(int argc, char *argv[]) {
exit(EXIT_SUCCESS);
}
- cursor = create_cursor(conn, screen, win, curs_choice);
-
- grab_pointer_and_keyboard(conn, screen, cursor);
/* Load the keymap again to sync the current modifier state. Since we first
* loaded the keymap, there might have been changes, but starting from now,
* we should get all key presses/releases due to having grabbed the
@@ -1007,6 +1010,10 @@ int main(int argc, char *argv[]) {
if (main_loop == NULL)
errx(EXIT_FAILURE, "Could not initialize libev. Bad LIBEV_FLAGS?\n");
+ /* Explicitly call the screen redraw in case "locking…" message was displayed */
+ pam_state = STATE_PAM_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);