/*
* Copyright © 2010 Intel Corporation
+ * Copyright © 2011 Collabora, Ltd.
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
#include <stdlib.h>
#include <stdio.h>
+#include <stdbool.h>
#include <string.h>
#include <unistd.h>
#include <linux/input.h>
struct {
struct wlsc_process process;
struct wl_client *client;
+ struct wl_resource *desktop_shell;
} child;
+
+ bool locked;
+ bool prepare_event_sent;
};
struct wlsc_move_grab {
output->current->height);
}
+static void
+desktop_shell_set_lock_surface(struct wl_client *client,
+ struct wl_resource *resource,
+ struct wl_resource *surface_resource)
+{
+}
+
+static void
+desktop_shell_unlock(struct wl_client *client,
+ struct wl_resource *resource)
+{
+ struct wl_shell *shell = resource->data;
+
+ shell->locked = false;
+ shell->prepare_event_sent = false;
+}
+
static const struct desktop_shell_interface desktop_shell_implementation = {
desktop_shell_set_background,
- desktop_shell_set_panel
+ desktop_shell_set_panel,
+ desktop_shell_set_lock_surface,
+ desktop_shell_unlock
};
static void
}
static void
-lock(struct wlsc_shell *shell)
+lock(struct wlsc_shell *base)
{
+ struct wl_shell *shell = container_of(base, struct wl_shell, shell);
+
+ shell->locked = true;
+}
+
+static void
+unlock(struct wlsc_shell *base)
+{
+ struct wl_shell *shell = container_of(base, struct wl_shell, shell);
+
+ if (!shell->locked) {
+ wlsc_compositor_wake(shell->compositor);
+ return;
+ }
+
+ /* If desktop-shell client has gone away, unlock immediately. */
+ if (!shell->child.desktop_shell) {
+ shell->locked = false;
+ return;
+ }
+
+ if (shell->prepare_event_sent)
+ return;
+
+ wl_resource_post_event(shell->child.desktop_shell,
+ DESKTOP_SHELL_PREPARE_LOCK_SURFACE);
+ shell->prepare_event_sent = true;
}
static void
}
static void
+unbind_desktop_shell(struct wl_resource *resource)
+{
+ struct wl_shell *shell = resource->data;
+ shell->child.desktop_shell = NULL;
+ shell->prepare_event_sent = false;
+ free(resource);
+}
+
+static void
bind_desktop_shell(struct wl_client *client,
void *data, uint32_t version, uint32_t id)
{
&desktop_shell_implementation,
id, shell);
- if (client == shell->child.client)
+ if (client == shell->child.client) {
+ resource->destroy = unbind_desktop_shell;
+ shell->child.desktop_shell = resource;
return;
+ }
wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
"permission to bind desktop_shell denied");
shell->compositor = ec;
shell->shell.activate = activate;
shell->shell.lock = lock;
+ shell->shell.unlock = unlock;
shell->shell.map = map;
shell->shell.configure = configure;
shell->shell.set_selection_focus = wlsc_selection_set_focus;
<arg name="surface" type="object" interface="wl_surface"/>
</request>
+ <request name="set_lock_surface">
+ <arg name="surface" type="object" interface="wl_surface"/>
+ </request>
+
+ <request name="unlock"/>
+
<!-- We'll fold most of wl_shell into this interface and then
they'll share the configure event. -->
<event name="configure">
<arg name="height" type="int"/>
</event>
+ <!-- Tell the shell we want it to create and set the lock surface,
+ which is a GUI asking the user to unlock the screen. The lock
+ surface is announced with 'set_lock_surface'. Whether or not
+ the shell actually implements locking, it MUST send 'unlock'
+ request to let the normal desktop resume. -->
+ <event name="prepare_lock_surface"/>
</interface>
</protocol>