[PATCH weston 04/10] Use text input protocol from wayland-protocols

Jonas Ådahl jadahl at gmail.com
Wed Nov 4 00:49:53 PST 2015


Signed-off-by: Jonas Ådahl <jadahl at gmail.com>
---
 Makefile.am        |  21 ++-
 clients/editor.c   | 119 +++++++++--------
 clients/keyboard.c |  12 +-
 protocol/text.xml  | 374 -----------------------------------------------------
 src/text-backend.c |  56 ++++----
 tests/text-test.c  |  52 ++++----
 6 files changed, 133 insertions(+), 501 deletions(-)
 delete mode 100644 protocol/text.xml

diff --git a/Makefile.am b/Makefile.am
index 175e924..e14878e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -117,8 +117,8 @@ nodist_weston_SOURCES =					\
 	protocol/screenshooter-server-protocol.h	\
 	protocol/text-cursor-position-protocol.c	\
 	protocol/text-cursor-position-server-protocol.h	\
-	protocol/text-protocol.c			\
-	protocol/text-server-protocol.h			\
+	protocol/text-input-unstable-v1-protocol.c			\
+	protocol/text-input-unstable-v1-server-protocol.h		\
 	protocol/input-method-protocol.c		\
 	protocol/input-method-server-protocol.h		\
 	protocol/workspaces-protocol.c			\
@@ -686,8 +686,8 @@ weston_editor_SOURCES = 			\
 	clients/editor.c			\
 	shared/helpers.h
 nodist_weston_editor_SOURCES =			\
-	protocol/text-protocol.c		\
-	protocol/text-client-protocol.h
+	protocol/text-input-unstable-v1-protocol.c		\
+	protocol/text-input-unstable-v1-client-protocol.h
 weston_editor_LDADD = libtoytoolkit.la $(PANGO_LIBS)
 weston_editor_CFLAGS = $(AM_CFLAGS) $(CLIENT_CFLAGS) $(PANGO_CFLAGS)
 endif
@@ -753,8 +753,8 @@ BUILT_SOURCES +=					\
 	protocol/screenshooter-client-protocol.h	\
 	protocol/text-cursor-position-client-protocol.h	\
 	protocol/text-cursor-position-protocol.c	\
-	protocol/text-protocol.c			\
-	protocol/text-client-protocol.h			\
+	protocol/text-input-unstable-v1-protocol.c			\
+	protocol/text-input-unstable-v1-client-protocol.h		\
 	protocol/input-method-protocol.c		\
 	protocol/input-method-client-protocol.h		\
 	protocol/desktop-shell-client-protocol.h	\
@@ -1212,8 +1212,8 @@ devices_weston_LDADD = libtest-client.la
 
 text_weston_SOURCES = tests/text-test.c
 nodist_text_weston_SOURCES =			\
-	protocol/text-protocol.c		\
-	protocol/text-client-protocol.h
+	protocol/text-input-unstable-v1-protocol.c		\
+	protocol/text-input-unstable-v1-client-protocol.h
 text_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS)
 text_weston_LDADD = libtest-client.la
 
@@ -1336,13 +1336,12 @@ BUILT_SOURCES +=				\
 	protocol/weston-test-protocol.c	\
 	protocol/weston-test-server-protocol.h	\
 	protocol/weston-test-client-protocol.h	\
-	protocol/text-protocol.c		\
-	protocol/text-client-protocol.h
+	protocol/text-input-unstable-v1-protocol.c		\
+	protocol/text-input-unstable-v1-client-protocol.h
 
 EXTRA_DIST +=					\
 	protocol/desktop-shell.xml		\
 	protocol/screenshooter.xml		\
-	protocol/text.xml			\
 	protocol/input-method.xml		\
 	protocol/workspaces.xml			\
 	protocol/text-cursor-position.xml	\
diff --git a/clients/editor.c b/clients/editor.c
index 7d388a4..c3ac217 100644
--- a/clients/editor.c
+++ b/clients/editor.c
@@ -38,7 +38,7 @@
 
 #include "shared/helpers.h"
 #include "window.h"
