Fix fullscreen in xdg-shell

This commit is contained in:
emersion 2017-11-20 20:53:13 +01:00
parent bc68f26960
commit 54f1135c05
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
4 changed files with 40 additions and 33 deletions

View file

@ -1,9 +1,10 @@
#ifndef WLR_TYPES_WLR_SURFACE_H #ifndef WLR_TYPES_WLR_SURFACE_H
#define WLR_TYPES_WLR_SURFACE_H #define WLR_TYPES_WLR_SURFACE_H
#include <wayland-server.h>
#include <pixman.h>
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <time.h>
#include <pixman.h>
#include <wayland-server.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
struct wlr_frame_callback { 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, void wlr_surface_send_leave(struct wlr_surface *surface,
struct wlr_output *output); struct wlr_output *output);
void wlr_surface_send_frame_done(struct wlr_surface *surface,
const struct timespec *when);
#endif #endif

View file

@ -13,10 +13,6 @@
#include "rootston/desktop.h" #include "rootston/desktop.h"
#include "rootston/config.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), * 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). * 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, wlr_render_with_matrix(desktop->server->renderer, surface->texture,
&matrix); &matrix);
struct wlr_frame_callback *cb, *cnext; wlr_surface_send_frame_done(surface, when);
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 wlr_subsurface *subsurface; 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) { static bool has_standalone_surface(struct roots_view *view) {
if (!wl_list_empty(&view->wlr_surface->subsurface_list)) { if (!wl_list_empty(&view->wlr_surface->subsurface_list)) {
wlr_log(L_DEBUG, "has subsurfaces");
return false; return false;
} }

View file

@ -253,7 +253,7 @@ void wlr_output_make_current(struct wlr_output *output) {
} }
static void output_fullscreen_surface_render(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 x = (output->width - surface->current->width) / 2;
int y = (output->height - surface->current->height) / 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, wlr_texture_get_matrix(surface->texture, &matrix, &output->transform_matrix,
x, y); x, y);
wlr_render_with_matrix(surface->renderer, surface->texture, &matrix); 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, 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; 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_texture *texture = cursor->texture;
struct wlr_renderer *renderer = cursor->renderer; struct wlr_renderer *renderer = cursor->renderer;
if (cursor->surface != NULL) { 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, wlr_texture_get_matrix(texture, &matrix, &cursor->output->transform_matrix,
x, y); x, y);
wlr_render_with_matrix(renderer, texture, &matrix); 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) { void wlr_output_swap_buffers(struct wlr_output *output) {
wl_signal_emit(&output->events.swap_buffers, &output); wl_signal_emit(&output->events.swap_buffers, &output);
struct timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
if (output->fullscreen_surface != NULL) { 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; 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) { if (!cursor->enabled || output->hardware_cursor == cursor) {
continue; continue;
} }
output_cursor_render(cursor); output_cursor_render(cursor, &now);
} }
output->impl->swap_buffers(output); output->impl->swap_buffers(output);
@ -472,30 +483,18 @@ static void output_cursor_commit(struct wlr_output_cursor *cursor) {
cursor->output->needs_swap = true; cursor->output->needs_swap = true;
} else { } else {
// TODO: upload pixels // TODO: upload pixels
}
}
static inline int64_t timespec_to_msec(const struct timespec *a) { struct timespec now;
return (int64_t)a->tv_sec * 1000 + a->tv_nsec / 1000000; clock_gettime(CLOCK_MONOTONIC, &now);
wlr_surface_send_frame_done(cursor->surface, &now);
}
} }
static void output_cursor_handle_commit(struct wl_listener *listener, static void output_cursor_handle_commit(struct wl_listener *listener,
void *data) { void *data) {
struct wlr_output_cursor *cursor = wl_container_of(listener, cursor, struct wlr_output_cursor *cursor = wl_container_of(listener, cursor,
surface_commit); surface_commit);
struct wlr_surface *surface = data;
output_cursor_commit(cursor); 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, static void output_cursor_handle_destroy(struct wl_listener *listener,

View file

@ -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);
}
}