diff options
author | emersion <contact@emersion.fr> | 2017-11-20 20:53:13 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2017-11-20 20:53:13 +0100 |
commit | 54f1135c057e76b1c05058592a6878a07a524b99 (patch) | |
tree | 2afd63b18c2e7cdf073dfcece8e1f2812c3bff90 | |
parent | bc68f269605ddd681b3ab968bdf80a72f3618982 (diff) |
Fix fullscreen in xdg-shell
-rw-r--r-- | include/wlr/types/wlr_surface.h | 8 | ||||
-rw-r--r-- | rootston/output.c | 12 | ||||
-rw-r--r-- | types/wlr_output.c | 39 | ||||
-rw-r--r-- | types/wlr_surface.c | 14 |
4 files changed, 40 insertions, 33 deletions
diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h index cea53109..c8e3761a 100644 --- a/include/wlr/types/wlr_surface.h +++ b/include/wlr/types/wlr_surface.h @@ -1,9 +1,10 @@ #ifndef WLR_TYPES_WLR_SURFACE_H #define WLR_TYPES_WLR_SURFACE_H -#include <wayland-server.h> -#include <pixman.h> #include <stdint.h> #include <stdbool.h> +#include <time.h> +#include <pixman.h> +#include <wayland-server.h> #include <wlr/types/wlr_output.h> struct wlr_frame_callback { @@ -142,4 +143,7 @@ void wlr_surface_send_enter(struct wlr_surface *surface, void wlr_surface_send_leave(struct wlr_surface *surface, struct wlr_output *output); +void wlr_surface_send_frame_done(struct wlr_surface *surface, + const struct timespec *when); + #endif diff --git a/rootston/output.c b/rootston/output.c index 82618b06..52db62f1 100644 --- a/rootston/output.c +++ b/rootston/output.c @@ -13,10 +13,6 @@ #include "rootston/desktop.h" #include "rootston/config.h" -static inline int64_t timespec_to_msec(const struct timespec *a) { - return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000; -} - /** * Rotate a child's position relative to a parent. The parent size is (pw, ph), * the child position is (*sx, *sy) and its size is (sw, sh). @@ -75,12 +71,7 @@ static void render_surface(struct wlr_surface *surface, wlr_render_with_matrix(desktop->server->renderer, surface->texture, &matrix); - 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); - } + wlr_surface_send_frame_done(surface, when); } struct wlr_subsurface *subsurface; @@ -176,7 +167,6 @@ static void render_view(struct roots_view *view, struct roots_desktop *desktop, static bool has_standalone_surface(struct roots_view *view) { if (!wl_list_empty(&view->wlr_surface->subsurface_list)) { - wlr_log(L_DEBUG, "has subsurfaces"); return false; } diff --git a/types/wlr_output.c b/types/wlr_output.c index 3ef91179..8accf7a5 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -253,7 +253,7 @@ void wlr_output_make_current(struct wlr_output *output) { } static void output_fullscreen_surface_render(struct wlr_output *output, - struct wlr_surface *surface) { + struct wlr_surface *surface, const struct timespec *when) { int x = (output->width - surface->current->width) / 2; int y = (output->height - surface->current->height) / 2; @@ -268,6 +268,8 @@ static void output_fullscreen_surface_render(struct wlr_output *output, wlr_texture_get_matrix(surface->texture, &matrix, &output->transform_matrix, x, y); wlr_render_with_matrix(surface->renderer, surface->texture, &matrix); + + wlr_surface_send_frame_done(surface, when); } static void output_cursor_get_box(struct wlr_output_cursor *cursor, @@ -278,7 +280,8 @@ static void output_cursor_get_box(struct wlr_output_cursor *cursor, box->height = cursor->height; } -static void output_cursor_render(struct wlr_output_cursor *cursor) { +static void output_cursor_render(struct wlr_output_cursor *cursor, + const struct timespec *when) { struct wlr_texture *texture = cursor->texture; struct wlr_renderer *renderer = cursor->renderer; if (cursor->surface != NULL) { @@ -321,13 +324,21 @@ static void output_cursor_render(struct wlr_output_cursor *cursor) { wlr_texture_get_matrix(texture, &matrix, &cursor->output->transform_matrix, x, y); wlr_render_with_matrix(renderer, texture, &matrix); + + if (cursor->surface != NULL) { + wlr_surface_send_frame_done(cursor->surface, when); + } } void wlr_output_swap_buffers(struct wlr_output *output) { wl_signal_emit(&output->events.swap_buffers, &output); + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + if (output->fullscreen_surface != NULL) { - output_fullscreen_surface_render(output, output->fullscreen_surface); + output_fullscreen_surface_render(output, output->fullscreen_surface, + &now); } struct wlr_output_cursor *cursor; @@ -335,7 +346,7 @@ void wlr_output_swap_buffers(struct wlr_output *output) { if (!cursor->enabled || output->hardware_cursor == cursor) { continue; } - output_cursor_render(cursor); + output_cursor_render(cursor, &now); } output->impl->swap_buffers(output); @@ -472,30 +483,18 @@ static void output_cursor_commit(struct wlr_output_cursor *cursor) { cursor->output->needs_swap = true; } else { // TODO: upload pixels - } -} -static inline int64_t timespec_to_msec(const struct timespec *a) { - return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000; + struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); + wlr_surface_send_frame_done(cursor->surface, &now); + } } static void output_cursor_handle_commit(struct wl_listener *listener, void *data) { struct wlr_output_cursor *cursor = wl_container_of(listener, cursor, surface_commit); - struct wlr_surface *surface = data; - output_cursor_commit(cursor); - - struct timespec now; - clock_gettime(CLOCK_MONOTONIC, &now); - - 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(&now)); - wl_resource_destroy(cb->resource); - } } static void output_cursor_handle_destroy(struct wl_listener *listener, diff --git a/types/wlr_surface.c b/types/wlr_surface.c index 8cc2aa33..ad0c6f68 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -929,3 +929,17 @@ void wlr_surface_send_leave(struct wlr_surface *surface, } } } + +static inline int64_t timespec_to_msec(const struct timespec *a) { + return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000; +} + +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); + } +} |