[PATCH 13/13] text: Move text protocol to wayland
Jan Arne Petersen
jpetersen at openismus.com
Tue Feb 19 10:27:07 PST 2013
From: Jan Arne Petersen <jpetersen at openismus.com>
Signed-off-by: Jan Arne Petersen <jpetersen at openismus.com>
---
clients/Makefile.am | 6 +-
clients/editor.c | 89 +++++++-------
clients/keyboard.c | 11 +-
protocol/Makefile.am | 1 -
protocol/text.xml | 330 ---------------------------------------------------
src/Makefile.am | 4 -
src/text-backend.c | 35 +++---
tests/Makefile.am | 5 +-
tests/text-test.c | 47 ++++----
9 files changed, 91 insertions(+), 437 deletions(-)
delete mode 100644 protocol/text.xml
diff --git a/clients/Makefile.am b/clients/Makefile.am
index 8c9bcd4..5013331 100644
--- a/clients/Makefile.am
+++ b/clients/Makefile.am
@@ -132,9 +132,7 @@ calibrator_LDADD = libtoytoolkit.la
if HAVE_PANGO
pango_programs = editor
editor_SOURCES = \
- editor.c \
- text-protocol.c \
- text-client-protocol.h
+ editor.c
editor_LDADD = libtoytoolkit.la $(PANGO_LIBS)
editor_CPPFLAGS = $(AM_CPPFLAGS) $(PANGO_CFLAGS)
endif
@@ -177,8 +175,6 @@ BUILT_SOURCES = \
screenshooter-protocol.c \
text-cursor-position-client-protocol.h \
text-cursor-position-protocol.c \
- text-protocol.c \
- text-client-protocol.h \
input-method-protocol.c \
input-method-client-protocol.h \
desktop-shell-client-protocol.h \
diff --git a/clients/editor.c b/clients/editor.c
index 45b97f6..254b051 100644
--- a/clients/editor.c
+++ b/clients/editor.c
@@ -34,7 +34,6 @@
#include <pango/pangocairo.h>
#include "window.h"
-#include "text-client-protocol.h"
struct text_entry {
struct widget *widget;
@@ -57,7 +56,7 @@ struct text_entry {
int32_t cursor;
int32_t anchor;
} pending_commit;
- struct text_input *text_input;
+ struct wl_text_input *text_input;
PangoLayout *layout;
struct {
xkb_mod_mask_t shift_mask;
@@ -69,7 +68,7 @@ struct text_entry {
};
struct editor {
- struct text_input_manager *text_input_manager;
+ struct wl_text_input_manager *text_input_manager;
struct display *display;
struct window *window;
struct widget *widget;
@@ -130,7 +129,7 @@ static void text_entry_commit_and_reset(struct text_entry *entry);
static void
text_input_commit_string(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
uint32_t serial,
const char *text)
{
@@ -150,7 +149,7 @@ text_input_commit_string(void *data,
static void
text_input_preedit_string(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
uint32_t serial,
const char *text,
const char *commit)
@@ -170,7 +169,7 @@ text_input_preedit_string(void *data,
static void
text_input_delete_surrounding_text(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
uint32_t serial,
int32_t index,
uint32_t length)
@@ -202,7 +201,7 @@ text_input_delete_surrounding_text(void *data,
static void
text_input_cursor_position(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
uint32_t serial,
int32_t index,
int32_t anchor)
@@ -215,7 +214,7 @@ text_input_cursor_position(void *data,
static void
text_input_preedit_styling(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
uint32_t serial,
uint32_t index,
uint32_t length,
@@ -229,24 +228,24 @@ text_input_preedit_styling(void *data,
entry->preedit_info.attr_list = pango_attr_list_new();
switch (style) {
- case TEXT_INPUT_PREEDIT_STYLE_DEFAULT:
- case TEXT_INPUT_PREEDIT_STYLE_UNDERLINE:
+ case WL_TEXT_INPUT_PREEDIT_STYLE_DEFAULT:
+ case WL_TEXT_INPUT_PREEDIT_STYLE_UNDERLINE:
attr1 = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
break;
- case TEXT_INPUT_PREEDIT_STYLE_INCORRECT:
+ case WL_TEXT_INPUT_PREEDIT_STYLE_INCORRECT:
attr1 = pango_attr_underline_new(PANGO_UNDERLINE_ERROR);
attr2 = pango_attr_underline_color_new(65535, 0, 0);
break;
- case TEXT_INPUT_PREEDIT_STYLE_SELECTION:
+ case WL_TEXT_INPUT_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 TEXT_INPUT_PREEDIT_STYLE_HIGHLIGHT:
- case TEXT_INPUT_PREEDIT_STYLE_ACTIVE:
+ case WL_TEXT_INPUT_PREEDIT_STYLE_HIGHLIGHT:
+ case WL_TEXT_INPUT_PREEDIT_STYLE_ACTIVE:
attr1 = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
attr2 = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
break;
- case TEXT_INPUT_PREEDIT_STYLE_INACTIVE:
+ case WL_TEXT_INPUT_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;
@@ -267,7 +266,7 @@ text_input_preedit_styling(void *data,
static void
text_input_preedit_cursor(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
uint32_t serial,
int32_t index)
{
@@ -278,7 +277,7 @@ text_input_preedit_cursor(void *data,
static void
text_input_modifiers_map(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
struct wl_array *map)
{
struct text_entry *entry = data;
@@ -288,7 +287,7 @@ text_input_modifiers_map(void *data,
static void
text_input_keysym(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
uint32_t serial,
uint32_t time,
uint32_t key,
@@ -357,7 +356,7 @@ text_input_keysym(void *data,
static void
text_input_enter(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
struct wl_surface *surface)
{
struct text_entry *entry = data;
@@ -372,7 +371,7 @@ text_input_enter(void *data,
static void
text_input_leave(void *data,
- struct text_input *text_input)
+ struct wl_text_input *text_input)
{
struct text_entry *entry = data;
@@ -380,21 +379,21 @@ text_input_leave(void *data,
entry->active = 0;
- text_input_hide_input_panel(text_input);
+ wl_text_input_hide_input_panel(text_input);
widget_schedule_redraw(entry->widget);
}
static void
text_input_input_panel_state(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
uint32_t state)
{
}
static void
text_input_language(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
uint32_t serial,
const char *language)
{
@@ -403,7 +402,7 @@ text_input_language(void *data,
static void
text_input_text_direction(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
uint32_t serial,
uint32_t direction)
{
@@ -413,13 +412,13 @@ text_input_text_direction(void *data,
switch (direction) {
- case TEXT_INPUT_TEXT_DIRECTION_LTR:
+ case WL_TEXT_INPUT_TEXT_DIRECTION_LTR:
pango_direction = PANGO_DIRECTION_LTR;
break;
- case TEXT_INPUT_TEXT_DIRECTION_RTL:
+ case WL_TEXT_INPUT_TEXT_DIRECTION_RTL:
pango_direction = PANGO_DIRECTION_RTL;
break;
- case TEXT_INPUT_TEXT_DIRECTION_AUTO:
+ case WL_TEXT_INPUT_TEXT_DIRECTION_AUTO:
default:
pango_direction = PANGO_DIRECTION_NEUTRAL;
}
@@ -427,7 +426,7 @@ text_input_text_direction(void *data,
pango_context_set_base_dir(context, pango_direction);
}
-static const struct text_input_listener text_input_listener = {
+static const struct wl_text_input_listener text_input_listener = {
text_input_enter,
text_input_leave,
text_input_modifiers_map,
@@ -456,8 +455,8 @@ text_entry_create(struct editor *editor, const char *text)
entry->active = 0;
entry->cursor = strlen(text);
entry->anchor = entry->cursor;
- entry->text_input = text_input_manager_create_text_input(editor->text_input_manager);
- text_input_add_listener(entry->text_input, &text_input_listener, entry);
+ 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);
widget_set_redraw_handler(entry->widget, text_entry_redraw_handler);
widget_set_button_handler(entry->widget, text_entry_button_handler);
@@ -469,7 +468,7 @@ static void
text_entry_destroy(struct text_entry *entry)
{
widget_destroy(entry->widget);
- text_input_destroy(entry->text_input);
+ wl_text_input_destroy(entry->text_input);
g_clear_object(&entry->layout);
free(entry->text);
free(entry);
@@ -537,17 +536,17 @@ text_entry_activate(struct text_entry *entry,
struct wl_surface *surface = window_get_wl_surface(entry->window);
if (entry->click_to_show && entry->active) {
- text_input_show_input_panel(entry->text_input);
+ wl_text_input_show_input_panel(entry->text_input);
return;
}
if (!entry->click_to_show)
- text_input_show_input_panel(entry->text_input);
+ wl_text_input_show_input_panel(entry->text_input);
entry->serial++;
- text_input_activate(entry->text_input,
+ wl_text_input_activate(entry->text_input,
entry->serial,
seat,
surface);
@@ -557,7 +556,7 @@ static void
text_entry_deactivate(struct text_entry *entry,
struct wl_seat *seat)
{
- text_input_deactivate(entry->text_input,
+ wl_text_input_deactivate(entry->text_input,
seat);
}
@@ -627,20 +626,20 @@ text_entry_update_layout(struct text_entry *entry)
static void
text_entry_update(struct text_entry *entry)
{
- text_input_set_content_type(entry->text_input,
- TEXT_INPUT_CONTENT_HINT_NONE,
+ wl_text_input_set_content_type(entry->text_input,
+ WL_TEXT_INPUT_CONTENT_HINT_NONE,
entry->content_purpose);
- text_input_set_surrounding_text(entry->text_input,
+ wl_text_input_set_surrounding_text(entry->text_input,
entry->text,
entry->cursor,
entry->anchor);
if (entry->preferred_language)
- text_input_set_preferred_language(entry->text_input,
+ wl_text_input_set_preferred_language(entry->text_input,
entry->preferred_language);
- text_input_commit_state(entry->text_input);
+ wl_text_input_commit_state(entry->text_input);
}
static void
@@ -702,7 +701,7 @@ text_entry_commit_and_reset(struct text_entry *entry)
}
entry->serial++;
- text_input_reset(entry->text_input, entry->serial);
+ wl_text_input_reset(entry->text_input, entry->serial);
}
static void
@@ -746,7 +745,7 @@ text_entry_try_invoke_preedit_action(struct text_entry *entry,
}
if (state == WL_POINTER_BUTTON_STATE_RELEASED)
- text_input_invoke_action(entry->text_input,
+ wl_text_input_invoke_action(entry->text_input,
button,
cursor - entry->cursor);
@@ -1073,10 +1072,10 @@ global_handler(struct display *display, uint32_t name,
{
struct editor *editor = data;
- if (!strcmp(interface, "text_input_manager")) {
+ if (!strcmp(interface, "wl_text_input_manager")) {
editor->text_input_manager =
display_bind(display, name,
- &text_input_manager_interface, 1);
+ &wl_text_input_manager_interface, 1);
}
}
@@ -1122,7 +1121,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 = TEXT_INPUT_CONTENT_PURPOSE_NUMBER;
+ editor.editor->content_purpose = WL_TEXT_INPUT_CONTENT_PURPOSE_NUMBER;
editor.editor->click_to_show = click_to_show;
window_set_title(editor.window, "Text Editor");
diff --git a/clients/keyboard.c b/clients/keyboard.c
index 18a54d9..6fc4626 100644
--- a/clients/keyboard.c
+++ b/clients/keyboard.c
@@ -30,7 +30,6 @@
#include "window.h"
#include "input-method-client-protocol.h"
-#include "text-client-protocol.h"
struct keyboard;
@@ -211,7 +210,7 @@ static const struct layout normal_layout = {
12,
4,
"en",
- TEXT_INPUT_TEXT_DIRECTION_LTR
+ WL_TEXT_INPUT_TEXT_DIRECTION_LTR
};
static const struct layout numeric_layout = {
@@ -220,7 +219,7 @@ static const struct layout numeric_layout = {
12,
2,
"en",
- TEXT_INPUT_TEXT_DIRECTION_LTR
+ WL_TEXT_INPUT_TEXT_DIRECTION_LTR
};
static const struct layout arabic_layout = {
@@ -229,7 +228,7 @@ static const struct layout arabic_layout = {
13,
4,
"ar",
- TEXT_INPUT_TEXT_DIRECTION_RTL
+ WL_TEXT_INPUT_TEXT_DIRECTION_RTL
};
static const char *style_labels[] = {
@@ -314,8 +313,8 @@ static const struct layout *
get_current_layout(struct virtual_keyboard *keyboard)
{
switch (keyboard->content_purpose) {
- case TEXT_INPUT_CONTENT_PURPOSE_DIGITS:
- case TEXT_INPUT_CONTENT_PURPOSE_NUMBER:
+ case WL_TEXT_INPUT_CONTENT_PURPOSE_DIGITS:
+ case WL_TEXT_INPUT_CONTENT_PURPOSE_NUMBER:
return &numeric_layout;
default:
if (keyboard->preferred_language &&
diff --git a/protocol/Makefile.am b/protocol/Makefile.am
index 8c1803c..e53111e 100644
--- a/protocol/Makefile.am
+++ b/protocol/Makefile.am
@@ -3,7 +3,6 @@ EXTRA_DIST = \
screenshooter.xml \
tablet-shell.xml \
xserver.xml \
- text.xml \
input-method.xml \
workspaces.xml \
wayland-test.xml
diff --git a/protocol/text.xml b/protocol/text.xml
deleted file mode 100644
index 02c5041..0000000
--- a/protocol/text.xml
+++ /dev/null
@@ -1,330 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<protocol name="text">
-
- <copyright>
- Copyright © 2012 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.
- </copyright>
-
- <interface name="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
- 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.
- </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="serial" type="uint"/>
- <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>
- <arg name="serial" type="uint"/>
- </request>
- <request name="set_surrounding_text">
- <description summary="sets the surrounding text">
- Sets the plain surrounding text around the input position. Cursor is the
- byte index within the surrounding text. Anchor is the byte index of the
- selection anchor within the surrounding text. If there is no selected
- text anchor then it 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">
- </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).
- </description>
- <arg name="serial" type="uint"/>
- <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 (in bytes) characters from index relative to the beginning of
- the composing text (as byte index). Multiple styles can be applied
- to a composing text.
-
- This event should be handled as part of a following preedit_string
- event.
- </description>
- <arg name="serial" type="uint"/>
- <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 index)
- relative to the start of the composing text.
-
- This event should be handled as part of a following preedit_string
- event.
- </description>
- <arg name="serial" type="uint"/>
- <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 also sets the new cursor
- position (as byte index) relative to the beginning of inserted text.
-
- Any previously set composing text should be removed.
- </description>
- <arg name="serial" type="uint"/>
- <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. It
- should take effect after the next commit_string event.
- </description>
- <arg name="serial" type="uint"/>
- <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 (as byte index).
- Length is the length of deleted text (in bytes).
- </description>
- <arg name="serial" type="uint"/>
- <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_surrounfing_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"/>
- <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"/>
- <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"/>
- <arg name="direction" type="uint"/>
- </event>
- </interface>
-
- <interface name="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="text_input"/>
- </request>
- </interface>
-</protocol>
diff --git a/src/Makefile.am b/src/Makefile.am
index 7da2c01..3a7b135 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -28,8 +28,6 @@ weston_SOURCES = \
text-cursor-position-server-protocol.h \
zoom.c \
text-backend.c \
- text-protocol.c \
- text-server-protocol.h \
input-method-protocol.c \
input-method-server-protocol.h \
workspaces-protocol.c \
@@ -245,8 +243,6 @@ BUILT_SOURCES = \
tablet-shell-server-protocol.h \
desktop-shell-protocol.c \
desktop-shell-server-protocol.h \
- text-protocol.c \
- text-server-protocol.h \
input-method-protocol.c \
input-method-server-protocol.h \
workspaces-server-protocol.h \
diff --git a/src/text-backend.c b/src/text-backend.c
index 13fff24..74caa8c 100644
--- a/src/text-backend.c
+++ b/src/text-backend.c
@@ -25,7 +25,6 @@
#include <string.h>
#include "compositor.h"
-#include "text-server-protocol.h"
#include "input-method-server-protocol.h"
struct input_method;
@@ -119,7 +118,7 @@ deactivate_text_input(struct text_input *text_input,
input_method->model = NULL;
input_method->context = NULL;
wl_signal_emit(&ec->hide_input_panel_signal, ec);
- text_input_send_leave(&text_input->resource);
+ wl_text_input_send_leave(&text_input->resource);
}
}
@@ -188,7 +187,7 @@ text_input_activate(struct wl_client *client,
if (text_input->input_panel_visible)
wl_signal_emit(&ec->show_input_panel_signal, ec);
- text_input_send_enter(&text_input->resource, &text_input->surface->resource);
+ wl_text_input_send_enter(&text_input->resource, &text_input->surface->resource);
}
static void
@@ -316,7 +315,7 @@ text_input_set_preferred_language(struct wl_client *client,
}
}
-static const struct text_input_interface text_input_implementation = {
+static const struct wl_text_input_interface text_input_implementation = {
text_input_activate,
text_input_deactivate,
text_input_show_input_panel,
@@ -340,7 +339,7 @@ static void text_input_manager_create_text_input(struct wl_client *client,
text_input = calloc(1, sizeof *text_input);
text_input->resource.object.id = id;
- text_input->resource.object.interface = &text_input_interface;
+ text_input->resource.object.interface = &wl_text_input_interface;
text_input->resource.object.implementation =
(void (**)(void)) &text_input_implementation;
@@ -354,7 +353,7 @@ static void text_input_manager_create_text_input(struct wl_client *client,
wl_client_add_resource(client, &text_input->resource);
};
-static const struct text_input_manager_interface text_input_manager_implementation = {
+static const struct wl_text_input_manager_interface text_input_manager_implementation = {
text_input_manager_create_text_input
};
@@ -368,7 +367,7 @@ bind_text_input_manager(struct wl_client *client,
/* No checking for duplicate binding necessary.
* No events have to be sent, so we don't need the return value. */
- wl_client_add_object(client, &text_input_manager_interface,
+ wl_client_add_object(client, &wl_text_input_manager_interface,
&text_input_manager_implementation,
id, text_input_manager);
}
@@ -396,7 +395,7 @@ text_input_manager_create(struct weston_compositor *ec)
text_input_manager->text_input_manager_global =
wl_display_add_global(ec->wl_display,
- &text_input_manager_interface,
+ &wl_text_input_manager_interface,
text_input_manager, bind_text_input_manager);
text_input_manager->destroy_listener.notify = text_input_manager_notifier_destroy;
@@ -418,7 +417,7 @@ input_method_context_commit_string(struct wl_client *client,
{
struct input_method_context *context = resource->data;
- text_input_send_commit_string(&context->model->resource, serial, text);
+ wl_text_input_send_commit_string(&context->model->resource, serial, text);
}
static void
@@ -430,7 +429,7 @@ input_method_context_preedit_string(struct wl_client *client,
{
struct input_method_context *context = resource->data;
- text_input_send_preedit_string(&context->model->resource, serial, text, commit);
+ wl_text_input_send_preedit_string(&context->model->resource, serial, text, commit);
}
static void
@@ -443,7 +442,7 @@ input_method_context_preedit_styling(struct wl_client *client,
{
struct input_method_context *context = resource->data;
- text_input_send_preedit_styling(&context->model->resource, serial, index, length, style);
+ wl_text_input_send_preedit_styling(&context->model->resource, serial, index, length, style);
}
static void
@@ -454,7 +453,7 @@ input_method_context_preedit_cursor(struct wl_client *client,
{
struct input_method_context *context = resource->data;
- text_input_send_preedit_cursor(&context->model->resource, serial, cursor);
+ wl_text_input_send_preedit_cursor(&context->model->resource, serial, cursor);
}
static void
@@ -466,7 +465,7 @@ input_method_context_delete_surrounding_text(struct wl_client *client,
{
struct input_method_context *context = resource->data;
- text_input_send_delete_surrounding_text(&context->model->resource, serial, index, length);
+ wl_text_input_send_delete_surrounding_text(&context->model->resource, serial, index, length);
}
static void
@@ -478,7 +477,7 @@ input_method_context_cursor_position(struct wl_client *client,
{
struct input_method_context *context = resource->data;
- text_input_send_cursor_position(&context->model->resource, serial, index, anchor);
+ wl_text_input_send_cursor_position(&context->model->resource, serial, index, anchor);
}
static void
@@ -488,7 +487,7 @@ input_method_context_modifiers_map(struct wl_client *client,
{
struct input_method_context *context = resource->data;
- text_input_send_modifiers_map(&context->model->resource, map);
+ wl_text_input_send_modifiers_map(&context->model->resource, map);
}
static void
@@ -502,7 +501,7 @@ input_method_context_keysym(struct wl_client *client,
{
struct input_method_context *context = resource->data;
- text_input_send_keysym(&context->model->resource, serial, time,
+ wl_text_input_send_keysym(&context->model->resource, serial, time,
sym, state, modifiers);
}
@@ -626,7 +625,7 @@ input_method_context_language(struct wl_client *client,
{
struct input_method_context *context = resource->data;
- text_input_send_language(&context->model->resource, serial, language);
+ wl_text_input_send_language(&context->model->resource, serial, language);
}
static void
@@ -637,7 +636,7 @@ input_method_context_text_direction(struct wl_client *client,
{
struct input_method_context *context = resource->data;
- text_input_send_text_direction(&context->model->resource, serial, direction);
+ wl_text_input_send_text_direction(&context->model->resource, serial, direction);
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f2960f1..74790b2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -73,10 +73,7 @@ event_test_LDADD = $(weston_test_client_libs)
button_test_SOURCES = button-test.c $(weston_test_client_src)
button_test_LDADD = $(weston_test_client_libs)
-text_test_SOURCES = \
- text-test.c \
- ../clients/text-protocol.c \
- $(weston_test_client_src)
+text_test_SOURCES = text-test.c $(weston_test_client_src)
text_test_LDADD = $(weston_test_client_libs)
xwayland_test_SOURCES = xwayland-test.c $(weston_test_client_src)
diff --git a/tests/text-test.c b/tests/text-test.c
index 1feae66..9939364 100644
--- a/tests/text-test.c
+++ b/tests/text-test.c
@@ -24,7 +24,6 @@
#include <stdio.h>
#include <linux/input.h>
#include "weston-test-client-helper.h"
-#include "../clients/text-client-protocol.h"
struct text_input_state {
int activated;
@@ -33,7 +32,7 @@ struct text_input_state {
static void
text_input_commit_string(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
uint32_t serial,
const char *text)
{
@@ -41,7 +40,7 @@ text_input_commit_string(void *data,
static void
text_input_preedit_string(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
uint32_t serial,
const char *text,
const char *commit)
@@ -50,7 +49,7 @@ text_input_preedit_string(void *data,
static void
text_input_delete_surrounding_text(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
uint32_t serial,
int32_t index,
uint32_t length)
@@ -59,7 +58,7 @@ text_input_delete_surrounding_text(void *data,
static void
text_input_cursor_position(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
uint32_t serial,
int32_t index,
int32_t anchor)
@@ -68,7 +67,7 @@ text_input_cursor_position(void *data,
static void
text_input_preedit_styling(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
uint32_t serial,
uint32_t index,
uint32_t length,
@@ -78,7 +77,7 @@ text_input_preedit_styling(void *data,
static void
text_input_preedit_cursor(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
uint32_t serial,
int32_t index)
{
@@ -86,14 +85,14 @@ text_input_preedit_cursor(void *data,
static void
text_input_modifiers_map(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
struct wl_array *map)
{
}
static void
text_input_keysym(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
uint32_t serial,
uint32_t time,
uint32_t sym,
@@ -104,7 +103,7 @@ text_input_keysym(void *data,
static void
text_input_enter(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
struct wl_surface *surface)
{
@@ -117,7 +116,7 @@ text_input_enter(void *data,
static void
text_input_leave(void *data,
- struct text_input *text_input)
+ struct wl_text_input *text_input)
{
struct text_input_state *state = data;
@@ -126,14 +125,14 @@ text_input_leave(void *data,
static void
text_input_input_panel_state(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
uint32_t state)
{
}
static void
text_input_language(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
uint32_t serial,
const char *language)
{
@@ -141,13 +140,13 @@ text_input_language(void *data,
static void
text_input_text_direction(void *data,
- struct text_input *text_input,
+ struct wl_text_input *text_input,
uint32_t serial,
uint32_t direction)
{
}
-static const struct text_input_listener text_input_listener = {
+static const struct wl_text_input_listener text_input_listener = {
text_input_enter,
text_input_leave,
text_input_modifiers_map,
@@ -167,8 +166,8 @@ TEST(text_test)
{
struct client *client;
struct global *global;
- struct text_input_manager *factory;
- struct text_input *text_input;
+ struct wl_text_input_manager *factory;
+ struct wl_text_input *text_input;
struct text_input_state state;
client = client_create(100, 100, 100, 100);
@@ -176,17 +175,17 @@ TEST(text_test)
factory = NULL;
wl_list_for_each(global, &client->global_list, link) {
- if (strcmp(global->interface, "text_input_manager") == 0)
+ if (strcmp(global->interface, "wl_text_input_manager") == 0)
factory = wl_registry_bind(client->wl_registry,
global->name,
- &text_input_manager_interface, 1);
+ &wl_text_input_manager_interface, 1);
}
assert(factory);
memset(&state, 0, sizeof state);
- text_input = text_input_manager_create_text_input(factory);
- text_input_add_listener(text_input, &text_input_listener, &state);
+ text_input = wl_text_input_manager_create_text_input(factory);
+ wl_text_input_add_listener(text_input, &text_input_listener, &state);
/* Make sure our test surface has keyboard focus. */
wl_test_activate_surface(client->test->wl_test,
@@ -195,18 +194,18 @@ TEST(text_test)
assert(client->input->keyboard->focus == client->surface);
/* Activate test model and make sure we get enter event. */
- text_input_activate(text_input, 0, client->input->wl_seat,
+ wl_text_input_activate(text_input, 0, 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. */
- text_input_deactivate(text_input, client->input->wl_seat);
+ wl_text_input_deactivate(text_input, client->input->wl_seat);
client_roundtrip(client);
assert(state.activated == 1 && state.deactivated == 1);
/* Activate test model again. */
- text_input_activate(text_input, 0, client->input->wl_seat,
+ wl_text_input_activate(text_input, 0, client->input->wl_seat,
client->surface->wl_surface);
client_roundtrip(client);
assert(state.activated == 2 && state.deactivated == 1);
--
1.8.1.2
More information about the wayland-devel
mailing list