mirror of https://github.com/i3/i3lock.git
Handle MappingNotify-events (Thanks Pascal)
parent
a93f110584
commit
c14cb4a250
28
i3lock.c
28
i3lock.c
|
@ -34,6 +34,7 @@
|
||||||
#include "cursors.h"
|
#include "cursors.h"
|
||||||
|
|
||||||
static xcb_connection_t *conn;
|
static xcb_connection_t *conn;
|
||||||
|
static xcb_cursor_t cursor;
|
||||||
static xcb_key_symbols_t *symbols;
|
static xcb_key_symbols_t *symbols;
|
||||||
static xcb_screen_t *scr;
|
static xcb_screen_t *scr;
|
||||||
static pam_handle_t *pam_handle;
|
static pam_handle_t *pam_handle;
|
||||||
|
@ -61,6 +62,8 @@ static void input_done() {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "Authentication failure\n");
|
||||||
|
|
||||||
/* beep on authentication failure, if enabled */
|
/* beep on authentication failure, if enabled */
|
||||||
if (beep) {
|
if (beep) {
|
||||||
xcb_bell(conn, 100);
|
xcb_bell(conn, 100);
|
||||||
|
@ -218,6 +221,25 @@ void handle_visibility_notify(xcb_visibility_notify_event_t *event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Called when the keyboard mapping changes. We update our symbols and re-grab
|
||||||
|
* pointer/keyboard.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void handle_mapping_notify(xcb_mapping_notify_event_t *event) {
|
||||||
|
printf("mapping notify\n");
|
||||||
|
xcb_refresh_keyboard_mapping(symbols, event);
|
||||||
|
|
||||||
|
xcb_ungrab_pointer(conn, XCB_CURRENT_TIME);
|
||||||
|
xcb_ungrab_keyboard(conn, XCB_CURRENT_TIME);
|
||||||
|
grab_pointer_and_keyboard(conn, scr, cursor);
|
||||||
|
|
||||||
|
modeswitchmask = get_mod_mask(conn, symbols, XK_Mode_switch);
|
||||||
|
numlockmask = get_mod_mask(conn, symbols, XK_Num_Lock);
|
||||||
|
|
||||||
|
xcb_flush(conn);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Callback function for PAM. We only react on password request callbacks.
|
* Callback function for PAM. We only react on password request callbacks.
|
||||||
*
|
*
|
||||||
|
@ -264,7 +286,6 @@ int main(int argc, char *argv[]) {
|
||||||
xcb_visualtype_t *vistype;
|
xcb_visualtype_t *vistype;
|
||||||
xcb_generic_event_t *event;
|
xcb_generic_event_t *event;
|
||||||
xcb_window_t win;
|
xcb_window_t win;
|
||||||
xcb_cursor_t cursor;
|
|
||||||
int curs_choice = CURS_NONE;
|
int curs_choice = CURS_NONE;
|
||||||
char o;
|
char o;
|
||||||
int optind = 0;
|
int optind = 0;
|
||||||
|
@ -436,6 +457,11 @@ int main(int argc, char *argv[]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type == XCB_MAPPING_NOTIFY) {
|
||||||
|
handle_mapping_notify((xcb_mapping_notify_event_t*)event);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
printf("WARNING: unhandled event of type %d\n", type);
|
printf("WARNING: unhandled event of type %d\n", type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
3
xcb.c
3
xcb.c
|
@ -191,9 +191,6 @@ void grab_pointer_and_keyboard(xcb_connection_t *conn, xcb_screen_t *screen, xcb
|
||||||
usleep(50);
|
usleep(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cursor != XCB_NONE)
|
|
||||||
xcb_free_cursor(conn, cursor);
|
|
||||||
|
|
||||||
while (tries-- > 0) {
|
while (tries-- > 0) {
|
||||||
kcookie = xcb_grab_keyboard(
|
kcookie = xcb_grab_keyboard(
|
||||||
conn,
|
conn,
|
||||||
|
|
Loading…
Reference in New Issue