[PATCH 15/18] text: Add output argument to set_toplevel

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


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

Allow to specify an output for a toplevel  input panel surface.

Signed-off-by: Jan Arne Petersen <jpetersen at openismus.com>
---
 clients/keyboard.c        | 26 ++++++++++----------------
 protocol/input-method.xml |  1 +
 src/shell.c               | 28 ++++++++++++++++------------
 3 files changed, 27 insertions(+), 28 deletions(-)

diff --git a/clients/keyboard.c b/clients/keyboard.c
index 2f28a8f..17fb683 100644
--- a/clients/keyboard.c
+++ b/clients/keyboard.c
@@ -39,6 +39,7 @@ struct virtual_keyboard {
 	struct input_method *input_method;
 	struct input_method_context *context;
 	struct display *display;
+	struct output *output;
 	char *preedit_string;
 	uint32_t preedit_style;
 	struct {
@@ -768,7 +769,7 @@ keyboard_create(struct output *output, struct virtual_keyboard *virtual_keyboard
 	struct keyboard *keyboard;
 	const struct layout *layout;
 	struct input_panel_surface *ips;
-
+	
 	layout = get_current_layout(virtual_keyboard);
 
 	keyboard = malloc(sizeof *keyboard);
@@ -795,27 +796,18 @@ keyboard_create(struct output *output, struct virtual_keyboard *virtual_keyboard
 	ips = input_panel_get_input_panel_surface(virtual_keyboard->input_panel,
 						  window_get_wl_surface(keyboard->window));
 
-	input_panel_surface_set_toplevel(ips, INPUT_PANEL_SURFACE_POSITION_CENTER_BOTTOM);
-}
-
-static void
-handle_output_configure(struct output *output, void *data)
-{
-	struct virtual_keyboard *virtual_keyboard = data;
+	input_panel_surface_set_toplevel(ips,
+					 output_get_wl_output(output),
+					 INPUT_PANEL_SURFACE_POSITION_CENTER_BOTTOM);
 
-	/* skip existing outputs */
-	if (output_get_user_data(output))
-		return;
-
-	output_set_user_data(output, virtual_keyboard);
-
-	keyboard_create(output, virtual_keyboard);
+	fprintf(stderr, "%s, %p\n", __FUNCTION__, output_get_wl_output(output));
 }
 
 int
 main(int argc, char *argv[])
 {
 	struct virtual_keyboard virtual_keyboard;
+	struct output *output;
 
 	memset(&virtual_keyboard, 0, sizeof virtual_keyboard);
 
@@ -827,7 +819,9 @@ main(int argc, char *argv[])
 
 	display_set_user_data(virtual_keyboard.display, &virtual_keyboard);
 	display_set_global_handler(virtual_keyboard.display, global_handler);
-	display_set_output_configure_handler(virtual_keyboard.display, handle_output_configure);
+
+	output = display_get_output(virtual_keyboard.display);
+	keyboard_create(output, &virtual_keyboard);
 
 	display_run(virtual_keyboard.display);
 
diff --git a/protocol/input-method.xml b/protocol/input-method.xml
index 8a4ea7f..d9ae4a9 100644
--- a/protocol/input-method.xml
+++ b/protocol/input-method.xml
@@ -208,6 +208,7 @@
       <description summary="set the surface type as a keyboard">
 	A keybaord surface is only shown, when a text model is active
       </description>
+      <arg name="output" type="object" interface="wl_output"/>
       <arg name="position" type="uint"/>
     </request>
 
diff --git a/src/shell.c b/src/shell.c
index 4e268a8..e2967db 100644
--- a/src/shell.c
+++ b/src/shell.c
@@ -79,6 +79,7 @@ struct input_panel_surface {
 	struct weston_surface *surface;
 	struct wl_listener surface_destroy_listener;
 
+	struct weston_output *output;
 	uint32_t panel;
 };
 
@@ -3053,9 +3054,8 @@ show_input_panels(struct wl_listener *listener, void *data)
 	wl_list_for_each_safe(surface, next,
 			      &shell->input_panel.surfaces, link) {
 		ws = surface->surface;
-		if (!weston_surface_is_mapped(ws)) {
+		if (!ws->buffer_ref.buffer)
 			continue;
-		}
 		wl_list_insert(&shell->input_panel_layer.surface_list,
 			       &ws->layer_link);
 		weston_surface_geometry_dirty(ws);
@@ -3523,31 +3523,29 @@ input_panel_configure(struct weston_surface *surface, int32_t sx, int32_t sy, in
 		if (!shell->showing_input_panels)
 			return;
 
-		wl_list_insert(&shell->input_panel_layer.surface_list,
-			       &surface->layer_link);
-		weston_surface_geometry_dirty(surface);
-		weston_surface_update_transform(surface);
 		show_surface = 1;
 	}
 
-	mode = surface->output->current;
+	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 {
-		x = surface->output->x + (mode->width - width) / 2;
-		y = surface->output->y + mode->height - height;
-	}
+		mode = ip_surface->output->current;
 
-	/* Don't map the input panel here, wait for
-	 * show_input_panels signal. */
+		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);
 	}
@@ -3619,6 +3617,7 @@ create_input_panel_surface(struct desktop_shell *shell,
 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;
@@ -3627,7 +3626,12 @@ input_panel_surface_set_toplevel(struct wl_client *client,
 	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
-- 
1.8.1.4



More information about the wayland-devel mailing list