Updated fullscreen shell to current protocol level.

This commit is contained in:
Armin Novak 2019-01-22 13:09:59 +01:00
parent 7f158b97be
commit 0ef64f8a84
5 changed files with 84 additions and 54 deletions

View File

@ -38,7 +38,7 @@ endmacro()
generate_protocol_file(xdg-shell)
generate_protocol_file(ivi-application)
generate_protocol_file(fullscreen-shell)
generate_protocol_file(fullscreen-shell-unstable-v1)
if(FREEBSD)
include_directories(${EPOLLSHIM_INCLUDE_DIR})

View File

@ -103,23 +103,26 @@ struct wl_shm_listener shm_listener =
cb_shm_format
};
static void xdg_shell_ping(void* data, struct xdg_shell* shell, uint32_t serial)
static void xdg_shell_ping(void *data,
struct xdg_wm_base *xdg_wm_base,
uint32_t serial)
{
xdg_shell_pong(shell, serial);
xdg_wm_base_pong(xdg_wm_base, serial);
}
static const struct xdg_shell_listener xdg_shell_listener =
static const struct xdg_wm_base_listener xdg_wm_base_listener =
{
xdg_shell_ping,
};
#ifdef BUILD_FULLSCREEN_SHELL
static void fullscreen_capability(void* data, struct _wl_fullscreen_shell* _wl_fullscreen_shell,
uint32_t capabilty)
static void fullscreen_capability(void *data,
struct zwp_fullscreen_shell_v1 *zwp_fullscreen_shell_v1,
uint32_t capability)
{
}
static const struct _wl_fullscreen_shell_listener fullscreen_shell_listener =
static const struct zwp_fullscreen_shell_v1_listener fullscreen_shell_listener =
{
fullscreen_capability,
};
@ -208,11 +211,10 @@ static void registry_handle_global(void* data, struct wl_registry* registry, uin
d->shell = wl_registry_bind(registry, id, &wl_shell_interface, min(TARGET_SHELL_INTERFACE,
version));
}
else if (strcmp(interface, "xdg_shell") == 0)
else if (strcmp(interface, "xdg_wm_base") == 0)
{
d->xdg_shell = wl_registry_bind(registry, id, &xdg_shell_interface, 1);
xdg_shell_use_unstable_version(d->xdg_shell, TARGET_XDG_VERSION);
xdg_shell_add_listener(d->xdg_shell, &xdg_shell_listener, d);
d->xdg_base = wl_registry_bind(registry, id, &xdg_wm_base_interface, 1);
xdg_wm_base_add_listener(d->xdg_base, &xdg_wm_base_listener, d);
#if BUILD_IVI
}
else if (strcmp(interface, "ivi_application") == 0)
@ -221,10 +223,10 @@ static void registry_handle_global(void* data, struct wl_registry* registry, uin
#endif
#if BUILD_FULLSCREEN_SHELL
}
else if (strcmp(interface, "_wl_fullscreen_shell") == 0)
else if (strcmp(interface, "zwp_fullscreen_shell_v1") == 0)
{
d->fullscreen_shell = wl_registry_bind(registry, id, &_wl_fullscreen_shell_interface, 1);
_wl_fullscreen_shell_add_listener(d->fullscreen_shell, &fullscreen_shell_listener, d);
d->fullscreen_shell = wl_registry_bind(registry, id, &zwp_fullscreen_shell_v1_interface, 1);
zwp_fullscreen_shell_v1_add_listener(d->fullscreen_shell, &fullscreen_shell_listener, d);
#endif
#if 0
}
@ -513,7 +515,7 @@ UwacReturnCode UwacCloseDisplay(UwacDisplay** pdisplay)
#ifdef BUILD_FULLSCREEN_SHELL
if (display->fullscreen_shell)
_wl_fullscreen_shell_destroy(display->fullscreen_shell);
zwp_fullscreen_shell_v1_destroy(display->fullscreen_shell);
#endif
#ifdef BUILD_IVI
@ -523,8 +525,11 @@ UwacReturnCode UwacCloseDisplay(UwacDisplay** pdisplay)
#endif
if (display->xdg_shell)
xdg_shell_destroy(display->xdg_shell);
if (display->xdg_toplevel)
xdg_toplevel_destroy(display->xdg_toplevel);
if (display->xdg_base)
xdg_wm_base_destroy(display->xdg_base);
if (display->shell)
wl_shell_destroy(display->shell);

View File

