text: Add content type support to text protocol

Support content types in text protocol. Content is defined by a hint
bitmask and a purpose field.

Signed-off-by: Jan Arne Petersen <jpetersen@openismus.com>
dev
Jan Arne Petersen 12 years ago committed by Kristian Høgsberg
parent 0a1cf393c6
commit 26ffa814d9
  1. 4
      protocol/input-method.xml
  2. 52
      protocol/text.xml
  3. 12
      src/text-backend.c

@ -123,6 +123,10 @@
<event name="reset"> <event name="reset">
<arg name="serial" type="uint"/> <arg name="serial" type="uint"/>
</event> </event>
<event name="content_type">
<arg name="hint" type="uint"/>
<arg name="purpose" type="uint"/>
</event>
</interface> </interface>
<interface name="input_method" version="1"> <interface name="input_method" version="1">

@ -83,8 +83,58 @@
<arg name="height" type="int"/> <arg name="height" type="int"/>
</request> </request>
<request name="set_preedit"/> <request name="set_preedit"/>
<request name="set_content_type"/> <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="0xc" 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 dependend)"/>
<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>
<event name="commit_string"> <event name="commit_string">
<description summary="commit"> <description summary="commit">
Notify when text should be inserted into the editor widget. The text Notify when text should be inserted into the editor widget. The text

@ -234,8 +234,18 @@ text_model_set_preedit(struct wl_client *client,
static void static void
text_model_set_content_type(struct wl_client *client, text_model_set_content_type(struct wl_client *client,
struct wl_resource *resource) struct wl_resource *resource,
uint32_t hint,
uint32_t purpose)
{ {
struct text_model *text_model = resource->data;
struct input_method *input_method, *next;
wl_list_for_each_safe(input_method, next, &text_model->input_methods, link) {
if (!input_method->context)
continue;
input_method_context_send_content_type(&input_method->context->resource, hint, purpose);
}
} }
static const struct text_model_interface text_model_implementation = { static const struct text_model_interface text_model_implementation = {

Loading…
Cancel
Save