[server] Put text-input (de-)activate, en-/disable callbacks in child classes

Summary:
The activate/deactivate and enable/disable callback functionality was in the
TextInputInterface::Private interface, but these calls are each specific to v0
and v2 of the protocol.

Since v3 will have again a different function signature, put all the callbacks
and their helper functions in the protocol version specific child classes.

Test Plan: Compiles, runs.

Reviewers: #kwin, #frameworks, davidedmundson, zzag

Reviewed By: #kwin, davidedmundson, zzag

Subscribers: zzag, kde-frameworks-devel

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D16676
This commit is contained in:
Roman Gilg 2018-11-06 13:52:25 +01:00
parent 422e7789a6
commit cd53ae5c28
4 changed files with 44 additions and 46 deletions

View file

@ -34,35 +34,6 @@ namespace KWayland
namespace Server
{
void TextInputInterface::Private::activateCallback(wl_client *client, wl_resource *resource, wl_resource *seat, wl_resource *surface)
{
auto p = cast<Private>(resource);
Q_ASSERT(*p->client == client);
p->requestActivate(SeatInterface::get(seat), SurfaceInterface::get(surface));
}
void TextInputInterface::Private::deactivateCallback(wl_client *client, wl_resource *resource, wl_resource *seat)
{
auto p = cast<Private>(resource);
Q_ASSERT(*p->client == client);
p->requestDeactivate(SeatInterface::get(seat));
}
void TextInputInterface::Private::enableCallback(wl_client *client, wl_resource *resource, wl_resource *surface)
{
auto p = cast<Private>(resource);
Q_ASSERT(*p->client == client);
p->requestActivate(nullptr, SurfaceInterface::get(surface));
}
void TextInputInterface::Private::disableCallback(wl_client *client, wl_resource *resource, wl_resource *surface)
{
Q_UNUSED(surface)
auto p = cast<Private>(resource);
Q_ASSERT(*p->client == client);
p->requestDeactivate(nullptr);
}
void TextInputInterface::Private::showInputPanelCallback(wl_client *client, wl_resource *resource)
{
auto p = cast<Private>(resource);

View file

@ -54,8 +54,6 @@ public:
virtual void sendEnter(SurfaceInterface *surface, quint32 serial) = 0;
virtual void sendLeave(quint32 serial, SurfaceInterface *surface) = 0;
virtual void requestActivate(SeatInterface *seat, SurfaceInterface *surface) = 0;
virtual void requestDeactivate(SeatInterface *seat) = 0;
virtual void preEdit(const QByteArray &text, const QByteArray &commit) = 0;
virtual void commit(const QByteArray &text) = 0;
virtual void deleteSurroundingText(quint32 beforeLength, quint32 afterLength) = 0;
@ -85,10 +83,6 @@ public:
protected:
Private(TextInputInterface *q, Global *c, wl_resource *parentResource, const wl_interface *interface, const void *implementation);
static void activateCallback(wl_client *client, wl_resource *resource, wl_resource * seat, wl_resource * surface);
static void deactivateCallback(wl_client *client, wl_resource *resource, wl_resource * seat);
static void enableCallback(wl_client *client, wl_resource *resource, wl_resource * surface);
static void disableCallback(wl_client *client, wl_resource *resource, wl_resource * surface);
static void showInputPanelCallback(wl_client *client, wl_resource *resource);
static void hideInputPanelCallback(wl_client *client, wl_resource *resource);
static void setSurroundingTextCallback(wl_client *client, wl_resource *resource, const char * text, int32_t cursor, int32_t anchor);

View file

@ -36,10 +36,11 @@ public:
Private(TextInputInterface *q, TextInputManagerUnstableV0Interface *c, wl_resource *parentResource);
~Private();
void activate(SeatInterface *seat, SurfaceInterface *surface);
void deactivate();
void sendEnter(SurfaceInterface *surface, quint32 serial) override;
void sendLeave(quint32 serial, SurfaceInterface *surface) override;
void requestActivate(SeatInterface *seat, SurfaceInterface *surface) override;
void requestDeactivate(SeatInterface *seat) override;
void preEdit(const QByteArray &text, const QByteArray &commit) override;
void commit(const QByteArray &text) override;
void deleteSurroundingText(quint32 beforeLength, quint32 afterLength) override;
@ -60,6 +61,8 @@ private:
return reinterpret_cast<TextInputUnstableV0Interface *>(q);
}
static void activateCallback(wl_client *client, wl_resource *resource, wl_resource * seat, wl_resource * surface);
static void deactivateCallback(wl_client *client, wl_resource *resource, wl_resource * seat);
static void resetCallback(wl_client *client, wl_resource *resource);
static void setSurroundingTextUintCallback(wl_client *client, wl_resource *resource, const char * text, uint32_t cursor, uint32_t anchor);
static void commitStateCallback(wl_client *client, wl_resource *resource, uint32_t serial);
@ -84,7 +87,7 @@ const struct wl_text_input_interface TextInputUnstableV0Interface::Private::s_in
};
#endif
void TextInputUnstableV0Interface::Private::requestActivate(SeatInterface *seat, SurfaceInterface *s)
void TextInputUnstableV0Interface::Private::activate(SeatInterface *seat, SurfaceInterface *s)
{
surface = QPointer<SurfaceInterface>(s);
enabled = true;
@ -92,9 +95,8 @@ void TextInputUnstableV0Interface::Private::requestActivate(SeatInterface *seat,
emit q_func()->requestActivate(seat, surface);
}
void TextInputUnstableV0Interface::Private::requestDeactivate(SeatInterface *seat)
void TextInputUnstableV0Interface::Private::deactivate()
{
Q_UNUSED(seat)
surface.clear();
enabled = false;
emit q_func()->enabledChanged();
@ -223,6 +225,21 @@ TextInputUnstableV0Interface::Private::Private(TextInputInterface *q, TextInputM
TextInputUnstableV0Interface::Private::~Private() = default;
void TextInputUnstableV0Interface::Private::activateCallback(wl_client *client, wl_resource *resource, wl_resource *seat, wl_resource *surface)
{
auto p = cast<Private>(resource);
Q_ASSERT(*p->client == client);
p->activate(SeatInterface::get(seat), SurfaceInterface::get(surface));
}
void TextInputUnstableV0Interface::Private::deactivateCallback(wl_client *client, wl_resource *resource, wl_resource *seat)
{
Q_UNUSED(seat)
auto p = cast<Private>(resource);
Q_ASSERT(*p->client == client);
p->deactivate();
}
void TextInputUnstableV0Interface::Private::resetCallback(wl_client *client, wl_resource *resource)
{
auto p = cast<Private>(resource);

View file

@ -38,8 +38,6 @@ public:
void sendEnter(SurfaceInterface *surface, quint32 serial) override;
void sendLeave(quint32 serial, SurfaceInterface *surface) override;
void requestActivate(SeatInterface *seat, SurfaceInterface *surface) override;
void requestDeactivate(SeatInterface *seat) override;
void preEdit(const QByteArray &text, const QByteArray &commit) override;
void commit(const QByteArray &text) override;
void deleteSurroundingText(quint32 beforeLength, quint32 afterLength) override;
@ -55,12 +53,17 @@ public:
void sendLanguage() override;
private:
static void enableCallback(wl_client *client, wl_resource *resource, wl_resource * surface);
static void disableCallback(wl_client *client, wl_resource *resource, wl_resource * surface);
static void updateStateCallback(wl_client *client, wl_resource *resource, uint32_t serial, uint32_t reason);
static const struct zwp_text_input_v2_interface s_interface;
TextInputUnstableV2Interface *q_func() {
return reinterpret_cast<TextInputUnstableV2Interface *>(q);
}
void enable(SurfaceInterface *s);
void disable();
};
#ifndef DOXYGEN_SHOULD_SKIP_THIS
@ -78,17 +81,15 @@ const struct zwp_text_input_v2_interface TextInputUnstableV2Interface::Private::
};
#endif
void TextInputUnstableV2Interface::Private::requestActivate(SeatInterface *seat, SurfaceInterface *s)
void TextInputUnstableV2Interface::Private::enable(SurfaceInterface *s)
{
Q_UNUSED(seat)
surface = QPointer<SurfaceInterface>(s);
enabled = true;
emit q_func()->enabledChanged();
}
void TextInputUnstableV2Interface::Private::requestDeactivate(SeatInterface *seat)
void TextInputUnstableV2Interface::Private::disable()
{
Q_UNUSED(seat)
surface.clear();
enabled = false;
emit q_func()->enabledChanged();
@ -216,6 +217,21 @@ TextInputUnstableV2Interface::Private::Private(TextInputInterface *q, TextInputM
TextInputUnstableV2Interface::Private::~Private() = default;
void TextInputUnstableV2Interface::Private::enableCallback(wl_client *client, wl_resource *resource, wl_resource *surface)
{
auto p = cast<Private>(resource);
Q_ASSERT(*p->client == client);
p->enable(SurfaceInterface::get(surface));
}
void TextInputUnstableV2Interface::Private::disableCallback(wl_client *client, wl_resource *resource, wl_resource *surface)
{
Q_UNUSED(surface)
auto p = cast<Private>(resource);
Q_ASSERT(*p->client == client);
p->disable();
}
void TextInputUnstableV2Interface::Private::updateStateCallback(wl_client *client, wl_resource *resource, uint32_t serial, uint32_t reason)
{
auto p = cast<Private>(resource);