Skip to content

Commit

Permalink
hwcomposer: Simulate a key press on window close
Browse files Browse the repository at this point in the history
This is meant to restart the idle timer, so suspending can work
even after closing the window with idle timeout already passed.
See waydroid/waydroid#500
  • Loading branch information
dos1 authored and aleasto committed Sep 19, 2022
1 parent 7fdaf9d commit 5b8b88e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions hwcomposer/wayland-hwc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,18 @@ xdg_toplevel_handle_configure(void *data, struct xdg_toplevel *,
}
}

static void
send_key_event(display *data, uint32_t key, wl_keyboard_key_state state);

static void
xdg_toplevel_handle_close(void *data, struct xdg_toplevel *)
{
struct window *window = (struct window *)data;

// simulate user input to restart idle timeout (TODO: find a better way)
send_key_event(window->display, 0, WL_KEYBOARD_KEY_STATE_PRESSED);
send_key_event(window->display, 0, WL_KEYBOARD_KEY_STATE_RELEASED);

if (window->display->task != nullptr) {
if (window->taskID != "none") {
if (window->taskID == "0") {
Expand Down

0 comments on commit 5b8b88e

Please sign in to comment.