From 0f1944c66f8acace4f7eee9d83734b50df42889e Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Sun, 9 Feb 2014 11:39:01 -0500 Subject: xdg-shell: Update to latest state change mechanism --- gdk/wayland/gdkwindow-wayland.c | 84 +++++++++----------- gdk/wayland/protocol/xdg-shell.xml | 156 ++++++++++++++++--------------------- 2 files changed, 103 insertions(+), 137 deletions(-) diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c index b0772b51ea..f1156c3c40 100644 --- a/gdk/wayland/gdkwindow-wayland.c +++ b/gdk/wayland/gdkwindow-wayland.c @@ -107,7 +107,6 @@ struct _GdkWindowImplWayland struct gtk_surface *gtk_surface; unsigned int mapped : 1; - unsigned int fullscreen : 1; unsigned int use_custom_surface : 1; unsigned int pending_commit : 1; GdkWindowTypeHint hint; @@ -943,35 +942,31 @@ xdg_surface_configure (void *data, } static void -xdg_surface_request_set_fullscreen (void *data, - struct xdg_surface *xdg_surface) +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); - gdk_window_fullscreen (window); -} - -static void -xdg_surface_request_unset_fullscreen (void *data, - struct xdg_surface *xdg_surface) -{ - GdkWindow *window = GDK_WINDOW (data); - gdk_window_unfullscreen (window); -} -static void -xdg_surface_request_set_maximized (void *data, - struct xdg_surface *xdg_surface) -{ - GdkWindow *window = GDK_WINDOW (data); - gdk_window_maximize (window); -} + switch (state_type) + { + case XDG_SURFACE_STATE_TYPE_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_TYPE_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_request_unset_maximized (void *data, - struct xdg_surface *xdg_surface) -{ - GdkWindow *window = GDK_WINDOW (data); - gdk_window_unmaximize (window); + xdg_surface_ack_change_state (xdg_surface, state_type, value, serial); } static void @@ -1010,10 +1005,7 @@ xdg_surface_delete (void *data, static const struct xdg_surface_listener xdg_surface_listener = { xdg_surface_configure, - xdg_surface_request_set_fullscreen, - xdg_surface_request_unset_fullscreen, - xdg_surface_request_set_maximized, - xdg_surface_request_unset_maximized, + xdg_surface_change_state, xdg_surface_activated, xdg_surface_deactivated, xdg_surface_delete, @@ -1732,8 +1724,10 @@ gdk_wayland_window_maximize (GdkWindow *window) if (!impl->xdg_surface) return; - xdg_surface_set_maximized (impl->xdg_surface); - gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_MAXIMIZED); + xdg_surface_request_change_state (impl->xdg_surface, + XDG_SURFACE_STATE_TYPE_MAXIMIZED, + TRUE, + 0 /* serial, unused */); } static void @@ -1747,8 +1741,10 @@ gdk_wayland_window_unmaximize (GdkWindow *window) if (!impl->xdg_surface) return; - xdg_surface_unset_maximized (impl->xdg_surface); - gdk_synthesize_window_state (window, GDK_WINDOW_STATE_MAXIMIZED, 0); + xdg_surface_request_change_state (impl->xdg_surface, + XDG_SURFACE_STATE_TYPE_MAXIMIZED, + FALSE, + 0 /* serial, unused */); } static void @@ -1759,15 +1755,13 @@ gdk_wayland_window_fullscreen (GdkWindow *window) if (GDK_WINDOW_DESTROYED (window)) return; - if (impl->fullscreen) - return; - if (!impl->xdg_surface) return; - xdg_surface_set_fullscreen (impl->xdg_surface); - impl->fullscreen = TRUE; - gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN); + xdg_surface_request_change_state (impl->xdg_surface, + XDG_SURFACE_STATE_TYPE_FULLSCREEN, + TRUE, + 0 /* serial, unused */); } static void @@ -1778,15 +1772,13 @@ gdk_wayland_window_unfullscreen (GdkWindow *window) if (GDK_WINDOW_DESTROYED (window)) return; - if (!impl->fullscreen) - return; - if (!impl->xdg_surface) return; - xdg_surface_unset_fullscreen (impl->xdg_surface); - impl->fullscreen = FALSE; - gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FULLSCREEN, 0); + xdg_surface_request_change_state (impl->xdg_surface, + XDG_SURFACE_STATE_TYPE_FULLSCREEN, + FALSE, + 0 /* serial, unused */); } static void diff --git a/gdk/wayland/protocol/xdg-shell.xml b/gdk/wayland/protocol/xdg-shell.xml index 4a1d08aba5..ad525afe45 100644 --- a/gdk/wayland/protocol/xdg-shell.xml +++ b/gdk/wayland/protocol/xdg-shell.xml @@ -275,113 +275,87 @@ - - - Event sent from the compositor to the client requesting that the client - goes to a fullscreen state. It's the client job to call set_fullscreen - and really trigger the fullscreen state. + + + 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. + + 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 - - - - - Event sent from the compositor to the client requesting that the client - leaves the fullscreen state. It's the client job to call - unset_fullscreen and really leave the fullscreen state. - - - - - - 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. - - + + A non-zero value indicates the surface is maximized. Otherwise, + the surface is unmaximized. + + + A non-zero value indicates the surface is fullscreen. Otherwise, + the surface is not fullscreen. + + - - - Unset the surface fullscreen state. + + + 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. - Same negotiation as set_fullscreen must be used. + 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. + - - - Event sent from the compositor to the client requesting that the client - goes to a maximized state. It's the client job to call set_maximized - and really trigger the maximized 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 + guarantee that the compositor knows that the client has seen it. - - - - Event sent from the compositor to the client requesting that the client - leaves the maximized state. It's the client job to call unset_maximized - and really leave the maximized state. - + + + - - - Set the surface as maximized. - - 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. + + + When a change_state event is received, a client should then ack it + using the ack_change_state request to ensure that the compositor + knows the client has seen the event. - 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. + By this point, the state is confirmed, and the next attach should + contain the buffer drawn for the new state value. - Setting one state won't unset another state. Use - xdg_surface.unset_maximized for unsetting it. - - - - - - Unset the surface maximized state. - - Same negotiation as set_maximized must be used. + The values here need to be the same as the values in the cooresponding + change_state event. + + + - - Set the surface minimized state. - - Setting one state won't unset another state. + + Minimize the surface. -- cgit v1.2.1