* static_assert to ensure the protocol and implementation versions match.
*/
enum xdg_shell_version {
- XDG_SHELL_VERSION_CURRENT = 3,
+ XDG_SHELL_VERSION_CURRENT = 4,
};
#endif /* XDG_SHELL_VERSION_ENUM */
* xdg_surface_state - types of state on the surface
* @XDG_SURFACE_STATE_MAXIMIZED: the surface is maximized
* @XDG_SURFACE_STATE_FULLSCREEN: the surface is fullscreen
+ * @XDG_SURFACE_STATE_RESIZING: (none)
+ * @XDG_SURFACE_STATE_ACTIVATED: (none)
*
* The different state values used on the surface. This is designed for
- * state values like maximized, fullscreen. It is paired with the
- * request_change_state event to ensure that both the client and the
- * compositor setting the state can be synchronized.
+ * state values like maximized, fullscreen. It is paired with the configure
+ * 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.
enum xdg_surface_state {
XDG_SURFACE_STATE_MAXIMIZED = 1,
XDG_SURFACE_STATE_FULLSCREEN = 2,
+ XDG_SURFACE_STATE_RESIZING = 3,
+ XDG_SURFACE_STATE_ACTIVATED = 4,
};
#endif /* XDG_SURFACE_STATE_ENUM */
/**
* xdg_surface - desktop-style metadata interface
- * @configure: suggest resize
- * @change_state: compositor wants to change a surface's state
- * @activated: surface was activated
- * @deactivated: surface was deactivated
+ * @configure: suggest a surface change
* @close: surface wants to be closed
*
* An interface that may be implemented by a wl_surface, for
*/
struct xdg_surface_listener {
/**
- * configure - suggest resize
+ * configure - suggest a surface change
* @width: (none)
* @height: (none)
+ * @states: (none)
+ * @serial: (none)
*
* 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 width and height arguments specify a hint to the window
+ * about how its surface should be resized in window geometry
+ * coordinates. The states listed in the event specify how the
+ * width/height arguments should be interpreted.
*
- * The client is free to dismiss all but the last configure event
- * it received.
+ * A client should arrange a new surface, and then send a
+ * ack_configure request with the serial sent in this configure
+ * event before attaching a new surface.
*
- * The width and height arguments specify the size of the window in
- * surface local coordinates.
+ * 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.
*/
void (*configure)(void *data,
struct xdg_surface *xdg_surface,
int32_t width,
- int32_t height);
- /**
- * change_state - compositor wants to change a surface's state
- * @state_type: the state to set
- * @value: the value to change the state to
- * @serial: a serial for the compositor's own tracking
- *
- * 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 guarantee that the compositor knows that the
- * client has seen it.
- */
- void (*change_state)(void *data,
- struct xdg_surface *xdg_surface,
- uint32_t state_type,
- uint32_t value,
- uint32_t serial);
- /**
- * activated - 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.
- */
- void (*activated)(void *data,
- struct xdg_surface *xdg_surface);
- /**
- * deactivated - 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.
- */
- void (*deactivated)(void *data,
- struct xdg_surface *xdg_surface);
+ int32_t height,
+ struct wl_array *states,
+ uint32_t serial);
/**
* close - surface wants to be closed
*
}
#define XDG_SURFACE_DESTROY 0
-#define XDG_SURFACE_SET_TRANSIENT_FOR 1
-#define XDG_SURFACE_SET_MARGIN 2
-#define XDG_SURFACE_SET_TITLE 3
-#define XDG_SURFACE_SET_APP_ID 4
+#define XDG_SURFACE_SET_PARENT 1
+#define XDG_SURFACE_SET_TITLE 2
+#define XDG_SURFACE_SET_APP_ID 3
+#define XDG_SURFACE_SHOW_WINDOW_MENU 4
#define XDG_SURFACE_MOVE 5
#define XDG_SURFACE_RESIZE 6
-#define XDG_SURFACE_SET_OUTPUT 7
-#define XDG_SURFACE_REQUEST_CHANGE_STATE 8
-#define XDG_SURFACE_ACK_CHANGE_STATE 9
-#define XDG_SURFACE_SET_MINIMIZED 10
+#define XDG_SURFACE_ACK_CONFIGURE 7
+#define XDG_SURFACE_SET_WINDOW_GEOMETRY 8
+#define XDG_SURFACE_SET_MAXIMIZED 9
+#define XDG_SURFACE_UNSET_MAXIMIZED 10
+#define XDG_SURFACE_SET_FULLSCREEN 11
+#define XDG_SURFACE_UNSET_FULLSCREEN 12
+#define XDG_SURFACE_SET_MINIMIZED 13
static inline void
xdg_surface_set_user_data(struct xdg_surface *xdg_surface, void *user_data)
}
static inline void
-xdg_surface_set_transient_for(struct xdg_surface *xdg_surface, struct wl_surface *parent)
+xdg_surface_set_parent(struct xdg_surface *xdg_surface, struct wl_surface *parent)
{
wl_proxy_marshal((struct wl_proxy *) xdg_surface,
- XDG_SURFACE_SET_TRANSIENT_FOR, parent);
+ XDG_SURFACE_SET_PARENT, parent);
}
static inline void
-xdg_surface_set_margin(struct xdg_surface *xdg_surface, int32_t left_margin, int32_t right_margin, int32_t top_margin, int32_t bottom_margin)
+xdg_surface_set_title(struct xdg_surface *xdg_surface, const char *title)
{
wl_proxy_marshal((struct wl_proxy *) xdg_surface,
- XDG_SURFACE_SET_MARGIN, left_margin, right_margin, top_margin, bottom_margin);
+ XDG_SURFACE_SET_TITLE, title);
}
static inline void
-xdg_surface_set_title(struct xdg_surface *xdg_surface, const char *title)
+xdg_surface_set_app_id(struct xdg_surface *xdg_surface, const char *app_id)
{
wl_proxy_marshal((struct wl_proxy *) xdg_surface,
- XDG_SURFACE_SET_TITLE, title);
+ XDG_SURFACE_SET_APP_ID, app_id);
}
static inline void
-xdg_surface_set_app_id(struct xdg_surface *xdg_surface, const char *app_id)
+xdg_surface_show_window_menu(struct xdg_surface *xdg_surface, struct wl_seat *seat, uint32_t serial, int32_t x, int32_t y)
{
wl_proxy_marshal((struct wl_proxy *) xdg_surface,
- XDG_SURFACE_SET_APP_ID, app_id);
+ XDG_SURFACE_SHOW_WINDOW_MENU, seat, serial, x, y);
}
static inline void
}
static inline void
-xdg_surface_set_output(struct xdg_surface *xdg_surface, struct wl_output *output)
+xdg_surface_ack_configure(struct xdg_surface *xdg_surface, uint32_t serial)
+{
+ wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+ XDG_SURFACE_ACK_CONFIGURE, serial);
+}
+
+static inline void
+xdg_surface_set_window_geometry(struct xdg_surface *xdg_surface, int32_t x, int32_t y, int32_t width, int32_t height)
+{
+ wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+ XDG_SURFACE_SET_WINDOW_GEOMETRY, x, y, width, height);
+}
+
+static inline void
+xdg_surface_set_maximized(struct xdg_surface *xdg_surface)
+{
+ wl_proxy_marshal((struct wl_proxy *) xdg_surface,
+ XDG_SURFACE_SET_MAXIMIZED);
+}
+
+static inline void
+xdg_surface_unset_maximized(struct xdg_surface *xdg_surface)
{
wl_proxy_marshal((struct wl_proxy *) xdg_surface,
- XDG_SURFACE_SET_OUTPUT, output);
+ XDG_SURFACE_UNSET_MAXIMIZED);
}
static inline void
-xdg_surface_request_change_state(struct xdg_surface *xdg_surface, uint32_t state_type, uint32_t value, uint32_t serial)
+xdg_surface_set_fullscreen(struct xdg_surface *xdg_surface, struct wl_output *output)
{
wl_proxy_marshal((struct wl_proxy *) xdg_surface,
- XDG_SURFACE_REQUEST_CHANGE_STATE, state_type, value, serial);
+ XDG_SURFACE_SET_FULLSCREEN, output);
}
static inline void
-xdg_surface_ack_change_state(struct xdg_surface *xdg_surface, uint32_t state_type, uint32_t value, uint32_t serial)
+xdg_surface_unset_fullscreen(struct xdg_surface *xdg_surface)
{
wl_proxy_marshal((struct wl_proxy *) xdg_surface,
- XDG_SURFACE_ACK_CHANGE_STATE, state_type, value, serial);
+ XDG_SURFACE_UNSET_FULLSCREEN);
}
static inline void
&wl_surface_interface,
&wl_seat_interface,
NULL,
+ NULL,
+ NULL,
+ &wl_seat_interface,
+ NULL,
&wl_seat_interface,
NULL,
NULL,
static const struct wl_message xdg_surface_requests[] = {
{ "destroy", "", types + 0 },
- { "set_transient_for", "?o", types + 14 },
- { "set_margin", "iiii", types + 0 },
+ { "set_parent", "?o", types + 14 },
{ "set_title", "s", types + 0 },
{ "set_app_id", "s", types + 0 },
- { "move", "ou", types + 15 },
- { "resize", "ouu", types + 17 },
- { "set_output", "?o", types + 20 },
- { "request_change_state", "uuu", types + 0 },
- { "ack_change_state", "uuu", types + 0 },
+ { "show_window_menu", "ouii", types + 15 },
+ { "move", "ou", types + 19 },
+ { "resize", "ouu", types + 21 },
+ { "ack_configure", "u", types + 0 },
+ { "set_window_geometry", "iiii", types + 0 },
+ { "set_maximized", "", types + 0 },
+ { "unset_maximized", "", types + 0 },
+ { "set_fullscreen", "?o", types + 24 },
+ { "unset_fullscreen", "", types + 0 },
{ "set_minimized", "", types + 0 },
};
static const struct wl_message xdg_surface_events[] = {
- { "configure", "ii", types + 0 },
- { "change_state", "uuu", types + 0 },
- { "activated", "", types + 0 },
- { "deactivated", "", types + 0 },
+ { "configure", "iiau", types + 0 },
{ "close", "", types + 0 },
};
WL_EXPORT const struct wl_interface xdg_surface_interface = {
"xdg_surface", 1,
- 11, xdg_surface_requests,
- 5, xdg_surface_events,
+ 14, xdg_surface_requests,
+ 2, xdg_surface_events,
};
static const struct wl_message xdg_popup_requests[] = {
static const xdg_surface_listener xdg_surface_listener = {
XDGShellSurface::HandleConfigure,
- XDGShellSurface::HandleChangeState,
- XDGShellSurface::HandleActivate,
- XDGShellSurface::HandleDeactivate,
XDGShellSurface::HandleDelete
};
switch (type) {
case WaylandWindow::TOPLEVEL: {
if (maximized_) {
- xdg_surface_request_change_state(xdg_surface_,
- XDG_SURFACE_STATE_MAXIMIZED,
- false, 0);
+ xdg_surface_unset_maximized(xdg_surface_);
maximized_ = false;
}
break;
break;
}
case WaylandWindow::FULLSCREEN:
- xdg_surface_request_change_state(xdg_surface_,
- XDG_SURFACE_STATE_FULLSCREEN,
- true, 0);
+ xdg_surface_set_fullscreen(xdg_surface_,
+ NULL);
break;
case WaylandWindow::CUSTOM:
NOTREACHED() << "Unsupported shell type: " << type;
}
void XDGShellSurface::Maximize() {
- xdg_surface_request_change_state(xdg_surface_,
- XDG_SURFACE_STATE_MAXIMIZED,
- true, 0);
+ xdg_surface_set_maximized(xdg_surface_);
maximized_ = true;
WaylandShellSurface::FlushDisplay();
}
void XDGShellSurface::Unminimize() {
minimized_ = false;
+ //xdg_surface_needs_attention(xdg_surface_);
}
bool XDGShellSurface::IsMinimized() const {
}
void XDGShellSurface::HandleConfigure(void* data,
- struct xdg_surface* xdg_surface,
- int32_t width,
- int32_t height) {
- WaylandShellSurface::WindowResized(data, width, height);
-}
-
-void XDGShellSurface::HandleChangeState(void* data,
- struct xdg_surface* xdg_surface,
- uint32_t state,
- uint32_t value,
- uint32_t serial) {
- xdg_surface_ack_change_state(xdg_surface, state, value, serial);
-}
+ struct xdg_surface* xdg_surface,
+ int32_t width,
+ int32_t height,
+ struct wl_array* states,
+ uint32_t serial) {
+ uint32_t* state;
+
+ for (state = (uint32_t*)(states)->data;
+ (const char*)state < ((const char*)(states)->data + (states)->size);
+ state++)
+ {
+ if (*state == XDG_SURFACE_STATE_ACTIVATED)
+ WaylandShellSurface::WindowActivated(data);
+ }
-void XDGShellSurface::HandleActivate(void* data,
- struct xdg_surface* xdg_surface) {
- WaylandShellSurface::WindowActivated(data);
-}
+ if ((width > 0) && (height > 0))
+ WaylandShellSurface::WindowResized(data, width, height);
-void XDGShellSurface::HandleDeactivate(void* data,
- struct xdg_surface* xdg_surface) {
- WaylandShellSurface::WindowDeActivated(data);
+ xdg_surface_ack_configure(xdg_surface, serial);
}
void XDGShellSurface::HandleDelete(void* data,