wayland: Make gtk-text-input "legacy"

It is superseded by zwp_text_input_v3.
This commit is contained in:
Carlos Garnacho 2018-08-13 18:03:49 +02:00 committed by Carlos Garnacho
parent 7c06e21e5a
commit 9510fbcbac
6 changed files with 70 additions and 72 deletions

View File

@ -459,8 +459,8 @@ libmutter_@LIBMUTTER_API_VERSION@_la_SOURCES += \
wayland/meta-wayland-subsurface.h \ wayland/meta-wayland-subsurface.h \
wayland/meta-wayland-shell-surface.c \ wayland/meta-wayland-shell-surface.c \
wayland/meta-wayland-shell-surface.h \ wayland/meta-wayland-shell-surface.h \
wayland/meta-wayland-text-input.c \ wayland/meta-wayland-text-input-legacy.c \
wayland/meta-wayland-text-input.h \ wayland/meta-wayland-text-input-legacy.h \
wayland/meta-wayland-types.h \ wayland/meta-wayland-types.h \
wayland/meta-wayland-versions.h \ wayland/meta-wayland-versions.h \
wayland/meta-wayland-outputs.c \ wayland/meta-wayland-outputs.c \

View File

@ -225,7 +225,7 @@ meta_wayland_seat_new (MetaWaylandCompositor *compositor,
"seat", seat, "seat", seat,
NULL); NULL);
seat->text_input = meta_wayland_text_input_new (seat); seat->gtk_text_input = meta_wayland_gtk_text_input_new (seat);
meta_wayland_data_device_init (&seat->data_device); meta_wayland_data_device_init (&seat->data_device);
@ -262,7 +262,7 @@ meta_wayland_seat_free (MetaWaylandSeat *seat)
g_object_unref (seat->pointer); g_object_unref (seat->pointer);
g_object_unref (seat->keyboard); g_object_unref (seat->keyboard);
g_object_unref (seat->touch); g_object_unref (seat->touch);
meta_wayland_text_input_destroy (seat->text_input); meta_wayland_gtk_text_input_destroy (seat->gtk_text_input);
g_slice_free (MetaWaylandSeat, seat); g_slice_free (MetaWaylandSeat, seat);
} }
@ -382,7 +382,8 @@ meta_wayland_seat_handle_event (MetaWaylandSeat *seat,
break; break;
case CLUTTER_KEY_PRESS: case CLUTTER_KEY_PRESS:
case CLUTTER_KEY_RELEASE: case CLUTTER_KEY_RELEASE:
if (meta_wayland_text_input_handle_event (seat->text_input, event)) if (meta_wayland_gtk_text_input_handle_event (seat->gtk_text_input,
event))
return TRUE; return TRUE;
if (meta_wayland_seat_has_keyboard (seat)) if (meta_wayland_seat_has_keyboard (seat))
@ -428,7 +429,7 @@ meta_wayland_seat_set_input_focus (MetaWaylandSeat *seat,
tablet_seat = meta_wayland_tablet_manager_ensure_seat (compositor->tablet_manager, seat); tablet_seat = meta_wayland_tablet_manager_ensure_seat (compositor->tablet_manager, seat);
meta_wayland_tablet_seat_set_pad_focus (tablet_seat, surface); meta_wayland_tablet_seat_set_pad_focus (tablet_seat, surface);
meta_wayland_text_input_set_focus (seat->text_input, surface); meta_wayland_gtk_text_input_set_focus (seat->gtk_text_input, surface);
} }
gboolean gboolean

View File

@ -32,7 +32,7 @@
#include "meta-wayland-touch.h" #include "meta-wayland-touch.h"
#include "meta-wayland-data-device.h" #include "meta-wayland-data-device.h"
#include "meta-wayland-tablet-tool.h" #include "meta-wayland-tablet-tool.h"
#include "meta-wayland-text-input.h" #include "meta-wayland-text-input-legacy.h"
struct _MetaWaylandSeat struct _MetaWaylandSeat
{ {
@ -45,7 +45,7 @@ struct _MetaWaylandSeat
MetaWaylandDataDevice data_device; MetaWaylandDataDevice data_device;
MetaWaylandTextInput *text_input; MetaWaylandGtkTextInput *gtk_text_input;
guint capabilities; guint capabilities;
}; };

View File

