Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wayland: Use suspended event only if supported #97480

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions platform/linuxbsd/wayland/display_server_wayland.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1219,9 +1219,31 @@ void DisplayServerWayland::process_events() {
} else {
try_suspend();
}
} else if (!wayland_thread.is_suspended() || wayland_thread.get_reset_frame()) {
// At last, a sign of life! We're no longer suspended.
suspended = false;
} else {
// We have to pick into the Wayland thread to figure out if suspension events
// are supported or if we have to use an heuristic as a fallback.
WaylandThread::WindowState *ws = wayland_thread.wl_surface_get_window_state(wayland_thread.window_get_wl_surface(MAIN_WINDOW_ID));
ERR_FAIL_NULL(ws);

struct xdg_toplevel *xdg_toplevel = ws->xdg_toplevel;

#ifdef LIBDECOR_ENABLED
if (!xdg_toplevel) {
xdg_toplevel = libdecor_frame_get_xdg_toplevel(ws->libdecor_frame);
}
#endif

ERR_FAIL_NULL(xdg_toplevel);

bool suspend_supported = xdg_toplevel_get_version(xdg_toplevel) >= 6;

if (suspend_supported) {
suspended = wayland_thread.is_suspended();
} else {
// Older compositors don't have any way of telling us that a window is
// suspended so we'll kick us out of the suspended state with a frame event.
suspended = !wayland_thread.get_reset_frame();
}
}

#ifdef DBUS_ENABLED
Expand Down
Loading