mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-12 08:21:33 -04:00
compositor: add wlr_surface_queue_lazy_leave()
And also wlr_surface_process_lazy_leaves() This is motivated by fixing inconsistent enter/leave events sent by wlr_scene when there are multiple scenes active with distinct outputs.
This commit is contained in:
parent
f295d0322a
commit
8e44489bf7
2 changed files with 69 additions and 0 deletions
|
|
@ -127,6 +127,8 @@ struct wlr_surface_output {
|
||||||
struct {
|
struct {
|
||||||
struct wl_listener bind;
|
struct wl_listener bind;
|
||||||
struct wl_listener destroy;
|
struct wl_listener destroy;
|
||||||
|
|
||||||
|
bool lazy_leave;
|
||||||
} WLR_PRIVATE;
|
} WLR_PRIVATE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -399,6 +401,33 @@ void wlr_surface_send_enter(struct wlr_surface *surface,
|
||||||
void wlr_surface_send_leave(struct wlr_surface *surface,
|
void wlr_surface_send_leave(struct wlr_surface *surface,
|
||||||
struct wlr_output *output);
|
struct wlr_output *output);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Queue a lazy wl_surface.leave event to be sent in a future call to
|
||||||
|
* wlr_surface_process_lazy_leaves().
|
||||||
|
*
|
||||||
|
* If wlr_surface_send_enter() is called before wlr_surface_process_lazy_leaves()
|
||||||
|
* actually sends a leave event, the lazy leave mark is cleared.
|
||||||
|
*/
|
||||||
|
void wlr_surface_queue_lazy_leave(struct wlr_surface *surface, struct wlr_output *output);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If at least one output would remain entered after all lazy leave events
|
||||||
|
* are sent, send all lazy leave events. Otherwise do nothing.
|
||||||
|
*
|
||||||
|
* This behavior helps the compositor implement the following recommended policy:
|
||||||
|
*
|
||||||
|
* 1. When a surface transitions from being visible on >0 outputs to being visible on 0 outputs
|
||||||
|
* don't send any leave events.
|
||||||
|
*
|
||||||
|
* 2. When a surface transitions from being visible on 0 outputs to being visible on >0 outputs
|
||||||
|
* send leave events for all entered outputs on which the surface is no longer visible as
|
||||||
|
* well as enter events for any outputs not already entered.
|
||||||
|
*
|
||||||
|
* This policy avoids sending redundant enter/leave events when a surface is hidden and then shown
|
||||||
|
* again without any change to the set of intersected outputs.
|
||||||
|
*/
|
||||||
|
void wlr_surface_process_lazy_leaves(struct wlr_surface *surface);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Complete the queued frame callbacks for this surface.
|
* Complete the queued frame callbacks for this surface.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -1084,6 +1084,7 @@ void wlr_surface_send_enter(struct wlr_surface *surface,
|
||||||
|
|
||||||
wl_list_for_each(surface_output, &surface->current_outputs, link) {
|
wl_list_for_each(surface_output, &surface->current_outputs, link) {
|
||||||
if (surface_output->output == output) {
|
if (surface_output->output == output) {
|
||||||
|
surface_output->lazy_leave = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1129,6 +1130,45 @@ void wlr_surface_send_leave(struct wlr_surface *surface,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wlr_surface_queue_lazy_leave(struct wlr_surface *surface, struct wlr_output *output) {
|
||||||
|
struct wlr_surface_output *surface_output;
|
||||||
|
wl_list_for_each(surface_output, &surface->current_outputs, link) {
|
||||||
|
if (surface_output->output == output) {
|
||||||
|
surface_output->lazy_leave = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wlr_surface_process_lazy_leaves(struct wlr_surface *surface) {
|
||||||
|
// Only send leave events if at least one output would remain entered.
|
||||||
|
bool send_leave_events = false;
|
||||||
|
struct wlr_surface_output *surface_output;
|
||||||
|
wl_list_for_each(surface_output, &surface->current_outputs, link) {
|
||||||
|
if (!surface_output->lazy_leave) {
|
||||||
|
send_leave_events = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!send_leave_events) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct wl_client *client = wl_resource_get_client(surface->resource);
|
||||||
|
struct wlr_surface_output *tmp;
|
||||||
|
wl_list_for_each_safe(surface_output, tmp, &surface->current_outputs, link) {
|
||||||
|
if (surface_output->lazy_leave) {
|
||||||
|
struct wl_resource *resource;
|
||||||
|
wl_resource_for_each(resource, &surface_output->output->resources) {
|
||||||
|
if (client == wl_resource_get_client(resource)) {
|
||||||
|
wl_surface_send_leave(surface->resource, resource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
surface_output_destroy(surface_output);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wlr_surface_send_frame_done(struct wlr_surface *surface,
|
void wlr_surface_send_frame_done(struct wlr_surface *surface,
|
||||||
const struct timespec *when) {
|
const struct timespec *when) {
|
||||||
struct wl_resource *resource, *tmp;
|
struct wl_resource *resource, *tmp;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue