You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1085 lines
29 KiB
1085 lines
29 KiB
13 years ago
|
/*
|
||
|
* Copyright © 2012 Openismus GmbH
|
||
12 years ago
|
* Copyright © 2012 Intel Corporation
|
||
13 years ago
|
*
|
||
10 years ago
|
* 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:
|
||
13 years ago
|
*
|
||
10 years ago
|
* 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.
|
||
13 years ago
|
*/
|
||
|
|
||
12 years ago
|
#include "config.h"
|
||
|
|
||
10 years ago
|
#include <stdbool.h>
|
||
13 years ago
|
#include <stdlib.h>
|
||
12 years ago
|
#include <string.h>
|
||
12 years ago
|
#include <unistd.h>
|
||
12 years ago
|
#include <time.h>
|
||
13 years ago
|
|
||
|
#include "compositor.h"
|
||
9 years ago
|
#include "weston.h"
|
||
9 years ago
|
#include "text-input-unstable-v1-server-protocol.h"
|
||
9 years ago
|
#include "input-method-unstable-v1-server-protocol.h"
|
||
10 years ago
|
#include "shared/helpers.h"
|
||
13 years ago
|
|
||
10 years ago
|
struct text_input_manager;
|
||
13 years ago
|
struct input_method;
|
||
12 years ago
|
struct input_method_context;
|
||
12 years ago
|
struct text_backend;
|
||
13 years ago
|
|
||
12 years ago
|
struct text_input {
|
||
12 years ago
|
struct wl_resource *resource;
|
||
13 years ago
|
|
||
13 years ago
|
struct weston_compositor *ec;
|
||
13 years ago
|
|
||
13 years ago
|
struct wl_list input_methods;
|
||
13 years ago
|
|
||
12 years ago
|
struct weston_surface *surface;
|
||
12 years ago
|
|
||
12 years ago
|
pixman_box32_t cursor_rectangle;
|
||
|
|
||
10 years ago
|
bool input_panel_visible;
|
||
10 years ago
|
|
||
|
struct text_input_manager *manager;
|
||
13 years ago
|
};
|
||
|
|
||
12 years ago
|
struct text_input_manager {
|
||
|
struct wl_global *text_input_manager_global;
|
||
12 years ago
|
struct wl_listener destroy_listener;
|
||
|
|
||
10 years ago
|
struct text_input *current_panel;
|
||
|
|
||
12 years ago
|
struct weston_compositor *ec;
|
||
|
};
|
||
|
|
||
13 years ago
|
struct input_method {
|
||
13 years ago
|
struct wl_resource *input_method_binding;
|
||
|
struct wl_global *input_method_global;
|
||
13 years ago
|
struct wl_listener destroy_listener;
|
||
|
|
||
12 years ago
|
struct weston_seat *seat;
|
||
10 years ago
|
struct text_input *input;
|
||
13 years ago
|
|
||
|
struct wl_list link;
|
||
13 years ago
|
|
||
|
struct wl_listener keyboard_focus_listener;
|
||
|
|
||
10 years ago
|
bool focus_listener_initialized;
|
||
12 years ago
|
|
||
|
struct input_method_context *context;
|
||
12 years ago
|
|
||
|
struct text_backend *text_backend;
|
||
12 years ago
|
};
|
||
|
|
||
|
struct input_method_context {
|
||
12 years ago
|
struct wl_resource *resource;
|
||
12 years ago
|
|
||
10 years ago
|
struct text_input *input;
|
||
12 years ago
|
struct input_method *input_method;
|
||
12 years ago
|
|
||
12 years ago
|
struct wl_resource *keyboard;
|
||
13 years ago
|
};
|
||
|
|
||
12 years ago
|
struct text_backend {
|
||
|
struct weston_compositor *compositor;
|
||
|
|
||
|
struct {
|
||
|
char *path;
|
||
|
struct wl_client *client;
|
||
12 years ago
|
|
||
|
unsigned deathcount;
|
||
|
uint32_t deathstamp;
|
||
12 years ago
|
} input_method;
|
||
|
|
||
10 years ago
|
struct wl_listener client_listener;
|
||
12 years ago
|
struct wl_listener seat_created_listener;
|
||
|
};
|
||
|
|
||
10 years ago
|
static void
|
||
10 years ago
|
input_method_context_create(struct text_input *input,
|
||
10 years ago
|
struct input_method *input_method);
|
||
|
static void
|
||
|
input_method_context_end_keyboard_grab(struct input_method_context *context);
|
||
12 years ago
|
|
||
10 years ago
|
static void
|
||
|
input_method_init_seat(struct weston_seat *seat);
|
||
13 years ago
|
|
||
13 years ago
|
static void
|
||
10 years ago
|
deactivate_input_method(struct input_method *input_method)
|
||
13 years ago
|
{
|
||
10 years ago
|
struct text_input *text_input = input_method->input;
|
||
12 years ago
|
struct weston_compositor *ec = text_input->ec;
|
||
13 years ago
|
|
||
10 years ago
|
if (input_method->context && input_method->input_method_binding) {
|
||
|
input_method_context_end_keyboard_grab(input_method->context);
|
||
9 years ago
|
zwp_input_method_v1_send_deactivate(
|
||
10 years ago
|
input_method->input_method_binding,
|
||
|
input_method->context->resource);
|
||
10 years ago
|
}
|
||
|
|
||
|
wl_list_remove(&input_method->link);
|
||
10 years ago
|
input_method->input = NULL;
|
||
10 years ago
|
input_method->context = NULL;
|
||
|
|
||
|
if (wl_list_empty(&text_input->input_methods) &&
|
||
|
text_input->input_panel_visible) {
|
||
13 years ago
|
wl_signal_emit(&ec->hide_input_panel_signal, ec);
|
||
10 years ago
|
text_input->input_panel_visible = false;
|
||
|
text_input->manager->current_panel = NULL;
|
||
13 years ago
|
}
|
||
9 years ago
|
zwp_text_input_v1_send_leave(text_input->resource);
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
static void
|
||
12 years ago
|
destroy_text_input(struct wl_resource *resource)
|
||
13 years ago
|
{
|
||
12 years ago
|
struct text_input *text_input = wl_resource_get_user_data(resource);
|
||
13 years ago
|
struct input_method *input_method, *next;
|
||
13 years ago
|
|
||
10 years ago
|
wl_list_for_each_safe(input_method, next,
|
||
|
&text_input->input_methods, link)
|
||
10 years ago
|
deactivate_input_method(input_method);
|
||
13 years ago
|
|
||
12 years ago
|
free(text_input);
|
||
13 years ago
|
}
|
||
|
|
||
|
static void
|
||
12 years ago
|
text_input_set_surrounding_text(struct wl_client *client,
|
||
13 years ago
|
struct wl_resource *resource,
|
||
12 years ago
|
const char *text,
|
||
|
uint32_t cursor,
|
||
|
uint32_t anchor)
|
||
13 years ago
|
{
|
||
12 years ago
|
struct text_input *text_input = wl_resource_get_user_data(resource);
|
||
12 years ago
|
struct input_method *input_method, *next;
|
||
|
|
||
10 years ago
|
wl_list_for_each_safe(input_method, next,
|
||
|
&text_input->input_methods, link) {
|
||
12 years ago
|
if (!input_method->context)
|
||
|
continue;
|
||
9 years ago
|
zwp_input_method_context_v1_send_surrounding_text(
|
||
10 years ago
|
input_method->context->resource, text, cursor, anchor);
|
||
12 years ago
|
}
|
||
13 years ago
|
}
|
||
|
|
||
|
static void
|
||
12 years ago
|
text_input_activate(struct wl_client *client,
|
||
12 years ago
|
struct wl_resource *resource,
|
||
13 years ago
|
struct wl_resource *seat,
|
||
|
struct wl_resource *surface)
|
||
13 years ago
|
{
|
||
12 years ago
|
struct text_input *text_input = wl_resource_get_user_data(resource);
|
||
12 years ago
|
struct weston_seat *weston_seat = wl_resource_get_user_data(seat);
|
||
12 years ago
|
struct input_method *input_method = weston_seat->input_method;
|
||
12 years ago
|
struct weston_compositor *ec = text_input->ec;
|
||
10 years ago
|
struct text_input *current;
|
||
13 years ago
|
|
||
10 years ago
|
if (input_method->input == text_input)
|
||
13 years ago
|
return;
|
||
13 years ago
|
|
||
10 years ago
|
if (input_method->input)
|
||
10 years ago
|
deactivate_input_method(input_method);
|
||
13 years ago
|
|
||
10 years ago
|
input_method->input = text_input;
|
||
12 years ago
|
wl_list_insert(&text_input->input_methods, &input_method->link);
|
||
13 years ago
|
input_method_init_seat(weston_seat);
|
||
|
|
||
12 years ago
|
text_input->surface = wl_resource_get_user_data(surface);
|
||
13 years ago
|
|
||
12 years ago
|
input_method_context_create(text_input, input_method);
|
||
12 years ago
|
|
||
10 years ago
|
current = text_input->manager->current_panel;
|
||
|
|
||
|
if (current && current != text_input) {
|
||
|
current->input_panel_visible = false;
|
||
|
wl_signal_emit(&ec->hide_input_panel_signal, ec);
|
||
|
text_input->manager->current_panel = NULL;
|
||
|
}
|
||
|
|
||
12 years ago
|
if (text_input->input_panel_visible) {
|
||
10 years ago
|
wl_signal_emit(&ec->show_input_panel_signal,
|
||
|
text_input->surface);
|
||
|
wl_signal_emit(&ec->update_input_panel_signal,
|
||
|
&text_input->cursor_rectangle);
|
||
10 years ago
|
text_input->manager->current_panel = text_input;
|
||
12 years ago
|
}
|
||
13 years ago
|
|
||
9 years ago
|
zwp_text_input_v1_send_enter(text_input->resource,
|
||
|
text_input->surface->resource);
|
||
13 years ago
|
}
|
||
|
|
||
|
static void
|
||
12 years ago
|
text_input_deactivate(struct wl_client *client,
|
||
13 years ago
|
struct wl_resource *resource,
|
||
|
struct wl_resource *seat)
|
||
13 years ago
|
{
|
||
12 years ago
|
struct weston_seat *weston_seat = wl_resource_get_user_data(seat);
|
||
13 years ago
|
|
||
10 years ago
|
if (weston_seat->input_method->input)
|
||
10 years ago
|
deactivate_input_method(weston_seat->input_method);
|
||
13 years ago
|
}
|
||
|
|
||
12 years ago
|
static void
|
||
12 years ago
|
text_input_reset(struct wl_client *client,
|
||
12 years ago
|
struct wl_resource *resource)
|
||
12 years ago
|
{
|
||
12 years ago
|
struct text_input *text_input = wl_resource_get_user_data(resource);
|
||
12 years ago
|
struct input_method *input_method, *next;
|
||
|
|
||
10 years ago
|
wl_list_for_each_safe(input_method, next,
|
||
|
&text_input->input_methods, link) {
|
||
12 years ago
|
if (!input_method->context)
|
||
|
continue;
|
||
9 years ago
|
zwp_input_method_context_v1_send_reset(
|
||
10 years ago
|
input_method->context->resource);
|
||
12 years ago
|
}
|
||
|
}
|
||
|
|
||
13 years ago
|
static void
|
||
12 years ago
|
text_input_set_cursor_rectangle(struct wl_client *client,
|
||
12 years ago
|
struct wl_resource *resource,
|
||
|
int32_t x,
|
||
|
int32_t y,
|
||
|
int32_t width,
|
||
|
int32_t height)
|
||
13 years ago
|
{
|
||
12 years ago
|
struct text_input *text_input = wl_resource_get_user_data(resource);
|
||
12 years ago
|
struct weston_compositor *ec = text_input->ec;
|
||
|
|
||
|
text_input->cursor_rectangle.x1 = x;
|
||
|
text_input->cursor_rectangle.y1 = y;
|
||
|
text_input->cursor_rectangle.x2 = x + width;
|
||
|
text_input->cursor_rectangle.y2 = y + height;
|
||
|
|
||
10 years ago
|
wl_signal_emit(&ec->update_input_panel_signal,
|
||
|
&text_input->cursor_rectangle);
|
||
13 years ago
|
}
|
||
|
|
||
|
static void
|
||
12 years ago
|
text_input_set_content_type(struct wl_client *client,
|
||
12 years ago
|
struct wl_resource *resource,
|
||
|
uint32_t hint,
|
||
|
uint32_t purpose)
|
||
13 years ago
|
{
|
||
12 years ago
|
struct text_input *text_input = wl_resource_get_user_data(resource);
|
||
12 years ago
|
struct input_method *input_method, *next;
|
||
|
|
||
10 years ago
|
wl_list_for_each_safe(input_method, next,
|
||
|
&text_input->input_methods, link) {
|
||
12 years ago
|
if (!input_method->context)
|
||
|
continue;
|
||
9 years ago
|
zwp_input_method_context_v1_send_content_type(
|
||
10 years ago
|
input_method->context->resource, hint, purpose);
|
||
12 years ago
|
}
|
||
13 years ago
|
}
|
||
|
|
||
12 years ago
|
static void
|
||
12 years ago
|
text_input_invoke_action(struct wl_client *client,
|
||
12 years ago
|
struct wl_resource *resource,
|
||
|
uint32_t button,
|
||
|
uint32_t index)
|
||
|
{
|
||
12 years ago
|
struct text_input *text_input = wl_resource_get_user_data(resource);
|
||
12 years ago
|
struct input_method *input_method, *next;
|
||
|
|
||
10 years ago
|
wl_list_for_each_safe(input_method, next,
|
||
|
&text_input->input_methods, link) {
|
||
12 years ago
|
if (!input_method->context)
|
||
|
continue;
|
||
9 years ago
|
zwp_input_method_context_v1_send_invoke_action(
|
||
10 years ago
|
input_method->context->resource, button, index);
|
||
12 years ago
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
static void
|
||
12 years ago
|
text_input_commit_state(struct wl_client *client,
|
||
12 years ago
|
struct wl_resource *resource,
|
||
|
uint32_t serial)
|
||
12 years ago
|
{
|
||
12 years ago
|
struct text_input *text_input = wl_resource_get_user_data(resource);
|
||
12 years ago
|
struct input_method *input_method, *next;
|
||
|
|
||
10 years ago
|
wl_list_for_each_safe(input_method, next,
|
||
|
&text_input->input_methods, link) {
|
||
12 years ago
|
if (!input_method->context)
|
||
|
continue;
|
||
9 years ago
|
zwp_input_method_context_v1_send_commit_state(
|
||
10 years ago
|
input_method->context->resource, serial);
|
||
12 years ago
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
static void
|
||
12 years ago
|
text_input_show_input_panel(struct wl_client *client,
|
||
12 years ago
|
struct wl_resource *resource)
|
||
|
{
|
||
12 years ago
|
struct text_input *text_input = wl_resource_get_user_data(resource);
|
||
12 years ago
|
struct weston_compositor *ec = text_input->ec;
|
||
12 years ago
|
|
||
10 years ago
|
text_input->input_panel_visible = true;
|
||
12 years ago
|
|
||
12 years ago
|
if (!wl_list_empty(&text_input->input_methods)) {
|
||
10 years ago
|
wl_signal_emit(&ec->show_input_panel_signal,
|
||
|
text_input->surface);
|
||
|
wl_signal_emit(&ec->update_input_panel_signal,
|
||
|
&text_input->cursor_rectangle);
|
||
12 years ago
|
}
|
||
12 years ago
|
}
|
||
|
|
||
|
static void
|
||
12 years ago
|
text_input_hide_input_panel(struct wl_client *client,
|
||
12 years ago
|
struct wl_resource *resource)
|
||
|
{
|
||
12 years ago
|
struct text_input *text_input = wl_resource_get_user_data(resource);
|
||
12 years ago
|
struct weston_compositor *ec = text_input->ec;
|
||
12 years ago
|
|
||
10 years ago
|
text_input->input_panel_visible = false;
|
||
12 years ago
|
|
||
10 years ago
|
if (!wl_list_empty(&text_input->input_methods) &&
|
||
|
text_input == text_input->manager->current_panel) {
|
||
|
text_input->manager->current_panel = NULL;
|
||
12 years ago
|
wl_signal_emit(&ec->hide_input_panel_signal, ec);
|
||
10 years ago
|
}
|
||
12 years ago
|
}
|
||
|
|
||
12 years ago
|
static void
|
||
12 years ago
|
text_input_set_preferred_language(struct wl_client *client,
|
||
12 years ago
|
struct wl_resource *resource,
|
||
|
const char *language)
|
||
|
{
|
||
12 years ago
|
struct text_input *text_input = wl_resource_get_user_data(resource);
|
||
12 years ago
|
struct input_method *input_method, *next;
|
||
|
|
||
10 years ago
|
wl_list_for_each_safe(input_method, next,
|
||
|
&text_input->input_methods, link) {
|
||
12 years ago
|
if (!input_method->context)
|
||
|
continue;
|
||
9 years ago
|
zwp_input_method_context_v1_send_preferred_language(
|
||
10 years ago
|
input_method->context->resource, language);
|
||
12 years ago
|
}
|
||
|
}
|
||
|
|
||
9 years ago
|
static const struct zwp_text_input_v1_interface text_input_implementation = {
|
||
12 years ago
|
text_input_activate,
|
||
|
text_input_deactivate,
|
||
|
text_input_show_input_panel,
|
||
|
text_input_hide_input_panel,
|
||
|
text_input_reset,
|
||
|
text_input_set_surrounding_text,
|
||
|
text_input_set_content_type,
|
||
|
text_input_set_cursor_rectangle,
|
||
|
text_input_set_preferred_language,
|
||
|
text_input_commit_state,
|
||
|
text_input_invoke_action
|
||
13 years ago
|
};
|
||
|
|
||
12 years ago
|
static void text_input_manager_create_text_input(struct wl_client *client,
|
||
13 years ago
|
struct wl_resource *resource,
|
||
12 years ago
|
uint32_t id)
|
||
13 years ago
|
{
|
||
10 years ago
|
struct text_input_manager *text_input_manager =
|
||
|
wl_resource_get_user_data(resource);
|
||
12 years ago
|
struct text_input *text_input;
|
||
13 years ago
|
|
||
10 years ago
|
text_input = zalloc(sizeof *text_input);
|
||
|
if (text_input == NULL)
|
||
|
return;
|
||
13 years ago
|
|
||
12 years ago
|
text_input->resource =
|
||
9 years ago
|
wl_resource_create(client, &zwp_text_input_v1_interface, 1, id);
|
||
12 years ago
|
wl_resource_set_implementation(text_input->resource,
|
||
|
&text_input_implementation,
|
||
|
text_input, destroy_text_input);
|
||
13 years ago
|
|
||
12 years ago
|
text_input->ec = text_input_manager->ec;
|
||
10 years ago
|
text_input->manager = text_input_manager;
|
||
13 years ago
|
|
||
12 years ago
|
wl_list_init(&text_input->input_methods);
|
||
13 years ago
|
};
|
||
|
|
||
9 years ago
|
static const struct zwp_text_input_manager_v1_interface manager_implementation = {
|
||
12 years ago
|
text_input_manager_create_text_input
|
||
13 years ago
|
};
|
||
|
|
||
|
static void
|
||
12 years ago
|
bind_text_input_manager(struct wl_client *client,
|
||
13 years ago
|
void *data,
|
||
|
uint32_t version,
|
||
|
uint32_t id)
|
||
|
{
|
||
12 years ago
|
struct text_input_manager *text_input_manager = data;
|
||
12 years ago
|
struct wl_resource *resource;
|
||
13 years ago
|
|
||
12 years ago
|
/* No checking for duplicate binding necessary. */
|
||
|
resource =
|
||
|
wl_resource_create(client,
|
||
9 years ago
|
&zwp_text_input_manager_v1_interface, 1, id);
|
||
12 years ago
|
if (resource)
|
||
|
wl_resource_set_implementation(resource,
|
||
10 years ago
|
&manager_implementation,
|
||
12 years ago
|
text_input_manager, NULL);
|
||
12 years ago
|
}
|
||
|
|
||
|
static void
|
||
12 years ago
|
text_input_manager_notifier_destroy(struct wl_listener *listener, void *data)
|
||
12 years ago
|
{
|
||
12 years ago
|
struct text_input_manager *text_input_manager =
|
||
10 years ago
|
container_of(listener,
|
||
|
struct text_input_manager,
|
||
|
destroy_listener);
|
||
12 years ago
|
|
||
12 years ago
|
wl_global_destroy(text_input_manager->text_input_manager_global);
|
||
12 years ago
|
|
||
12 years ago
|
free(text_input_manager);
|
||
12 years ago
|
}
|
||
|
|
||
12 years ago
|
static void
|
||
12 years ago
|
text_input_manager_create(struct weston_compositor *ec)
|
||
12 years ago
|
{
|
||
12 years ago
|
struct text_input_manager *text_input_manager;
|
||
12 years ago
|
|
||
10 years ago
|
text_input_manager = zalloc(sizeof *text_input_manager);
|
||
|
if (text_input_manager == NULL)
|
||
|
return;
|
||
12 years ago
|
|
||
12 years ago
|
text_input_manager->ec = ec;
|
||
12 years ago
|
|
||
12 years ago
|
text_input_manager->text_input_manager_global =
|
||
12 years ago
|
wl_global_create(ec->wl_display,
|
||
9 years ago
|
&zwp_text_input_manager_v1_interface, 1,
|
||
12 years ago
|
text_input_manager, bind_text_input_manager);
|
||
12 years ago
|
|
||
10 years ago
|
text_input_manager->destroy_listener.notify =
|
||
|
text_input_manager_notifier_destroy;
|
||
|
wl_signal_add(&ec->destroy_signal,
|
||
|
&text_input_manager->destroy_listener);
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
static void
|
||
12 years ago
|
input_method_context_destroy(struct wl_client *client,
|
||
|
struct wl_resource *resource)
|
||
13 years ago
|
{
|
||
12 years ago
|
wl_resource_destroy(resource);
|
||
|
}
|
||
13 years ago
|
|
||
12 years ago
|
static void
|
||
|
input_method_context_commit_string(struct wl_client *client,
|
||
|
struct wl_resource *resource,
|
||
12 years ago
|
uint32_t serial,
|
||
12 years ago
|
const char *text)
|
||
12 years ago
|
{
|
||
12 years ago
|
struct input_method_context *context =
|
||
|
wl_resource_get_user_data(resource);
|
||
12 years ago
|
|
||
10 years ago
|
if (context->input)
|
||
9 years ago
|
zwp_text_input_v1_send_commit_string(context->input->resource,
|
||
|
serial, text);
|
||
13 years ago
|
}
|
||
|
|
||
12 years ago
|
static void
|
||
|
input_method_context_preedit_string(struct wl_client *client,
|
||
12 years ago
|
struct wl_resource *resource,
|
||
12 years ago
|
uint32_t serial,
|
||
12 years ago
|
const char *text,
|
||
|
const char *commit)
|
||
|
{
|
||
12 years ago
|
struct input_method_context *context =
|
||
|
wl_resource_get_user_data(resource);
|
||
12 years ago
|
|
||
10 years ago
|
if (context->input)
|
||
9 years ago
|
zwp_text_input_v1_send_preedit_string(context->input->resource,
|
||
|
serial, text, commit);
|
||
12 years ago
|
}
|
||
|
|
||
|
static void
|
||
|
input_method_context_preedit_styling(struct wl_client *client,
|
||
|
struct wl_resource *resource,
|
||
|
uint32_t index,
|
||
|
uint32_t length,
|
||
|
uint32_t style)
|
||
|
{
|
||
12 years ago
|
struct input_method_context *context =
|
||
|
wl_resource_get_user_data(resource);
|
||
12 years ago
|
|
||
10 years ago
|
if (context->input)
|
||
9 years ago
|
zwp_text_input_v1_send_preedit_styling(context->input->resource,
|
||
|
index, length, style);
|
||
12 years ago
|
}
|
||
|
|
||
|
static void
|
||
|
input_method_context_preedit_cursor(struct wl_client *client,
|
||
|
struct wl_resource *resource,
|
||
|
int32_t cursor)
|
||
12 years ago
|
{
|
||
12 years ago
|
struct input_method_context *context =
|
||
|
wl_resource_get_user_data(resource);
|
||
12 years ago
|
|
||
10 years ago
|
if (context->input)
|
||
9 years ago
|
zwp_text_input_v1_send_preedit_cursor(context->input->resource,
|
||
|
cursor);
|
||
12 years ago
|
}
|
||
|
|
||
12 years ago
|
static void
|
||
|
input_method_context_delete_surrounding_text(struct wl_client *client,
|
||
|
struct wl_resource *resource,
|
||
|
int32_t index,
|
||
|
uint32_t length)
|
||
|
{
|
||
12 years ago
|
struct input_method_context *context =
|
||
|
wl_resource_get_user_data(resource);
|
||
12 years ago
|
|
||
10 years ago
|
if (context->input)
|
||
9 years ago
|
zwp_text_input_v1_send_delete_surrounding_text(
|
||
10 years ago
|
context->input->resource, index, length);
|
||
12 years ago
|
}
|
||
|
|
||
12 years ago
|
static void
|
||
|
input_method_context_cursor_position(struct wl_client *client,
|
||
|
struct wl_resource *resource,
|
||
|
int32_t index,
|
||
|
int32_t anchor)
|
||
|
{
|
||
12 years ago
|
struct input_method_context *context =
|
||
|
wl_resource_get_user_data(resource);
|
||
12 years ago
|
|
||
10 years ago
|
if (context->input)
|
||
9 years ago
|
zwp_text_input_v1_send_cursor_position(context->input->resource,
|
||
|
index, anchor);
|
||
12 years ago
|
}
|
||
|
|
||
12 years ago
|
static void
|
||
12 years ago
|
input_method_context_modifiers_map(struct wl_client *client,
|
||
|
struct wl_resource *resource,
|
||
|
struct wl_array *map)
|
||
|
{
|
||
12 years ago
|
struct input_method_context *context =
|
||
|
wl_resource_get_user_data(resource);
|
||
12 years ago
|
|
||
10 years ago
|
if (context->input)
|
||
9 years ago
|
zwp_text_input_v1_send_modifiers_map(context->input->resource,
|
||
|
map);
|
||
12 years ago
|
}
|
||
|
|
||
|
static void
|
||
|
input_method_context_keysym(struct wl_client *client,
|
||
|
struct wl_resource *resource,
|
||
|
uint32_t serial,
|
||
|
uint32_t time,
|
||
|
uint32_t sym,
|
||
|
uint32_t state,
|
||
|
uint32_t modifiers)
|
||
12 years ago
|
{
|
||
12 years ago
|
struct input_method_context *context =
|
||
|
wl_resource_get_user_data(resource);
|
||
12 years ago
|
|
||
10 years ago
|
if (context->input)
|
||
9 years ago
|
zwp_text_input_v1_send_keysym(context->input->resource,
|
||
|
serial, time,
|
||
|
sym, state, modifiers);
|
||
12 years ago
|
}
|
||
|
|
||
12 years ago
|
static void
|
||
|
unbind_keyboard(struct wl_resource *resource)
|
||
|
{
|
||
12 years ago
|
struct input_method_context *context =
|
||
|
wl_resource_get_user_data(resource);
|
||
12 years ago
|
|
||
|
input_method_context_end_keyboard_grab(context);
|
||
|
context->keyboard = NULL;
|
||
|
}
|
||
|
|
||
|
static void
|
||
12 years ago
|
input_method_context_grab_key(struct weston_keyboard_grab *grab,
|
||
12 years ago
|
uint32_t time, uint32_t key, uint32_t state_w)
|
||
|
{
|
||
12 years ago
|
struct weston_keyboard *keyboard = grab->keyboard;
|
||
12 years ago
|
struct wl_display *display;
|
||
12 years ago
|
uint32_t serial;
|
||
12 years ago
|
|
||
|
if (!keyboard->input_method_resource)
|
||
|
return;
|
||
|
|
||
10 years ago
|
display = wl_client_get_display(
|
||
|
wl_resource_get_client(keyboard->input_method_resource));
|
||
12 years ago
|
serial = wl_display_next_serial(display);
|
||
|
wl_keyboard_send_key(keyboard->input_method_resource,
|
||
|
serial, time, key, state_w);
|
||
12 years ago
|
}
|
||
|
|
||
|
static void
|
||
10 years ago
|
input_method_context_grab_modifier(struct weston_keyboard_grab *grab,
|
||
|
uint32_t serial,
|
||
|
uint32_t mods_depressed,
|
||
|
uint32_t mods_latched,
|
||
|
uint32_t mods_locked,
|
||
|
uint32_t group)
|
||
12 years ago
|
{
|
||
12 years ago
|
struct weston_keyboard *keyboard = grab->keyboard;
|
||
12 years ago
|
|
||
12 years ago
|
if (!keyboard->input_method_resource)
|
||
12 years ago
|
return;
|
||
|
|
||
12 years ago
|
wl_keyboard_send_modifiers(keyboard->input_method_resource,
|
||
12 years ago
|
serial, mods_depressed, mods_latched,
|
||
|
mods_locked, group);
|
||
|
}
|
||
|
|
||
11 years ago
|
static void
|
||
|
input_method_context_grab_cancel(struct weston_keyboard_grab *grab)
|
||
|
{
|
||
|
weston_keyboard_end_grab(grab->keyboard);
|
||
|
}
|
||
|
|
||
12 years ago
|
static const struct weston_keyboard_grab_interface input_method_context_grab = {
|
||
12 years ago
|
input_method_context_grab_key,
|
||
|
input_method_context_grab_modifier,
|
||
11 years ago
|
input_method_context_grab_cancel,
|
||
12 years ago
|
};
|
||
|
|
||
|
static void
|
||
|
input_method_context_grab_keyboard(struct wl_client *client,
|
||
|
struct wl_resource *resource,
|
||
|
uint32_t id)
|
||
|
{
|
||
10 years ago
|
struct input_method_context *context =
|
||
|
wl_resource_get_user_data(resource);
|
||
12 years ago
|
struct wl_resource *cr;
|
||
|
struct weston_seat *seat = context->input_method->seat;
|
||
10 years ago
|
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
|
||
12 years ago
|
|
||
12 years ago
|
cr = wl_resource_create(client, &wl_keyboard_interface, 1, id);
|
||
|
wl_resource_set_implementation(cr, NULL, context, unbind_keyboard);
|
||
12 years ago
|
|
||
|
context->keyboard = cr;
|
||
|
|
||
|
wl_keyboard_send_keymap(cr, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
|
||
11 years ago
|
keyboard->xkb_info->keymap_fd,
|
||
|
keyboard->xkb_info->keymap_size);
|
||
12 years ago
|
|
||
12 years ago
|
if (keyboard->grab != &keyboard->default_grab) {
|
||
|
weston_keyboard_end_grab(keyboard);
|
||
12 years ago
|
}
|
||
12 years ago
|
weston_keyboard_start_grab(keyboard, &keyboard->input_method_grab);
|
||
12 years ago
|
keyboard->input_method_resource = cr;
|
||
12 years ago
|
}
|
||
|
|
||
12 years ago
|
static void
|
||
|
input_method_context_key(struct wl_client *client,
|
||
|
struct wl_resource *resource,
|
||
|
uint32_t serial,
|
||
|
uint32_t time,
|
||
|
uint32_t key,
|
||
|
uint32_t state_w)
|
||
|
{
|
||
10 years ago
|
struct input_method_context *context =
|
||
|
wl_resource_get_user_data(resource);
|
||
12 years ago
|
struct weston_seat *seat = context->input_method->seat;
|
||
10 years ago
|
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
|
||
12 years ago
|
struct weston_keyboard_grab *default_grab = &keyboard->default_grab;
|
||
12 years ago
|
|
||
|
default_grab->interface->key(default_grab, time, key, state_w);
|
||
|
}
|
||
|
|
||
|
static void
|
||
|
input_method_context_modifiers(struct wl_client *client,
|
||
|
struct wl_resource *resource,
|
||
|
uint32_t serial,
|
||
|
uint32_t mods_depressed,
|
||
|
uint32_t mods_latched,
|
||
|
uint32_t mods_locked,
|
||
|
uint32_t group)
|
||
|
{
|
||
10 years ago
|
struct input_method_context *context =
|
||
|
wl_resource_get_user_data(resource);
|
||
12 years ago
|
|
||
|
struct weston_seat *seat = context->input_method->seat;
|
||
10 years ago
|
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
|
||
12 years ago
|
struct weston_keyboard_grab *default_grab = &keyboard->default_grab;
|
||
12 years ago
|
|
||
|
default_grab->interface->modifiers(default_grab,
|
||
|
serial, mods_depressed,
|
||
|
mods_latched, mods_locked,
|
||
|
group);
|
||
|
}
|
||
|
|
||
12 years ago
|
static void
|
||
|
input_method_context_language(struct wl_client *client,
|
||
|
struct wl_resource *resource,
|
||
|
uint32_t serial,
|
||
|
const char *language)
|
||
|
{
|
||
10 years ago
|
struct input_method_context *context =
|
||
|
wl_resource_get_user_data(resource);
|
||
12 years ago
|
|
||
10 years ago
|
if (context->input)
|
||
9 years ago
|
zwp_text_input_v1_send_language(context->input->resource,
|
||
|
serial, language);
|
||
12 years ago
|
}
|
||
|
|
||
|
static void
|
||
|
input_method_context_text_direction(struct wl_client *client,
|
||
|
struct wl_resource *resource,
|
||
|
uint32_t serial,
|
||
|
uint32_t direction)
|
||
|
{
|
||
10 years ago
|
struct input_method_context *context =
|
||
|
wl_resource_get_user_data(resource);
|
||
12 years ago
|
|
||
10 years ago
|
if (context->input)
|
||
9 years ago
|
zwp_text_input_v1_send_text_direction(context->input->resource,
|
||
|
serial, direction);
|
||
12 years ago
|
}
|
||
|
|
||
|
|
||
9 years ago
|
static const struct zwp_input_method_context_v1_interface context_implementation = {
|
||
12 years ago
|
input_method_context_destroy,
|
||
12 years ago
|
input_method_context_commit_string,
|
||
|
input_method_context_preedit_string,
|
||
12 years ago
|
input_method_context_preedit_styling,
|
||
|
input_method_context_preedit_cursor,
|
||
12 years ago
|
input_method_context_delete_surrounding_text,
|
||
12 years ago
|
input_method_context_cursor_position,
|
||
12 years ago
|
input_method_context_modifiers_map,
|
||
12 years ago
|
input_method_context_keysym,
|
||
12 years ago
|
input_method_context_grab_keyboard,
|
||
|
input_method_context_key,
|
||
12 years ago
|
input_method_context_modifiers,
|
||
|
input_method_context_language,
|
||
|
input_method_context_text_direction
|
||
13 years ago
|
};
|
||
|
|
||
12 years ago
|
static void
|
||
|
destroy_input_method_context(struct wl_resource *resource)
|
||
|
{
|
||
10 years ago
|
struct input_method_context *context =
|
||
|
wl_resource_get_user_data(resource);
|
||
12 years ago
|
|
||
10 years ago
|
if (context->keyboard)
|
||
12 years ago
|
wl_resource_destroy(context->keyboard);
|
||
|
|
||
10 years ago
|
if (context->input_method && context->input_method->context == context)
|
||
|
context->input_method->context = NULL;
|
||
|
|
||
12 years ago
|
free(context);
|
||
|
}
|
||
|
|
||
|
static void
|
||
10 years ago
|
input_method_context_create(struct text_input *input,
|
||
12 years ago
|
struct input_method *input_method)
|
||
12 years ago
|
{
|
||
|
struct input_method_context *context;
|
||
12 years ago
|
struct wl_resource *binding;
|
||
12 years ago
|
|
||
|
if (!input_method->input_method_binding)
|
||
|
return;
|
||
|
|
||
10 years ago
|
context = zalloc(sizeof *context);
|
||
12 years ago
|
if (context == NULL)
|
||
|
return;
|
||
|
|
||
12 years ago
|
binding = input_method->input_method_binding;
|
||
12 years ago
|
context->resource =
|
||
|
wl_resource_create(wl_resource_get_client(binding),
|
||
9 years ago
|
&zwp_input_method_context_v1_interface,
|
||
|
1, 0);
|
||
12 years ago
|
wl_resource_set_implementation(context->resource,
|
||
10 years ago
|
&context_implementation,
|
||
12 years ago
|
context, destroy_input_method_context);
|
||
12 years ago
|
|
||
10 years ago
|
context->input = input;
|
||
12 years ago
|
context->input_method = input_method;
|
||
12 years ago
|
input_method->context = context;
|
||
|
|
||
|
|
||
9 years ago
|
zwp_input_method_v1_send_activate(binding, context->resource);
|
||
12 years ago
|
}
|
||
|
|
||
12 years ago
|
static void
|
||
|
input_method_context_end_keyboard_grab(struct input_method_context *context)
|
||
|
{
|
||
10 years ago
|
struct weston_keyboard_grab *grab;
|
||
|
struct weston_keyboard *keyboard;
|
||
|
|
||
10 years ago
|
keyboard = weston_seat_get_keyboard(context->input_method->seat);
|
||
|
if (!keyboard)
|
||
10 years ago
|
return;
|
||
12 years ago
|
|
||
10 years ago
|
grab = &keyboard->input_method_grab;
|
||
10 years ago
|
keyboard = grab->keyboard;
|
||
|
if (!keyboard)
|
||
12 years ago
|
return;
|
||
|
|
||
10 years ago
|
if (keyboard->grab == grab)
|
||
|
weston_keyboard_end_grab(keyboard);
|
||
12 years ago
|
|
||
12 years ago
|
keyboard->input_method_resource = NULL;
|
||
|
}
|
||
12 years ago
|
|
||
13 years ago
|
static void
|
||
|
unbind_input_method(struct wl_resource *resource)
|
||
|
{
|
||
12 years ago
|
struct input_method *input_method = wl_resource_get_user_data(resource);
|
||
13 years ago
|
|
||
|
input_method->input_method_binding = NULL;
|
||
12 years ago
|
input_method->context = NULL;
|
||
13 years ago
|
}
|
||
|
|
||
13 years ago
|
static void
|
||
|
bind_input_method(struct wl_client *client,
|
||
|
void *data,
|
||
|
uint32_t version,
|
||
|
uint32_t id)
|
||
|
{
|
||
13 years ago
|
struct input_method *input_method = data;
|
||
12 years ago
|
struct text_backend *text_backend = input_method->text_backend;
|
||
13 years ago
|
struct wl_resource *resource;
|
||
|
|
||
12 years ago
|
resource =
|
||
9 years ago
|
wl_resource_create(client,
|
||
|
&zwp_input_method_v1_interface, 1, id);
|
||
13 years ago
|
|
||
12 years ago
|
if (input_method->input_method_binding != NULL) {
|
||
10 years ago
|
wl_resource_post_error(resource,
|
||
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
||
12 years ago
|
"interface object already bound");
|
||
|
return;
|
||
|
}
|
||
12 years ago
|
|
||
12 years ago
|
if (text_backend->input_method.client != client) {
|
||
10 years ago
|
wl_resource_post_error(resource,
|
||
|
WL_DISPLAY_ERROR_INVALID_OBJECT,
|
||
|
"permission to bind "
|
||
|
"input_method denied");
|
||
13 years ago
|
return;
|
||
|
}
|
||
|
|
||
12 years ago
|
wl_resource_set_implementation(resource, NULL, input_method,
|
||
|
unbind_input_method);
|
||
12 years ago
|
input_method->input_method_binding = resource;
|
||
13 years ago
|
}
|
||
|
|
||
|
static void
|
||
|
input_method_notifier_destroy(struct wl_listener *listener, void *data)
|
||
|
{
|
||
13 years ago
|
struct input_method *input_method =
|
||
|
container_of(listener, struct input_method, destroy_listener);
|
||
13 years ago
|
|
||
10 years ago
|
if (input_method->input)
|
||
10 years ago
|
deactivate_input_method(input_method);
|
||
12 years ago
|
|
||
12 years ago
|
wl_global_destroy(input_method->input_method_global);
|
||
12 years ago
|
wl_list_remove(&input_method->destroy_listener.link);
|
||
12 years ago
|
|
||
13 years ago
|
free(input_method);
|
||
|
}
|
||
|
|
||
13 years ago
|
static void
|
||
|
handle_keyboard_focus(struct wl_listener *listener, void *data)
|
||
|
{
|
||
12 years ago
|
struct weston_keyboard *keyboard = data;
|
||
13 years ago
|
struct input_method *input_method =
|
||
10 years ago
|
container_of(listener, struct input_method,
|
||
|
keyboard_focus_listener);
|
||
12 years ago
|
struct weston_surface *surface = keyboard->focus;
|
||
13 years ago
|
|
||
10 years ago
|
if (!input_method->input)
|
||
13 years ago
|
return;
|
||
|
|
||
10 years ago
|
if (!surface || input_method->input->surface != surface)
|
||
10 years ago
|
deactivate_input_method(input_method);
|
||
13 years ago
|
}
|
||
|
|
||
|
static void
|
||
|
input_method_init_seat(struct weston_seat *seat)
|
||
|
{
|
||
10 years ago
|
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
|
||
|
|
||
13 years ago
|
if (seat->input_method->focus_listener_initialized)
|
||
|
return;
|
||
|
|
||
10 years ago
|
if (keyboard) {
|
||
10 years ago
|
seat->input_method->keyboard_focus_listener.notify =
|
||
|
handle_keyboard_focus;
|
||
10 years ago
|
wl_signal_add(&keyboard->focus_signal,
|
||
10 years ago
|
&seat->input_method->keyboard_focus_listener);
|
||
10 years ago
|
keyboard->input_method_grab.interface =
|
||
10 years ago
|
&input_method_context_grab;
|
||
13 years ago
|
}
|
||
|
|
||
10 years ago
|
seat->input_method->focus_listener_initialized = true;
|
||
13 years ago
|
}
|
||
|
|
||
12 years ago
|
static void launch_input_method(struct text_backend *text_backend);
|
||
|
|
||
12 years ago
|
static void
|
||
10 years ago
|
respawn_input_method_process(struct text_backend *text_backend)
|
||
12 years ago
|
{
|
||
12 years ago
|
uint32_t time;
|
||
|
|
||
|
/* if input_method dies more than 5 times in 10 seconds, give up */
|
||
|
time = weston_compositor_get_time();
|
||
|
if (time - text_backend->input_method.deathstamp > 10000) {
|
||
|
text_backend->input_method.deathstamp = time;
|
||
|
text_backend->input_method.deathcount = 0;
|
||
|
}
|
||
|
|
||
|
text_backend->input_method.deathcount++;
|
||
|
if (text_backend->input_method.deathcount > 5) {
|
||
10 years ago
|
weston_log("input_method disconnected, giving up.\n");
|
||
12 years ago
|
return;
|
||
|
}
|
||
|
|
||
10 years ago
|
weston_log("input_method disconnected, respawning...\n");
|
||
12 years ago
|
launch_input_method(text_backend);
|
||
12 years ago
|
}
|
||
|
|
||
10 years ago
|
static void
|
||
|
input_method_client_notifier(struct wl_listener *listener, void *data)
|
||
|
{
|
||
|
struct text_backend *text_backend;
|
||
|
|
||
|
text_backend = container_of(listener, struct text_backend,
|
||
|
client_listener);
|
||
|
|
||
|
text_backend->input_method.client = NULL;
|
||
|
respawn_input_method_process(text_backend);
|
||
|
}
|
||
|
|
||
12 years ago
|
static void
|
||
|
launch_input_method(struct text_backend *text_backend)
|
||
|
{
|
||
|
if (!text_backend->input_method.path)
|
||
|
return;
|
||
10 years ago
|
|
||
|
if (strcmp(text_backend->input_method.path, "") == 0)
|
||
|
return;
|
||
12 years ago
|
|
||
10 years ago
|
text_backend->input_method.client =
|
||
10 years ago
|
weston_client_start(text_backend->compositor,
|
||
|
text_backend->input_method.path);
|
||
12 years ago
|
|
||
10 years ago
|
if (!text_backend->input_method.client) {
|
||
10 years ago
|
weston_log("not able to start %s\n",
|
||
|
text_backend->input_method.path);
|
||
10 years ago
|
return;
|
||
|
}
|
||
|
|
||
|
text_backend->client_listener.notify = input_method_client_notifier;
|
||
|
wl_client_add_destroy_listener(text_backend->input_method.client,
|
||
|
&text_backend->client_listener);
|
||
12 years ago
|
}
|
||
|
|
||
|
static void
|
||
10 years ago
|
text_backend_seat_created(struct text_backend *text_backend,
|
||
|
struct weston_seat *seat)
|
||
13 years ago
|
{
|
||
|
struct input_method *input_method;
|
||
12 years ago
|
struct weston_compositor *ec = seat->compositor;
|
||
13 years ago
|
|
||
10 years ago
|
input_method = zalloc(sizeof *input_method);
|
||
|
if (input_method == NULL)
|
||
|
return;
|
||
13 years ago
|
|
||
12 years ago
|
input_method->seat = seat;
|
||
10 years ago
|
input_method->input = NULL;
|
||
10 years ago
|
input_method->focus_listener_initialized = false;
|
||
12 years ago
|
input_method->context = NULL;
|
||
12 years ago
|
input_method->text_backend = text_backend;
|
||
13 years ago
|
|
||
13 years ago
|
input_method->input_method_global =
|
||
9 years ago
|
wl_global_create(ec->wl_display,
|
||
|
&zwp_input_method_v1_interface, 1,
|
||
12 years ago
|
input_method, bind_input_method);
|
||
13 years ago
|
|
||
13 years ago
|
input_method->destroy_listener.notify = input_method_notifier_destroy;
|
||
12 years ago
|
wl_signal_add(&seat->destroy_signal, &input_method->destroy_listener);
|
||
13 years ago
|
|
||
|
seat->input_method = input_method;
|
||
12 years ago
|
}
|
||
|
|
||
10 years ago
|
static void
|
||
|
handle_seat_created(struct wl_listener *listener, void *data)
|
||
|
{
|
||
|
struct weston_seat *seat = data;
|
||
|
struct text_backend *text_backend =
|
||
|
container_of(listener, struct text_backend,
|
||
|
seat_created_listener);
|
||
|
|
||
|
text_backend_seat_created(text_backend, seat);
|
||
|
}
|
||
|
|
||
12 years ago
|
static void
|
||
|
text_backend_configuration(struct text_backend *text_backend)
|
||
|
{
|
||
9 years ago
|
struct weston_config *config = wet_get_config(text_backend->compositor);
|
||
12 years ago
|
struct weston_config_section *section;
|
||
11 years ago
|
char *client;
|
||
10 years ago
|
int ret;
|
||
12 years ago
|
|
||
9 years ago
|
section = weston_config_get_section(config,
|
||
12 years ago
|
"input-method", NULL, NULL);
|
||
10 years ago
|
ret = asprintf(&client, "%s/weston-keyboard",
|
||
|
weston_config_get_libexec_dir());
|
||
|
if (ret < 0)
|
||
|
client = NULL;
|
||
12 years ago
|
weston_config_section_get_string(section, "path",
|
||
|
&text_backend->input_method.path,
|
||
11 years ago
|
client);
|
||
|
free(client);
|
||
12 years ago
|
}
|
||
|
|
||
10 years ago
|
WL_EXPORT void
|
||
|
text_backend_destroy(struct text_backend *text_backend)
|
||
12 years ago
|
{
|
||
10 years ago
|
if (text_backend->input_method.client) {
|
||
|
/* disable respawn */
|
||
|
wl_list_remove(&text_backend->client_listener.link);
|
||
12 years ago
|
wl_client_destroy(text_backend->input_method.client);
|
||
10 years ago
|
}
|
||
12 years ago
|
|
||
|
free(text_backend->input_method.path);
|
||
|
free(text_backend);
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
10 years ago
|
WL_EXPORT struct text_backend *
|
||
12 years ago
|
text_backend_init(struct weston_compositor *ec)
|
||
|
{
|
||
|
struct text_backend *text_backend;
|
||
10 years ago
|
struct weston_seat *seat;
|
||
12 years ago
|
|
||
10 years ago
|
text_backend = zalloc(sizeof(*text_backend));
|
||
|
if (text_backend == NULL)
|
||
10 years ago
|
return NULL;
|
||
12 years ago
|
|
||
|
text_backend->compositor = ec;
|
||
|
|
||
10 years ago
|
text_backend_configuration(text_backend);
|
||
|
|
||
|
wl_list_for_each(seat, &ec->seat_list, link)
|
||
|
text_backend_seat_created(text_backend, seat);
|
||
12 years ago
|
text_backend->seat_created_listener.notify = handle_seat_created;
|
||
|
wl_signal_add(&ec->seat_created_signal,
|
||
|
&text_backend->seat_created_listener);
|
||
|
|
||
12 years ago
|
text_input_manager_create(ec);
|
||
12 years ago
|
|
||
10 years ago
|
launch_input_method(text_backend);
|
||
|
|
||
10 years ago
|
return text_backend;
|
||
12 years ago
|
}
|