@ -32,7 +32,7 @@
#include "ivi-application-client-protocol.h"
#endif
#ifdef BUILD_FULLSCREEN_SHELL
#include "fullscreen-shell-client-protocol.h"
#include "fullscreen-shell-unstable-v1-client-protocol.h"
#endif
#ifdef HAVE_PIXMAN_REGION
@ -84,12 +84,13 @@ struct uwac_display {
struct wl_compositor *compositor;
struct wl_subcompositor *subcompositor;
struct wl_shell *shell;
struct xdg_shell *xdg_shell;
struct xdg_toplevel *xdg_toplevel;
struct xdg_wm_base *xdg_base;
#ifdef BUILD_IVI
struct ivi_application *ivi_application;
#endif
#ifdef BUILD_FULLSCREEN_SHELL
struct _wl_fullscreen_shell *fullscreen_shell;
struct zwp_fullscreen_shell_v1 *fullscreen_shell;
#endif
struct wl_shm *shm;
@ -210,6 +211,7 @@ struct uwac_window {
struct wl_surface *surface;
struct wl_shell_surface *shell_surface;
struct xdg_surface *xdg_surface;
struct xdg_toplevel *xdg_toplevel;
#ifdef BUILD_IVI
struct ivi_surface *ivi_surface;
#endif

View File

@ -82,32 +82,34 @@ void UwacWindowDestroyBuffers(UwacWindow* w)
int UwacWindowShmAllocBuffers(UwacWindow* w, int nbuffers, int allocSize, uint32_t width,
uint32_t height, enum wl_shm_format format);
static void xdg_handle_configure(void* data, struct xdg_surface* surface,
int32_t width, int32_t height,
struct wl_array* states, uint32_t serial)
static void xdg_handle_configure(void *data,
struct xdg_toplevel *xdg_toplevel,
int32_t width,
int32_t height,
struct wl_array *states)
{
UwacWindow* window = (UwacWindow*)data;
UwacConfigureEvent* event;
int ret, surfaceState;
enum xdg_surface_state* state;
enum xdg_toplevel_state* state;
surfaceState = 0;
wl_array_for_each(state, states)
{
switch (*state)
{
case XDG_SURFACE_STATE_MAXIMIZED:
case XDG_TOPLEVEL_STATE_MAXIMIZED:
surfaceState |= UWAC_WINDOW_MAXIMIZED;
break;
case XDG_SURFACE_STATE_FULLSCREEN:
case XDG_TOPLEVEL_STATE_FULLSCREEN:
surfaceState |= UWAC_WINDOW_FULLSCREEN;
break;
case XDG_SURFACE_STATE_ACTIVATED:
case XDG_TOPLEVEL_STATE_ACTIVATED:
surfaceState |= UWAC_WINDOW_ACTIVATED;
break;
case XDG_SURFACE_STATE_RESIZING:
case XDG_TOPLEVEL_STATE_RESIZING:
surfaceState |= UWAC_WINDOW_RESIZING;
break;
@ -155,10 +157,11 @@ static void xdg_handle_configure(void* data, struct xdg_surface* surface,
}
ack:
xdg_surface_ack_configure(surface, serial);
return;
}
static void xdg_handle_close(void* data, struct xdg_surface* xdg_surface)
static void xdg_handle_close(void *data,
struct xdg_toplevel *xdg_toplevel)
{
UwacCloseEvent* event;
UwacWindow* window = (UwacWindow*)data;
@ -174,12 +177,11 @@ static void xdg_handle_close(void* data, struct xdg_surface* xdg_surface)
event->window = window;
}
static const struct xdg_surface_listener xdg_surface_listener =
static const struct xdg_toplevel_listener xdg_toplevel_listener =
{
xdg_handle_configure,
xdg_handle_close,
};
#if BUILD_IVI
static void ivi_handle_configure(void* data, struct ivi_surface* surface,
@ -428,9 +430,9 @@ UwacWindow* UwacCreateWindowShm(UwacDisplay* display, uint32_t width, uint32_t h
wl_surface_set_user_data(w->surface, w);
if (display->xdg_shell)
if (display->xdg_base)
{
w->xdg_surface = xdg_shell_get_xdg_surface(display->xdg_shell, w->surface);
w->xdg_surface = xdg_wm_base_get_xdg_surface(display->xdg_base, w->surface);
if (!w->xdg_surface)
{
@ -438,8 +440,15 @@ UwacWindow* UwacCreateWindowShm(UwacDisplay* display, uint32_t width, uint32_t h
goto out_error_shell;
}
w->xdg_toplevel = xdg_surface_get_toplevel(w->xdg_surface);
if (!w->xdg_toplevel)
{
display->last_error = UWAC_ERROR_NOMEMORY;
goto out_error_shell;
}
assert(w->xdg_surface);
xdg_surface_add_listener(w->xdg_surface, &xdg_surface_listener, w);
xdg_toplevel_add_listener(w->xdg_toplevel, &xdg_toplevel_listener, w);
#if BUILD_IVI
}
else if (display->ivi_application)
@ -452,8 +461,8 @@ UwacWindow* UwacCreateWindowShm(UwacDisplay* display, uint32_t width, uint32_t h
}
else if (display->fullscreen_shell)
{
_wl_fullscreen_shell_present_surface(display->fullscreen_shell, w->surface,
_WL_FULLSCREEN_SHELL_PRESENT_METHOD_CENTER, NULL);
zwp_fullscreen_shell_v1_present_surface(display->fullscreen_shell, w->surface,
ZWP_FULLSCREEN_SHELL_V1_PRESENT_METHOD_CENTER, NULL);
#endif
}
else
@ -672,15 +681,15 @@ UwacReturnCode UwacWindowGetGeometry(UwacWindow* window, UwacSize* geometry)
UwacReturnCode UwacWindowSetFullscreenState(UwacWindow* window, UwacOutput* output,
bool isFullscreen)
{
if (window->xdg_surface)
if (window->xdg_toplevel)
{
if (isFullscreen)
{
xdg_surface_set_fullscreen(window->xdg_surface, output ? output->output : NULL);
xdg_toplevel_set_fullscreen(window->xdg_toplevel, output ? output->output : NULL);
}
else
{
xdg_surface_unset_fullscreen(window->xdg_surface);
xdg_toplevel_unset_fullscreen(window->xdg_toplevel);
}
}
else if (window->shell_surface)
@ -703,8 +712,8 @@ UwacReturnCode UwacWindowSetFullscreenState(UwacWindow* window, UwacOutput* outp
void UwacWindowSetTitle(UwacWindow* window, const char* name)
{
if (window->xdg_surface)
xdg_surface_set_title(window->xdg_surface, name);
if (window->xdg_toplevel)
xdg_toplevel_set_title(window->xdg_toplevel, name);
else if (window->shell_surface)
wl_shell_surface_set_title(window->shell_surface, name);
}

View File

@ -1,6 +1,8 @@
<protocol name="fullscreen_shell">
<interface name="_wl_fullscreen_shell" version="1">
<description summary="Displays a single surface per output">
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="fullscreen_shell_unstable_v1">
<interface name="zwp_fullscreen_shell_v1" version="1">
<description summary="displays a single surface per output">
Displays a single surface per output.
This interface provides a mechanism for a single client to display
@ -14,7 +16,7 @@
details about scaling and mode switches.
The client can have at most one surface per output at any time.
Requesting a surface be presented on an output that already has a
Requesting a surface to be presented on an output that already has a
surface replaces the previously presented surface. Presenting a null
surface removes its content and effectively disables the output.
Exactly what happens when an output is "disabled" is
@ -25,11 +27,20 @@
until either the client removes it or the compositor destroys the
output. This way, the client can update the output's contents by
simply attaching a new buffer.
Warning! The protocol described in this file is experimental and
backward incompatible changes may be made. Backward compatible changes
may be added together with the corresponding interface version bump.
Backward incompatible changes are done by bumping the version number in
the protocol and interface names and resetting the interface version.
Once the protocol is to be declared stable, the 'z' prefix and the
version number in the protocol and interface names are removed and the
interface version number is reset.
</description>
<request name="release" type="destructor">
<description summary="release the wl_fullscreen_shell interface">
Release the binding from the wl_fullscreen_shell interface
Release the binding from the wl_fullscreen_shell interface.
This destroys the server-side object and frees this binding. If
the client binds to wl_fullscreen_shell multiple times, it may wish
@ -43,7 +54,7 @@
are advertised one-at-a-time when the wl_fullscreen_shell interface is
bound. See the wl_fullscreen_shell.capability event for more details.
ARBITRARY_MODE:
ARBITRARY_MODES:
This is a hint to the client that indicates that the compositor is
capable of setting practically any mode on its outputs. If this
capability is provided, wl_fullscreen_shell.present_surface_for_mode
@ -76,7 +87,7 @@
wl_display.sync request immediately after binding to ensure that they
receive all the capability events.
</description>
<arg name="capabilty" type="uint"/>
<arg name="capability" type="uint"/>
</event>
<enum name="present_method">
@ -160,18 +171,18 @@
<arg name="surface" type="object" interface="wl_surface"/>
<arg name="output" type="object" interface="wl_output"/>
<arg name="framerate" type="int"/>
<arg name="feedback" type="new_id" interface="_wl_fullscreen_shell_mode_feedback"/>
<arg name="feedback" type="new_id" interface="zwp_fullscreen_shell_mode_feedback_v1"/>
</request>
<enum name="error">
<description summary="wl_fullscreen_shell error values">
These errors can be emitted in response to wl_fullscreen_shell requests
These errors can be emitted in response to wl_fullscreen_shell requests.
</description>
<entry name="invalid_method" value="0" summary="present_method is not known"/>
</enum>
</interface>
<interface name="_wl_fullscreen_shell_mode_feedback" version="1">
<interface name="zwp_fullscreen_shell_mode_feedback_v1" version="1">
<event name="mode_successful">
<description summary="mode switch succeeded">
This event indicates that the attempted mode switch operation was
@ -182,6 +193,7 @@
wl_fullscreen_shell_mode_feedback object.
</description>
</event>
<event name="mode_failed">
<description summary="mode switch failed">
This event indicates that the attempted mode switch operation
@ -192,6 +204,7 @@
wl_fullscreen_shell_mode_feedback object.
</description>
</event>
<event name="present_cancelled">
<description summary="mode switch cancelled">
This event indicates that the attempted mode switch operation was
@ -203,4 +216,5 @@
</description>
</event>
</interface>
</protocol>