opt: opt optimize idleinhibit check

This commit is contained in:
DreamMaoMao
2025-12-18 10:50:52 +08:00
parent ff35c7afe9
commit 5f884bdf51

View File

@@ -2000,16 +2000,24 @@ buttonpress(struct wl_listener *listener, void *data) {
} }
void checkidleinhibitor(struct wlr_surface *exclude) { void checkidleinhibitor(struct wlr_surface *exclude) {
int inhibited = 0, unused_lx, unused_ly; int inhibited = 0;
struct wlr_idle_inhibitor_v1 *inhibitor; struct wlr_idle_inhibitor_v1 *inhibitor;
wl_list_for_each(inhibitor, &idle_inhibit_mgr->inhibitors, link) { wl_list_for_each(inhibitor, &idle_inhibit_mgr->inhibitors, link) {
struct wlr_surface *surface = struct wlr_surface *surface =
wlr_surface_get_root_surface(inhibitor->surface); wlr_surface_get_root_surface(inhibitor->surface);
if (exclude == surface) {
continue;
}
if (inhibit_regardless_of_visibility) {
inhibited = 1;
break;
}
struct wlr_scene_tree *tree = surface->data; struct wlr_scene_tree *tree = surface->data;
if (exclude != surface && if (!tree || tree->node.enabled) {
(inhibit_regardless_of_visibility ||
(!tree ||
wlr_scene_node_coords(&tree->node, &unused_lx, &unused_ly)))) {
inhibited = 1; inhibited = 1;
break; break;
} }