KWin
Loading...
Searching...
No Matches
textinput_v1_p.h
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2022 Xuetian Weng <wengxt@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6#pragma once
7
8#include "clientconnection.h"
9#include "wayland/seat.h"
10#include "wayland/seat_p.h"
11#include "wayland/surface.h"
13
14#include <QList>
15#include <QPointer>
16#include <QRect>
17#include <QSet>
18
19#include <qwayland-server-text-input-unstable-v1.h>
20
21namespace KWin
22{
23class TextInputManagerV1InterfacePrivate : public QtWaylandServer::zwp_text_input_manager_v1
24{
25public:
27
30 std::unique_ptr<TextInputV1Interface> textInputV1;
31
32protected:
33 void zwp_text_input_manager_v1_create_text_input(Resource *resource, uint32_t id) override;
34};
35
36class TextInputV1InterfacePrivate : public QtWaylandServer::zwp_text_input_v1
37{
38public:
40
43 void preEdit(const QString &text, const QString &commit);
44 void preEditStyling(quint32 index, uint32_t length, uint32_t style);
45 void commitString(const QString &text);
46 void deleteSurroundingText(qint32 index, quint32 length);
47 void setTextDirection(Qt::LayoutDirection direction);
48 void setPreEditCursor(qint32 index);
49 void setCursorPosition(qint32 index, qint32 anchor);
50 void keysymPressed(quint32 time, quint32 keysym, quint32 modifiers);
51 void keysymReleased(quint32 time, quint32 keysym, quint32 modifiers);
53 void sendLanguage();
54 void sendModifiersMap();
55
56 template<typename T>
57 void forActivatedResource(const T &callback)
58 {
59 if (auto resource = activated.value(surface)) {
60 callback(resource);
61 }
62 }
63
64 QList<Resource *> textInputsForClient(ClientConnection *client) const;
66 {
67 return inputInterface->d.get();
68 }
69
74 QPointer<SeatInterface> seat;
75 QPointer<SurfaceInterface> surface;
79 bool inputPanelVisible = false;
81 QString language;
82 QByteArray modifiersMap;
84 // Based on weston reference implementation, one surface can have only one activated text input.
85 QHash<SurfaceInterface *, Resource *> activated;
86 QHash<Resource *, quint32> serialHash;
87
88protected:
89 void zwp_text_input_v1_bind_resource(Resource *resource) override;
90 void zwp_text_input_v1_destroy_resource(Resource *resource) override;
91 void zwp_text_input_v1_activate(Resource *resource, struct wl_resource *seat, struct wl_resource *surface) override;
92 void zwp_text_input_v1_deactivate(Resource *resource, wl_resource *seat) override;
93 void zwp_text_input_v1_show_input_panel(Resource *resource) override;
94 void zwp_text_input_v1_hide_input_panel(Resource *resource) override;
95 void zwp_text_input_v1_reset(Resource *resource) override;
96 void zwp_text_input_v1_set_surrounding_text(Resource *resource, const QString &text, uint32_t cursor, uint32_t anchor) override;
97 void zwp_text_input_v1_set_content_type(Resource *resource, uint32_t hint, uint32_t purpose) override;
98 void zwp_text_input_v1_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override;
99 void zwp_text_input_v1_set_preferred_language(Resource *resource, const QString &language) override;
100 void zwp_text_input_v1_commit_state(Resource *resource, uint32_t serial) override;
101 void zwp_text_input_v1_invoke_action(Resource *resource, uint32_t button, uint32_t index) override;
102};
103
104}
Convenient Class which represents a wl_client.
Class holding the Wayland server display loop.
Definition display.h:34
Represents a Seat on the Wayland Display.
Definition seat.h:134
Resource representing a wl_surface.
Definition surface.h:80
Represent the Global for the interface.
std::unique_ptr< TextInputV1Interface > textInputV1
TextInputManagerV1Interface * q
void zwp_text_input_manager_v1_create_text_input(Resource *resource, uint32_t id) override
TextInputManagerV1InterfacePrivate(TextInputManagerV1Interface *_q, Display *display)
Represents a generic Resource for a text input object.
void keysymReleased(quint32 time, quint32 keysym, quint32 modifiers)
QHash< Resource *, quint32 > serialHash
void sendEnter(SurfaceInterface *surface)
TextInputContentPurpose contentPurpose
void zwp_text_input_v1_show_input_panel(Resource *resource) override
void setCursorPosition(qint32 index, qint32 anchor)
void keysymPressed(quint32 time, quint32 keysym, quint32 modifiers)
void commitString(const QString &text)
QPointer< SurfaceInterface > surface
void deleteSurroundingText(qint32 index, quint32 length)
void sendLeave(SurfaceInterface *surface)
void forActivatedResource(const T &callback)
void setTextDirection(Qt::LayoutDirection direction)
void preEditStyling(quint32 index, uint32_t length, uint32_t style)
void zwp_text_input_v1_reset(Resource *resource) override
void zwp_text_input_v1_set_preferred_language(Resource *resource, const QString &language) override
void preEdit(const QString &text, const QString &commit)
TextInputContentHints contentHints
void zwp_text_input_v1_set_cursor_rectangle(Resource *resource, int32_t x, int32_t y, int32_t width, int32_t height) override
void zwp_text_input_v1_destroy_resource(Resource *resource) override
void zwp_text_input_v1_set_content_type(Resource *resource, uint32_t hint, uint32_t purpose) override
void zwp_text_input_v1_deactivate(Resource *resource, wl_resource *seat) override
QList< Resource * > textInputsForClient(ClientConnection *client) const
QHash< SurfaceInterface *, Resource * > activated
void zwp_text_input_v1_hide_input_panel(Resource *resource) override
void zwp_text_input_v1_invoke_action(Resource *resource, uint32_t button, uint32_t index) override
void zwp_text_input_v1_bind_resource(Resource *resource) override
void zwp_text_input_v1_activate(Resource *resource, struct wl_resource *seat, struct wl_resource *surface) override
void zwp_text_input_v1_set_surrounding_text(Resource *resource, const QString &text, uint32_t cursor, uint32_t anchor) override
QPointer< SeatInterface > seat
void zwp_text_input_v1_commit_state(Resource *resource, uint32_t serial) override
TextInputV1InterfacePrivate(SeatInterface *seat, TextInputV1Interface *_q)
static TextInputV1InterfacePrivate * get(TextInputV1Interface *inputInterface)
TextInputContentPurpose
Definition textinput.h:72