wayland: Update to latest xdg-shell protocol

This commit is contained in:
Jasper St. Pierre 2014-04-11 17:31:27 -07:00
parent c1efc4ad7b
commit 9b4668c82c
2 changed files with 101 additions and 165 deletions

View File

@ -113,6 +113,8 @@ struct _GdkWindowImplWayland
cairo_surface_t *cairo_surface; cairo_surface_t *cairo_surface;
int32_t next_attach_serial;
gchar *title; gchar *title;
/* Time of most recent user interaction. */ /* Time of most recent user interaction. */
@ -520,6 +522,12 @@ gdk_wayland_window_attach_image (GdkWindow *window)
if (GDK_WINDOW_DESTROYED (window)) if (GDK_WINDOW_DESTROYED (window))
return; return;
if (impl->next_attach_serial > 0)
{
xdg_surface_ack_configure (impl->xdg_surface, impl->next_attach_serial);
impl->next_attach_serial = 0;
}
/* Attach this new buffer to the surface */ /* Attach this new buffer to the surface */
wl_surface_attach (impl->surface, wl_surface_attach (impl->surface,
_gdk_wayland_shm_surface_get_wl_buffer (impl->cairo_surface), _gdk_wayland_shm_surface_get_wl_buffer (impl->cairo_surface),
@ -800,11 +808,17 @@ static void
xdg_surface_configure (void *data, xdg_surface_configure (void *data,
struct xdg_surface *xdg_surface, struct xdg_surface *xdg_surface,
int32_t width, int32_t width,
int32_t height) int32_t height,
struct wl_array *states,
uint32_t serial)
{ {
GdkWindow *window = GDK_WINDOW (data); GdkWindow *window = GDK_WINDOW (data);
GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl); GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
GdkWindowState new_state = 0;
uint32_t *p;
if (width > 0 && height > 0)
{
gdk_window_constrain_size (&impl->geometry_hints, gdk_window_constrain_size (&impl->geometry_hints,
impl->geometry_mask, impl->geometry_mask,
width, width,
@ -813,50 +827,32 @@ xdg_surface_configure (void *data,
&height); &height);
gdk_wayland_window_configure (window, width, height); gdk_wayland_window_configure (window, width, height);
}
static void
xdg_surface_change_state (void *data,
struct xdg_surface *xdg_surface,
uint32_t state_type,
uint32_t value,
uint32_t serial)
{
GdkWindow *window = GDK_WINDOW (data);
switch (state_type)
{
case XDG_SURFACE_STATE_MAXIMIZED:
if (value)
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_MAXIMIZED);
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;
} }
xdg_surface_ack_change_state (xdg_surface, state_type, value, serial); wl_array_for_each(p, states)
} {
uint32_t state = *p;
switch (state)
{
case XDG_SURFACE_STATE_FULLSCREEN:
new_state |= GDK_WINDOW_STATE_FULLSCREEN;
break;
case XDG_SURFACE_STATE_MAXIMIZED:
new_state |= GDK_WINDOW_STATE_MAXIMIZED;
break;
case XDG_SURFACE_STATE_ACTIVATED:
new_state |= GDK_WINDOW_STATE_FOCUSED;
break;
case XDG_SURFACE_STATE_RESIZING:
break;
default:
/* Unknown state */
break;
}
}
static void _gdk_set_window_state (window, new_state);
xdg_surface_activated (void *data, impl->next_attach_serial = serial;
struct xdg_surface *xdg_surface)
{
GdkWindow *window = GDK_WINDOW (data);
gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FOCUSED);
}
static void
xdg_surface_deactivated (void *data,
struct xdg_surface *xdg_surface)
{
GdkWindow *window = GDK_WINDOW (data);
gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FOCUSED, 0);
} }
static void static void
@ -879,9 +875,6 @@ xdg_surface_close (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_change_state,
xdg_surface_activated,
xdg_surface_deactivated,
xdg_surface_close, xdg_surface_close,
}; };
@ -1612,10 +1605,7 @@ gdk_wayland_window_maximize (GdkWindow *window)
if (!impl->xdg_surface) if (!impl->xdg_surface)
return; return;
xdg_surface_request_change_state (impl->xdg_surface, xdg_surface_set_maximized (impl->xdg_surface);
XDG_SURFACE_STATE_MAXIMIZED,
TRUE,
0 /* serial, unused */);
} }
static void static void
@ -1629,10 +1619,7 @@ gdk_wayland_window_unmaximize (GdkWindow *window)
if (!impl->xdg_surface) if (!impl->xdg_surface)
return; return;
xdg_surface_request_change_state (impl->xdg_surface, xdg_surface_unset_maximized (impl->xdg_surface);
XDG_SURFACE_STATE_MAXIMIZED,
FALSE,
0 /* serial, unused */);
} }
static void static void
@ -1646,10 +1633,7 @@ gdk_wayland_window_fullscreen (GdkWindow *window)
if (!impl->xdg_surface) if (!impl->xdg_surface)
return; return;
xdg_surface_request_change_state (impl->xdg_surface, xdg_surface_set_fullscreen (impl->xdg_surface, NULL);
XDG_SURFACE_STATE_FULLSCREEN,
TRUE,
0 /* serial, unused */);
} }
static void static void
@ -1663,10 +1647,7 @@ gdk_wayland_window_unfullscreen (GdkWindow *window)
if (!impl->xdg_surface) if (!impl->xdg_surface)
return; return;
xdg_surface_request_change_state (impl->xdg_surface, xdg_surface_unset_fullscreen (impl->xdg_surface);
XDG_SURFACE_STATE_FULLSCREEN,
FALSE,
0 /* serial, unused */);
} }
static void static void

