[PATCH 16/18] text: Move input panel into an own file

Jan Arne Petersen jpetersen at openismus.com
Sun Apr 7 15:12:09 PDT 2013


From: Jan Arne Petersen <jpetersen at openismus.com>

Signed-off-by: Jan Arne Petersen <jpetersen at openismus.com>
---
 src/Makefile.am   |   3 +-
 src/compositor.c  |   1 +
 src/compositor.h  |  13 ++
 src/input-panel.c | 470 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/shell.c       | 350 +---------------------------------------
 5 files changed, 493 insertions(+), 344 deletions(-)
 create mode 100644 src/input-panel.c

diff --git a/src/Makefile.am b/src/Makefile.am
index d33ebc5..77b24b5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -43,7 +43,8 @@ weston_SOURCES =				\
 	../shared/matrix.c			\
 	../shared/matrix.h			\
 	weston-launch.h				\
-	weston-egl-ext.h
+	weston-egl-ext.h			\
+	input-panel.c
 
 if ENABLE_EGL
 weston_SOURCES +=				\
diff --git a/src/compositor.c b/src/compositor.c
index e078850..0697ab0 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -3181,6 +3181,7 @@ weston_compositor_init(struct weston_compositor *ec,
 	screenshooter_create(ec);
 	text_cursor_position_notifier_create(ec);
 	text_backend_init(ec);
+	ec->input_panel = input_panel_create(ec);
 
 	wl_data_device_manager_init(ec->wl_display);
 
diff --git a/src/compositor.h b/src/compositor.h
index cde5e9a..993e832 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -52,6 +52,7 @@ struct shell_surface;
 struct weston_seat;
 struct weston_output;
 struct input_method;
+struct input_panel;
 
 enum weston_keyboard_modifier {
 	MODIFIER_CTRL = (1 << 0),
@@ -360,6 +361,8 @@ struct weston_compositor {
 	struct xkb_rule_names xkb_names;
 	struct xkb_context *xkb_context;
 	struct weston_xkb_info xkb_info;
+
+	struct input_panel *input_panel;
 };
 
 struct weston_buffer_reference {
@@ -821,6 +824,16 @@ text_cursor_position_notifier_create(struct weston_compositor *ec);
 int
 text_backend_init(struct weston_compositor *ec);
 
+struct input_panel*
+input_panel_create(struct weston_compositor *ec);
+
+void
+input_panel_show_layer(struct input_panel *input_panel,
+		       struct weston_layer *previous_layer,
+		       struct weston_layer *next_layer);
+void
+input_panel_hide_layer(struct input_panel *panel);
+
 struct weston_process;
 typedef void (*weston_process_cleanup_func_t)(struct weston_process *process,
 					    int status);
diff --git a/src/input-panel.c b/src/input-panel.c
new file mode 100644
index 0000000..78dfe21
--- /dev/null
+++ b/src/input-panel.c
@@ -0,0 +1,470 @@
+/*
+ * Copyright © 2012-2013 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 <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <wayland-server.h>
+#include "compositor.h"
+
+#include "input-method-server-protocol.h"
+
+struct input_panel {
+	struct wl_listener destroy_listener;
+	struct wl_listener show_input_panel_listener;
+	struct wl_listener hide_input_panel_listener;
+	struct wl_listener update_input_panel_listener;
+
+	struct wl_resource *binding;
+
+	struct wl_list surfaces;
+
+	bool showing_input_panels;
+
+	struct {
+		struct weston_layer input_panel;
+
+		struct weston_layer *previous;
+		struct weston_layer *next;
+
+		bool visible;
+	} layer;
+
+	struct {
+		struct weston_surface *surface;
+		pixman_box32_t cursor_rectangle;
+	} text_input;
+
+};
+
+struct input_panel_surface {
+	struct wl_resource resource;
+
+	struct input_panel *input_panel;
+
+	struct wl_list link;
+	struct weston_surface *surface;
+	struct wl_listener surface_destroy_listener;
+
+	struct weston_output *output;
+	uint32_t overlay_panel;
+};
+
+static void
+map_input_panel_surface(struct input_panel *input_panel,
+			struct input_panel_surface *input_panel_surface)
+{
+	struct weston_surface *surface = input_panel_surface->surface;
+
+	weston_surface_geometry_dirty(surface);
+	wl_list_insert(&input_panel->layer.input_panel.surface_list,
+		       &surface->layer_link);
+	weston_surface_update_transform(surface);
+	weston_surface_damage(surface);
+
+	if (!input_panel_surface->overlay_panel)
+		weston_slide_run(surface, surface->geometry.height, 0, NULL, NULL);
+}
+
+static void
+show_input_panels(struct wl_listener *listener, void *data)
+{
+	struct input_panel *input_panel =
+		container_of(listener, struct input_panel,
+			     show_input_panel_listener);
+	struct input_panel_surface *surface, *next;
+	struct weston_surface *ws;
+
+	input_panel->text_input.surface = (struct weston_surface*)data;
+
+	fprintf(stderr,
+		"%s layer visible: %d input panel visible: %d\n",
+		__FUNCTION__,
+		input_panel->layer.visible,
+		input_panel->showing_input_panels);
+
+	if (input_panel->showing_input_panels)
+		return;
+
+	input_panel->showing_input_panels = true;
+
+	if (input_panel->layer.visible) {
+		wl_list_insert(&input_panel->layer.previous->link,
+			       &input_panel->layer.input_panel.link);
+	}
+
+	wl_list_for_each_safe(surface, next,
+			      &input_panel->surfaces, link) {
+		ws = surface->surface;
+		if (!ws->buffer_ref.buffer)
+			continue;
+		map_input_panel_surface(input_panel, surface);
+	}
+}
+
+static void
+hide_input_panels(struct wl_listener *listener, void *data)
+{
+	struct input_panel *input_panel =
+		container_of(listener, struct input_panel,
+			     hide_input_panel_listener);
+	struct weston_surface *surface, *next;
+
+	if (!input_panel->showing_input_panels)
+		return;
+
+	input_panel->showing_input_panels = false;
+
+	if (input_panel->layer.visible)
+		wl_list_remove(&input_panel->layer.input_panel.link);
+
+	wl_list_for_each_safe(surface, next,
+			      &input_panel->layer.input_panel.surface_list, layer_link)
+		weston_surface_unmap(surface);
+}
+
+static void
+overlay_panel_get_position(struct input_panel_surface *surface,
+			   float *x, float *y)
+{
+	struct input_panel *input_panel = surface->input_panel;
+
+	if (!surface->overlay_panel) {
+		fprintf(stderr, "%s: surface is not overlay panel\n", __FUNCTION__);
+		return;
+	}
+
+	*x = input_panel->text_input.surface->geometry.x + input_panel->text_input.cursor_rectangle.x2;
+	*y = input_panel->text_input.surface->geometry.y + input_panel->text_input.cursor_rectangle.y2;
+}
+
+static void
+update_input_panels(struct wl_listener *listener, void *data)
+{
+	struct input_panel *input_panel =
+		container_of(listener, struct input_panel,
+			     update_input_panel_listener);
+	struct input_panel_surface *surface, *next;
+	float x = 0, y = 0;
+
+	memcpy(&input_panel->text_input.cursor_rectangle, data, sizeof(pixman_box32_t));
+
+	wl_list_for_each_safe(surface, next,
+			      &input_panel->surfaces, link) {
+		if (!surface->overlay_panel)
+			continue;
+		if (!weston_surface_is_mapped(surface->surface))
+			continue;
+		overlay_panel_get_position(surface, &x, &y);
+		weston_surface_set_position(surface->surface, x, y);
+		weston_surface_update_transform(surface->surface);
+	}
+}
+
+
+static void
+input_panel_configure(struct weston_surface *surface, int32_t sx, int32_t sy, int32_t width, int32_t height)
+{
+	struct input_panel_surface *ip_surface = surface->configure_private;
+	struct input_panel *input_panel = ip_surface->input_panel;
+	struct weston_mode *mode;
+	float x, y;
+
+	if (width == 0)
+		return;
+
+	if (ip_surface->overlay_panel) {
+		overlay_panel_get_position(ip_surface, &x, &y);
+	} else {
+		mode = ip_surface->output->current;
+
+		x = ip_surface->output->x + (mode->width - width) / 2;
+		y = ip_surface->output->y + mode->height - height;
+	}
+
+	weston_surface_configure(surface,
+				 x, y,
+				 width, height);
+
+	if (!weston_surface_is_mapped(surface) && input_panel->showing_input_panels)
+		map_input_panel_surface(input_panel, ip_surface);
+}
+
+static void
+destroy_input_panel_surface(struct input_panel_surface *input_panel_surface)
+{
+	wl_list_remove(&input_panel_surface->surface_destroy_listener.link);
+	wl_list_remove(&input_panel_surface->link);
+
+	input_panel_surface->surface->configure = NULL;
+
+	free(input_panel_surface);
+}
+
+static struct input_panel_surface *
+get_input_panel_surface(struct weston_surface *surface)
+{
+	if (surface->configure == input_panel_configure) {
+		return surface->configure_private;
+	} else {
+		return NULL;
+	}
+}
+
+static void
+input_panel_handle_surface_destroy(struct wl_listener *listener, void *data)
+{
+	struct input_panel_surface *ipsurface = container_of(listener,
+							     struct input_panel_surface,
+							     surface_destroy_listener);
+
+	if (ipsurface->resource.client) {
+		wl_resource_destroy(&ipsurface->resource);
+	} else {
+		wl_signal_emit(&ipsurface->resource.destroy_signal,
+			       &ipsurface->resource);
+		destroy_input_panel_surface(ipsurface);
+	}
+}
+static struct input_panel_surface *
+create_input_panel_surface(struct input_panel *input_panel,
+			   struct weston_surface *surface)
+{
+	struct input_panel_surface *input_panel_surface;
+
+	input_panel_surface = calloc(1, sizeof *input_panel_surface);
+	if (!input_panel_surface)
+		return NULL;
+
+	surface->configure = input_panel_configure;
+	surface->configure_private = input_panel_surface;
+
+	input_panel_surface->input_panel = input_panel;
+
+	input_panel_surface->surface = surface;
+
+	wl_signal_init(&input_panel_surface->resource.destroy_signal);
+	input_panel_surface->surface_destroy_listener.notify = input_panel_handle_surface_destroy;
+	wl_signal_add(&surface->surface.resource.destroy_signal,
+		      &input_panel_surface->surface_destroy_listener);
+
+	wl_list_init(&input_panel_surface->link);
+
+	return input_panel_surface;
+}
+
+static void
+input_panel_surface_set_toplevel(struct wl_client *client,
+				 struct wl_resource *resource,
+				 struct wl_resource *output_resource,
+				 uint32_t position)
+{
+	struct input_panel_surface *input_panel_surface = resource->data;
+	struct input_panel *input_panel = input_panel_surface->input_panel;
+
+	wl_list_insert(&input_panel->surfaces,
+		       &input_panel_surface->link);
+
+	input_panel_surface->output = output_resource->data;
+	input_panel_surface->overlay_panel = 0;
+}
+
+static void
+input_panel_surface_set_panel(struct wl_client *client,
+			      struct wl_resource *resource)
+{
+	struct input_panel_surface *input_panel_surface = resource->data;
+	struct input_panel *input_panel = input_panel_surface->input_panel;
+
+	wl_list_insert(&input_panel->surfaces,
+		       &input_panel_surface->link);
+
+	input_panel_surface->overlay_panel = 1;
+}
+
+static const struct input_panel_surface_interface input_panel_surface_implementation = {
+	input_panel_surface_set_toplevel,
+	input_panel_surface_set_panel
+};
+
+static void
+destroy_input_panel_surface_resource(struct wl_resource *resource)
+{
+	struct input_panel_surface *ipsurf = resource->data;
+
+	destroy_input_panel_surface(ipsurf);
+}
+
+static void
+input_panel_get_input_panel_surface(struct wl_client *client,
+				    struct wl_resource *resource,
+				    uint32_t id,
+				    struct wl_resource *surface_resource)
+{
+	struct weston_surface *surface = surface_resource->data;
+	struct input_panel *input_panel = resource->data;
+	struct input_panel_surface *ipsurf;
+
+	if (get_input_panel_surface(surface)) {
+		wl_resource_post_error(surface_resource,
+				       WL_DISPLAY_ERROR_INVALID_OBJECT,
+				       "input_panel::get_input_panel_surface already requested");
+		return;
+	}
+
+	ipsurf = create_input_panel_surface(input_panel, surface);
+	if (!ipsurf) {
+		wl_resource_post_error(surface_resource,
+				       WL_DISPLAY_ERROR_INVALID_OBJECT,
+				       "surface->configure already set");
+		return;
+	}
+
+	ipsurf->resource.destroy = destroy_input_panel_surface_resource;
+	ipsurf->resource.object.id = id;
+	ipsurf->resource.object.interface = &input_panel_surface_interface;
+	ipsurf->resource.object.implementation =
+		(void (**)(void)) &input_panel_surface_implementation;
+	ipsurf->resource.data = ipsurf;
+
+	wl_client_add_resource(client, &ipsurf->resource);
+}
+
+static const struct input_panel_interface input_panel_implementation = {
+	input_panel_get_input_panel_surface
+};
+
+static void
+input_panel_destroy(struct wl_listener *listener, void *data)
+{
+	struct input_panel *input_panel = 
+		container_of(listener, struct input_panel, destroy_listener);
+
+	wl_list_remove(&input_panel->show_input_panel_listener.link);
+	wl_list_remove(&input_panel->hide_input_panel_listener.link);
+	wl_list_remove(&input_panel->update_input_panel_listener.link);
+
+	free(input_panel);
+}
+
+static void
+unbind_input_panel(struct wl_resource *resource)
+{
+	struct input_panel *input_panel = resource->data;
+
+	input_panel->binding = NULL;
+	free(resource);
+}
+
+static void
+bind_input_panel(struct wl_client *client,
+	      void *data, uint32_t version, uint32_t id)
+{
+	struct input_panel *input_panel = data;
+	struct wl_resource *resource;
+
+	resource = wl_client_add_object(client, &input_panel_interface,
+					&input_panel_implementation,
+					id, input_panel);
+
+	if (input_panel->binding != NULL) {
+		wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
+				       "interface object already bound");
+		wl_resource_destroy(resource);
+		return;
+	}
+	
+	resource->destroy = unbind_input_panel;
+	input_panel->binding = resource;
+}
+
+WL_EXPORT struct input_panel *
+input_panel_create(struct weston_compositor *ec)
+{
+	struct input_panel *input_panel;
+
+	input_panel = malloc(sizeof *input_panel);
+	if (!input_panel)
+		return NULL;
+	memset(input_panel, 0, sizeof *input_panel);
+
+	input_panel->destroy_listener.notify = input_panel_destroy;
+	wl_signal_add(&ec->destroy_signal, &input_panel->destroy_listener);
+	input_panel->show_input_panel_listener.notify = show_input_panels;
+	wl_signal_add(&ec->show_input_panel_signal, &input_panel->show_input_panel_listener);
+	input_panel->hide_input_panel_listener.notify = hide_input_panels;
+	wl_signal_add(&ec->hide_input_panel_signal, &input_panel->hide_input_panel_listener);
+	input_panel->update_input_panel_listener.notify = update_input_panels;
+	wl_signal_add(&ec->update_input_panel_signal, &input_panel->update_input_panel_listener);
+
+	wl_list_init(&input_panel->surfaces);
+
+	weston_layer_init(&input_panel->layer.input_panel, NULL);
+
+	if (wl_display_add_global(ec->wl_display, &input_panel_interface,
+				  input_panel, bind_input_panel) == NULL)
+		return NULL;
+
+	return input_panel;
+}
+
+WL_EXPORT void
+input_panel_show_layer(struct input_panel *input_panel,
+		       struct weston_layer *previous,
+		       struct weston_layer *next)
+{
+	if (input_panel->layer.visible) {
+		fprintf(stderr, "%s - input panel layer is already shown.\n", __FUNCTION__);
+		return;
+	}
+
+	input_panel->layer.previous = previous;
+	input_panel->layer.next = next;
+
+	input_panel->layer.visible = true;
+
+	if (input_panel->showing_input_panels) {
+		wl_list_insert(&input_panel->layer.previous->link,
+			       &input_panel->layer.input_panel.link);
+		wl_list_insert(&input_panel->layer.input_panel.link,
+			       &input_panel->layer.next->link);
+	} else {
+		wl_list_insert(&previous->link, &next->link);
+
+	}
+}
+
+WL_EXPORT void
+input_panel_hide_layer(struct input_panel *input_panel)
+{
+	if (!input_panel->layer.visible) {
+		fprintf(stderr, "%s - input panel layer is already hidden.\n", __FUNCTION__);
+		return;
+	}
+
+	input_panel->layer.visible = false;
+
+	if (input_panel->showing_input_panels)
+		wl_list_remove(&input_panel->layer.input_panel.link);
+}
+
diff --git a/src/shell.c b/src/shell.c
index e2967db..c9620e9 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -35,7 +35,6 @@
 #include <wayland-server.h>
 #include "compositor.h"
 #include "desktop-shell-server-protocol.h"
-#include "input-method-server-protocol.h"
 #include "workspaces-server-protocol.h"
 #include "../shared/config-parser.h"
 
@@ -70,34 +69,17 @@ struct workspace {
 	struct wl_listener seat_destroyed_listener;
 };
 
-struct input_panel_surface {
-	struct wl_resource resource;
-
-	struct desktop_shell *shell;
-
-	struct wl_list link;
-	struct weston_surface *surface;
-	struct wl_listener surface_destroy_listener;
-
-	struct weston_output *output;
-	uint32_t panel;
-};
-
 struct desktop_shell {
 	struct weston_compositor *compositor;
 
 	struct wl_listener idle_listener;
 	struct wl_listener wake_listener;
 	struct wl_listener destroy_listener;
-	struct wl_listener show_input_panel_listener;
-	struct wl_listener hide_input_panel_listener;
-	struct wl_listener update_input_panel_listener;
 
 	struct weston_layer fullscreen_layer;
 	struct weston_layer panel_layer;
 	struct weston_layer background_layer;
 	struct weston_layer lock_layer;
-	struct weston_layer input_panel_layer;
 
 	struct wl_listener pointer_focus_listener;
 	struct weston_surface *grab_surface;
@@ -112,14 +94,8 @@ struct desktop_shell {
 	} child;
 
 	bool locked;
-	bool showing_input_panels;
 	bool prepare_event_sent;
 
-	struct {
-		struct weston_surface *surface;
-		pixman_box32_t cursor_rectangle;
-	} text_input;
-
 	struct weston_surface *lock_surface;
 	struct wl_listener lock_surface_listener;
 
@@ -148,11 +124,6 @@ struct desktop_shell {
 	} screensaver;
 
 	struct {
-		struct wl_resource *binding;
-		struct wl_list surfaces;
-	} input_panel;
-
-	struct {
 		struct weston_surface *surface;
 		struct weston_surface_animation *animation;
 		enum fade_type type;
@@ -604,7 +575,9 @@ activate_workspace(struct desktop_shell *shell, unsigned int index)
 	struct workspace *ws;
 
 	ws = get_workspace(shell, index);
-	wl_list_insert(&shell->panel_layer.link, &ws->layer.link);
+	input_panel_show_layer(shell->compositor->input_panel,
+			       &shell->panel_layer,
+			       &ws->layer);
 
 	shell->workspaces.current = index;
 }
@@ -2457,14 +2430,9 @@ resume_desktop(struct desktop_shell *shell)
 		       &shell->fullscreen_layer.link);
 	wl_list_insert(&shell->fullscreen_layer.link,
 		       &shell->panel_layer.link);
-	if (shell->showing_input_panels) {
-		wl_list_insert(&shell->panel_layer.link,
-			       &shell->input_panel_layer.link);
-		wl_list_insert(&shell->input_panel_layer.link,
-			       &ws->layer.link);
-	} else {
-		wl_list_insert(&shell->panel_layer.link, &ws->layer.link);
-	}
+	input_panel_show_layer(shell->compositor->input_panel,
+			       &shell->panel_layer,
+			       &ws->layer);
 
 	restore_focus_state(shell, get_current_workspace(shell));
 
@@ -2914,8 +2882,7 @@ lock(struct desktop_shell *shell)
 
 	wl_list_remove(&shell->panel_layer.link);
 	wl_list_remove(&shell->fullscreen_layer.link);
-	if (shell->showing_input_panels)
-		wl_list_remove(&shell->input_panel_layer.link);
+	input_panel_hide_layer(shell->compositor->input_panel);
 	wl_list_remove(&ws->layer.link);
 	wl_list_insert(&shell->compositor->cursor_layer.link,
 		       &shell->lock_layer.link);
@@ -3032,71 +2999,6 @@ wake_handler(struct wl_listener *listener, void *data)
 }
 
 static void
-show_input_panels(struct wl_listener *listener, void *data)
-{
-	struct desktop_shell *shell =
-		container_of(listener, struct desktop_shell,
-			     show_input_panel_listener);
-	struct input_panel_surface *surface, *next;
-	struct weston_surface *ws;
-
-	shell->text_input.surface = (struct weston_surface*)data;
-
-	if (shell->showing_input_panels)
-		return;
-
-	shell->showing_input_panels = true;
-
-	if (!shell->locked)
-		wl_list_insert(&shell->panel_layer.link,
-			       &shell->input_panel_layer.link);
-
-	wl_list_for_each_safe(surface, next,
-			      &shell->input_panel.surfaces, link) {
-		ws = surface->surface;
-		if (!ws->buffer_ref.buffer)
-			continue;
-		wl_list_insert(&shell->input_panel_layer.surface_list,
-			       &ws->layer_link);
-		weston_surface_geometry_dirty(ws);
-		weston_surface_update_transform(ws);
-		weston_surface_damage(ws);
-		weston_slide_run(ws, ws->geometry.height, 0, NULL, NULL);
-	}
-}
-
-static void
-hide_input_panels(struct wl_listener *listener, void *data)
-{
-	struct desktop_shell *shell =
-		container_of(listener, struct desktop_shell,
-			     hide_input_panel_listener);
-	struct weston_surface *surface, *next;
-
-	if (!shell->showing_input_panels)
-		return;
-
-	shell->showing_input_panels = false;
-
-	if (!shell->locked)
-		wl_list_remove(&shell->input_panel_layer.link);
-
-	wl_list_for_each_safe(surface, next,
-			      &shell->input_panel_layer.surface_list, layer_link)
-		weston_surface_unmap(surface);
-}
-
-static void
-update_input_panels(struct wl_listener *listener, void *data)
-{
-	struct desktop_shell *shell =
-		container_of(listener, struct desktop_shell,
-			     update_input_panel_listener);
-
-	memcpy(&shell->text_input.cursor_rectangle, data, sizeof(pixman_box32_t));
-}
-
-static void
 center_on_output(struct weston_surface *surface, struct weston_output *output)
 {
 	int32_t width = weston_surface_buffer_width(surface);
@@ -3507,229 +3409,6 @@ bind_screensaver(struct wl_client *client,
 	wl_resource_destroy(resource);
 }
 
-static void
-input_panel_configure(struct weston_surface *surface, int32_t sx, int32_t sy, int32_t width, int32_t height)
-{
-	struct input_panel_surface *ip_surface = surface->private;
-	struct desktop_shell *shell = ip_surface->shell;
-	struct weston_mode *mode;
-	float x, y;
-	uint32_t show_surface = 0;
-
-	if (width == 0)
-		return;
-
-	if (!weston_surface_is_mapped(surface)) {
-		if (!shell->showing_input_panels)
-			return;
-
-		show_surface = 1;
-	}
-
-	fprintf(stderr, "%s panel: %d, output: %p\n", __FUNCTION__, ip_surface->panel, ip_surface->output);
-
-	if (ip_surface->panel) {
-		x = shell->text_input.surface->geometry.x + shell->text_input.cursor_rectangle.x2;
-		y = shell->text_input.surface->geometry.y + shell->text_input.cursor_rectangle.y2;
-	} else {
-		mode = ip_surface->output->current;
-
-		x = ip_surface->output->x + (mode->width - width) / 2;
-		y = ip_surface->output->y + mode->height - height;
-	}
-
-	weston_surface_configure(surface,
-				 x, y,
-				 width, height);
-
-	if (show_surface) {
-		wl_list_insert(&shell->input_panel_layer.surface_list,
-			       &surface->layer_link);
-		weston_surface_update_transform(surface);
-		weston_surface_damage(surface);
-		weston_slide_run(surface, surface->geometry.height, 0, NULL, NULL);
-	}
-}
-
-static void
-destroy_input_panel_surface(struct input_panel_surface *input_panel_surface)
-{
-	wl_list_remove(&input_panel_surface->surface_destroy_listener.link);
-	wl_list_remove(&input_panel_surface->link);
-
-	input_panel_surface->surface->configure = NULL;
-
-	free(input_panel_surface);
-}
-
-static struct input_panel_surface *
-get_input_panel_surface(struct weston_surface *surface)
-{
-	if (surface->configure == input_panel_configure) {
-		return surface->configure_private;
-	} else {
-		return NULL;
-	}
-}
-
-static void
-input_panel_handle_surface_destroy(struct wl_listener *listener, void *data)
-{
-	struct input_panel_surface *ipsurface = container_of(listener,
-							     struct input_panel_surface,
-							     surface_destroy_listener);
-
-	if (ipsurface->resource.client) {
-		wl_resource_destroy(&ipsurface->resource);
-	} else {
-		wl_signal_emit(&ipsurface->resource.destroy_signal,
-			       &ipsurface->resource);
-		destroy_input_panel_surface(ipsurface);
-	}
-}
-static struct input_panel_surface *
-create_input_panel_surface(struct desktop_shell *shell,
-			   struct weston_surface *surface)
-{
-	struct input_panel_surface *input_panel_surface;
-
-	input_panel_surface = calloc(1, sizeof *input_panel_surface);
-	if (!input_panel_surface)
-		return NULL;
-
-	surface->configure = input_panel_configure;
-	surface->configure_private = input_panel_surface;
-
-	input_panel_surface->shell = shell;
-
-	input_panel_surface->surface = surface;
-
-	wl_signal_init(&input_panel_surface->resource.destroy_signal);
-	input_panel_surface->surface_destroy_listener.notify = input_panel_handle_surface_destroy;
-	wl_signal_add(&surface->surface.resource.destroy_signal,
-		      &input_panel_surface->surface_destroy_listener);
-
-	wl_list_init(&input_panel_surface->link);
-
-	return input_panel_surface;
-}
-
-static void
-input_panel_surface_set_toplevel(struct wl_client *client,
-				 struct wl_resource *resource,
-				 struct wl_resource *output_resource,
-				 uint32_t position)
-{
-	struct input_panel_surface *input_panel_surface = resource->data;
-	struct desktop_shell *shell = input_panel_surface->shell;
-
-	wl_list_insert(&shell->input_panel.surfaces,
-		       &input_panel_surface->link);
-
-	input_panel_surface->output = output_resource->data;
-	input_panel_surface->panel = 0;
-
-	fprintf(stderr, "%s panel: %d, output: %p\n", __FUNCTION__,
-		input_panel_surface->panel,
-		input_panel_surface->output);
-}
-
-static void
-input_panel_surface_set_panel(struct wl_client *client,
-			      struct wl_resource *resource)
-{
-	struct input_panel_surface *input_panel_surface = resource->data;
-	struct desktop_shell *shell = input_panel_surface->shell;
-
-	wl_list_insert(&shell->input_panel.surfaces,
-		       &input_panel_surface->link);
-
-	input_panel_surface->panel = 1;
-}
-
-static const struct input_panel_surface_interface input_panel_surface_implementation = {
-	input_panel_surface_set_toplevel,
-	input_panel_surface_set_panel
-};
-
-static void
-destroy_input_panel_surface_resource(struct wl_resource *resource)
-{
-	struct input_panel_surface *ipsurf = resource->data;
-
-	destroy_input_panel_surface(ipsurf);
-}
-
-static void
-input_panel_get_input_panel_surface(struct wl_client *client,
-				    struct wl_resource *resource,
-				    uint32_t id,
-				    struct wl_resource *surface_resource)
-{
-	struct weston_surface *surface = surface_resource->data;
-	struct desktop_shell *shell = resource->data;
-	struct input_panel_surface *ipsurf;
-
-	if (get_input_panel_surface(surface)) {
-		wl_resource_post_error(surface_resource,
-				       WL_DISPLAY_ERROR_INVALID_OBJECT,
-				       "input_panel::get_input_panel_surface already requested");
-		return;
-	}
-
-	ipsurf = create_input_panel_surface(shell, surface);
-	if (!ipsurf) {
-		wl_resource_post_error(surface_resource,
-				       WL_DISPLAY_ERROR_INVALID_OBJECT,
-				       "surface->configure already set");
-		return;
-	}
-
-	ipsurf->resource.destroy = destroy_input_panel_surface_resource;
-	ipsurf->resource.object.id = id;
-	ipsurf->resource.object.interface = &input_panel_surface_interface;
-	ipsurf->resource.object.implementation =
-		(void (**)(void)) &input_panel_surface_implementation;
-	ipsurf->resource.data = ipsurf;
-
-	wl_client_add_resource(client, &ipsurf->resource);
-}
-
-static const struct input_panel_interface input_panel_implementation = {
-	input_panel_get_input_panel_surface
-};
-
-static void
-unbind_input_panel(struct wl_resource *resource)
-{
-	struct desktop_shell *shell = resource->data;
-
-	shell->input_panel.binding = NULL;
-	free(resource);
-}
-
-static void
-bind_input_panel(struct wl_client *client,
-	      void *data, uint32_t version, uint32_t id)
-{
-	struct desktop_shell *shell = data;
-	struct wl_resource *resource;
-
-	resource = wl_client_add_object(client, &input_panel_interface,
-					&input_panel_implementation,
-					id, shell);
-
-	if (shell->input_panel.binding == NULL) {
-		resource->destroy = unbind_input_panel;
-		shell->input_panel.binding = resource;
-		return;
-	}
-
-	wl_resource_post_error(resource, WL_DISPLAY_ERROR_INVALID_OBJECT,
-			       "interface object already bound");
-	wl_resource_destroy(resource);
-}
-
 struct switcher {
 	struct desktop_shell *shell;
 	struct weston_surface *current;
@@ -4147,8 +3826,6 @@ shell_destroy(struct wl_listener *listener, void *data)
 
 	wl_list_remove(&shell->idle_listener.link);
 	wl_list_remove(&shell->wake_listener.link);
-	wl_list_remove(&shell->show_input_panel_listener.link);
-	wl_list_remove(&shell->hide_input_panel_listener.link);
 
 	wl_array_for_each(ws, &shell->workspaces.array)
 		workspace_destroy(*ws);
@@ -4254,12 +3931,6 @@ module_init(struct weston_compositor *ec,
 	wl_signal_add(&ec->idle_signal, &shell->idle_listener);
 	shell->wake_listener.notify = wake_handler;
 	wl_signal_add(&ec->wake_signal, &shell->wake_listener);
-	shell->show_input_panel_listener.notify = show_input_panels;
-	wl_signal_add(&ec->show_input_panel_signal, &shell->show_input_panel_listener);
-	shell->hide_input_panel_listener.notify = hide_input_panels;
-	wl_signal_add(&ec->hide_input_panel_signal, &shell->hide_input_panel_listener);
-	shell->update_input_panel_listener.notify = update_input_panels;
-	wl_signal_add(&ec->update_input_panel_signal, &shell->update_input_panel_listener);
 	ec->ping_handler = ping_handler;
 	ec->shell_interface.shell = shell;
 	ec->shell_interface.create_shell_surface = create_shell_surface;
@@ -4269,13 +3940,10 @@ module_init(struct weston_compositor *ec,
 	ec->shell_interface.move = surface_move;
 	ec->shell_interface.resize = surface_resize;
 
-	wl_list_init(&shell->input_panel.surfaces);
-
 	weston_layer_init(&shell->fullscreen_layer, &ec->cursor_layer.link);
 	weston_layer_init(&shell->panel_layer, &shell->fullscreen_layer.link);
 	weston_layer_init(&shell->background_layer, &shell->panel_layer.link);
 	weston_layer_init(&shell->lock_layer, NULL);
-	weston_layer_init(&shell->input_panel_layer, NULL);
 
 	wl_array_init(&shell->workspaces.array);
 	wl_list_init(&shell->workspaces.client_list);
@@ -4310,10 +3978,6 @@ module_init(struct weston_compositor *ec,
 				  shell, bind_screensaver) == NULL)
 		return -1;
 
-	if (wl_display_add_global(ec->wl_display, &input_panel_interface,
-				  shell, bind_input_panel) == NULL)
-		return -1;
-
 	if (wl_display_add_global(ec->wl_display, &workspace_manager_interface,
 				  shell, bind_workspace_manager) == NULL)
 		return -1;
-- 
1.8.1.4



More information about the wayland-devel mailing list