xwayland: Allow shells to make xwayland surfaces fullscreen

The fullscreen state for xwayland surfaces can currently only be
effectively set from the client side. This commit enables
libweston-desktop based shells to properly set the fullscreen state
for xwayland surfaces.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
This commit is contained in:
Alexandros Frantzis 2020-05-14 15:44:20 +03:00 committed by Sergio Gómez
parent eefd8ae2e0
commit ca7b631310
3 changed files with 48 additions and 1 deletions

View File

@ -65,6 +65,7 @@ struct weston_desktop_xwayland_surface {
bool added;
enum weston_desktop_xwayland_surface_state state;
enum weston_desktop_xwayland_surface_state prev_state;
bool state_updated;
};
static void
@ -85,6 +86,10 @@ weston_desktop_xwayland_surface_change_state(struct weston_desktop_xwayland_surf
}
wsurface = weston_desktop_surface_get_surface(surface->surface);
/* In some cases when adding a surface, the state may be updated by the
* shell (e.g., to fullscreen). Track if this has happened and respect
* the updated value. */
surface->state_updated = false;
if (surface->state != state) {
if (surface->state == XWAYLAND) {
@ -126,7 +131,13 @@ weston_desktop_xwayland_surface_change_state(struct weston_desktop_xwayland_surf
weston_surface_map(wsurface);
}
surface->state = state;
/* If the surface state was updated by the shell during this
* call, respect the updated value, otherwise assign the new
* value. */
if (!surface->state_updated) {
surface->state = state;
surface->state_updated = true;
}
}
if (parent != NULL)
@ -194,6 +205,19 @@ weston_desktop_xwayland_surface_set_size(struct weston_desktop_surface *dsurface
surface->client_interface->send_configure(wsurface, width, height);
}
static void
weston_desktop_xwayland_surface_set_fullscreen(struct weston_desktop_surface *dsurface,
void *user_data, bool fullscreen)
{
struct weston_desktop_xwayland_surface *surface = user_data;
struct weston_surface *wsurface =
weston_desktop_surface_get_surface(surface->surface);
surface->state = fullscreen ? FULLSCREEN : TOPLEVEL;
surface->state_updated = true;
surface->client_interface->send_fullscreen(wsurface, fullscreen);
}
static void
weston_desktop_xwayland_surface_destroy(struct weston_desktop_surface *dsurface,
void *user_data)
@ -244,6 +268,7 @@ weston_desktop_xwayland_surface_get_fullscreen(struct weston_desktop_surface *ds
static const struct weston_desktop_surface_implementation weston_desktop_xwayland_surface_internal_implementation = {
.committed = weston_desktop_xwayland_surface_committed,
.set_size = weston_desktop_xwayland_surface_set_size,
.set_fullscreen = weston_desktop_xwayland_surface_set_fullscreen,
.get_maximized = weston_desktop_xwayland_surface_get_maximized,
.get_fullscreen = weston_desktop_xwayland_surface_get_fullscreen,

View File

@ -3130,9 +3130,30 @@ send_position(struct weston_surface *surface, int32_t x, int32_t y)
}
}
static void
send_fullscreen(struct weston_surface *surface, bool fullscreen)
{
struct weston_wm_window *window = get_wm_window(surface);
if (!window || !window->wm)
return;
if (window->fullscreen == fullscreen)
return;
window->fullscreen = fullscreen;
weston_wm_window_set_net_wm_state(window);
if (window->fullscreen) {
window->saved_width = window->width;
window->saved_height = window->height;
}
}
static const struct weston_xwayland_client_interface shell_client = {
send_configure,
send_close,
send_fullscreen,
};
static int

View File

@ -32,6 +32,7 @@ struct weston_desktop_xwayland_surface;
struct weston_xwayland_client_interface {
void (*send_configure)(struct weston_surface *surface, int32_t width, int32_t height);
void (*send_close)(struct weston_surface *surface);
void (*send_fullscreen)(struct weston_surface *surface, bool fullscreen);
};
struct weston_desktop_xwayland_interface {