View File

@ -241,40 +241,6 @@
<arg name="edges" type="uint" summary="which edge or corner is being dragged"/> <arg name="edges" type="uint" summary="which edge or corner is being dragged"/>
</request> </request>
<event name="configure">
<description summary="suggest resize">
The configure event asks the client to resize its surface.
The size is a hint, in the sense that the client is free to
ignore it if it doesn't resize, pick a smaller size (to
satisfy aspect ratio or resize in steps of NxM pixels).
The client is free to dismiss all but the last configure
event it received.
The width and height arguments specify the size of the window
in surface local coordinates.
</description>
<arg name="width" type="int"/>
<arg name="height" type="int"/>
</event>
<request name="set_output">
<description summary="set the default output used by this surface">
Set the default output used by this surface when it is first mapped.
If this value is NULL (default), it's up to the compositor to choose
which display will be used to map this surface.
When fullscreen or maximized state are set on this surface, and it
wasn't mapped yet, the output set with this method will be used.
Otherwise, the output where the surface is currently mapped will be
used.
</description>
<arg name="output" type="object" interface="wl_output" allow-null="true"/>
</request>
<enum name="state"> <enum name="state">
<description summary="types of state on the surface"> <description summary="types of state on the surface">
The different state values used on the surface. This is designed for The different state values used on the surface. This is designed for
@ -297,89 +263,78 @@
0x1000 - 0x1FFF: GNOME 0x1000 - 0x1FFF: GNOME
</description> </description>
<entry name="maximized" value="1" summary="the surface is maximized"> <entry name="maximized" value="1" summary="the surface is maximized">
A non-zero value indicates the surface is maximized. Otherwise, The surface is maximized. The window geometry specified in the configure
the surface is unmaximized. event must be obeyed by the client.
</entry> </entry>
<entry name="fullscreen" value="2" summary="the surface is fullscreen"> <entry name="fullscreen" value="2" summary="the surface is fullscreen">
A non-zero value indicates the surface is fullscreen. Otherwise, The surface is fullscreen. The window geometry specified in the configure
the surface is not fullscreen. event must be obeyed by the client.
</entry>
<entry name="resizing" value="3">
The surface is being resized. The window geometry specified in the
configure event is a maximum; the client cannot resize beyond it.
Clients that have aspect ratio or cell sizing configuration can use
a smaller size, however.
</entry>
<entry name="activated" value="4">
Client window decorations should be painted as if the window is
active. Do not assume this means that the window actually has
keyboard or pointer focus.
</entry> </entry>
</enum> </enum>
<request name="request_change_state"> <event name="configure">
<description summary="client requests to change a surface's state"> <description summary="suggest a surface chnage">
This asks the compositor to change the state. If the compositor wants The configure event asks the client to resize its surface.
to change the state, it will send a change_state event with the same
state_type, value, and serial, and the event flow continues as if it
it was initiated by the compositor.
If the compositor does not want to change the state, it will send a The width and height arguments specify a hint to the window
change_state to the client with the old value of the state. about how its surface should be resized in surface local
</description> coordinates. The states listed in the event specify how the
<arg name="state_type" type="uint" summary="the state to set"/> width/height arguments should be interpreted.
<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>
<event name="change_state"> A client should arrange a new surface, and then send a
<description summary="compositor wants to change a surface's state"> ack_configure request with the serial sent in this configure
This event tells the client to change a surface's state. The client event before attaching a new surface.
should respond with an ack_change_state request to the compositor to
guarantee that the compositor knows that the client has seen it. If the client receives multiple configure events before it
can respond to one, it is free to discard all but the last
event it received.
</description> </description>
<arg name="state_type" type="uint" summary="the state to set"/> <arg name="width" type="int"/>
<arg name="value" type="uint" summary="the value to change the state to"/> <arg name="height" type="int"/>
<arg name="serial" type="uint" summary="a serial for the compositor's own tracking"/> <arg name="states" type="array"/>
<arg name="serial" type="uint"/>
</event> </event>
<request name="ack_change_state"> <request name="ack_configure">
<description summary="ack a change_state event"> <description summary="ack a configure event">
When a change_state event is received, a client should then ack it When a configure event is received, a client should then ack it
using the ack_change_state request to ensure that the compositor using the ack_configure request to ensure that the compositor
knows the client has seen the event. knows the client has seen the event.
By this point, the state is confirmed, and the next attach should By this point, the state is confirmed, and the next attach should
contain the buffer drawn for the new state value. contain the buffer drawn for the configure event you are acking.
The values here need to be the same as the values in the cooresponding
change_state event.
</description> </description>
<arg name="state_type" type="uint" summary="the state to set"/> <arg name="serial" type="uint" summary="a serial to configure for"/>
<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_maximized" />
<description summary="minimize the surface"> <request name="unset_maximized" />
Minimize the surface.
<request name="set_fullscreen">
<description summary="set the window as fullscreen on a monitor">
Make the surface fullscreen.
You can specify an output that you would prefer to be fullscreen.
If this value is NULL, it's up to the compositor to choose which
display will be used to map this surface.
</description> </description>
<arg name="output" type="object" interface="wl_output" allow-null="true"/>
</request> </request>
<request name="unset_fullscreen" />
<event name="activated"> <request name="set_minimized" />
<description summary="surface was activated">
The activated_set event is sent when this surface has been
activated, which means that the surface has user attention.
Window decorations should be updated accordingly. You should
not use this event for anything but the style of decorations
you display, use wl_keyboard.enter and wl_keyboard.leave for
determining keyboard focus.
</description>
</event>
<event name="deactivated">
<description summary="surface was deactivated">
The deactivate event is sent when this surface has been
deactivated, which means that the surface lost user attention.
Window decorations should be updated accordingly. You should
not use this event for anything but the style of decorations
you display, use wl_keyboard.enter and wl_keyboard.leave for
determining keyboard focus.
</description>
</event>
<event name="close"> <event name="close">
<description summary="surface wants to be closed"> <description summary="surface wants to be closed">