summaryrefslogtreecommitdiff
path: root/src/wayland
diff options
context:
space:
mode:
authorJasper St. Pierre <jstpierre@mecheye.net>2014-02-09 11:45:09 -0500
committerJasper St. Pierre <jstpierre@mecheye.net>2014-03-12 23:42:55 -0400
commitb37ad66e9dc674ff728966b30058aec3ea71c919 (patch)
tree27107a4544c7fb00d22ab925d1bfc34443aaf8d8 /src/wayland
parentc1f15348a5cd9768faa32373365cf2591280859d (diff)
downloadmutter-b37ad66e9dc674ff728966b30058aec3ea71c919.tar.gz
xdg-shell: Update for new state change mechanism
We're still not properly going through the request system. This will require a dense investigation of the code, but it will happen soon...
Diffstat (limited to 'src/wayland')
-rw-r--r--src/wayland/meta-wayland-surface.c132
-rw-r--r--src/wayland/meta-wayland-surface.h15
2 files changed, 87 insertions, 60 deletions
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index 14010a41e..71017cab5 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -336,22 +336,6 @@ toplevel_surface_commit (MetaWaylandSurface *surface,
if (pending->frame_extents_changed)
meta_window_set_custom_frame_extents (surface->window, &pending->frame_extents);
-
- if (pending->maximized.changed)
- {
- if (pending->maximized.value)
- meta_window_maximize (surface->window, META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL);
- else
- meta_window_unmaximize (surface->window, META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL);
- }
-
- if (pending->fullscreen.changed)
- {
- if (pending->fullscreen.value)
- meta_window_make_fullscreen (surface->window);
- else
- meta_window_unmake_fullscreen (surface->window);
- }
}
static void
@@ -377,8 +361,6 @@ double_buffered_state_init (MetaWaylandDoubleBufferedState *state)
wl_list_init (&state->frame_callback_list);
state->frame_extents_changed = FALSE;
- state->maximized.changed = FALSE;
- state->fullscreen.changed = FALSE;
}
static void
@@ -861,43 +843,44 @@ xdg_surface_set_output (struct wl_client *client,
}
static void
-xdg_surface_set_fullscreen (struct wl_client *client,
- struct wl_resource *resource)
+xdg_surface_request_change_state (struct wl_client *client,
+ struct wl_resource *resource,
+ uint32_t state_type,
+ uint32_t value,
+ uint32_t serial)
{
MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
- surface->pending.fullscreen.changed = TRUE;
- surface->pending.fullscreen.value = TRUE;
-}
+ surface->state_changed_serial = serial;
-static void
-xdg_surface_unset_fullscreen (struct wl_client *client,
- struct wl_resource *resource)
-{
- MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
-
- surface->pending.fullscreen.changed = TRUE;
- surface->pending.fullscreen.value = FALSE;
-}
-
-static void
-xdg_surface_set_maximized (struct wl_client *client,
- struct wl_resource *resource)
-{
- MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
-
- surface->pending.maximized.changed = TRUE;
- surface->pending.maximized.value = TRUE;
+ switch (state_type)
+ {
+ case XDG_SURFACE_STATE_MAXIMIZED:
+ if (value)
+ meta_window_maximize (surface->window, META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL);
+ else
+ meta_window_unmaximize (surface->window, META_MAXIMIZE_HORIZONTAL | META_MAXIMIZE_VERTICAL);
+ break;
+ case XDG_SURFACE_STATE_FULLSCREEN:
+ if (value)
+ meta_window_make_fullscreen (surface->window);
+ else
+ meta_window_unmake_fullscreen (surface->window);
+ }
}
static void
-xdg_surface_unset_maximized (struct wl_client *client,
- struct wl_resource *resource)
+xdg_surface_ack_change_state (struct wl_client *client,
+ struct wl_resource *resource,
+ uint32_t state_type,
+ uint32_t value,
+ uint32_t serial)
{
- MetaWaylandSurface *surface = wl_resource_get_user_data (resource);
-
- surface->pending.maximized.changed = TRUE;
- surface->pending.maximized.value = FALSE;
+ /* Do nothing for now. In the future, we'd imagine that
+ * we'd ignore attaches when we have a state pending that
+ * we haven't had the client ACK'd, to prevent a race
+ * condition when we have an in-flight attach when the
+ * client gets the new state. */
}
static void
@@ -918,10 +901,8 @@ static const struct xdg_surface_interface meta_wayland_xdg_surface_interface = {
xdg_surface_move,
xdg_surface_resize,
xdg_surface_set_output,
- xdg_surface_set_fullscreen,
- xdg_surface_unset_fullscreen,
- xdg_surface_set_maximized,
- xdg_surface_unset_maximized,
+ xdg_surface_request_change_state,
+ xdg_surface_ack_change_state,
xdg_surface_set_minimized,
};
@@ -1735,6 +1716,55 @@ meta_wayland_surface_configure_notify (MetaWaylandSurface *surface,
0, new_width, new_height);
}
+static void
+send_change_state (MetaWaylandSurface *surface,
+ uint32_t state_type,
+ uint32_t value)
+{
+ if (surface->xdg_surface.resource)
+ {
+ uint32_t serial;
+
+ if (surface->state_changed_serial != 0)
+ {
+ serial = surface->state_changed_serial;
+ surface->state_changed_serial = 0;
+ }
+ else
+ {
+ struct wl_client *client = wl_resource_get_client (surface->xdg_surface.resource);
+ struct wl_display *display = wl_client_get_display (client);
+ serial = wl_display_next_serial (display);
+ }
+
+ xdg_surface_send_change_state (surface->xdg_surface.resource, state_type, value, serial);
+ }
+}
+
+void
+meta_wayland_surface_send_maximized (MetaWaylandSurface *surface)
+{
+ send_change_state (surface, XDG_SURFACE_STATE_MAXIMIZED, TRUE);
+}
+
+void
+meta_wayland_surface_send_unmaximized (MetaWaylandSurface *surface)
+{
+ send_change_state (surface, XDG_SURFACE_STATE_MAXIMIZED, FALSE);
+}
+
+void
+meta_wayland_surface_send_fullscreened (MetaWaylandSurface *surface)
+{
+ send_change_state (surface, XDG_SURFACE_STATE_FULLSCREEN, TRUE);
+}
+
+void
+meta_wayland_surface_send_unfullscreened (MetaWaylandSurface *surface)
+{
+ send_change_state (surface, XDG_SURFACE_STATE_FULLSCREEN, FALSE);
+}
+
void
meta_wayland_surface_activated (MetaWaylandSurface *surface)
{
diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h
index ef9ccaa4f..e0886536e 100644
--- a/src/wayland/meta-wayland-surface.h
+++ b/src/wayland/meta-wayland-surface.h
@@ -43,12 +43,6 @@ struct _MetaWaylandBuffer
typedef struct
{
- guint changed : 1;
- guint value : 1;
-} MetaWaylandStateFlag;
-
-typedef struct
-{
/* wl_surface.attach */
gboolean newly_attached;
MetaWaylandBuffer *buffer;
@@ -67,9 +61,6 @@ typedef struct
gboolean frame_extents_changed;
GtkBorder frame_extents;
-
- MetaWaylandStateFlag fullscreen;
- MetaWaylandStateFlag maximized;
} MetaWaylandDoubleBufferedState;
typedef struct
@@ -107,6 +98,8 @@ struct _MetaWaylandSurface
GSList *pending_placement_ops;
} sub;
+ uint32_t state_changed_serial;
+
/* All the pending state, that wl_surface.commit will apply. */
MetaWaylandDoubleBufferedState pending;
};
@@ -124,6 +117,10 @@ void meta_wayland_surface_window_unmanaged (MetaWaylandSurface *s
void meta_wayland_surface_configure_notify (MetaWaylandSurface *surface,
int width,
int height);
+void meta_wayland_surface_send_maximized (MetaWaylandSurface *surface);
+void meta_wayland_surface_send_unmaximized (MetaWaylandSurface *surface);
+void meta_wayland_surface_send_fullscreened (MetaWaylandSurface *surface);
+void meta_wayland_surface_send_unfullscreened (MetaWaylandSurface *surface);
void meta_wayland_surface_activated (MetaWaylandSurface *surface);
void meta_wayland_surface_deactivated (MetaWaylandSurface *surface);