mirror of
https://github.com/swaywm/sway.git
synced 2024-11-13 05:54:11 +01:00
Merge pull request #572 from fluxchief/swaylock-flush
Improve swaylock event flushing
This commit is contained in:
commit
9f4df8b758
@ -21,6 +21,14 @@
|
|||||||
struct registry *registry;
|
struct registry *registry;
|
||||||
struct render_data render_data;
|
struct render_data render_data;
|
||||||
|
|
||||||
|
void wl_dispatch_events() {
|
||||||
|
wl_display_flush(registry->display);
|
||||||
|
if (wl_display_dispatch(registry->display) == -1) {
|
||||||
|
sway_log(L_ERROR, "failed to run wl_display_dispatch");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void sigalarm_handler(int sig) {
|
void sigalarm_handler(int sig) {
|
||||||
signal(SIGALRM, SIG_IGN);
|
signal(SIGALRM, SIG_IGN);
|
||||||
// Hide typing indicator
|
// Hide typing indicator
|
||||||
@ -104,7 +112,6 @@ bool verify_password() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void notify_key(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t code, uint32_t codepoint) {
|
void notify_key(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t code, uint32_t codepoint) {
|
||||||
int i;
|
|
||||||
int redraw_screen = 0;
|
int redraw_screen = 0;
|
||||||
if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
||||||
switch (sym) {
|
switch (sym) {
|
||||||
@ -113,14 +120,8 @@ void notify_key(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t cod
|
|||||||
|
|
||||||
render(&render_data);
|
render(&render_data);
|
||||||
// Make sure our render call will actually be displayed on the screen
|
// Make sure our render call will actually be displayed on the screen
|
||||||
wl_display_flush(registry->display);
|
wl_dispatch_events();
|
||||||
|
|
||||||
// However, this is not how it should be done.
|
|
||||||
for (i = 0; i < registry->outputs->length; ++i) {
|
|
||||||
if (wl_display_dispatch(registry->display) == -1) {
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (verify_password()) {
|
if (verify_password()) {
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@ -157,6 +158,7 @@ void notify_key(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t cod
|
|||||||
}
|
}
|
||||||
if (redraw_screen) {
|
if (redraw_screen) {
|
||||||
render(&render_data);
|
render(&render_data);
|
||||||
|
wl_dispatch_events();
|
||||||
// Hide the indicator after a couple of seconds
|
// Hide the indicator after a couple of seconds
|
||||||
alarm(5);
|
alarm(5);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user