mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 06:21:14 +00:00
xdg-shell: Update to latest state change mechanism
This commit is contained in:
parent
1779789f65
commit
c737045462
@ -107,7 +107,6 @@ struct _GdkWindowImplWayland
|
|||||||
struct gtk_surface *gtk_surface;
|
struct gtk_surface *gtk_surface;
|
||||||
|
|
||||||
unsigned int mapped : 1;
|
unsigned int mapped : 1;
|
||||||
unsigned int fullscreen : 1;
|
|
||||||
unsigned int use_custom_surface : 1;
|
unsigned int use_custom_surface : 1;
|
||||||
unsigned int pending_commit : 1;
|
unsigned int pending_commit : 1;
|
||||||
GdkWindowTypeHint hint;
|
GdkWindowTypeHint hint;
|
||||||
@ -963,35 +962,31 @@ xdg_surface_configure (void *data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xdg_surface_request_set_fullscreen (void *data,
|
xdg_surface_change_state (void *data,
|
||||||
struct xdg_surface *xdg_surface)
|
struct xdg_surface *xdg_surface,
|
||||||
|
uint32_t state_type,
|
||||||
|
uint32_t value,
|
||||||
|
uint32_t serial)
|
||||||
{
|
{
|
||||||
GdkWindow *window = GDK_WINDOW (data);
|
GdkWindow *window = GDK_WINDOW (data);
|
||||||
gdk_window_fullscreen (window);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
switch (state_type)
|
||||||
xdg_surface_request_unset_fullscreen (void *data,
|
{
|
||||||
struct xdg_surface *xdg_surface)
|
case XDG_SURFACE_STATE_MAXIMIZED:
|
||||||
{
|
if (value)
|
||||||
GdkWindow *window = GDK_WINDOW (data);
|
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_MAXIMIZED);
|
||||||
gdk_window_unfullscreen (window);
|
else
|
||||||
}
|
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_MAXIMIZED, 0);
|
||||||
|
break;
|
||||||
|
case XDG_SURFACE_STATE_FULLSCREEN:
|
||||||
|
if (value)
|
||||||
|
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN);
|
||||||
|
else
|
||||||
|
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FULLSCREEN, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
xdg_surface_ack_change_state (xdg_surface, state_type, value, serial);
|
||||||
xdg_surface_request_set_maximized (void *data,
|
|
||||||
struct xdg_surface *xdg_surface)
|
|
||||||
{
|
|
||||||
GdkWindow *window = GDK_WINDOW (data);
|
|
||||||
gdk_window_maximize (window);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
xdg_surface_request_unset_maximized (void *data,
|
|
||||||
struct xdg_surface *xdg_surface)
|
|
||||||
{
|
|
||||||
GdkWindow *window = GDK_WINDOW (data);
|
|
||||||
gdk_window_unmaximize (window);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1030,10 +1025,7 @@ xdg_surface_delete (void *data,
|
|||||||
|
|
||||||
static const struct xdg_surface_listener xdg_surface_listener = {
|
static const struct xdg_surface_listener xdg_surface_listener = {
|
||||||
xdg_surface_configure,
|
xdg_surface_configure,
|
||||||
xdg_surface_request_set_fullscreen,
|
xdg_surface_change_state,
|
||||||
xdg_surface_request_unset_fullscreen,
|
|
||||||
xdg_surface_request_set_maximized,
|
|
||||||
xdg_surface_request_unset_maximized,
|
|
||||||
xdg_surface_activated,
|
xdg_surface_activated,
|
||||||
xdg_surface_deactivated,
|
xdg_surface_deactivated,
|
||||||
xdg_surface_delete,
|
xdg_surface_delete,
|
||||||
@ -1751,8 +1743,10 @@ gdk_wayland_window_maximize (GdkWindow *window)
|
|||||||
if (!impl->xdg_surface)
|
if (!impl->xdg_surface)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xdg_surface_set_maximized (impl->xdg_surface);
|
xdg_surface_request_change_state (impl->xdg_surface,
|
||||||
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_MAXIMIZED);
|
XDG_SURFACE_STATE_MAXIMIZED,
|
||||||
|
TRUE,
|
||||||
|
0 /* serial, unused */);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1766,8 +1760,10 @@ gdk_wayland_window_unmaximize (GdkWindow *window)
|
|||||||
if (!impl->xdg_surface)
|
if (!impl->xdg_surface)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xdg_surface_unset_maximized (impl->xdg_surface);
|
xdg_surface_request_change_state (impl->xdg_surface,
|
||||||
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_MAXIMIZED, 0);
|
XDG_SURFACE_STATE_MAXIMIZED,
|
||||||
|
FALSE,
|
||||||
|
0 /* serial, unused */);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1778,15 +1774,13 @@ gdk_wayland_window_fullscreen (GdkWindow *window)
|
|||||||
if (GDK_WINDOW_DESTROYED (window))
|
if (GDK_WINDOW_DESTROYED (window))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (impl->fullscreen)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!impl->xdg_surface)
|
if (!impl->xdg_surface)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xdg_surface_set_fullscreen (impl->xdg_surface);
|
xdg_surface_request_change_state (impl->xdg_surface,
|
||||||
impl->fullscreen = TRUE;
|
XDG_SURFACE_STATE_FULLSCREEN,
|
||||||
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN);
|
TRUE,
|
||||||
|
0 /* serial, unused */);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1797,15 +1791,13 @@ gdk_wayland_window_unfullscreen (GdkWindow *window)
|
|||||||
if (GDK_WINDOW_DESTROYED (window))
|
if (GDK_WINDOW_DESTROYED (window))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!impl->fullscreen)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!impl->xdg_surface)
|
if (!impl->xdg_surface)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
xdg_surface_unset_fullscreen (impl->xdg_surface);
|
xdg_surface_request_change_state (impl->xdg_surface,
|
||||||
impl->fullscreen = FALSE;
|
XDG_SURFACE_STATE_FULLSCREEN,
|
||||||
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FULLSCREEN, 0);
|
FALSE,
|
||||||
|
0 /* serial, unused */);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -40,19 +40,22 @@
|
|||||||
|
|
||||||
<enum name="version">
|
<enum name="version">
|
||||||
<description summary="latest protocol version">
|
<description summary="latest protocol version">
|
||||||
Use this enum to check the protocol version, and it will be updated
|
The 'current' member of this enum gives the version of the
|
||||||
automatically.
|
protocol. Implementations can compare this to the version
|
||||||
|
they implement using static_assert to ensure the protocol and
|
||||||
|
implementation versions match.
|
||||||
</description>
|
</description>
|
||||||
<entry name="current" value="2" summary="Always the latest version"/>
|
<entry name="current" value="3" summary="Always the latest version"/>
|
||||||
</enum>
|
</enum>
|
||||||
|
|
||||||
|
|
||||||
<request name="use_unstable_version">
|
<request name="use_unstable_version">
|
||||||
<description summary="enable use of this unstable version">
|
<description summary="enable use of this unstable version">
|
||||||
Use this request in order to enable use of this interface.
|
Negotiate the unstable version of the interface. This
|
||||||
|
mechanism is in place to ensure client and server agree on the
|
||||||
Understand and agree that one is using an unstable interface,
|
unstable versions of the protocol that they speak or exit
|
||||||
that will likely change in the future, breaking the API.
|
cleanly if they don't agree. This request will go away once
|
||||||
|
the xdg-shell protocol is stable.
|
||||||
</description>
|
</description>
|
||||||
<arg name="version" type="int"/>
|
<arg name="version" type="int"/>
|
||||||
</request>
|
</request>
|
||||||
@ -275,113 +278,87 @@
|
|||||||
<arg name="output" type="object" interface="wl_output" allow-null="true"/>
|
<arg name="output" type="object" interface="wl_output" allow-null="true"/>
|
||||||
</request>
|
</request>
|
||||||
|
|
||||||
<event name="request_set_fullscreen">
|
<enum name="state">
|
||||||
<description summary="server requests that the client set fullscreen">
|
<description summary="types of state on the surface">
|
||||||
Event sent from the compositor to the client requesting that the client
|
The different state values used on the surface. This is designed for
|
||||||
goes to a fullscreen state. It's the client job to call set_fullscreen
|
state values like maximized, fullscreen. It is paired with the
|
||||||
and really trigger the fullscreen state.
|
request_change_state event to ensure that both the client and the
|
||||||
|
compositor setting the state can be synchronized.
|
||||||
|
|
||||||
|
States set in this way are double-buffered. They will get applied on
|
||||||
|
the next commit.
|
||||||
|
|
||||||
|
Desktop environments may extend this enum by taking up a range of
|
||||||
|
values and documenting the range they chose in this description.
|
||||||
|
They are not required to document the values for the range that they
|
||||||
|
chose. Ideally, any good extensions from a desktop environment should
|
||||||
|
make its way into standardization into this enum.
|
||||||
|
|
||||||
|
The current reserved ranges are:
|
||||||
|
|
||||||
|
0x0000 - 0x0FFF: xdg-shell core values, documented below.
|
||||||
|
0x1000 - 0x1FFF: GNOME
|
||||||
</description>
|
</description>
|
||||||
</event>
|
<entry name="maximized" value="1" summary="the surface is maximized">
|
||||||
|
A non-zero value indicates the surface is maximized. Otherwise,
|
||||||
|
the surface is unmaximized.
|
||||||
|
</entry>
|
||||||
|
<entry name="fullscreen" value="2" summary="the surface is fullscreen">
|
||||||
|
A non-zero value indicates the surface is fullscreen. Otherwise,
|
||||||
|
the surface is not fullscreen.
|
||||||
|
</entry>
|
||||||
|
</enum>
|
||||||
|
|
||||||
<event name="request_unset_fullscreen">
|
<request name="request_change_state">
|
||||||
<description summary="server requests that the client unset fullscreen">
|
<description summary="client requests to change a surface's state">
|
||||||
Event sent from the compositor to the client requesting that the client
|
This asks the compositor to change the state. If the compositor wants
|
||||||
leaves the fullscreen state. It's the client job to call
|
to change the state, it will send a change_state event with the same
|
||||||
unset_fullscreen and really leave the fullscreen state.
|
state_type, value, and serial, and the event flow continues as if it
|
||||||
</description>
|
it was initiated by the compositor.
|
||||||
</event>
|
|
||||||
|
If the compositor does not want to change the state, it will send a
|
||||||
<request name="set_fullscreen">
|
change_state to the client with the old value of the state.
|
||||||
<description summary="set the surface state as fullscreen">
|
|
||||||
Set the surface as fullscreen.
|
|
||||||
|
|
||||||
After this request, the compositor should send a configure event
|
|
||||||
informing the output size.
|
|
||||||
|
|
||||||
This request informs the compositor that the next attached buffer
|
|
||||||
committed will be in a fullscreen state. The buffer size should be the
|
|
||||||
same size as the size informed in the configure event, if the client
|
|
||||||
doesn't want to leave any empty area.
|
|
||||||
|
|
||||||
In other words: the next attached buffer after set_maximized is the new
|
|
||||||
maximized buffer. And the surface will be positioned at the maximized
|
|
||||||
position on commit.
|
|
||||||
|
|
||||||
A simple way to synchronize and wait for the correct configure event is
|
|
||||||
to use a wl_display.sync request right after the set_fullscreen
|
|
||||||
request. When the sync callback returns, the last configure event
|
|
||||||
received just before it will be the correct one, and should contain the
|
|
||||||
right size for the surface to maximize.
|
|
||||||
|
|
||||||
Setting one state won't unset another state. Use
|
|
||||||
xdg_surface.unset_fullscreen for unsetting it.
|
|
||||||
</description>
|
</description>
|
||||||
|
<arg name="state_type" type="uint" summary="the state to set"/>
|
||||||
|
<arg name="value" type="uint" summary="the value to change the state to"/>
|
||||||
|
<arg name="serial" type="uint" summary="an event serial">
|
||||||
|
This serial is so the client can know which change_state event corresponds
|
||||||
|
to which request_change_state request it sent out.
|
||||||
|
</arg>
|
||||||
</request>
|
</request>
|
||||||
|
|
||||||
<request name="unset_fullscreen">
|
<event name="change_state">
|
||||||
<description summary="unset the surface state as fullscreen">
|
<description summary="compositor wants to change a surface's state">
|
||||||
Unset the surface fullscreen state.
|
This event tells the client to change a surface's state. The client
|
||||||
|
should respond with an ack_change_state request to the compositor to
|
||||||
Same negotiation as set_fullscreen must be used.
|
guarantee that the compositor knows that the client has seen it.
|
||||||
</description>
|
</description>
|
||||||
</request>
|
|
||||||
|
|
||||||
<event name="request_set_maximized">
|
<arg name="state_type" type="uint" summary="the state to set"/>
|
||||||
<description summary="server requests that the client set maximized">
|
<arg name="value" type="uint" summary="the value to change the state to"/>
|
||||||
Event sent from the compositor to the client requesting that the client
|
<arg name="serial" type="uint" summary="a serial for the compositor's own tracking"/>
|
||||||
goes to a maximized state. It's the client job to call set_maximized
|
|
||||||
and really trigger the maximized state.
|
|
||||||
</description>
|
|
||||||
</event>
|
</event>
|
||||||
|
|
||||||
<event name="request_unset_maximized">
|
<request name="ack_change_state">
|
||||||
<description summary="server requests that the client unset maximized">
|
<description summary="ack a change_state event">
|
||||||
Event sent from the compositor to the client requesting that the client
|
When a change_state event is received, a client should then ack it
|
||||||
leaves the maximized state. It's the client job to call unset_maximized
|
using the ack_change_state request to ensure that the compositor
|
||||||
and really leave the maximized state.
|
knows the client has seen the event.
|
||||||
</description>
|
|
||||||
</event>
|
By this point, the state is confirmed, and the next attach should
|
||||||
|
contain the buffer drawn for the new state value.
|
||||||
<request name="set_maximized">
|
|
||||||
<description summary="set the surface state as maximized">
|
The values here need to be the same as the values in the cooresponding
|
||||||
Set the surface as maximized.
|
change_state event.
|
||||||
|
|
||||||
After this request, the compositor will send a configure event
|
|
||||||
informing the output size minus panel and other MW decorations.
|
|
||||||
|
|
||||||
This request informs the compositor that the next attached buffer
|
|
||||||
committed will be in a maximized state. The buffer size should be the
|
|
||||||
same size as the size informed in the configure event, if the client
|
|
||||||
doesn't want to leave any empty area.
|
|
||||||
|
|
||||||
In other words: the next attached buffer after set_maximized is the new
|
|
||||||
maximized buffer. And the surface will be positioned at the maximized
|
|
||||||
position on commit.
|
|
||||||
|
|
||||||
A simple way to synchronize and wait for the correct configure event is
|
|
||||||
to use a wl_display.sync request right after the set_maximized request.
|
|
||||||
When the sync callback returns, the last configure event received just
|
|
||||||
before it will be the correct one, and should contain the right size
|
|
||||||
for the surface to maximize.
|
|
||||||
|
|
||||||
Setting one state won't unset another state. Use
|
|
||||||
xdg_surface.unset_maximized for unsetting it.
|
|
||||||
</description>
|
|
||||||
</request>
|
|
||||||
|
|
||||||
<request name="unset_maximized">
|
|
||||||
<description summary="unset the surface state as maximized">
|
|
||||||
Unset the surface maximized state.
|
|
||||||
|
|
||||||
Same negotiation as set_maximized must be used.
|
|
||||||
</description>
|
</description>
|
||||||
|
<arg name="state_type" type="uint" summary="the state to set"/>
|
||||||
|
<arg name="value" type="uint" summary="the value to change the state to"/>
|
||||||
|
<arg name="serial" type="uint" summary="a serial to pass to change_state"/>
|
||||||
</request>
|
</request>
|
||||||
|
|
||||||
<request name="set_minimized">
|
<request name="set_minimized">
|
||||||
<description summary="set the surface state as minimized">
|
<description summary="minimize the surface">
|
||||||
Set the surface minimized state.
|
Minimize the surface.
|
||||||
|
|
||||||
Setting one state won't unset another state.
|
|
||||||
</description>
|
</description>
|
||||||
</request>
|
</request>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user