diff options
-rw-r--r-- | backend/session/direct-ipc.c | 2 | ||||
-rw-r--r-- | include/wlr/types/wlr_surface.h | 8 | ||||
-rw-r--r-- | types/wlr_surface.c | 58 | ||||
-rw-r--r-- | types/xdg_shell/wlr_xdg_toplevel.c | 2 | ||||
-rw-r--r-- | types/xdg_shell_v6/wlr_xdg_toplevel_v6.c | 2 |
5 files changed, 22 insertions, 50 deletions
diff --git a/backend/session/direct-ipc.c b/backend/session/direct-ipc.c index 6c69b70a..f8ba07f7 100644 --- a/backend/session/direct-ipc.c +++ b/backend/session/direct-ipc.c @@ -130,7 +130,7 @@ static void communicate(int sock) { int drm_fd = -1; bool running = true; - while (running && recv_msg(sock, &drm_fd, &msg, sizeof(msg)) >= 0) { + while (running && recv_msg(sock, &drm_fd, &msg, sizeof(msg)) > 0) { switch (msg.type) { case MSG_OPEN: errno = 0; diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h index 8517934a..46588f0a 100644 --- a/include/wlr/types/wlr_surface.h +++ b/include/wlr/types/wlr_surface.h @@ -8,11 +8,6 @@ #include <wayland-server.h> #include <wlr/types/wlr_output.h> -struct wlr_frame_callback { - struct wl_resource *resource; - struct wl_list link; -}; - #define WLR_SURFACE_INVALID_BUFFER 1 #define WLR_SURFACE_INVALID_SURFACE_DAMAGE 2 #define WLR_SURFACE_INVALID_BUFFER_DAMAGE 4 @@ -79,9 +74,6 @@ struct wlr_surface { struct wlr_surface_state *current, *pending; const char *role; // the lifetime-bound role or null - float buffer_to_surface_matrix[9]; - float surface_to_buffer_matrix[9]; - struct { struct wl_signal commit; struct wl_signal new_subsurface; diff --git a/types/wlr_surface.c b/types/wlr_surface.c index af1e9446..59a6fc2c 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -86,40 +86,25 @@ static void surface_damage(struct wl_client *client, x, y, width, height); } -static struct wlr_frame_callback *frame_callback_from_resource( - struct wl_resource *resource) { - assert(wl_resource_instance_of(resource, &wl_callback_interface, NULL)); - return wl_resource_get_user_data(resource); -} - static void callback_handle_resource_destroy(struct wl_resource *resource) { - struct wlr_frame_callback *cb = frame_callback_from_resource(resource); - wl_list_remove(&cb->link); - free(cb); + wl_list_remove(wl_resource_get_link(resource)); } static void surface_frame(struct wl_client *client, struct wl_resource *resource, uint32_t callback) { struct wlr_surface *surface = wlr_surface_from_resource(resource); - struct wlr_frame_callback *cb = - calloc(1, sizeof(struct wlr_frame_callback)); - if (cb == NULL) { + struct wl_resource *callback_resource = wl_resource_create(client, + &wl_callback_interface, CALLBACK_VERSION, callback); + if (callback_resource == NULL) { wl_resource_post_no_memory(resource); return; } - - cb->resource = wl_resource_create(client, &wl_callback_interface, - CALLBACK_VERSION, callback); - if (cb->resource == NULL) { - free(cb); - wl_resource_post_no_memory(resource); - return; - } - wl_resource_set_implementation(cb->resource, NULL, cb, + wl_resource_set_implementation(callback_resource, NULL, NULL, callback_handle_resource_destroy); - wl_list_insert(surface->pending->frame_callback_list.prev, &cb->link); + wl_list_insert(surface->pending->frame_callback_list.prev, + wl_resource_get_link(callback_resource)); surface->pending->invalid |= WLR_SURFACE_INVALID_FRAME_CALLBACK_LIST; } @@ -325,8 +310,7 @@ static void surface_damage_subsurfaces(struct wlr_subsurface *subsurface) { } } -static void surface_apply_damage(struct wlr_surface *surface, - bool invalid_buffer) { +static void surface_apply_damage(struct wlr_surface *surface) { struct wl_resource *resource = surface->current->buffer; if (resource == NULL) { // NULL commit @@ -335,12 +319,6 @@ static void surface_apply_damage(struct wlr_surface *surface, return; } - if (surface->buffer != NULL && !surface->buffer->released && - !invalid_buffer) { - // The buffer is still the same, no need to re-upload - return; - } - if (surface->buffer != NULL && surface->buffer->released) { pixman_region32_t damage; pixman_region32_init(&damage); @@ -376,7 +354,9 @@ static void surface_commit_pending(struct wlr_surface *surface) { surface_move_state(surface, surface->pending, surface->current); - surface_apply_damage(surface, invalid_buffer); + if (invalid_buffer) { + surface_apply_damage(surface); + } // commit subsurface order struct wlr_subsurface *subsurface; @@ -554,9 +534,9 @@ static struct wlr_surface_state *surface_state_create(void) { static void surface_state_destroy(struct wlr_surface_state *state) { surface_state_reset_buffer(state); - struct wlr_frame_callback *cb, *tmp; - wl_list_for_each_safe(cb, tmp, &state->frame_callback_list, link) { - wl_resource_destroy(cb->resource); + struct wl_resource *resource, *tmp; + wl_resource_for_each_safe(resource, tmp, &state->frame_callback_list) { + wl_resource_destroy(resource); } pixman_region32_fini(&state->surface_damage); @@ -970,11 +950,11 @@ static inline int64_t timespec_to_msec(const struct timespec *a) { void wlr_surface_send_frame_done(struct wlr_surface *surface, const struct timespec *when) { - struct wlr_frame_callback *cb, *cnext; - wl_list_for_each_safe(cb, cnext, &surface->current->frame_callback_list, - link) { - wl_callback_send_done(cb->resource, timespec_to_msec(when)); - wl_resource_destroy(cb->resource); + struct wl_resource *resource, *tmp; + wl_resource_for_each_safe(resource, tmp, + &surface->current->frame_callback_list) { + wl_callback_send_done(resource, timespec_to_msec(when)); + wl_resource_destroy(resource); } } diff --git a/types/xdg_shell/wlr_xdg_toplevel.c b/types/xdg_shell/wlr_xdg_toplevel.c index fa0ec929..c1350931 100644 --- a/types/xdg_shell/wlr_xdg_toplevel.c +++ b/types/xdg_shell/wlr_xdg_toplevel.c @@ -40,7 +40,7 @@ bool compare_xdg_surface_toplevel_state(struct wlr_xdg_toplevel *state) { // last configure is actually the current state, just use it configured.state = state->current; configured.width = state->base->surface->current->width; - configured.height = state->base->surface->current->width; + configured.height = state->base->surface->current->height; } else { struct wlr_xdg_surface_configure *configure = wl_container_of(state->base->configure_list.prev, configure, link); diff --git a/types/xdg_shell_v6/wlr_xdg_toplevel_v6.c b/types/xdg_shell_v6/wlr_xdg_toplevel_v6.c index 0f9a26d3..e2e1e480 100644 --- a/types/xdg_shell_v6/wlr_xdg_toplevel_v6.c +++ b/types/xdg_shell_v6/wlr_xdg_toplevel_v6.c @@ -288,7 +288,7 @@ bool compare_xdg_surface_v6_toplevel_state(struct wlr_xdg_toplevel_v6 *state) { // last configure is actually the current state, just use it configured.state = state->current; configured.width = state->base->surface->current->width; - configured.height = state->base->surface->current->width; + configured.height = state->base->surface->current->height; } else { struct wlr_xdg_surface_v6_configure *configure = wl_container_of(state->base->configure_list.prev, configure, link); |