summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2011-06-12 17:14:48 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2011-06-12 17:14:48 +0800
commit026af775173e46a3a8acc2535e637502f605b326 (patch)
tree39be48af9d0e347624c11f4a53a76dbebb3a18cc
parent35ebebff37565c61a5b4c524002f247bb1553c50 (diff)
downloadcompositionkit-026af775173e46a3a8acc2535e637502f605b326.tar.gz
compositionkit-026af775173e46a3a8acc2535e637502f605b326.tar.bz2
Don't care about shells
-rw-r--r--CMakeLists.txt36
-rw-r--r--compositor/compositor-wayland.c21
-rw-r--r--compositor/compositor.c17
-rw-r--r--compositor/compositor.h10
-rw-r--r--compositor/meego-tablet-shell.c636
-rw-r--r--compositor/shell.c769
-rw-r--r--compositor/surface.c8
-rw-r--r--compositor/switcher.c131
8 files changed, 1 insertions, 1627 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c494f66..9a315b1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,7 +26,6 @@ option (BUILD_X11_COMPOSITOR "Build X11 Composition Backend" OFF)
option (BUILD_DRM_COMPOSITOR "Build DRM Composition Backend" OFF)
option (BUILD_WAYLAND_COMPOSITOR "Build Wayland Composition Backend" OFF)
option (BUILD_OPENWFD_COMPOSITOR "Build OpenWF Composition Backend" OFF)
-option (BUILD_DESKTOP_SHELL "Build Wayland Desktop Shell" OFF)
cmake_minimum_required(VERSION 2.8)
@@ -155,41 +154,6 @@ if (BUILD_WAYLAND_COMPOSITOR)
endif (BUILD_WAYLAND_COMPOSITOR)
-if (BUILD_DESKTOP_SHELL)
-
- pkg_check_modules (COMPOSITIONKIT_DESKTOP_SHELL wayland-client wayland-egl)
-
- if (COMPOSITIONKIT_DESKTOP_SHELL_FOUND)
-
- include_directories (${COMPOSITIONKIT_DESKTOP_SHELL_INCLUDE_DIRS} ${compositionkit_BINARY_DIR}/generated/)
- link_directories (${COMPOSITIONKIT_DESKTOP_SHELL_LIBRARY_DIRS})
- add_library (desktop-shell SHARED compositor/shell.c compositor/switcher.c)
- target_link_libraries (desktop-shell ${COMPOSITIONKIT_DESKTOP_SHELL_LIBRARIES})
-
- list (APPEND COMPOSITIONKIT_SHELLS "Desktop")
-
- else (COMPOSITIONKIT_DESKTOP_SHELL_FOUND)
-
- set (BUILD_DESKTOP_SHELL OFF)
-
- endif (COMPOSITIONKIT_DESKTOP_SHELL_FOUND)
-
-endif (BUILD_DESKTOP_SHELL)
-
-list (LENGTH COMPOSITIONKIT_SHELLS LENGTH_COMPOSITIONKIT_SHELLS)
-
-if (${LENGTH_COMPOSITIONKIT_SHELLS} EQUAL 0)
-
- message (FATAL_ERROR "At least one shell must be selected")
-
-else (${LENGTH_COMPOSITIONKIT_SHELLS} EQUAL 0)
-
- foreach (COMPOSITIONKIT_SHELL ${COMPOSITIONKIT_SHELLS})
- message ("Using shell: " ${COMPOSITIONKIT_SHELL})
- endforeach ()
-
-endif (${LENGTH_COMPOSITIONKIT_SHELLS} EQUAL 0)
-
list (LENGTH COMPOSITIONKIT_BACKENDS LENGTH_COMPOSITIONKIT_BACKENDS)
if (${LENGTH_COMPOSITIONKIT_BACKENDS} EQUAL 0)
diff --git a/compositor/compositor-wayland.c b/compositor/compositor-wayland.c
index 6cd02ed..0ac7178 100644
--- a/compositor/compositor-wayland.c
+++ b/compositor/compositor-wayland.c
@@ -44,7 +44,6 @@ struct wayland_compositor {
struct {
struct wl_display *display;
struct wl_compositor *compositor;
- struct wl_shell *shell;
struct wl_output *output;
struct {
@@ -299,23 +298,6 @@ static const struct wl_output_listener output_listener = {
display_handle_geometry,
};
-/* parent shell interface */
-static void
-handle_configure(void *data, struct wl_shell *shell,
- uint32_t time, uint32_t edges,
- struct wl_surface *surface, int32_t width, int32_t height)
-{
-#if 0
- struct output *output = wl_surface_get_user_data(surface);
-
- /* FIXME: add resize? */
-#endif
-}
-
-static const struct wl_shell_listener shell_listener = {
- handle_configure,
-};
-
/* parent input interface */
static void
input_handle_motion(void *data, struct wl_input_device *input_device,
@@ -429,9 +411,6 @@ display_handle_global(struct wl_display *display, uint32_t id,
wl_output_add_listener(c->parent.output, &output_listener, c);
} else if (strcmp(interface, "wl_input_device") == 0) {
display_add_input(c, id);
- } else if (strcmp(interface, "wl_shell") == 0) {
- c->parent.shell = wl_shell_create(display, id, 1);
- wl_shell_add_listener(c->parent.shell, &shell_listener, c);
}
}
diff --git a/compositor/compositor.c b/compositor/compositor.c
index 5d14ecc..6bb4106 100644
--- a/compositor/compositor.c
+++ b/compositor/compositor.c
@@ -327,13 +327,11 @@ int main(int argc, char *argv[])
struct wlsc_compositor *ec;
struct wl_event_loop *loop;
int o;
- void *shell_module, *backend_module;
- int (*shell_init)(struct wlsc_compositor *ec);
+ void *backend_module;
struct wlsc_compositor
*(*backend_init)(struct wl_display *display, char *options);
char *backend = NULL;
char *backend_options = "";
- char *shell = NULL;
char *p;
static const char opts[] = "B:b:o:S:i:s:";
@@ -343,7 +341,6 @@ int main(int argc, char *argv[])
{ "background", 1, NULL, 'b' },
{ "socket", 1, NULL, 'S' },
{ "idle-time", 1, NULL, 'i' },
- { "shell", 1, NULL, 's' },
{ NULL, }
};
@@ -370,8 +367,6 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
break;
- case 's':
- shell = optarg;
break;
}
}
@@ -391,26 +386,16 @@ int main(int argc, char *argv[])
backend = "libdrm-backend.so";
}
- if (!shell)
- shell = "libdesktop-shell.so";
-
backend_init = load_module(backend, "backend_init", &backend_module);
if (!backend_init)
exit(EXIT_FAILURE);
- shell_init = load_module(shell, "shell_init", &shell_module);
- if (!shell_init)
- exit(EXIT_FAILURE);
-
ec = backend_init(display, backend_options);
if (ec == NULL) {
fprintf(stderr, "failed to create compositor\n");
exit(EXIT_FAILURE);
}
- if (shell_init(ec) < 0)
- exit(EXIT_FAILURE);
-
if (wl_display_add_socket(display, option_socket_name)) {
fprintf(stderr, "failed to add socket: %m\n");
exit(EXIT_FAILURE);
diff --git a/compositor/compositor.h b/compositor/compositor.h
index 343e93e..badfddc 100644
--- a/compositor/compositor.h
+++ b/compositor/compositor.h
@@ -137,14 +137,6 @@ struct wlsc_spring {
uint32_t timestamp;
};
-struct wlsc_shell {
- void (*lock)(struct wlsc_shell *shell);
- void (*attach)(struct wlsc_shell *shell, struct wlsc_surface *surface);
- void (*set_selection_focus)(struct wlsc_shell *shell,
- struct wl_selection *selection,
- struct wl_surface *surface, uint32_t time);
-};
-
enum {
WLSC_COMPOSITOR_ACTIVE,
WLSC_COMPOSITOR_SLEEPING
@@ -165,8 +157,6 @@ struct wlsc_compositor {
struct wlsc_shader solid_shader;
struct wl_display *wl_display;
- struct wlsc_shell *shell;
-
/* There can be more than one, but not right now... */
struct wl_input_device *input_device;
diff --git a/compositor/meego-tablet-shell.c b/compositor/meego-tablet-shell.c
deleted file mode 100644
index 5f6b764..0000000
--- a/compositor/meego-tablet-shell.c
+++ /dev/null
@@ -1,636 +0,0 @@
-/*
- * Copyright © 2011 Intel Corporation
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holders not be used in
- * advertising or publicity pertaining to distribution of the software
- * without specific, written prior permission. The copyright holders make
- * no representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
- * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sys/wait.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <fcntl.h>
-#include <linux/input.h>
-
-#include "compositor.h"
-#include "meego-tablet-server-protocol.h"
-
-/*
- * TODO: Don't fade back from black until we've received a lockscreen
- * attachment.
- */
-
-enum {
- STATE_STARTING,
- STATE_LOCKED,
- STATE_HOME,
- STATE_SWITCHER,
- STATE_TASK
-};
-
-struct meego_tablet_shell {
- struct wl_object object;
-
- struct wlsc_shell shell;
-
- struct wlsc_compositor *compositor;
- struct wl_event_source *sigchld_source;
- pid_t pid;
- struct wlsc_input_device *device;
- struct wl_client *client;
-
- struct wlsc_surface *surface;
-
- struct wlsc_surface *lockscreen_surface;
- struct wl_listener lockscreen_listener;
-
- struct wlsc_surface *home_surface;
-
- struct wlsc_surface *switcher_surface;
- struct wl_listener switcher_listener;
-
- struct meego_tablet_client *current_client;
-
- int state, previous_state;
- int long_press_active;
- struct wl_event_source *long_press_source;
-};
-
-struct meego_tablet_client {
- struct wl_resource resource;
- struct meego_tablet_shell *shell;
- struct wl_client *client;
- struct wlsc_surface *surface;
- char *name;
-};
-
-struct meego_tablet_zoom {
- struct wlsc_surface *surface;
- struct wlsc_animation animation;
- struct wlsc_spring spring;
- struct wlsc_transform transform;
- struct wl_listener listener;
-};
-
-static int
-sigchld_handler(int signal_number, void *data)
-{
- struct meego_tablet_shell *shell = data;
- int status;
-
- wait(&status);
- shell->pid = 0;
-
- fprintf(stderr, "meego-ux-daemon crashed, exit code %d\n", status);
-
- return 1;
-}
-
-static void
-meego_tablet_shell_set_state(struct meego_tablet_shell *shell, int state)
-{
- static const char *states[] = {
- "STARTING", "LOCKED", "HOME", "SWITCHER", "TASK"
- };
-
- fprintf(stderr, "switching to state %s (from %s)\n",
- states[state], states[shell->state]);
- shell->previous_state = shell->state;
- shell->state = state;
-}
-
-static void
-handle_zoom_surface_destroy(struct wl_listener *listener,
- struct wl_resource *resource, uint32_t time)
-{
- struct meego_tablet_zoom *zoom =
- container_of(listener, struct meego_tablet_zoom, listener);
-
- wl_list_remove(&zoom->animation.link);
- fprintf(stderr, "animation surface gone\n");
- free(zoom);
-}
-
-static void
-meego_tablet_zoom_frame(struct wlsc_animation *animation,
- struct wlsc_output *output, uint32_t msecs)
-{
- struct meego_tablet_zoom *zoom =
- container_of(animation, struct meego_tablet_zoom, animation);
- struct wlsc_surface *es = zoom->surface;
- GLfloat scale;
-
- wlsc_spring_update(&zoom->spring, msecs);
-
- if (wlsc_spring_done(&zoom->spring)) {
- wl_list_remove(&animation->link);
- fprintf(stderr, "animation done\n");
- es->transform = NULL;
- free(zoom);
- }
-
- scale = zoom->spring.current;
- wlsc_matrix_init(&zoom->transform.matrix);
- wlsc_matrix_translate(&zoom->transform.matrix,
- -es->width / 2.0, -es->height / 2.0, 0);
- wlsc_matrix_scale(&zoom->transform.matrix, scale, scale, scale);
- wlsc_matrix_translate(&zoom->transform.matrix,
- es->width / 2.0, es->height / 2.0, 0);
-
- scale = 1.0 / zoom->spring.current;
- wlsc_matrix_init(&zoom->transform.inverse);
- wlsc_matrix_scale(&zoom->transform.inverse, scale, scale, scale);
-
- wlsc_surface_damage(es);
-}
-
-static void
-meego_tablet_zoom_run(struct meego_tablet_shell *shell,
- struct wlsc_surface *surface)
-{
- struct meego_tablet_zoom *zoom;
- GLfloat scale;
-
- fprintf(stderr, "starting animation for surface %p\n", surface);
-
- zoom = malloc(sizeof *zoom);
- if (!zoom)
- return;
-
- zoom->surface = surface;
- surface->transform = &zoom->transform;
- scale = 0.3;
- wlsc_spring_init(&zoom->spring, 100.0, scale, 1.0);
- zoom->spring.timestamp = wlsc_compositor_get_time();
- zoom->animation.frame = meego_tablet_zoom_frame;
- meego_tablet_zoom_frame(&zoom->animation, NULL,
- zoom->spring.timestamp);
-
- zoom->listener.func = handle_zoom_surface_destroy;
- wl_list_insert(surface->surface.resource.destroy_listener_list.prev,
- &zoom->listener.link);
-
- wl_list_insert(shell->compositor->animation_list.prev,
- &zoom->animation.link);
-}
-
-/* FIXME: We should be handling map, not attach... Map is when the
- * surface becomes visible, which is what we want to catch. Attach
- * will happen whenever the surface changes. */
-
-static void
-meego_tablet_shell_attach(struct wlsc_shell *base,
- struct wlsc_surface *surface)
-{
- struct meego_tablet_shell *shell =
- container_of(base, struct meego_tablet_shell, shell);
-
- surface->x = 0;
- surface->y = 0;
-
- if (surface == shell->lockscreen_surface) {
- wlsc_compositor_fade(shell->compositor, 0.0);
- wlsc_compositor_wake(shell->compositor);
- } else if (surface == shell->switcher_surface) {
- /* */
- } else if (surface == shell->home_surface) {
- if (shell->state == STATE_STARTING) {
- meego_tablet_shell_set_state(shell, STATE_LOCKED);
- shell->previous_state = STATE_HOME;
- wl_client_post_event(shell->client, &shell->object,
- MEEGO_TABLET_SHELL_SHOW_LOCKSCREEN);
- }
- } else if (shell->current_client &&
- shell->current_client->surface != surface &&
- shell->current_client->client == surface->surface.client) {
- meego_tablet_shell_set_state(shell, STATE_TASK);
- shell->current_client->surface = surface;
- meego_tablet_zoom_run(shell, surface);
- }
-}
-
-static void
-handle_lockscreen_surface_destroy(struct wl_listener *listener,
- struct wl_resource *resource, uint32_t time)
-{
- struct meego_tablet_shell *shell =
- container_of(listener,
- struct meego_tablet_shell, lockscreen_listener);
-
- shell->lockscreen_surface = NULL;
- meego_tablet_shell_set_state(shell, shell->previous_state);
-}
-
-static void
-tablet_shell_set_lockscreen(struct wl_client *client,
- struct meego_tablet_shell *shell,
- struct wl_surface *surface)
-{
- struct wlsc_surface *es = (struct wlsc_surface *) surface;
- struct wlsc_input_device *device =
- (struct wlsc_input_device *) shell->compositor->input_device;
-
- es->x = 0;
- es->y = 0;
- wlsc_surface_activate(es, device, wlsc_compositor_get_time());
- shell->lockscreen_surface = es;
-
- shell->lockscreen_listener.func = handle_lockscreen_surface_destroy;
- wl_list_insert(es->surface.resource.destroy_listener_list.prev,
- &shell->lockscreen_listener.link);
-}
-
-static void
-handle_switcher_surface_destroy(struct wl_listener *listener,
- struct wl_resource *resource, uint32_t time)
-{
- struct meego_tablet_shell *shell =
- container_of(listener,
- struct meego_tablet_shell, switcher_listener);
-
- shell->switcher_surface = NULL;
- if (shell->state != STATE_LOCKED)
- meego_tablet_shell_set_state(shell, shell->previous_state);
-}
-
-static void
-tablet_shell_set_switcher(struct wl_client *client,
- struct meego_tablet_shell *shell,
- struct wl_surface *surface)
-{
- struct wlsc_input_device *device =
- (struct wlsc_input_device *) shell->compositor->input_device;
- struct wlsc_surface *es = (struct wlsc_surface *) surface;
-
- /* FIXME: Switcher should be centered and the compositor
- * should do the tinting of the background. With the cache
- * layer idea, we should be able to hit the framerate on the
- * fade/zoom in. */
- shell->switcher_surface = es;
- shell->switcher_surface->x = 0;
- shell->switcher_surface->y = 0;
-
- wlsc_surface_activate(es, device, wlsc_compositor_get_time());
-
- shell->switcher_listener.func = handle_switcher_surface_destroy;
- wl_list_insert(es->surface.resource.destroy_listener_list.prev,
- &shell->switcher_listener.link);
-}
-
-static void
-tablet_shell_set_homescreen(struct wl_client *client,
- struct meego_tablet_shell *shell,
- struct wl_surface *surface)
-{
- struct wlsc_input_device *device =
- (struct wlsc_input_device *) shell->compositor->input_device;
-
- shell->home_surface = (struct wlsc_surface *) surface;
- shell->home_surface->x = 0;
- shell->home_surface->y = 0;
-
- wlsc_surface_activate(shell->home_surface, device,
- wlsc_compositor_get_time());
-}
-
-static void
-meego_tablet_shell_switch_to(struct meego_tablet_shell *shell,
- struct wlsc_surface *surface)
-{
- struct wlsc_compositor *compositor = shell->compositor;
- struct wlsc_input_device *device =
- (struct wlsc_input_device *) compositor->input_device;
-
- wlsc_surface_activate(surface, device, wlsc_compositor_get_time());
-
- if (shell->state == STATE_SWITCHER) {
- wl_list_remove(&shell->switcher_listener.link);
- shell->switcher_surface = NULL;
- };
-
- if (surface == shell->home_surface)
- meego_tablet_shell_set_state(shell, STATE_HOME);
- else
- meego_tablet_shell_set_state(shell, STATE_TASK);
-}
-
-static void
-tablet_shell_show_grid(struct wl_client *client,
- struct meego_tablet_shell *shell,
- struct wl_surface *surface)
-{
- meego_tablet_shell_switch_to(shell, (struct wlsc_surface *) surface);
-}
-
-static void
-tablet_shell_show_panels(struct wl_client *client,
- struct meego_tablet_shell *shell,
- struct wl_surface *surface)
-{
- meego_tablet_shell_switch_to(shell, (struct wlsc_surface *) surface);
-}
-
-static void
-destroy_tablet_client(struct wl_resource *resource, struct wl_client *client)
-{
- struct meego_tablet_client *tablet_client =
- container_of(resource, struct meego_tablet_client, resource);
-
- free(tablet_client->name);
- free(tablet_client);
-}
-
-static void
-tablet_client_destroy(struct wl_client *client,
- struct meego_tablet_client *tablet_client)
-{
- wl_resource_destroy(&tablet_client->resource,
- client, wlsc_compositor_get_time());
-}
-
-static void
-tablet_client_activate(struct wl_client *client,
- struct meego_tablet_client *tablet_client)
-{
- struct meego_tablet_shell *shell = tablet_client->shell;
-
- shell->current_client = tablet_client;
- if (!tablet_client->surface)
- return;
-
- meego_tablet_shell_switch_to(shell, tablet_client->surface);
-}
-
-static const struct meego_tablet_client_interface tablet_client_interface = {
- tablet_client_destroy,
- tablet_client_activate
-};
-
-static void
-tablet_shell_create_client(struct wl_client *client,
- struct meego_tablet_shell *shell,
- uint32_t id, const char *name, int fd)
-{
- struct wlsc_compositor *compositor = shell->compositor;
- struct meego_tablet_client *tablet_client;
-
- tablet_client = malloc(sizeof *tablet_client);
- if (tablet_client == NULL) {
- wl_client_post_no_memory(client);
- return;
- }
-
- tablet_client->client = wl_client_create(compositor->wl_display, fd);
- tablet_client->shell = shell;
- tablet_client->name = strdup(name);
-
- tablet_client->resource.destroy = destroy_tablet_client;
- tablet_client->resource.object.id = id;
- tablet_client->resource.object.interface =
- &meego_tablet_client_interface;
- tablet_client->resource.object.implementation =
- (void (**)(void)) &tablet_client_interface;
-
- wl_client_add_resource(client, &tablet_client->resource);
- tablet_client->surface = NULL;
- shell->current_client = tablet_client;
-
- fprintf(stderr, "created client %p, id %d, name %s, fd %d\n",
- tablet_client->client, id, name, fd);
-}
-
-static const struct meego_tablet_shell_interface tablet_shell_interface = {
- tablet_shell_set_lockscreen,
- tablet_shell_set_switcher,
- tablet_shell_set_homescreen,
- tablet_shell_show_grid,
- tablet_shell_show_panels,
- tablet_shell_create_client
-};
-
-static void
-launch_ux_daemon(struct meego_tablet_shell *shell)
-{
- struct wlsc_compositor *compositor = shell->compositor;
- char s[32];
- int sv[2], flags;
-
- if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sv) < 0) {
- fprintf(stderr, "socketpair failed\n");
- return;
- }
-
- shell->pid = fork();
- switch (shell->pid) {
- case 0:
- /* SOCK_CLOEXEC closes both ends, so we need to unset
- * the flag on the client fd. */
- flags = fcntl(sv[1], F_GETFD);
- if (flags != -1)
- fcntl(sv[1], F_SETFD, flags & ~FD_CLOEXEC);
-
- snprintf(s, sizeof s, "%d", sv[1]);
- setenv("WAYLAND_SOCKET", s, 1);
- setenv("EGL_PLATFORM", "wayland", 1);
- setenv("QT_QPA_PLATFORM", "waylandgl", 1);
- if (execl("/usr/libexec/meego-ux-daemon",
- "/usr/libexec/meego-ux-daemon", NULL) < 0)
- fprintf(stderr, "exec failed: %m\n");
- exit(-1);
-
- default:
- close(sv[1]);
- shell->client =
- wl_client_create(compositor->wl_display, sv[0]);
- break;
-
- case -1:
- fprintf(stderr, "failed to fork\n");
- break;
- }
-}
-
-static void
-toggle_switcher(struct meego_tablet_shell *shell)
-{
- switch (shell->state) {
- case STATE_SWITCHER:
- wl_client_post_event(shell->client, &shell->object,
- MEEGO_TABLET_SHELL_HIDE_SWITCHER);
- break;
- default:
- wl_client_post_event(shell->client, &shell->object,
- MEEGO_TABLET_SHELL_SHOW_SWITCHER);
- meego_tablet_shell_set_state(shell, STATE_SWITCHER);
- break;
- }
-}
-
-static void
-meego_tablet_shell_lock(struct wlsc_shell *base)
-{
- struct meego_tablet_shell *shell =
- container_of(base, struct meego_tablet_shell, shell);
-
- if (shell->state == STATE_LOCKED)
- return;
- if (shell->state == STATE_SWITCHER)
- wl_client_post_event(shell->client, &shell->object,
- MEEGO_TABLET_SHELL_HIDE_SWITCHER);
-
- wl_client_post_event(shell->client, &shell->object,
- MEEGO_TABLET_SHELL_SHOW_LOCKSCREEN);
-
- meego_tablet_shell_set_state(shell, STATE_LOCKED);
-}
-
-static void
-go_home(struct meego_tablet_shell *shell)
-{
- struct wlsc_input_device *device =
- (struct wlsc_input_device *) shell->compositor->input_device;
-
- if (shell->state == STATE_SWITCHER)
- wl_client_post_event(shell->client, &shell->object,
- MEEGO_TABLET_SHELL_HIDE_SWITCHER);
-
- wlsc_surface_activate(shell->home_surface, device,
- wlsc_compositor_get_time());
-
- meego_tablet_shell_set_state(shell, STATE_HOME);
-}
-
-static int
-long_press_handler(void *data)
-{
- struct meego_tablet_shell *shell = data;
-
- shell->long_press_active = 0;
- toggle_switcher(shell);
-
- return 1;
-}
-
-static void
-menu_key_binding(struct wl_input_device *device, uint32_t time,
- uint32_t key, uint32_t button, uint32_t state, void *data)
-{
- struct meego_tablet_shell *shell = data;
-
- if (shell->state == STATE_LOCKED)
- return;
-
- if (state)
- toggle_switcher(shell);
-}
-
-static void
-home_key_binding(struct wl_input_device *device, uint32_t time,
- uint32_t key, uint32_t button, uint32_t state, void *data)
-{
- struct meego_tablet_shell *shell = data;
-
- if (shell->state == STATE_LOCKED)
- return;
-
- shell->device = (struct wlsc_input_device *) device;
-
- if (state) {
- wl_event_source_timer_update(shell->long_press_source, 500);
- shell->long_press_active = 1;
- } else if (shell->long_press_active) {
- wl_event_source_timer_update(shell->long_press_source, 0);
- shell->long_press_active = 0;
-
- switch (shell->state) {
- case STATE_HOME:
- case STATE_SWITCHER:
- toggle_switcher(shell);
- break;
- default:
- go_home(shell);
- break;
- }
- }
-}
-
-static void
-meego_tablet_shell_set_selection_focus(struct wlsc_shell *shell,
- struct wl_selection *selection,
- struct wl_surface *surface,
- uint32_t time)
-{
-}
-
-void
-shell_init(struct wlsc_compositor *compositor);
-
-WL_EXPORT void
-shell_init(struct wlsc_compositor *compositor)
-{
- struct meego_tablet_shell *shell;
- struct wl_event_loop *loop;
-
- shell = malloc(sizeof *shell);
- if (shell == NULL)
- return;
-
- memset(shell, 0, sizeof *shell);
- shell->compositor = compositor;
-
- shell->object.interface = &meego_tablet_shell_interface;
- shell->object.implementation =
- (void (**)(void)) &tablet_shell_interface;
- wl_display_add_object(compositor->wl_display, &shell->object);
-
- /* FIXME: This will make the object available to all clients. */
- wl_display_add_global(compositor->wl_display, &shell->object, NULL);
-
- loop = wl_display_get_event_loop(compositor->wl_display);
- shell->sigchld_source =
- wl_event_loop_add_signal(loop, SIGCHLD,
- sigchld_handler, shell);
-
- shell->long_press_source =
- wl_event_loop_add_timer(loop, long_press_handler, shell);
-
- wlsc_compositor_add_binding(compositor, KEY_LEFTMETA, 0, 0,
- home_key_binding, shell);
- wlsc_compositor_add_binding(compositor, KEY_RIGHTMETA, 0, 0,
- home_key_binding, shell);
- wlsc_compositor_add_binding(compositor, KEY_LEFTMETA, 0,
- MODIFIER_SUPER, home_key_binding, shell);
- wlsc_compositor_add_binding(compositor, KEY_RIGHTMETA, 0,
- MODIFIER_SUPER, home_key_binding, shell);
- wlsc_compositor_add_binding(compositor, KEY_COMPOSE, 0, 0,
- menu_key_binding, shell);
-
- compositor->shell = &shell->shell;
-
- shell->shell.lock = meego_tablet_shell_lock;
- shell->shell.attach = meego_tablet_shell_attach;
- shell->shell.set_selection_focus =
- meego_tablet_shell_set_selection_focus;
- launch_ux_daemon(shell);
-
- wlsc_spring_init(&compositor->fade.spring, 40.0, 1.0, 1.0);
- meego_tablet_shell_set_state(shell, STATE_STARTING);
-}
diff --git a/compositor/shell.c b/compositor/shell.c
deleted file mode 100644
index 7c2c85f..0000000
--- a/compositor/shell.c
+++ /dev/null
@@ -1,769 +0,0 @@
-/*
- * Copyright © 2010 Intel Corporation
- *
- * Permission to use, copy, modify, distribute, and sell this software and
- * its documentation for any purpose is hereby granted without fee, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of the copyright holders not be used in
- * advertising or publicity pertaining to distribution of the software
- * without specific, written prior permission. The copyright holders make
- * no representations about the suitability of this software for any
- * purpose. It is provided "as is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
- * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
- * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
- * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <linux/input.h>
-
-#include "wayland-server.h"
-#include "compositor.h"
-
-struct wl_shell {
- struct wl_object object;
- struct wlsc_shell shell;
-};
-
-struct wlsc_move_grab {
- struct wl_grab grab;
- struct wlsc_surface *surface;
- int32_t dx, dy;
-};
-
-static void
-move_grab_motion(struct wl_grab *grab,
- uint32_t time, int32_t x, int32_t y)
-{
- struct wlsc_move_grab *move = (struct wlsc_move_grab *) grab;
- struct wlsc_surface *es = move->surface;
-
- wlsc_surface_damage_surface (es);
- es->x = x + move->dx;
- es->y = y + move->dy;
- wlsc_surface_assign_output(es);
- wlsc_surface_damage_surface (es);
-}
-
-static void
-move_grab_button(struct wl_grab *grab,
- uint32_t time, int32_t button, int32_t state)
-{
-}
-
-static void
-move_grab_end(struct wl_grab *grab, uint32_t time)
-{
- struct wlsc_surface *es;
- struct wl_input_device *device = grab->input_device;
- int32_t sx, sy;
-
- es = pick_surface(grab->input_device, &sx, &sy);
- wl_input_device_set_pointer_focus(device,
- &es->surface, time,
- device->x, device->y, sx, sy);
- free(grab);
-}
-
-static const struct wl_grab_interface move_grab_interface = {
- move_grab_motion,
- move_grab_button,
- move_grab_end
-};
-
-static void
-shell_move(struct wl_client *client, struct wl_shell *shell,
- struct wl_surface *surface,
- struct wl_input_device *device, uint32_t time)
-{
- struct wlsc_input_device *wd = (struct wlsc_input_device *) device;
- struct wlsc_surface *es = (struct wlsc_surface *) surface;
- struct wlsc_move_grab *move;
-
- /* FIXME: Reject if fullscreen */
-
- move = malloc(sizeof *move);
- if (!move) {
- wl_client_post_no_memory(client);
- return;
- }
-
- move->grab.interface = &move_grab_interface;
- move->dx = es->x - wd->input_device.grab_x;
- move->dy = es->y - wd->input_device.grab_y;
- move->surface = es;
-
- if (wl_input_device_update_grab(&wd->input_device,
- &move->grab, surface, time) < 0)
- return;
-
- wlsc_input_device_set_pointer_image(wd, WLSC_POINTER_DRAGGING);
- wl_input_device_set_pointer_focus(device, NULL, time, 0, 0, 0, 0);
-}
-
-struct wlsc_resize_grab {
- struct wl_grab grab;
- uint32_t edges;
- int32_t dx, dy, width, height;
- struct wlsc_surface *surface;
- struct wl_shell *shell;
-};
-
-static void
-resize_grab_motion(struct wl_grab *grab,
- uint32_t time, int32_t x, int32_t y)
-{
- struct wlsc_resize_grab *resize = (struct wlsc_resize_grab *) grab;
- struct wl_input_device *device = grab->input_device;
- struct wl_surface *surface = &resize->surface->surface;
- int32_t width, height;
-
- if (resize->edges & WL_SHELL_RESIZE_LEFT) {
- width = device->grab_x - x + resize->width;
- } else if (resize->edges & WL_SHELL_RESIZE_RIGHT) {
- width = x - device->grab_x + resize->width;
- } else {
- width = resize->width;
- }
-
- if (resize->edges & WL_SHELL_RESIZE_TOP) {
- height = device->grab_y - y + resize->height;
- } else if (resize->edges & WL_SHELL_RESIZE_BOTTOM) {
- height = y - device->grab_y + resize->height;
- } else {
- height = resize->height;
- }
-
- wl_client_post_event(surface->client, &resize->shell->object,
- WL_SHELL_CONFIGURE, time, resize->edges,
- surface, width, height);
-}
-
-static void
-resize_grab_button(struct wl_grab *grab,
- uint32_t time, int32_t button, int32_t state)
-{
-}
-
-static void
-resize_grab_end(struct wl_grab *grab, uint32_t time)
-{
- struct wlsc_surface *es;
- struct wl_input_device *device = grab->input_device;
- int32_t sx, sy;
-
- es = pick_surface(grab->input_device, &sx, &sy);
- wl_input_device_set_pointer_focus(device,
- &es->surface, time,
- device->x, device->y, sx, sy);
- free(grab);
-}
-
-static const struct wl_grab_interface resize_grab_interface = {
- resize_grab_motion,
- resize_grab_button,
- resize_grab_end
-};
-
-static void
-shell_resize(struct wl_client *client, struct wl_shell *shell,
- struct wl_surface *surface,
- struct wl_input_device *device, uint32_t time, uint32_t edges)
-{
- struct wlsc_input_device *wd = (struct wlsc_input_device *) device;
- struct wlsc_resize_grab *resize;
- enum wlsc_pointer_type pointer = WLSC_POINTER_LEFT_PTR;
- struct wlsc_surface *es = (struct wlsc_surface *) surface;
-
- /* FIXME: Reject if fullscreen */
-
- resize = malloc(sizeof *resize);
- if (!resize) {
- wl_client_post_no_memory(client);
- return;
- }
-
- resize->grab.interface = &resize_grab_interface;
- resize->edges = edges;
- resize->dx = es->x - wd->input_device.grab_x;
- resize->dy = es->y - wd->input_device.grab_y;
- resize->width = es->width;
- resize->height = es->height;
- resize->surface = es;
- resize->shell = shell;
-
- if (edges == 0 || edges > 15 ||
- (edges & 3) == 3 || (edges & 12) == 12)
- return;
-
- switch (edges) {
- case WL_SHELL_RESIZE_TOP:
- pointer = WLSC_POINTER_TOP;
- break;
- case WL_SHELL_RESIZE_BOTTOM:
- pointer = WLSC_POINTER_BOTTOM;
- break;
- case WL_SHELL_RESIZE_LEFT:
- pointer = WLSC_POINTER_LEFT;
- break;
- case WL_SHELL_RESIZE_TOP_LEFT:
- pointer = WLSC_POINTER_TOP_LEFT;
- break;
- case WL_SHELL_RESIZE_BOTTOM_LEFT:
- pointer = WLSC_POINTER_BOTTOM_LEFT;
- break;
- case WL_SHELL_RESIZE_RIGHT:
- pointer = WLSC_POINTER_RIGHT;
- break;
- case WL_SHELL_RESIZE_TOP_RIGHT:
- pointer = WLSC_POINTER_TOP_RIGHT;
- break;
- case WL_SHELL_RESIZE_BOTTOM_RIGHT:
- pointer = WLSC_POINTER_BOTTOM_RIGHT;
- break;
- }
-
- if (wl_input_device_update_grab(&wd->input_device,
- &resize->grab, surface, time) < 0)
- return;
-
- wlsc_input_device_set_pointer_image(wd, pointer);
- wl_input_device_set_pointer_focus(device, NULL, time, 0, 0, 0, 0);
-}
-
-static void
-destroy_drag(struct wl_resource *resource, struct wl_client *client)
-{
- struct wl_drag *drag =
- container_of(resource, struct wl_drag, resource);
-
- wl_list_remove(&drag->drag_focus_listener.link);
- if (drag->grab.input_device)
- wl_input_device_end_grab(drag->grab.input_device,
- wlsc_compositor_get_time());
-
- free(drag);
-}
-
-
-static void
-wl_drag_set_pointer_focus(struct wl_drag *drag,
- struct wl_surface *surface, uint32_t time,
- int32_t x, int32_t y, int32_t sx, int32_t sy)
-{
- char **p, **end;
-
- if (drag->drag_focus == surface)
- return;
-
- if (drag->drag_focus &&
- (!surface || drag->drag_focus->client != surface->client))
- wl_client_post_event(drag->drag_focus->client,
- &drag->drag_offer.object,
- WL_DRAG_OFFER_POINTER_FOCUS,
- time, NULL, 0, 0, 0, 0);
-
- if (surface &&
- (!drag->drag_focus ||
- drag->drag_focus->client != surface->client)) {
- wl_client_post_global(surface->client,
- &drag->drag_offer.object);
-
- end = drag->types.data + drag->types.size;
- for (p = drag->types.data; p < end; p++)
- wl_client_post_event(surface->client,
- &drag->drag_offer.object,
- WL_DRAG_OFFER_OFFER, *p);
- }
-
- if (surface) {
- wl_client_post_event(surface->client,
- &drag->drag_offer.object,
- WL_DRAG_OFFER_POINTER_FOCUS,
- time, surface,
- x, y, sx, sy);
-
- }
-
- drag->drag_focus = surface;
- drag->pointer_focus_time = time;
- drag->target = NULL;
-
- wl_list_remove(&drag->drag_focus_listener.link);
- if (surface)
- wl_list_insert(surface->resource.destroy_listener_list.prev,
- &drag->drag_focus_listener.link);
-}
-
-static void
-drag_offer_accept(struct wl_client *client,
- struct wl_drag_offer *offer, uint32_t time, const char *type)
-{
- struct wl_drag *drag = container_of(offer, struct wl_drag, drag_offer);
- char **p, **end;
-
- /* If the client responds to drag pointer_focus or motion
- * events after the pointer has left the surface, we just
- * discard the accept requests. The drag source just won't
- * get the corresponding 'target' events and eventually the
- * next surface/root will start sending events. */
- if (time < drag->pointer_focus_time)
- return;
-
- drag->target = client;
- drag->type = NULL;
- end = drag->types.data + drag->types.size;
- for (p = drag->types.data; p < end; p++)
- if (type && strcmp(*p, type) == 0)
- drag->type = *p;
-
- wl_client_post_event(drag->source->client, &drag->resource.object,
- WL_DRAG_TARGET, drag->type);
-}
-
-static void
-drag_offer_receive(struct wl_client *client,
- struct wl_drag_offer *offer, int fd)
-{
- struct wl_drag *drag = container_of(offer, struct wl_drag, drag_offer);
-
- wl_client_post_event(drag->source->client, &drag->resource.object,
- WL_DRAG_FINISH, fd);
- close(fd);
-}
-
-static void
-drag_offer_reject(struct wl_client *client, struct wl_drag_offer *offer)
-{
- struct wl_drag *drag = container_of(offer, struct wl_drag, drag_offer);
-
- wl_client_post_event(drag->source->client, &drag->resource.object,
- WL_DRAG_REJECT);
-}
-
-static const struct wl_drag_offer_interface drag_offer_interface = {
- drag_offer_accept,
- drag_offer_receive,
- drag_offer_reject
-};
-
-static void
-drag_offer(struct wl_client *client, struct wl_drag *drag, const char *type)
-{
- char **p;
-
- p = wl_array_add(&drag->types, sizeof *p);
- if (p)
- *p = strdup(type);
- if (!p || !*p)
- wl_client_post_no_memory(client);
-}
-
-static void
-drag_grab_motion(struct wl_grab *grab,
- uint32_t time, int32_t x, int32_t y)
-{
- struct wl_drag *drag = container_of(grab, struct wl_drag, grab);
- struct wlsc_surface *es;
- int32_t sx, sy;
-
- es = pick_surface(grab->input_device, &sx, &sy);
- wl_drag_set_pointer_focus(drag, &es->surface, time, x, y, sx, sy);
- if (es)
- wl_client_post_event(es->surface.client,
- &drag->drag_offer.object,
- WL_DRAG_OFFER_MOTION,
- time, x, y, sx, sy);
-}
-
-static void
-drag_grab_button(struct wl_grab *grab,
- uint32_t time, int32_t button, int32_t state)
-{
-}
-
-static void
-drag_grab_end(struct wl_grab *grab, uint32_t time)
-{
- struct wl_drag *drag = container_of(grab, struct wl_drag, grab);
- struct wlsc_surface *es;
- struct wl_input_device *device = grab->input_device;
- int32_t sx, sy;
-
- if (drag->target)
- wl_client_post_event(drag->target,
- &drag->drag_offer.object,
- WL_DRAG_OFFER_DROP);
-
- wl_drag_set_pointer_focus(drag, NULL, time, 0, 0, 0, 0);
-
- es = pick_surface(grab->input_device, &sx, &sy);
- wl_input_device_set_pointer_focus(device,
- &es->surface, time,
- device->x, device->y, sx, sy);
-}
-
-static const struct wl_grab_interface drag_grab_interface = {
- drag_grab_motion,
- drag_grab_button,
- drag_grab_end
-};
-
-static void
-drag_activate(struct wl_client *client,
- struct wl_drag *drag,
- struct wl_surface *surface,
- struct wl_input_device *device, uint32_t time)
-{
- struct wl_display *display = wl_client_get_display (client);
- struct wlsc_surface *target;
- int32_t sx, sy;
-
- if (wl_input_device_update_grab(device,
- &drag->grab, surface, time) < 0)
- return;
-
- drag->grab.interface = &drag_grab_interface;
-
- drag->source = surface;
-
- drag->drag_offer.object.interface = &wl_drag_offer_interface;
- drag->drag_offer.object.implementation =
- (void (**)(void)) &drag_offer_interface;
-
- wl_display_add_object(display, &drag->drag_offer.object);
-
- target = pick_surface(device, &sx, &sy);
- wl_input_device_set_pointer_focus(device, NULL, time, 0, 0, 0, 0);
- wl_drag_set_pointer_focus(drag, &target->surface, time,
- device->x, device->y, sx, sy);
-}
-
-static void
-drag_destroy(struct wl_client *client, struct wl_drag *drag)
-{
- wl_resource_destroy(&drag->resource, client,
- wlsc_compositor_get_time());
-}
-
-static const struct wl_drag_interface drag_interface = {
- drag_offer,
- drag_activate,
- drag_destroy,
-};
-
-static void
-drag_handle_surface_destroy(struct wl_listener *listener,
- struct wl_resource *resource, uint32_t time)
-{
- struct wl_drag *drag =
- container_of(listener, struct wl_drag, drag_focus_listener);
- struct wl_surface *surface = (struct wl_surface *) resource;
-
- if (drag->drag_focus == surface)
- wl_drag_set_pointer_focus(drag, NULL, time, 0, 0, 0, 0);
-}
-
-static void
-shell_create_drag(struct wl_client *client,
- struct wl_shell *shell, uint32_t id)
-{
- struct wl_drag *drag;
-
- drag = malloc(sizeof *drag);
- if (drag == NULL) {
- wl_client_post_no_memory(client);
- return;
- }
-
- memset(drag, 0, sizeof *drag);
- drag->resource.object.id = id;
- drag->resource.object.interface = &wl_drag_interface;
- drag->resource.object.implementation =
- (void (**)(void)) &drag_interface;
-
- drag->resource.destroy = destroy_drag;
-
- drag->drag_focus_listener.func = drag_handle_surface_destroy;
- wl_list_init(&drag->drag_focus_listener.link);
-
- wl_client_add_resource(client, &drag->resource);
-}
-
-static void
-wlsc_selection_set_focus(struct wlsc_shell *shell,
- struct wl_selection *selection,
- struct wl_surface *surface, uint32_t time)
-{
- char **p, **end;
-
- if (selection->selection_focus == surface)
- return;
-
- if (selection->selection_focus != NULL)
- wl_client_post_event(selection->selection_focus->client,
- &selection->selection_offer.object,
- WL_SELECTION_OFFER_KEYBOARD_FOCUS,
- NULL);
-
- if (surface) {
- wl_client_post_global(surface->client,
- &selection->selection_offer.object);
-
- end = selection->types.data + selection->types.size;
- for (p = selection->types.data; p < end; p++)
- wl_client_post_event(surface->client,
- &selection->selection_offer.object,
- WL_SELECTION_OFFER_OFFER, *p);
-
- wl_list_remove(&selection->selection_focus_listener.link);
- wl_list_insert(surface->resource.destroy_listener_list.prev,
- &selection->selection_focus_listener.link);
-
- wl_client_post_event(surface->client,
- &selection->selection_offer.object,
- WL_SELECTION_OFFER_KEYBOARD_FOCUS,
- selection->input_device);
- }
-
- selection->selection_focus = surface;
-
- wl_list_remove(&selection->selection_focus_listener.link);
- if (surface)
- wl_list_insert(surface->resource.destroy_listener_list.prev,
- &selection->selection_focus_listener.link);
-}
-
-static void
-selection_offer_receive(struct wl_client *client,
- struct wl_selection_offer *offer,
- const char *mime_type, int fd)
-{
- struct wl_selection *selection =
- container_of(offer, struct wl_selection, selection_offer);
-
- wl_client_post_event(selection->client,
- &selection->resource.object,
- WL_SELECTION_SEND, mime_type, fd);
- close(fd);
-}
-
-static const struct wl_selection_offer_interface selection_offer_interface = {
- selection_offer_receive
-};
-
-static void
-selection_offer(struct wl_client *client,
- struct wl_selection *selection, const char *type)
-{
- char **p;
-
- p = wl_array_add(&selection->types, sizeof *p);
- if (p)
- *p = strdup(type);
- if (!p || !*p)
- wl_client_post_no_memory(client);
-}
-
-static void
-selection_activate(struct wl_client *client,
- struct wl_selection *selection,
- struct wl_input_device *device, uint32_t time)
-{
- struct wlsc_input_device *wd = (struct wlsc_input_device *) device;
- struct wl_display *display = wl_client_get_display (client);
- struct wlsc_compositor *compositor =
- (struct wlsc_compositor *) device->compositor;
-
- selection->input_device = device;
-
- selection->selection_offer.object.interface =
- &wl_selection_offer_interface;
- selection->selection_offer.object.implementation =
- (void (**)(void)) &selection_offer_interface;
-
- wl_display_add_object(display, &selection->selection_offer.object);
-
- if (wd->selection) {
- wl_client_post_event(wd->selection->client,
- &wd->selection->resource.object,
- WL_SELECTION_CANCELLED);
- }
- wd->selection = selection;
-
- wlsc_selection_set_focus(compositor->shell,
- selection, device->keyboard_focus, time);
-}
-
-static void
-selection_destroy(struct wl_client *client, struct wl_selection *selection)
-{
- wl_resource_destroy(&selection->resource, client,
- wlsc_compositor_get_time());
-}
-
-static const struct wl_selection_interface selection_interface = {
- selection_offer,
- selection_activate,
- selection_destroy
-};
-
-static void
-destroy_selection(struct wl_resource *resource, struct wl_client *client)
-{
- struct wl_selection *selection =
- container_of(resource, struct wl_selection, resource);
- struct wlsc_input_device *wd =
- (struct wlsc_input_device *) selection->input_device;
- struct wlsc_compositor *compositor =
- (struct wlsc_compositor *) wd->input_device.compositor;
-
- if (wd && wd->selection == selection) {
- wd->selection = NULL;
- wlsc_selection_set_focus(compositor->shell,
- selection, NULL,
- wlsc_compositor_get_time());
- }
-
- wl_list_remove(&selection->selection_focus_listener.link);
- free(selection);
-}
-
-static void
-selection_handle_surface_destroy(struct wl_listener *listener,
- struct wl_resource *resource, uint32_t time)
-{
-}
-
-static void
-shell_create_selection(struct wl_client *client,
- struct wl_shell *shell, uint32_t id)
-{
- struct wl_selection *selection;
-
- selection = malloc(sizeof *selection);
- if (selection == NULL) {
- wl_client_post_no_memory(client);
- return;
- }
-
- memset(selection, 0, sizeof *selection);
- selection->resource.object.id = id;
- selection->resource.object.interface = &wl_selection_interface;
- selection->resource.object.implementation =
- (void (**)(void)) &selection_interface;
-
- selection->client = client;
- selection->resource.destroy = destroy_selection;
- selection->selection_focus = NULL;
-
- selection->selection_focus_listener.func =
- selection_handle_surface_destroy;
- wl_list_init(&selection->selection_focus_listener.link);
-
- wl_client_add_resource(client, &selection->resource);
-}
-
-const static struct wl_shell_interface shell_interface = {
- shell_move,
- shell_resize,
- shell_create_drag,
- shell_create_selection
-};
-
-static void
-move_binding(struct wl_input_device *device, uint32_t time,
- uint32_t key, uint32_t button, uint32_t state, void *data)
-{
- struct wl_shell *shell = data;
- struct wlsc_surface *surface =
- (struct wlsc_surface *) device->pointer_focus;
-
- if (surface == NULL)
- return;
-
- shell_move(NULL, shell, &surface->surface, device, time);
-}
-
-static void
-resize_binding(struct wl_input_device *device, uint32_t time,
- uint32_t key, uint32_t button, uint32_t state, void *data)
-{
- struct wl_shell *shell = data;
- struct wlsc_surface *surface =
- (struct wlsc_surface *) device->pointer_focus;
- uint32_t edges = 0;
- int32_t x, y;
-
- if (surface == NULL)
- return;
-
- x = device->grab_x - surface->x;
- y = device->grab_y - surface->y;
-
- if (x < surface->width / 3)
- edges |= WL_SHELL_RESIZE_LEFT;
- else if (x < 2 * surface->width / 3)
- edges |= 0;
- else
- edges |= WL_SHELL_RESIZE_RIGHT;
-
- if (y < surface->height / 3)
- edges |= WL_SHELL_RESIZE_TOP;
- else if (y < 2 * surface->height / 3)
- edges |= 0;
- else
- edges |= WL_SHELL_RESIZE_BOTTOM;
-
- shell_resize(NULL, shell, &surface->surface, device, time, edges);
-}
-
-static void
-lock(struct wlsc_shell *shell)
-{
-}
-
-static void
-attach(struct wlsc_shell *shell, struct wlsc_surface *surface)
-{
-}
-
-int
-shell_init(struct wlsc_compositor *ec);
-
-WL_EXPORT int
-shell_init(struct wlsc_compositor *ec)
-{
- struct wl_shell *shell;
-
- shell = malloc(sizeof *shell);
- if (shell == NULL)
- return -1;
-
- shell->shell.lock = lock;
- shell->shell.attach = attach;
- shell->shell.set_selection_focus = wlsc_selection_set_focus;
-
- shell->object.interface = &wl_shell_interface;
- shell->object.implementation = (void (**)(void)) &shell_interface;
- wl_display_add_object(ec->wl_display, &shell->object);
- if (wl_display_add_global(ec->wl_display, &shell->object, NULL))
- return -1;
-
- wlsc_compositor_add_binding(ec, 0, BTN_LEFT, MODIFIER_SUPER,
- move_binding, shell);
- wlsc_compositor_add_binding(ec, 0, BTN_MIDDLE, MODIFIER_SUPER,
- resize_binding, shell);
-
- ec->shell = &shell->shell;
-
- return 0;
-}
diff --git a/compositor/surface.c b/compositor/surface.c
index c70ba26..418f403 100644
--- a/compositor/surface.c
+++ b/compositor/surface.c
@@ -160,8 +160,6 @@ wlsc_surface_attach(struct wl_client *client,
wlsc_surface_assign_output(es);
wlsc_buffer_attach(buffer, surface);
-
- es->compositor->shell->attach(es->compositor->shell, es);
}
WL_EXPORT void
@@ -338,13 +336,7 @@ WL_EXPORT void
wlsc_surface_activate(struct wlsc_surface *surface,
struct wlsc_input_device *device, uint32_t time)
{
- struct wlsc_shell *shell = surface->compositor->shell;
-
wlsc_surface_raise(surface);
- if (device->selection)
- shell->set_selection_focus(shell,
- device->selection,
- &surface->surface, time);
wl_input_device_set_keyboard_focus(&device->input_device,
&surface->surface,
diff --git a/compositor/switcher.c b/compositor/switcher.c
deleted file mode 100644
index ce9252f..0000000
--- a/compositor/switcher.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright © 2011 Intel Corporation
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that copyright
- * notice and this permission notice appear in supporting documentation, and
- * that the name of the copyright holders not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. The copyright holders make no representations
- * about the suitability of this software for any purpose. It is provided "as
- * is" without express or implied warranty.
- *
- * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
- * OF THIS SOFTWARE.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <linux/input.h>
-
-#include "compositor.h"
-
-struct wlsc_switcher {
- struct wlsc_compositor *compositor;
- struct wlsc_surface *current;
- struct wl_listener listener;
-};
-
-static void
-wlsc_switcher_next(struct wlsc_switcher *switcher)
-{
- struct wl_list *l;
- struct wl_surface *current;
-
- wlsc_surface_damage_surface(switcher->current);
- l = switcher->current->link.next;
- if (l == &switcher->compositor->surface_list)
- l = switcher->compositor->surface_list.next;
- switcher->current = container_of(l, struct wlsc_surface, link);
- wl_list_remove(&switcher->listener.link);
- current = &switcher->current->surface;
- wl_list_insert(current->resource.destroy_listener_list.prev,
- &switcher->listener.link);
- switcher->compositor->overlay = switcher->current;
- wlsc_surface_damage_surface(switcher->current);
-}
-
-static void
-switcher_handle_surface_destroy(struct wl_listener *listener,
- struct wl_resource *resource, uint32_t time)
-{
- struct wlsc_switcher *switcher =
- container_of(listener, struct wlsc_switcher, listener);
-
- wlsc_switcher_next(switcher);
-}
-
-static struct wlsc_switcher *
-wlsc_switcher_create(struct wlsc_compositor *compositor)
-{
- struct wlsc_switcher *switcher;
-
- switcher = malloc(sizeof *switcher);
- switcher->compositor = compositor;
- switcher->current = container_of(compositor->surface_list.next,
- struct wlsc_surface, link);
- switcher->listener.func = switcher_handle_surface_destroy;
- wl_list_init(&switcher->listener.link);
-
- return switcher;
-}
-
-static void
-wlsc_switcher_destroy(struct wlsc_switcher *switcher)
-{
- wl_list_remove(&switcher->listener.link);
- free(switcher);
-}
-
-static void
-switcher_next_binding(struct wl_input_device *device, uint32_t time,
- uint32_t key, uint32_t button,
- uint32_t state, void *data)
-{
- struct wlsc_compositor *compositor = data;
-
- if (!state)
- return;
- if (wl_list_empty(&compositor->surface_list))
- return;
- if (compositor->switcher == NULL)
- compositor->switcher = wlsc_switcher_create(compositor);
-
- wlsc_switcher_next(compositor->switcher);
-}
-
-static void
-switcher_terminate_binding(struct wl_input_device *device,
- uint32_t time, uint32_t key, uint32_t button,
- uint32_t state, void *data)
-{
- struct wlsc_compositor *compositor = data;
- struct wlsc_input_device *wd = (struct wlsc_input_device *) device;
-
- if (compositor->switcher && !state) {
- wlsc_surface_activate(compositor->switcher->current, wd, time);
- wlsc_switcher_destroy(compositor->switcher);
- compositor->switcher = NULL;
- compositor->overlay = NULL;
- }
-}
-
-void
-wlsc_switcher_init(struct wlsc_compositor *compositor)
-{
- wlsc_compositor_add_binding(compositor,
- KEY_TAB, 0, MODIFIER_SUPER,
- switcher_next_binding, compositor);
- wlsc_compositor_add_binding(compositor,
- KEY_LEFTMETA, 0, MODIFIER_SUPER,
- switcher_terminate_binding, compositor);
- wlsc_compositor_add_binding(compositor,
- KEY_RIGHTMETA, 0, MODIFIER_SUPER,
- switcher_terminate_binding, compositor);
-}