From 9b4668c82c2368ce9598a91756fd182859619466 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Fri, 11 Apr 2014 17:31:27 -0700 Subject: [PATCH] wayland: Update to latest xdg-shell protocol --- gdk/wayland/gdkwindow-wayland.c | 117 ++++++++++------------ gdk/wayland/protocol/xdg-shell.xml | 149 ++++++++++------------------- 2 files changed, 101 insertions(+), 165 deletions(-) diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c index b172ad639a..9a66ad069d 100644 --- a/gdk/wayland/gdkwindow-wayland.c +++ b/gdk/wayland/gdkwindow-wayland.c @@ -113,6 +113,8 @@ struct _GdkWindowImplWayland cairo_surface_t *cairo_surface; + int32_t next_attach_serial; + gchar *title; /* Time of most recent user interaction. */ @@ -520,6 +522,12 @@ gdk_wayland_window_attach_image (GdkWindow *window) if (GDK_WINDOW_DESTROYED (window)) 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 */ wl_surface_attach (impl->surface, _gdk_wayland_shm_surface_get_wl_buffer (impl->cairo_surface), @@ -800,63 +808,51 @@ static void xdg_surface_configure (void *data, struct xdg_surface *xdg_surface, int32_t width, - int32_t height) + int32_t height, + struct wl_array *states, + uint32_t serial) { GdkWindow *window = GDK_WINDOW (data); GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl); + GdkWindowState new_state = 0; + uint32_t *p; - gdk_window_constrain_size (&impl->geometry_hints, - impl->geometry_mask, - width, - height, - &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) + if (width > 0 && height > 0) { - 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; + gdk_window_constrain_size (&impl->geometry_hints, + impl->geometry_mask, + width, + height, + &width, + &height); + + gdk_wayland_window_configure (window, width, height); } - 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 -xdg_surface_activated (void *data, - 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); + _gdk_set_window_state (window, new_state); + impl->next_attach_serial = serial; } static void @@ -879,9 +875,6 @@ xdg_surface_close (void *data, static const struct xdg_surface_listener xdg_surface_listener = { xdg_surface_configure, - xdg_surface_change_state, - xdg_surface_activated, - xdg_surface_deactivated, xdg_surface_close, }; @@ -1612,10 +1605,7 @@ gdk_wayland_window_maximize (GdkWindow *window) if (!impl->xdg_surface) return; - xdg_surface_request_change_state (impl->xdg_surface, - XDG_SURFACE_STATE_MAXIMIZED, - TRUE, - 0 /* serial, unused */); + xdg_surface_set_maximized (impl->xdg_surface); } static void @@ -1629,10 +1619,7 @@ gdk_wayland_window_unmaximize (GdkWindow *window) if (!impl->xdg_surface) return; - xdg_surface_request_change_state (impl->xdg_surface, - XDG_SURFACE_STATE_MAXIMIZED, - FALSE, - 0 /* serial, unused */); + xdg_surface_unset_maximized (impl->xdg_surface); } static void @@ -1646,10 +1633,7 @@ gdk_wayland_window_fullscreen (GdkWindow *window) if (!impl->xdg_surface) return; - xdg_surface_request_change_state (impl->xdg_surface, - XDG_SURFACE_STATE_FULLSCREEN, - TRUE, - 0 /* serial, unused */); + xdg_surface_set_fullscreen (impl->xdg_surface, NULL); } static void @@ -1663,10 +1647,7 @@ gdk_wayland_window_unfullscreen (GdkWindow *window) if (!impl->xdg_surface) return; - xdg_surface_request_change_state (impl->xdg_surface, - XDG_SURFACE_STATE_FULLSCREEN, - FALSE, - 0 /* serial, unused */); + xdg_surface_unset_fullscreen (impl->xdg_surface); } static void diff --git a/gdk/wayland/protocol/xdg-shell.xml b/gdk/wayland/protocol/xdg-shell.xml index 7882693475..3c186102bb 100644 --- a/gdk/wayland/protocol/xdg-shell.xml +++ b/gdk/wayland/protocol/xdg-shell.xml @@ -241,40 +241,6 @@ - - - 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. - - - - - - - - - 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. - - - - The different state values used on the surface. This is designed for @@ -297,89 +263,78 @@ 0x1000 - 0x1FFF: GNOME - A non-zero value indicates the surface is maximized. Otherwise, - the surface is unmaximized. + The surface is maximized. The window geometry specified in the configure + event must be obeyed by the client. - A non-zero value indicates the surface is fullscreen. Otherwise, - the surface is not fullscreen. + The surface is fullscreen. The window geometry specified in the configure + event must be obeyed by the client. + + + 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. + + + 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. - - - This asks the compositor to change the state. If the compositor wants - 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. + + + The configure event asks the client to resize its surface. - If the compositor does not want to change the state, it will send a - change_state to the client with the old value of the state. - - - - - This serial is so the client can know which change_state event corresponds - to which request_change_state request it sent out. - - + The width and height arguments specify a hint to the window + about how its surface should be resized in surface local + coordinates. The states listed in the event specify how the + width/height arguments should be interpreted. - - - 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. + 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. + + 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. - - - + + + + - - - When a change_state event is received, a client should then ack it - using the ack_change_state request to ensure that the compositor + + + When a configure event is received, a client should then ack it + using the ack_configure request to ensure that the compositor knows the client has seen the event. By this point, the state is confirmed, and the next attach should - contain the buffer drawn for the new state value. - - The values here need to be the same as the values in the cooresponding - change_state event. + contain the buffer drawn for the configure event you are acking. - - - + - - - Minimize the surface. + + + + + + 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. + + - - - 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. - - - - - - 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. - - +