@ -26,10 +26,10 @@
#include "gtk-text-input-server-protocol.h" #include "gtk-text-input-server-protocol.h"
#include "wayland/meta-wayland-private.h" #include "wayland/meta-wayland-private.h"
#include "wayland/meta-wayland-seat.h" #include "wayland/meta-wayland-seat.h"
#include "wayland/meta-wayland-text-input.h" #include "wayland/meta-wayland-text-input-legacy.h"
#include "wayland/meta-wayland-versions.h" #include "wayland/meta-wayland-versions.h"
#define META_TYPE_WAYLAND_TEXT_INPUT_FOCUS (meta_wayland_text_input_focus_get_type ()) #define META_TYPE_WAYLAND_GTK_TEXT_INPUT_FOCUS (meta_wayland_gtk_text_input_focus_get_type ())
typedef enum typedef enum
{ {
@ -39,9 +39,9 @@ typedef enum
META_WAYLAND_PENDING_STATE_SURROUNDING_TEXT = 1 << 2, META_WAYLAND_PENDING_STATE_SURROUNDING_TEXT = 1 << 2,
} MetaWaylandTextInputPendingState; } MetaWaylandTextInputPendingState;
typedef struct _MetaWaylandTextInput MetaWaylandTextInput; typedef struct _MetaWaylandGtkTextInput MetaWaylandGtkTextInput;
struct _MetaWaylandTextInput struct _MetaWaylandGtkTextInput
{ {
MetaWaylandSeat *seat; MetaWaylandSeat *seat;
ClutterInputFocus *input_focus; ClutterInputFocus *input_focus;
@ -67,23 +67,24 @@ struct _MetaWaylandTextInput
uint32_t content_type_purpose; uint32_t content_type_purpose;
}; };
struct _MetaWaylandTextInputFocus struct _MetaWaylandGtkTextInputFocus
{ {
ClutterInputFocus parent_instance; ClutterInputFocus parent_instance;
MetaWaylandTextInput *text_input; MetaWaylandGtkTextInput *text_input;
}; };
G_DECLARE_FINAL_TYPE (MetaWaylandTextInputFocus, meta_wayland_text_input_focus, G_DECLARE_FINAL_TYPE (MetaWaylandGtkTextInputFocus,
META, WAYLAND_TEXT_INPUT_FOCUS, ClutterInputFocus) meta_wayland_gtk_text_input_focus,
G_DEFINE_TYPE (MetaWaylandTextInputFocus, meta_wayland_text_input_focus, META, WAYLAND_GTK_TEXT_INPUT_FOCUS, ClutterInputFocus)
G_DEFINE_TYPE (MetaWaylandGtkTextInputFocus, meta_wayland_gtk_text_input_focus,
CLUTTER_TYPE_INPUT_FOCUS) CLUTTER_TYPE_INPUT_FOCUS)
static void static void
meta_wayland_text_input_focus_request_surrounding (ClutterInputFocus *focus) meta_wayland_text_input_focus_request_surrounding (ClutterInputFocus *focus)
{ {
MetaWaylandTextInput *text_input; MetaWaylandGtkTextInput *text_input;
text_input = META_WAYLAND_TEXT_INPUT_FOCUS (focus)->text_input; text_input = META_WAYLAND_GTK_TEXT_INPUT_FOCUS (focus)->text_input;
clutter_input_focus_set_surrounding (focus, clutter_input_focus_set_surrounding (focus,
text_input->surrounding.text, text_input->surrounding.text,
text_input->surrounding.cursor, text_input->surrounding.cursor,
@ -95,10 +96,10 @@ meta_wayland_text_input_focus_delete_surrounding (ClutterInputFocus *focus,
guint cursor, guint cursor,
guint len) guint len)
{ {
MetaWaylandTextInput *text_input; MetaWaylandGtkTextInput *text_input;
struct wl_resource *resource; struct wl_resource *resource;
text_input = META_WAYLAND_TEXT_INPUT_FOCUS (focus)->text_input; text_input = META_WAYLAND_GTK_TEXT_INPUT_FOCUS (focus)->text_input;
wl_resource_for_each (resource, &text_input->focus_resource_list) wl_resource_for_each (resource, &text_input->focus_resource_list)
{ {
@ -110,10 +111,10 @@ static void
meta_wayland_text_input_focus_commit_text (ClutterInputFocus *focus, meta_wayland_text_input_focus_commit_text (ClutterInputFocus *focus,
const gchar *text) const gchar *text)
{ {
MetaWaylandTextInput *text_input; MetaWaylandGtkTextInput *text_input;
struct wl_resource *resource; struct wl_resource *resource;
text_input = META_WAYLAND_TEXT_INPUT_FOCUS (focus)->text_input; text_input = META_WAYLAND_GTK_TEXT_INPUT_FOCUS (focus)->text_input;
wl_resource_for_each (resource, &text_input->focus_resource_list) wl_resource_for_each (resource, &text_input->focus_resource_list)
{ {
@ -127,10 +128,10 @@ meta_wayland_text_input_focus_set_preedit_text (ClutterInputFocus *focus,
const gchar *text, const gchar *text,
guint cursor) guint cursor)
{ {
MetaWaylandTextInput *text_input; MetaWaylandGtkTextInput *text_input;
struct wl_resource *resource; struct wl_resource *resource;
text_input = META_WAYLAND_TEXT_INPUT_FOCUS (focus)->text_input; text_input = META_WAYLAND_GTK_TEXT_INPUT_FOCUS (focus)->text_input;
wl_resource_for_each (resource, &text_input->focus_resource_list) wl_resource_for_each (resource, &text_input->focus_resource_list)
{ {
@ -139,7 +140,7 @@ meta_wayland_text_input_focus_set_preedit_text (ClutterInputFocus *focus,
} }
static void static void
meta_wayland_text_input_focus_class_init (MetaWaylandTextInputFocusClass *klass) meta_wayland_gtk_text_input_focus_class_init (MetaWaylandGtkTextInputFocusClass *klass)
{ {
ClutterInputFocusClass *focus_class = CLUTTER_INPUT_FOCUS_CLASS (klass); ClutterInputFocusClass *focus_class = CLUTTER_INPUT_FOCUS_CLASS (klass);
@ -150,16 +151,16 @@ meta_wayland_text_input_focus_class_init (MetaWaylandTextInputFocusClass *klass)
} }
static void static void
meta_wayland_text_input_focus_init (MetaWaylandTextInputFocus *focus) meta_wayland_gtk_text_input_focus_init (MetaWaylandGtkTextInputFocus *focus)
{ {
} }
static ClutterInputFocus * static ClutterInputFocus *
meta_wayland_text_input_focus_new (MetaWaylandTextInput *text_input) meta_wayland_text_input_focus_new (MetaWaylandGtkTextInput *text_input)
{ {
MetaWaylandTextInputFocus *focus; MetaWaylandGtkTextInputFocus *focus;
focus = g_object_new (META_TYPE_WAYLAND_TEXT_INPUT_FOCUS, NULL); focus = g_object_new (META_TYPE_WAYLAND_GTK_TEXT_INPUT_FOCUS, NULL);
focus->text_input = text_input; focus->text_input = text_input;
return CLUTTER_INPUT_FOCUS (focus); return CLUTTER_INPUT_FOCUS (focus);
@ -169,10 +170,10 @@ static void
text_input_handle_focus_surface_destroy (struct wl_listener *listener, text_input_handle_focus_surface_destroy (struct wl_listener *listener,
void *data) void *data)
{ {
MetaWaylandTextInput *text_input = wl_container_of (listener, text_input, MetaWaylandGtkTextInput *text_input = wl_container_of (listener, text_input,
surface_listener); surface_listener);
meta_wayland_text_input_set_focus (text_input, NULL); meta_wayland_gtk_text_input_set_focus (text_input, NULL);
} }
static void static void
@ -199,8 +200,8 @@ move_resources_for_client (struct wl_list *destination,
} }
void void
meta_wayland_text_input_set_focus (MetaWaylandTextInput *text_input, meta_wayland_gtk_text_input_set_focus (MetaWaylandGtkTextInput *text_input,
MetaWaylandSurface *surface) MetaWaylandSurface *surface)
{ {
if (text_input->surface == surface) if (text_input->surface == surface)
return; return;
@ -286,7 +287,7 @@ text_input_enable (struct wl_client *client,
uint32_t serial, uint32_t serial,
uint32_t flags) uint32_t flags)
{ {
MetaWaylandTextInput *text_input = wl_resource_get_user_data (resource); MetaWaylandGtkTextInput *text_input = wl_resource_get_user_data (resource);
ClutterInputFocus *focus = text_input->input_focus; ClutterInputFocus *focus = text_input->input_focus;
ClutterInputMethod *input_method; ClutterInputMethod *input_method;
gboolean show_preedit; gboolean show_preedit;
@ -314,7 +315,7 @@ static void
text_input_disable (struct wl_client *client, text_input_disable (struct wl_client *client,
struct wl_resource *resource) struct wl_resource *resource)
{ {
MetaWaylandTextInput *text_input = wl_resource_get_user_data (resource); MetaWaylandGtkTextInput *text_input = wl_resource_get_user_data (resource);
ClutterInputFocus *focus = text_input->input_focus; ClutterInputFocus *focus = text_input->input_focus;
ClutterInputMethod *input_method; ClutterInputMethod *input_method;
@ -335,7 +336,7 @@ text_input_set_surrounding_text (struct wl_client *client,
int32_t cursor, int32_t cursor,
int32_t anchor) int32_t anchor)
{ {
MetaWaylandTextInput *text_input = wl_resource_get_user_data (resource); MetaWaylandGtkTextInput *text_input = wl_resource_get_user_data (resource);
g_free (text_input->surrounding.text); g_free (text_input->surrounding.text);
text_input->surrounding.text = g_strdup (text); text_input->surrounding.text = g_strdup (text);
@ -416,7 +417,7 @@ text_input_set_content_type (struct wl_client *client,
uint32_t hint, uint32_t hint,
uint32_t purpose) uint32_t purpose)
{ {
MetaWaylandTextInput *text_input = wl_resource_get_user_data (resource); MetaWaylandGtkTextInput *text_input = wl_resource_get_user_data (resource);
if (!text_input->surface) if (!text_input->surface)
return; return;
@ -434,7 +435,7 @@ text_input_set_cursor_rectangle (struct wl_client *client,
int32_t width, int32_t width,
int32_t height) int32_t height)
{ {
MetaWaylandTextInput *text_input = wl_resource_get_user_data (resource); MetaWaylandGtkTextInput *text_input = wl_resource_get_user_data (resource);
if (!text_input->surface) if (!text_input->surface)
return; return;
@ -447,7 +448,7 @@ static void
text_input_commit_state (struct wl_client *client, text_input_commit_state (struct wl_client *client,
struct wl_resource *resource) struct wl_resource *resource)
{ {
MetaWaylandTextInput *text_input = wl_resource_get_user_data (resource); MetaWaylandGtkTextInput *text_input = wl_resource_get_user_data (resource);
ClutterInputFocus *focus = text_input->input_focus; ClutterInputFocus *focus = text_input->input_focus;
if (!clutter_input_focus_is_focused (focus)) if (!clutter_input_focus_is_focused (focus))
@ -503,12 +504,12 @@ static struct gtk_text_input_interface meta_text_input_interface = {
text_input_commit_state, text_input_commit_state,
}; };
MetaWaylandTextInput * MetaWaylandGtkTextInput *
meta_wayland_text_input_new (MetaWaylandSeat *seat) meta_wayland_gtk_text_input_new (MetaWaylandSeat *seat)
{ {
MetaWaylandTextInput *text_input; MetaWaylandGtkTextInput *text_input;
text_input = g_new0 (MetaWaylandTextInput, 1); text_input = g_new0 (MetaWaylandGtkTextInput, 1);
text_input->input_focus = meta_wayland_text_input_focus_new (text_input); text_input->input_focus = meta_wayland_text_input_focus_new (text_input);
text_input->seat = seat; text_input->seat = seat;
@ -520,18 +521,18 @@ meta_wayland_text_input_new (MetaWaylandSeat *seat)
} }
void void
meta_wayland_text_input_destroy (MetaWaylandTextInput *text_input) meta_wayland_gtk_text_input_destroy (MetaWaylandGtkTextInput *text_input)
{ {
meta_wayland_text_input_set_focus (text_input, NULL); meta_wayland_gtk_text_input_set_focus (text_input, NULL);
g_object_unref (text_input->input_focus); g_object_unref (text_input->input_focus);
g_free (text_input); g_free (text_input);
} }
static void static void
meta_wayland_text_input_create_new_resource (MetaWaylandTextInput *text_input, meta_wayland_text_input_create_new_resource (MetaWaylandGtkTextInput *text_input,
struct wl_client *client, struct wl_client *client,
struct wl_resource *seat_resource, struct wl_resource *seat_resource,
uint32_t id) uint32_t id)
{ {
struct wl_resource *text_input_resource; struct wl_resource *text_input_resource;
@ -576,7 +577,7 @@ text_input_manager_get_text_input (struct wl_client *client,
{ {
MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource); MetaWaylandSeat *seat = wl_resource_get_user_data (seat_resource);
meta_wayland_text_input_create_new_resource (seat->text_input, client, meta_wayland_text_input_create_new_resource (seat->gtk_text_input, client,
seat_resource, id); seat_resource, id);
} }
@ -603,18 +604,18 @@ bind_text_input (struct wl_client *client,
} }
gboolean gboolean
meta_wayland_text_input_init (MetaWaylandCompositor *compositor) meta_wayland_gtk_text_input_init (MetaWaylandCompositor *compositor)
{ {
return (wl_global_create (compositor->wayland_display, return (wl_global_create (compositor->wayland_display,
&gtk_text_input_manager_interface, &gtk_text_input_manager_interface,
META_GTK_TEXT_INPUT_VERSION, META_GTK_TEXT_INPUT_VERSION,
compositor->seat->text_input, compositor->seat->gtk_text_input,
bind_text_input) != NULL); bind_text_input) != NULL);
} }
gboolean gboolean
meta_wayland_text_input_handle_event (MetaWaylandTextInput *text_input, meta_wayland_gtk_text_input_handle_event (MetaWaylandGtkTextInput *text_input,
const ClutterEvent *event) const ClutterEvent *event)
{ {
if (!text_input->surface || if (!text_input->surface ||
!clutter_input_focus_is_focused (text_input->input_focus)) !clutter_input_focus_is_focused (text_input->input_focus))

View File

@ -19,28 +19,24 @@
* Author: Carlos Garnacho <carlosg@gnome.org> * Author: Carlos Garnacho <carlosg@gnome.org>
*/ */
#ifndef META_WAYLAND_TEXT_INPUT_H #ifndef META_WAYLAND_GTK_TEXT_INPUT_H
#define META_WAYLAND_TEXT_INPUT_H #define META_WAYLAND_GTK_TEXT_INPUT_H
#include <wayland-server.h> #include <wayland-server.h>
#include "wayland/meta-wayland-types.h" #include "wayland/meta-wayland-types.h"
#include "meta/window.h" #include "meta/window.h"
#define META_TYPE_WAYLAND_TEXT_INPUT (meta_wayland_text_input_get_type ()) typedef struct _MetaWaylandGtkTextInput MetaWaylandGtkTextInput;
G_DECLARE_FINAL_TYPE (MetaWaylandTextInput,
meta_wayland_text_input,
META, WAYLAND_TEXT_INPUT,
GObject);
MetaWaylandTextInput * meta_wayland_text_input_new (MetaWaylandSeat *seat); MetaWaylandGtkTextInput * meta_wayland_gtk_text_input_new (MetaWaylandSeat *seat);
void meta_wayland_text_input_destroy (MetaWaylandTextInput *text_input); void meta_wayland_gtk_text_input_destroy (MetaWaylandGtkTextInput *text_input);
gboolean meta_wayland_text_input_init (MetaWaylandCompositor *compositor); gboolean meta_wayland_gtk_text_input_init (MetaWaylandCompositor *compositor);
void meta_wayland_text_input_set_focus (MetaWaylandTextInput *text_input, void meta_wayland_gtk_text_input_set_focus (MetaWaylandGtkTextInput *text_input,
MetaWaylandSurface *surface); MetaWaylandSurface *surface);
gboolean meta_wayland_text_input_handle_event (MetaWaylandTextInput *text_input, gboolean meta_wayland_gtk_text_input_handle_event (MetaWaylandGtkTextInput *text_input,
const ClutterEvent *event); const ClutterEvent *event);
#endif /* META_WAYLAND_TEXT_INPUT_H */ #endif /* META_WAYLAND_GTK_TEXT_INPUT_H */

View File

@ -392,7 +392,7 @@ meta_wayland_init (void)
meta_wayland_dma_buf_init (compositor); meta_wayland_dma_buf_init (compositor);
meta_wayland_keyboard_shortcuts_inhibit_init (compositor); meta_wayland_keyboard_shortcuts_inhibit_init (compositor);
meta_wayland_surface_inhibit_shortcuts_dialog_init (); meta_wayland_surface_inhibit_shortcuts_dialog_init ();
meta_wayland_text_input_init (compositor); meta_wayland_gtk_text_input_init (compositor);
/* Xwayland specific protocol, needs to be filtered out for all other clients */ /* Xwayland specific protocol, needs to be filtered out for all other clients */
if (meta_xwayland_grab_keyboard_init (compositor)) if (meta_xwayland_grab_keyboard_init (compositor))