xwayland: Use buffer_damage instead of surface damage if available
When a viewport is set, damage will only work properly when using wl_surface_damage_buffer instead of wl_surface_damage. When no viewport is set, there should be no difference between surface and buffer damage. This is a preparation patch for using viewport to add support for fake mode-changes through xrandr for apps which want to change the resolution when going fullscreen. Changes by Hans de Goede <hdegoede@redhat.com>: -Split the damage changes out into their own patch -Add xwl_surface_damage helper -Also use buffer_damage / the new helper for the present and cursor code Reviewed-by: Olivier Fourdan <ofourdan@redhat.com> Acked-by: Michel Dänzer <mdaenzer@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
47bba46253
commit
7c6f17790d
|
@ -166,9 +166,9 @@ xwl_seat_set_cursor(struct xwl_seat *xwl_seat)
|
||||||
xwl_seat->x_cursor->bits->yhot);
|
xwl_seat->x_cursor->bits->yhot);
|
||||||
wl_surface_attach(xwl_cursor->surface,
|
wl_surface_attach(xwl_cursor->surface,
|
||||||
xwl_shm_pixmap_get_wl_buffer(pixmap), 0, 0);
|
xwl_shm_pixmap_get_wl_buffer(pixmap), 0, 0);
|
||||||
wl_surface_damage(xwl_cursor->surface, 0, 0,
|
xwl_surface_damage(xwl_seat->xwl_screen, xwl_cursor->surface, 0, 0,
|
||||||
xwl_seat->x_cursor->bits->width,
|
xwl_seat->x_cursor->bits->width,
|
||||||
xwl_seat->x_cursor->bits->height);
|
xwl_seat->x_cursor->bits->height);
|
||||||
|
|
||||||
xwl_cursor->frame_cb = wl_surface_frame(xwl_cursor->surface);
|
xwl_cursor->frame_cb = wl_surface_frame(xwl_cursor->surface);
|
||||||
wl_callback_add_listener(xwl_cursor->frame_cb, &frame_listener, xwl_cursor);
|
wl_callback_add_listener(xwl_cursor->frame_cb, &frame_listener, xwl_cursor);
|
||||||
|
@ -218,9 +218,9 @@ xwl_tablet_tool_set_cursor(struct xwl_tablet_tool *xwl_tablet_tool)
|
||||||
xwl_seat->x_cursor->bits->yhot);
|
xwl_seat->x_cursor->bits->yhot);
|
||||||
wl_surface_attach(xwl_cursor->surface,
|
wl_surface_attach(xwl_cursor->surface,
|
||||||
xwl_shm_pixmap_get_wl_buffer(pixmap), 0, 0);
|
xwl_shm_pixmap_get_wl_buffer(pixmap), 0, 0);
|
||||||
wl_surface_damage(xwl_cursor->surface, 0, 0,
|
xwl_surface_damage(xwl_seat->xwl_screen, xwl_cursor->surface, 0, 0,
|
||||||
xwl_seat->x_cursor->bits->width,
|
xwl_seat->x_cursor->bits->width,
|
||||||
xwl_seat->x_cursor->bits->height);
|
xwl_seat->x_cursor->bits->height);
|
||||||
|
|
||||||
xwl_cursor->frame_cb = wl_surface_frame(xwl_cursor->surface);
|
xwl_cursor->frame_cb = wl_surface_frame(xwl_cursor->surface);
|
||||||
wl_callback_add_listener(xwl_cursor->frame_cb, &frame_listener, xwl_cursor);
|
wl_callback_add_listener(xwl_cursor->frame_cb, &frame_listener, xwl_cursor);
|
||||||
|
|
|
@ -500,9 +500,9 @@ xwl_present_flip(WindowPtr present_window,
|
||||||
xwl_present_window->frame_timer_firing = FALSE;
|
xwl_present_window->frame_timer_firing = FALSE;
|
||||||
xwl_present_reset_timer(xwl_present_window);
|
xwl_present_reset_timer(xwl_present_window);
|
||||||
|
|
||||||
wl_surface_damage(xwl_window->surface, 0, 0,
|
xwl_surface_damage(xwl_window->xwl_screen, xwl_window->surface, 0, 0,
|
||||||
damage_box->x2 - damage_box->x1,
|
damage_box->x2 - damage_box->x1,
|
||||||
damage_box->y2 - damage_box->y1);
|
damage_box->y2 - damage_box->y1);
|
||||||
|
|
||||||
wl_surface_commit(xwl_window->surface);
|
wl_surface_commit(xwl_window->surface);
|
||||||
|
|
||||||
|
|
|
@ -796,6 +796,16 @@ xwl_destroy_window(WindowPtr window)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void xwl_surface_damage(struct xwl_screen *xwl_screen,
|
||||||
|
struct wl_surface *surface,
|
||||||
|
int32_t x, int32_t y, int32_t width, int32_t height)
|
||||||
|
{
|
||||||
|
if (wl_surface_get_version(surface) >= WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION)
|
||||||
|
wl_surface_damage_buffer(surface, x, y, width, height);
|
||||||
|
else
|
||||||
|
wl_surface_damage(surface, x, y, width, height);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xwl_window_post_damage(struct xwl_window *xwl_window)
|
xwl_window_post_damage(struct xwl_window *xwl_window)
|
||||||
{
|
{
|
||||||
|
@ -832,13 +842,15 @@ xwl_window_post_damage(struct xwl_window *xwl_window)
|
||||||
*/
|
*/
|
||||||
if (RegionNumRects(region) > 256) {
|
if (RegionNumRects(region) > 256) {
|
||||||
box = RegionExtents(region);
|
box = RegionExtents(region);
|
||||||
wl_surface_damage(xwl_window->surface, box->x1, box->y1,
|
xwl_surface_damage(xwl_screen, xwl_window->surface, box->x1, box->y1,
|
||||||
box->x2 - box->x1, box->y2 - box->y1);
|
box->x2 - box->x1, box->y2 - box->y1);
|
||||||
} else {
|
} else {
|
||||||
box = RegionRects(region);
|
box = RegionRects(region);
|
||||||
for (i = 0; i < RegionNumRects(region); i++, box++)
|
for (i = 0; i < RegionNumRects(region); i++, box++) {
|
||||||
wl_surface_damage(xwl_window->surface, box->x1, box->y1,
|
xwl_surface_damage(xwl_screen, xwl_window->surface,
|
||||||
box->x2 - box->x1, box->y2 - box->y1);
|
box->x1, box->y1,
|
||||||
|
box->x2 - box->x1, box->y2 - box->y1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xwl_window->frame_callback = wl_surface_frame(xwl_window->surface);
|
xwl_window->frame_callback = wl_surface_frame(xwl_window->surface);
|
||||||
|
@ -881,8 +893,13 @@ registry_global(void *data, struct wl_registry *registry, uint32_t id,
|
||||||
struct xwl_screen *xwl_screen = data;
|
struct xwl_screen *xwl_screen = data;
|
||||||
|
|
||||||
if (strcmp(interface, "wl_compositor") == 0) {
|
if (strcmp(interface, "wl_compositor") == 0) {
|
||||||
|
uint32_t request_version = 1;
|
||||||
|
|
||||||
|
if (version >= WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION)
|
||||||
|
request_version = WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION;
|
||||||
|
|
||||||
xwl_screen->compositor =
|
xwl_screen->compositor =
|
||||||
wl_registry_bind(registry, id, &wl_compositor_interface, 1);
|
wl_registry_bind(registry, id, &wl_compositor_interface, request_version);
|
||||||
}
|
}
|
||||||
else if (strcmp(interface, "wl_shm") == 0) {
|
else if (strcmp(interface, "wl_shm") == 0) {
|
||||||
xwl_screen->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
|
xwl_screen->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1);
|
||||||
|
|
|
@ -378,6 +378,9 @@ struct xwl_output {
|
||||||
};
|
};
|
||||||
|
|
||||||
void xwl_sync_events (struct xwl_screen *xwl_screen);
|
void xwl_sync_events (struct xwl_screen *xwl_screen);
|
||||||
|
void xwl_surface_damage(struct xwl_screen *xwl_screen,
|
||||||
|
struct wl_surface *surface,
|
||||||
|
int32_t x, int32_t y, int32_t width, int32_t height);
|
||||||
|
|
||||||
Bool xwl_screen_init_cursor(struct xwl_screen *xwl_screen);
|
Bool xwl_screen_init_cursor(struct xwl_screen *xwl_screen);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user