-#include "text-client-protocol.h"
+#include "text-input-unstable-v1-client-protocol.h"
 
 struct text_entry {
 	struct widget *widget;
@@ -64,7 +64,7 @@ struct text_entry {
 		uint32_t delete_length;
 		bool invalid_delete;
 	} pending_commit;
-	struct wl_text_input *text_input;
+	struct zwl_text_input1 *text_input;
 	PangoLayout *layout;
 	struct {
 		xkb_mod_mask_t shift_mask;
@@ -78,7 +78,7 @@ struct text_entry {
 };
 
 struct editor {
-	struct wl_text_input_manager *text_input_manager;
+	struct zwl_text_input_manager1 *text_input_manager;
 	struct wl_data_source *selection;
 	char *selected_text;
 	struct display *display;
@@ -182,7 +182,7 @@ static void text_entry_update(struct text_entry *entry);
 
 static void
 text_input_commit_string(void *data,
-			 struct wl_text_input *text_input,
+			 struct zwl_text_input1 *text_input,
 			 uint32_t serial,
 			 const char *text)
 {
@@ -234,7 +234,7 @@ clear_pending_preedit(struct text_entry *entry)
 
 static void
 text_input_preedit_string(void *data,
-			  struct wl_text_input *text_input,
+			  struct zwl_text_input1 *text_input,
 			  uint32_t serial,
 			  const char *text,
 			  const char *commit)
@@ -275,7 +275,7 @@ text_input_preedit_string(void *data,
 
 static void
 text_input_delete_surrounding_text(void *data,
-				   struct wl_text_input *text_input,
+				   struct zwl_text_input1 *text_input,
 				   int32_t index,
 				   uint32_t length)
 {
@@ -300,7 +300,7 @@ text_input_delete_surrounding_text(void *data,
 
 static void
 text_input_cursor_position(void *data,
-			   struct wl_text_input *text_input,
+			   struct zwl_text_input1 *text_input,
 			   int32_t index,
 			   int32_t anchor)
 {
@@ -312,7 +312,7 @@ text_input_cursor_position(void *data,
 
 static void
 text_input_preedit_styling(void *data,
-			   struct wl_text_input *text_input,
+			   struct zwl_text_input1 *text_input,
 			   uint32_t index,
 			   uint32_t length,
 			   uint32_t style)
@@ -325,24 +325,24 @@ text_input_preedit_styling(void *data,
 		entry->preedit_info.attr_list = pango_attr_list_new();
 
 	switch (style) {
-		case WL_TEXT_INPUT_PREEDIT_STYLE_DEFAULT:
-		case WL_TEXT_INPUT_PREEDIT_STYLE_UNDERLINE:
+		case ZWL_TEXT_INPUT1_PREEDIT_STYLE_DEFAULT:
+		case ZWL_TEXT_INPUT1_PREEDIT_STYLE_UNDERLINE:
 			attr1 = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
 			break;
-		case WL_TEXT_INPUT_PREEDIT_STYLE_INCORRECT:
+		case ZWL_TEXT_INPUT1_PREEDIT_STYLE_INCORRECT:
 			attr1 = pango_attr_underline_new(PANGO_UNDERLINE_ERROR);
 			attr2 = pango_attr_underline_color_new(65535, 0, 0);
 			break;
-		case WL_TEXT_INPUT_PREEDIT_STYLE_SELECTION:
+		case ZWL_TEXT_INPUT1_PREEDIT_STYLE_SELECTION:
 			attr1 = pango_attr_background_new(0.3 * 65535, 0.3 * 65535, 65535);
 			attr2 = pango_attr_foreground_new(65535, 65535, 65535);
 			break;
-		case WL_TEXT_INPUT_PREEDIT_STYLE_HIGHLIGHT:
-		case WL_TEXT_INPUT_PREEDIT_STYLE_ACTIVE:
+		case ZWL_TEXT_INPUT1_PREEDIT_STYLE_HIGHLIGHT:
+		case ZWL_TEXT_INPUT1_PREEDIT_STYLE_ACTIVE:
 			attr1 = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
 			attr2 = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
 			break;
-		case WL_TEXT_INPUT_PREEDIT_STYLE_INACTIVE:
+		case ZWL_TEXT_INPUT1_PREEDIT_STYLE_INACTIVE:
 			attr1 = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
 			attr2 = pango_attr_foreground_new(0.3 * 65535, 0.3 * 65535, 0.3 * 65535);
 			break;
@@ -363,7 +363,7 @@ text_input_preedit_styling(void *data,
 
 static void
 text_input_preedit_cursor(void *data,
-			  struct wl_text_input *text_input,
+			  struct zwl_text_input1 *text_input,
 			  int32_t index)
 {
 	struct text_entry *entry = data;
@@ -373,7 +373,7 @@ text_input_preedit_cursor(void *data,
 
 static void
 text_input_modifiers_map(void *data,
-			 struct wl_text_input *text_input,
+			 struct zwl_text_input1 *text_input,
 			 struct wl_array *map)
 {
 	struct text_entry *entry = data;
@@ -383,7 +383,7 @@ text_input_modifiers_map(void *data,
 
 static void
 text_input_keysym(void *data,
-		  struct wl_text_input *text_input,
+		  struct zwl_text_input1 *text_input,
 		  uint32_t serial,
 		  uint32_t time,
 		  uint32_t key,
@@ -470,7 +470,7 @@ text_input_keysym(void *data,
 
 static void
 text_input_enter(void *data,
-		 struct wl_text_input *text_input,
+		 struct zwl_text_input1 *text_input,
 		 struct wl_surface *surface)
 {
 	struct text_entry *entry = data;
@@ -488,7 +488,7 @@ text_input_enter(void *data,
 
 static void
 text_input_leave(void *data,
-		 struct wl_text_input *text_input)
+		 struct zwl_text_input1 *text_input)
 {
 	struct text_entry *entry = data;
 
@@ -496,21 +496,21 @@ text_input_leave(void *data,
 	entry->active--;
 
 	if (!entry->active)
-		wl_text_input_hide_input_panel(text_input);
+		zwl_text_input1_hide_input_panel(text_input);
 
 	widget_schedule_redraw(entry->widget);
 }
 
 static void
 text_input_input_panel_state(void *data,
-			     struct wl_text_input *text_input,
+			     struct zwl_text_input1 *text_input,
 			     uint32_t state)
 {
 }
 
 static void
 text_input_language(void *data,
-		    struct wl_text_input *text_input,
+		    struct zwl_text_input1 *text_input,
 		    uint32_t serial,
 		    const char *language)
 {
@@ -519,7 +519,7 @@ text_input_language(void *data,
 
 static void
 text_input_text_direction(void *data,
-			  struct wl_text_input *text_input,
+			  struct zwl_text_input1 *text_input,
 			  uint32_t serial,
 			  uint32_t direction)
 {
@@ -529,13 +529,13 @@ text_input_text_direction(void *data,
 
 
 	switch (direction) {
-		case WL_TEXT_INPUT_TEXT_DIRECTION_LTR:
+		case ZWL_TEXT_INPUT1_TEXT_DIRECTION_LTR:
 			pango_direction = PANGO_DIRECTION_LTR;
 			break;
-		case WL_TEXT_INPUT_TEXT_DIRECTION_RTL:
+		case ZWL_TEXT_INPUT1_TEXT_DIRECTION_RTL:
 			pango_direction = PANGO_DIRECTION_RTL;
 			break;
-		case WL_TEXT_INPUT_TEXT_DIRECTION_AUTO:
+		case ZWL_TEXT_INPUT1_TEXT_DIRECTION_AUTO:
 		default:
 			pango_direction = PANGO_DIRECTION_NEUTRAL;
 	}
@@ -543,7 +543,7 @@ text_input_text_direction(void *data,
 	pango_context_set_base_dir(context, pango_direction);
 }
 
-static const struct wl_text_input_listener text_input_listener = {
+static const struct zwl_text_input1_listener text_input_listener = {
 	text_input_enter,
 	text_input_leave,
 	text_input_modifiers_map,
@@ -695,8 +695,10 @@ text_entry_create(struct editor *editor, const char *text)
 	entry->active = 0;
 	entry->cursor = strlen(text);
 	entry->anchor = entry->cursor;
-	entry->text_input = wl_text_input_manager_create_text_input(editor->text_input_manager);
-	wl_text_input_add_listener(entry->text_input, &text_input_listener, entry);
+	entry->text_input =
+		zwl_text_input_manager1_create_text_input(editor->text_input_manager);
+	zwl_text_input1_add_listener(entry->text_input,
+				     &text_input_listener, entry);
 
 	widget_set_redraw_handler(entry->widget, text_entry_redraw_handler);
 	widget_set_button_handler(entry->widget, text_entry_button_handler);
@@ -710,7 +712,7 @@ static void
 text_entry_destroy(struct text_entry *entry)
 {
 	widget_destroy(entry->widget);
-	wl_text_input_destroy(entry->text_input);
+	zwl_text_input1_destroy(entry->text_input);
 	g_clear_object(&entry->layout);
 	free(entry->text);
 	free(entry);
@@ -778,25 +780,25 @@ text_entry_activate(struct text_entry *entry,
 	struct wl_surface *surface = window_get_wl_surface(entry->window);
 
 	if (entry->click_to_show && entry->active) {
-		wl_text_input_show_input_panel(entry->text_input);
+		zwl_text_input1_show_input_panel(entry->text_input);
 
 		return;
 	}
 
 	if (!entry->click_to_show)
-		wl_text_input_show_input_panel(entry->text_input);
+		zwl_text_input1_show_input_panel(entry->text_input);
 
-	wl_text_input_activate(entry->text_input,
-			       seat,
-			       surface);
+	zwl_text_input1_activate(entry->text_input,
+				 seat,
+				 surface);
 }
 
 static void
 text_entry_deactivate(struct text_entry *entry,
 		      struct wl_seat *seat)
 {
-	wl_text_input_deactivate(entry->text_input,
-				 seat);
+	zwl_text_input1_deactivate(entry->text_input,
+				   seat);
 }
 
 static void
@@ -867,24 +869,27 @@ text_entry_update(struct text_entry *entry)
 {
 	struct rectangle cursor_rectangle;
 
-	wl_text_input_set_content_type(entry->text_input,
-				       WL_TEXT_INPUT_CONTENT_HINT_NONE,
-				       entry->content_purpose);
+	zwl_text_input1_set_content_type(entry->text_input,
+					 ZWL_TEXT_INPUT1_CONTENT_HINT_NONE,
+					 entry->content_purpose);
 
-	wl_text_input_set_surrounding_text(entry->text_input,
-					   entry->text,
-					   entry->cursor,
-					   entry->anchor);
+	zwl_text_input1_set_surrounding_text(entry->text_input,
+					     entry->text,
+					     entry->cursor,
+					     entry->anchor);
 
 	if (entry->preferred_language)
-		wl_text_input_set_preferred_language(entry->text_input,
-						     entry->preferred_language);
+		zwl_text_input1_set_preferred_language(entry->text_input,
+						       entry->preferred_language);
 
 	text_entry_get_cursor_rectangle(entry, &cursor_rectangle);
-	wl_text_input_set_cursor_rectangle(entry->text_input, cursor_rectangle.x, cursor_rectangle.y,
-					   cursor_rectangle.width, cursor_rectangle.height);
+	zwl_text_input1_set_cursor_rectangle(entry->text_input,
+					     cursor_rectangle.x,
+					     cursor_rectangle.y,
+					     cursor_rectangle.width,
+					     cursor_rectangle.height);
 
-	wl_text_input_commit_state(entry->text_input, ++entry->serial);
+	zwl_text_input1_commit_state(entry->text_input, ++entry->serial);
 }
 
 static void
@@ -946,7 +951,7 @@ text_entry_commit_and_reset(struct text_entry *entry)
 		free(commit);
 	}
 
-	wl_text_input_reset(entry->text_input);
+	zwl_text_input1_reset(entry->text_input);
 	text_entry_update(entry);
 	entry->reset_serial = entry->serial;
 }
@@ -995,9 +1000,9 @@ text_entry_try_invoke_preedit_action(struct text_entry *entry,
 	}
 
 	if (state == WL_POINTER_BUTTON_STATE_RELEASED)
-		wl_text_input_invoke_action(entry->text_input,
-					    button,
-					    cursor - entry->cursor);
+		zwl_text_input1_invoke_action(entry->text_input,
+					      button,
+					      cursor - entry->cursor);
 
 	return 1;
 }
@@ -1472,10 +1477,10 @@ global_handler(struct display *display, uint32_t name,
 {
 	struct editor *editor = data;
 
-	if (!strcmp(interface, "wl_text_input_manager")) {
+	if (!strcmp(interface, "zwl_text_input_manager1")) {
 		editor->text_input_manager =
 			display_bind(display, name,
-				     &wl_text_input_manager_interface, 1);
+				     &zwl_text_input_manager1_interface, 1);
 	}
 }
 
@@ -1531,7 +1536,7 @@ main(int argc, char *argv[])
 	if (preferred_language)
 		editor.entry->preferred_language = strdup(preferred_language);
 	editor.editor = text_entry_create(&editor, "Numeric");
-	editor.editor->content_purpose = WL_TEXT_INPUT_CONTENT_PURPOSE_NUMBER;
+	editor.editor->content_purpose = ZWL_TEXT_INPUT1_CONTENT_PURPOSE_NUMBER;
 	editor.editor->click_to_show = click_to_show;
 	editor.selection = NULL;
 	editor.selected_text = NULL;
diff --git a/clients/keyboard.c b/clients/keyboard.c
index f5ffe30..61cfda5 100644
--- a/clients/keyboard.c
+++ b/clients/keyboard.c
@@ -33,7 +33,7 @@
 
 #include "window.h"
 #include "input-method-client-protocol.h"
-#include "text-client-protocol.h"
+#include "text-input-unstable-v1-client-protocol.h"
 
 struct keyboard;
 
@@ -216,7 +216,7 @@ static const struct layout normal_layout = {
 	12,
 	4,
 	"en",
-	WL_TEXT_INPUT_TEXT_DIRECTION_LTR
+	ZWL_TEXT_INPUT1_TEXT_DIRECTION_LTR
 };
 
 static const struct layout numeric_layout = {
@@ -225,7 +225,7 @@ static const struct layout numeric_layout = {
 	12,
 	2,
 	"en",
-	WL_TEXT_INPUT_TEXT_DIRECTION_LTR
+	ZWL_TEXT_INPUT1_TEXT_DIRECTION_LTR
 };
 
 static const struct layout arabic_layout = {
@@ -234,7 +234,7 @@ static const struct layout arabic_layout = {
 	13,
 	4,
 	"ar",
-	WL_TEXT_INPUT_TEXT_DIRECTION_RTL
+	ZWL_TEXT_INPUT1_TEXT_DIRECTION_RTL
 };
 
 static const char *style_labels[] = {
@@ -339,8 +339,8 @@ static const struct layout *
 get_current_layout(struct virtual_keyboard *keyboard)
 {
 	switch (keyboard->content_purpose) {
-		case WL_TEXT_INPUT_CONTENT_PURPOSE_DIGITS:
-		case WL_TEXT_INPUT_CONTENT_PURPOSE_NUMBER:
+		case ZWL_TEXT_INPUT1_CONTENT_PURPOSE_DIGITS:
+		case ZWL_TEXT_INPUT1_CONTENT_PURPOSE_NUMBER:
 			return &numeric_layout;
 		default:
 			if (keyboard->preferred_language &&
diff --git a/protocol/text.xml b/protocol/text.xml
deleted file mode 100644
index 0f824ea..0000000
--- a/protocol/text.xml
+++ /dev/null
@@ -1,374 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<protocol name="text">
-
-  <copyright>
-    Copyright © 2012, 2013 Intel Corporation
-
-	Permission is hereby granted, free of charge, to any person obtaining a
-	copy of this software and associated documentation files (the "Software"),
-	to deal in the Software without restriction, including without limitation
-	the rights to use, copy, modify, merge, publish, distribute, sublicense,
-	and/or sell copies of the Software, and to permit persons to whom the
-	Software is furnished to do so, subject to the following conditions:
-
-	The above copyright notice and this permission notice (including the next
-	paragraph) shall be included in all copies or substantial portions of the
-	Software.
-
-	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
-	THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-	FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-	DEALINGS IN THE SOFTWARE.
-  </copyright>
-
-  <interface name="wl_text_input" version="1">
-    <description summary="text input">
-      An object used for text input. Adds support for text input and input
-      methods to applications. A text-input object is created from a
-      wl_text_input_manager and corresponds typically to a text entry in an
-      application.
-      Requests are used to activate/deactivate the text-input object and set
-      state information like surrounding and selected text or the content type.
-      The information about entered text is sent to the text-input object via
-      the pre-edit and commit events. Using this interface removes the need
-      for applications to directly process hardware key events and compose text
-      out of them.
-
-      Text is generally UTF-8 encoded, indices and lengths are in bytes.
-
-      Serials are used to synchronize the state between the text input and
-      an input method. New serials are sent by the text input in the
-      commit_state request and are used by the input method to indicate
-      the known text input state in events like preedit_string, commit_string,
-      and keysym. The text input can then ignore events from the input method
-      which are based on an outdated state (for example after a reset).
-    </description>
-
-    <request name="activate">
-      <description summary="request activation">
-        Requests the text-input object to be activated (typically when the
-        text entry gets focus).
-        The seat argument is a wl_seat which maintains the focus for this
-        activation. The surface argument is a wl_surface assigned to the
-        text-input object and tracked for focus lost. The enter event
-        is emitted on successful activation.
-      </description>
-      <arg name="seat" type="object" interface="wl_seat"/>
-      <arg name="surface" type="object" interface="wl_surface"/>
-    </request>
-
-    <request name="deactivate">
-      <description summary="request deactivation">
-        Requests the text-input object to be deactivated (typically when the
-        text entry lost focus). The seat argument is a wl_seat which was used
-        for activation.
-      </description>
-      <arg name="seat" type="object" interface="wl_seat"/>
-    </request>
-
-    <request name="show_input_panel">
-      <description summary="show input panels">
-        Requests input panels (virtual keyboard) to show.
-      </description>
-    </request>
-
-    <request name="hide_input_panel">
-      <description summary="hide input panels">
-        Requests input panels (virtual keyboard) to hide.
-      </description>
-    </request>
-
-    <request name="reset">
-      <description summary="reset">
-        Should be called by an editor widget when the input state should be
-        reset, for example after the text was changed outside of the normal
-        input method flow.
-      </description>
-    </request>
-
-    <request name="set_surrounding_text">
-      <description summary="sets the surrounding text">
-        Sets the plain surrounding text around the input position. Text is
-        UTF-8 encoded. Cursor is the byte offset within the
-        surrounding text. Anchor is the byte offset of the
-        selection anchor within the surrounding text. If there is no selected
-        text anchor is the same as cursor.
-      </description>
-      <arg name="text" type="string"/>
-      <arg name="cursor" type="uint"/>
-      <arg name="anchor" type="uint"/>
-    </request>
-
-    <enum name="content_hint">
-      <description summary="content hint">
-        Content hint is a bitmask to allow to modify the behavior of the text
-        input.
-      </description>
-      <entry name="none" value="0x0" summary="no special behaviour"/>
-      <entry name="default" value="0x7" summary="auto completion, correction and capitalization"/>
-      <entry name="password" value="0xc0" summary="hidden and sensitive text"/>
-      <entry name="auto_completion" value="0x1" summary="suggest word completions"/>
-      <entry name="auto_correction" value="0x2" summary="suggest word corrections"/>
-      <entry name="auto_capitalization" value="0x4" summary="switch to uppercase letters at the start of a sentence"/>
-      <entry name="lowercase" value="0x8" summary="prefer lowercase letters"/>
-      <entry name="uppercase" value="0x10" summary="prefer uppercase letters"/>
-      <entry name="titlecase" value="0x20" summary="prefer casing for titles and headings (can be language dependent)"/>
-      <entry name="hidden_text" value="0x40" summary="characters should be hidden"/>
-      <entry name="sensitive_data" value="0x80" summary="typed text should not be stored"/>
-      <entry name="latin" value="0x100" summary="just latin characters should be entered"/>
-      <entry name="multiline" value="0x200" summary="the text input is multiline"/>
-    </enum>
-
-    <enum name="content_purpose">
-      <description summary="content purpose">
-        The content purpose allows to specify the primary purpose of a text
-        input.
-
-        This allows an input method to show special purpose input panels with
-        extra characters or to disallow some characters.
-      </description>
-      <entry name="normal" value="0" summary="default input, allowing all characters"/>
-      <entry name="alpha" value="1" summary="allow only alphabetic characters"/>
-      <entry name="digits" value="2" summary="allow only digits"/>
-      <entry name="number" value="3" summary="input a number (including decimal separator and sign)"/>
-      <entry name="phone" value="4" summary="input a phone number"/>
-      <entry name="url" value="5" summary="input an URL"/>
-      <entry name="email" value="6" summary="input an email address"/>
-      <entry name="name" value="7" summary="input a name of a person"/>
-      <entry name="password" value="8" summary="input a password (combine with password or sensitive_data hint)"/>
-      <entry name="date" value="9" summary="input a date"/>
-      <entry name="time" value="10" summary="input a time"/>
-      <entry name="datetime" value="11" summary="input a date and time"/>
-      <entry name="terminal" value="12" summary="input for a terminal"/>
-    </enum>
-
-    <request name="set_content_type">
-      <description summary="set content purpose and hint">
-        Sets the content purpose and content hint. While the purpose is the
-        basic purpose of an input field, the hint flags allow to modify some
-        of the behavior.
-
-        When no content type is explicitly set, a normal content purpose with
-        default hints (auto completion, auto correction, auto capitalization)
-        should be assumed.
-      </description>
-      <arg name="hint" type="uint"/>
-      <arg name="purpose" type="uint"/>
-    </request>
-
-    <request name="set_cursor_rectangle">
-      <arg name="x" type="int"/>
-      <arg name="y" type="int"/>
-      <arg name="width" type="int"/>
-      <arg name="height" type="int"/>
-    </request>
-
-    <request name="set_preferred_language">
-      <description summary="sets preferred language">
-        Sets a specific language. This allows for example a virtual keyboard to
-        show a language specific layout. The "language" argument is a RFC-3066
-	format language tag.
-
-	It could be used for example in a word processor to indicate language of
-	currently edited document or in an instant message application which tracks
-	languages of contacts.
-      </description>
-      <arg name="language" type="string"/>
-    </request>
-
-    <request name="commit_state">
-      <arg name="serial" type="uint" summary="used to identify the known state"/>
-    </request>
-
-    <request name="invoke_action">
-      <arg name="button" type="uint"/>
-      <arg name="index" type="uint"/>
-    </request>
-
-    <event name="enter">
-      <description summary="enter event">
-        Notify the text-input object when it received focus. Typically in
-        response to an activate request.
-      </description>
-      <arg name="surface" type="object" interface="wl_surface"/>
-    </event>
-
-    <event name="leave">
-      <description summary="leave event">
-        Notify the text-input object when it lost focus. Either in response
-        to a deactivate request or when the assigned surface lost focus or was
-        destroyed.
-      </description>
-    </event>
-
-    <event name="modifiers_map">
-      <description summary="modifiers map">
-        Transfer an array of 0-terminated modifiers names. The position in
-        the array is the index of the modifier as used in the modifiers
-        bitmask in the keysym event.
-      </description>
-      <arg name="map" type="array"/>
-    </event>
-
-    <event name="input_panel_state">
-      <description summary="state of the input panel">
-        Notify when the visibility state of the input panel changed.
-      </description>
-      <arg name="state" type="uint"/>
-    </event>
-
-    <event name="preedit_string">
-      <description summary="pre-edit">
-        Notify when a new composing text (pre-edit) should be set around the
-        current cursor position. Any previously set composing text should
-        be removed.
-
-        The commit text can be used to replace the preedit text on reset
-	(for example on unfocus).
-
-	The text input should also handle all preedit_style and preedit_cursor
-	events occurring directly before preedit_string.
-      </description>
-      <arg name="serial" type="uint" summary="serial of the latest known text input state"/>
-      <arg name="text" type="string"/>
-      <arg name="commit" type="string"/>
-    </event>
-
-    <enum name="preedit_style">
-      <entry name="default" value="0" summary="default style for composing text"/>
-      <entry name="none" value="1" summary="style should be the same as in non-composing text"/>
-      <entry name="active" value="2"/>
-      <entry name="inactive" value="3"/>
-      <entry name="highlight" value="4"/>
-      <entry name="underline" value="5"/>
-      <entry name="selection" value="6"/>
-      <entry name="incorrect" value="7"/>
-    </enum>
-
-    <event name="preedit_styling">
-      <description summary="pre-edit styling">
-        Sets styling information on composing text. The style is applied for
-	length bytes from index relative to the beginning of the composing
-	text (as byte offset). Multiple styles can
-        be applied to a composing text by sending multiple preedit_styling
-        events.
-
-        This event is handled as part of a following preedit_string event.
-      </description>
-      <arg name="index" type="uint"/>
-      <arg name="length" type="uint"/>
-      <arg name="style" type="uint"/>
-    </event>
-
-    <event name="preedit_cursor">
-      <description summary="pre-edit cursor">
-        Sets the cursor position inside the composing text (as byte
-        offset) relative to the start of the composing text. When index is a
-        negative number no cursor is shown.
-
-        This event is handled as part of a following preedit_string event.
-      </description>
-      <arg name="index" type="int"/>
-    </event>
-
-    <event name="commit_string">
-      <description summary="commit">
-        Notify when text should be inserted into the editor widget. The text to
-        commit could be either just a single character after a key press or the
-        result of some composing (pre-edit). It could be also an empty text
-        when some text should be removed (see delete_surrounding_text) or when
-        the input cursor should be moved (see cursor_position).
-
-        Any previously set composing text should be removed.
-      </description>
-      <arg name="serial" type="uint" summary="serial of the latest known text input state"/>
-      <arg name="text" type="string"/>
-    </event>
-
-    <event name="cursor_position">
-      <description summary="set cursor to new position">
-        Notify when the cursor or anchor position should be modified.
-
-        This event should be handled as part of a following commit_string
-        event.
-      </description>
-      <arg name="index" type="int"/>
-      <arg name="anchor" type="int"/>
-    </event>
-
-    <event name="delete_surrounding_text">
-      <description summary="delete surrounding text">
-        Notify when the text around the current cursor position should be
-        deleted.
-
-        Index is relative to the current cursor (in bytes).
-        Length is the length of deleted text (in bytes).
-
-        This event should be handled as part of a following commit_string
-        event.
-      </description>
-      <arg name="index" type="int"/>
-      <arg name="length" type="uint"/>
-    </event>
-
-    <event name="keysym">
-      <description summary="keysym">
-        Notify when a key event was sent. Key events should not be used
-        for normal text input operations, which should be done with
-        commit_string, delete_surrounding_text, etc. The key event follows
-        the wl_keyboard key event convention. Sym is a XKB keysym, state a
-        wl_keyboard key_state. Modifiers are a mask for effective modifiers
-        (where the modifier indices are set by the modifiers_map event)
-      </description>
-      <arg name="serial" type="uint" summary="serial of the latest known text input state"/>
-      <arg name="time" type="uint"/>
-      <arg name="sym" type="uint"/>
-      <arg name="state" type="uint"/>
-      <arg name="modifiers" type="uint"/>
-    </event>
-
-    <event name="language">
-      <description summary="language">
-        Sets the language of the input text. The "language" argument is a RFC-3066
-        format language tag.
-      </description>
-      <arg name="serial" type="uint" summary="serial of the latest known text input state"/>
-      <arg name="language" type="string"/>
-    </event>
-
-    <enum name="text_direction">
-      <entry name="auto" value="0" summary="automatic text direction based on text and language"/>
-      <entry name="ltr" value="1" summary="left-to-right"/>
-      <entry name="rtl" value="2" summary="right-to-left"/>
-    </enum>
-
-    <event name="text_direction">
-      <description summary="text direction">
-        Sets the text direction of input text.
-
-        It is mainly needed for showing input cursor on correct side of the
-        editor when there is no input yet done and making sure neutral
-        direction text is laid out properly.
-      </description>
-      <arg name="serial" type="uint" summary="serial of the latest known text input state"/>
-      <arg name="direction" type="uint"/>
-    </event>
-  </interface>
-
-  <interface name="wl_text_input_manager" version="1">
-    <description summary="text input manager">
-      A factory for text-input objects. This object is a global singleton.
-    </description>
-
-    <request name="create_text_input">
-      <description summary="create text input">
-        Creates a new text-input object.
-      </description>
-      <arg name="id" type="new_id" interface="wl_text_input"/>
-    </request>
-  </interface>
-
-</protocol>
diff --git a/src/text-backend.c b/src/text-backend.c
index 8c9e30d..5227b97 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -33,7 +33,7 @@
 #include <time.h>
 
 #include "compositor.h"
-#include "text-server-protocol.h"
+#include "text-input-unstable-v1-server-protocol.h"
 #include "input-method-server-protocol.h"
 #include "shared/helpers.h"
 
@@ -142,7 +142,7 @@ deactivate_input_method(struct input_method *input_method)
 		text_input->input_panel_visible = false;
 		text_input->manager->current_panel = NULL;
 	}
-	wl_text_input_send_leave(text_input->resource);
+	zwl_text_input1_send_leave(text_input->resource);
 }
 
 static void
@@ -219,8 +219,8 @@ text_input_activate(struct wl_client *client,
 		text_input->manager->current_panel = text_input;
 	}
 
-	wl_text_input_send_enter(text_input->resource,
-				 text_input->surface->resource);
+	zwl_text_input1_send_enter(text_input->resource,
+				   text_input->surface->resource);
 }
 
 static void
@@ -373,7 +373,7 @@ text_input_set_preferred_language(struct wl_client *client,
 	}
 }
 
-static const struct wl_text_input_interface text_input_implementation = {
+static const struct zwl_text_input1_interface text_input_implementation = {
 	text_input_activate,
 	text_input_deactivate,
 	text_input_show_input_panel,
@@ -400,7 +400,7 @@ static void text_input_manager_create_text_input(struct wl_client *client,
 		return;
 
 	text_input->resource =
-		wl_resource_create(client, &wl_text_input_interface, 1, id);
+		wl_resource_create(client, &zwl_text_input1_interface, 1, id);
 	wl_resource_set_implementation(text_input->resource,
 				       &text_input_implementation,
 				       text_input, destroy_text_input);
@@ -411,7 +411,7 @@ static void text_input_manager_create_text_input(struct wl_client *client,
 	wl_list_init(&text_input->input_methods);
 };
 
-static const struct wl_text_input_manager_interface manager_implementation = {
+static const struct zwl_text_input_manager1_interface manager_implementation = {
 	text_input_manager_create_text_input
 };
 
@@ -427,7 +427,7 @@ bind_text_input_manager(struct wl_client *client,
 	/* No checking for duplicate binding necessary.  */
 	resource =
 		wl_resource_create(client,
-				   &wl_text_input_manager_interface, 1, id);
+				   &zwl_text_input_manager1_interface, 1, id);
 	if (resource)
 		wl_resource_set_implementation(resource,
 					       &manager_implementation,
@@ -460,7 +460,7 @@ text_input_manager_create(struct weston_compositor *ec)
 
 	text_input_manager->text_input_manager_global =
 		wl_global_create(ec->wl_display,
-				 &wl_text_input_manager_interface, 1,
+				 &zwl_text_input_manager1_interface, 1,
 				 text_input_manager, bind_text_input_manager);
 
 	text_input_manager->destroy_listener.notify =
@@ -486,8 +486,8 @@ input_method_context_commit_string(struct wl_client *client,
 		wl_resource_get_user_data(resource);
 
 	if (context->input)
-		wl_text_input_send_commit_string(context->input->resource,
-						 serial, text);
+		zwl_text_input1_send_commit_string(context->input->resource,
+						   serial, text);
 }
 
 static void
@@ -501,8 +501,8 @@ input_method_context_preedit_string(struct wl_client *client,
 		wl_resource_get_user_data(resource);
 
 	if (context->input)
-		wl_text_input_send_preedit_string(context->input->resource,
-						  serial, text, commit);
+		zwl_text_input1_send_preedit_string(context->input->resource,
+						    serial, text, commit);
 }
 
 static void
@@ -516,8 +516,8 @@ input_method_context_preedit_styling(struct wl_client *client,
 		wl_resource_get_user_data(resource);
 
 	if (context->input)
-		wl_text_input_send_preedit_styling(context->input->resource,
-						   index, length, style);
+		zwl_text_input1_send_preedit_styling(context->input->resource,
+						     index, length, style);
 }
 
 static void
@@ -529,8 +529,8 @@ input_method_context_preedit_cursor(struct wl_client *client,
 		wl_resource_get_user_data(resource);
 
 	if (context->input)
-		wl_text_input_send_preedit_cursor(context->input->resource,
-						  cursor);
+		zwl_text_input1_send_preedit_cursor(context->input->resource,
+						    cursor);
 }
 
 static void
@@ -543,7 +543,7 @@ input_method_context_delete_surrounding_text(struct wl_client *client,
 		wl_resource_get_user_data(resource);
 
 	if (context->input)
-		wl_text_input_send_delete_surrounding_text(
+		zwl_text_input1_send_delete_surrounding_text(
 			context->input->resource, index, length);
 }
 
@@ -557,8 +557,8 @@ input_method_context_cursor_position(struct wl_client *client,
 		wl_resource_get_user_data(resource);
 
 	if (context->input)
-		wl_text_input_send_cursor_position(context->input->resource,
-						   index, anchor);
+		zwl_text_input1_send_cursor_position(context->input->resource,
+						     index, anchor);
 }
 
 static void
@@ -570,7 +570,8 @@ input_method_context_modifiers_map(struct wl_client *client,
 		wl_resource_get_user_data(resource);
 
 	if (context->input)
-		wl_text_input_send_modifiers_map(context->input->resource, map);
+		zwl_text_input1_send_modifiers_map(context->input->resource,
+						   map);
 }
 
 static void
@@ -586,8 +587,9 @@ input_method_context_keysym(struct wl_client *client,
 		wl_resource_get_user_data(resource);
 
 	if (context->input)
-		wl_text_input_send_keysym(context->input->resource,
-					  serial, time, sym, state, modifiers);
+		zwl_text_input1_send_keysym(context->input->resource,
+					    serial, time,
+					    sym, state, modifiers);
 }
 
 static void
@@ -724,8 +726,8 @@ input_method_context_language(struct wl_client *client,
 		wl_resource_get_user_data(resource);
 
 	if (context->input)
-		wl_text_input_send_language(context->input->resource,
-					    serial, language);
+		zwl_text_input1_send_language(context->input->resource,
+					      serial, language);
 }
 
 static void
@@ -738,8 +740,8 @@ input_method_context_text_direction(struct wl_client *client,
 		wl_resource_get_user_data(resource);
 
 	if (context->input)
-		wl_text_input_send_text_direction(context->input->resource,
-						  serial, direction);
+		zwl_text_input1_send_text_direction(context->input->resource,
+						    serial, direction);
 }
 
 
diff --git a/tests/text-test.c b/tests/text-test.c
index ce60c3d..1a1275d 100644
--- a/tests/text-test.c
+++ b/tests/text-test.c
@@ -29,7 +29,7 @@
 #include <stdio.h>
 
 #include "weston-test-client-helper.h"
-#include "text-client-protocol.h"
+#include "text-input-unstable-v1-client-protocol.h"
 
 struct text_input_state {
 	int activated;
@@ -38,7 +38,7 @@ struct text_input_state {
 
 static void
 text_input_commit_string(void *data,
-			 struct wl_text_input *text_input,
+			 struct zwl_text_input1 *text_input,
 			 uint32_t serial,
 			 const char *text)
 {
@@ -46,7 +46,7 @@ text_input_commit_string(void *data,
 
 static void
 text_input_preedit_string(void *data,
-			  struct wl_text_input *text_input,
+			  struct zwl_text_input1 *text_input,
 			  uint32_t serial,
 			  const char *text,
 			  const char *commit)
@@ -55,7 +55,7 @@ text_input_preedit_string(void *data,
 
 static void
 text_input_delete_surrounding_text(void *data,
-				   struct wl_text_input *text_input,
+				   struct zwl_text_input1 *text_input,
 				   int32_t index,
 				   uint32_t length)
 {
@@ -63,7 +63,7 @@ text_input_delete_surrounding_text(void *data,
 
 static void
 text_input_cursor_position(void *data,
-			   struct wl_text_input *text_input,
+			   struct zwl_text_input1 *text_input,
 			   int32_t index,
 			   int32_t anchor)
 {
@@ -71,7 +71,7 @@ text_input_cursor_position(void *data,
 
 static void
 text_input_preedit_styling(void *data,
-			   struct wl_text_input *text_input,
+			   struct zwl_text_input1 *text_input,
 			   uint32_t index,
 			   uint32_t length,
 			   uint32_t style)
@@ -80,21 +80,21 @@ text_input_preedit_styling(void *data,
 
 static void
 text_input_preedit_cursor(void *data,
-			  struct wl_text_input *text_input,
+			  struct zwl_text_input1 *text_input,
 			  int32_t index)
 {
 }
 
 static void
 text_input_modifiers_map(void *data,
-			 struct wl_text_input *text_input,
+			 struct zwl_text_input1 *text_input,
 			 struct wl_array *map)
 {
 }
 
 static void
 text_input_keysym(void *data,
-		  struct wl_text_input *text_input,
+		  struct zwl_text_input1 *text_input,
 		  uint32_t serial,
 		  uint32_t time,
 		  uint32_t sym,
@@ -105,7 +105,7 @@ text_input_keysym(void *data,
 
 static void
 text_input_enter(void *data,
-		 struct wl_text_input *text_input,
+		 struct zwl_text_input1 *text_input,
 		 struct wl_surface *surface)
 
 {
@@ -118,7 +118,7 @@ text_input_enter(void *data,
 
 static void
 text_input_leave(void *data,
-		 struct wl_text_input *text_input)
+		 struct zwl_text_input1 *text_input)
 {
 	struct text_input_state *state = data;
 
@@ -127,14 +127,14 @@ text_input_leave(void *data,
 
 static void
 text_input_input_panel_state(void *data,
-			     struct wl_text_input *text_input,
+			     struct zwl_text_input1 *text_input,
 			     uint32_t state)
 {
 }
 
 static void
 text_input_language(void *data,
-		    struct wl_text_input *text_input,
+		    struct zwl_text_input1 *text_input,
 		    uint32_t serial,
 		    const char *language)
 {
@@ -142,13 +142,13 @@ text_input_language(void *data,
 
 static void
 text_input_text_direction(void *data,
-			  struct wl_text_input *text_input,
+			  struct zwl_text_input1 *text_input,
 			  uint32_t serial,
 			  uint32_t direction)
 {
 }
 
-static const struct wl_text_input_listener text_input_listener = {
+static const struct zwl_text_input1_listener text_input_listener = {
 	text_input_enter,
 	text_input_leave,
 	text_input_modifiers_map,
@@ -168,8 +168,8 @@ TEST(text_test)
 {
 	struct client *client;
 	struct global *global;
-	struct wl_text_input_manager *factory;
-	struct wl_text_input *text_input;
+	struct zwl_text_input_manager1 *factory;
+	struct zwl_text_input1 *text_input;
 	struct text_input_state state;
 
 	client = create_client_and_test_surface(100, 100, 100, 100);
@@ -177,17 +177,17 @@ TEST(text_test)
 
 	factory = NULL;
 	wl_list_for_each(global, &client->global_list, link) {
-		if (strcmp(global->interface, "wl_text_input_manager") == 0)
+		if (strcmp(global->interface, "zwl_text_input_manager1") == 0)
 			factory = wl_registry_bind(client->wl_registry,
 						   global->name,
-						   &wl_text_input_manager_interface, 1);
+						   &zwl_text_input_manager1_interface, 1);
 	}
 
 	assert(factory);
 
 	memset(&state, 0, sizeof state);
-	text_input = wl_text_input_manager_create_text_input(factory);
-	wl_text_input_add_listener(text_input, &text_input_listener, &state);
+	text_input = zwl_text_input_manager1_create_text_input(factory);
+	zwl_text_input1_add_listener(text_input, &text_input_listener, &state);
 
 	/* Make sure our test surface has keyboard focus. */
 	weston_test_activate_surface(client->test->weston_test,
@@ -196,19 +196,19 @@ TEST(text_test)
 	assert(client->input->keyboard->focus == client->surface);
 
 	/* Activate test model and make sure we get enter event. */
-	wl_text_input_activate(text_input, client->input->wl_seat,
-			       client->surface->wl_surface);
+	zwl_text_input1_activate(text_input, client->input->wl_seat,
+				 client->surface->wl_surface);
 	client_roundtrip(client);
 	assert(state.activated == 1 && state.deactivated == 0);
 
 	/* Deactivate test model and make sure we get leave event. */
-	wl_text_input_deactivate(text_input, client->input->wl_seat);
+	zwl_text_input1_deactivate(text_input, client->input->wl_seat);
 	client_roundtrip(client);
 	assert(state.activated == 1 && state.deactivated == 1);
 
 	/* Activate test model again. */
-	wl_text_input_activate(text_input, client->input->wl_seat,
-			       client->surface->wl_surface);
+	zwl_text_input1_activate(text_input, client->input->wl_seat,
+				 client->surface->wl_surface);
 	client_roundtrip(client);
 	assert(state.activated == 2 && state.deactivated == 1);
 
-- 
2.4.3



More information about the wayland-devel mailing list