2023-03-14 12:57:50 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "../defines.hpp"
|
2024-07-29 11:14:19 -05:00
|
|
|
#include "../protocols/core/Compositor.hpp"
|
|
|
|
|
#include "text-input-unstable-v1.hpp"
|
|
|
|
|
#include "WaylandProtocol.hpp"
|
2023-03-14 12:57:50 +00:00
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2024-03-22 23:08:52 +00:00
|
|
|
class CTextInput;
|
2023-03-14 12:57:50 +00:00
|
|
|
|
2024-07-29 11:14:19 -05:00
|
|
|
class CTextInputV1 {
|
|
|
|
|
public:
|
|
|
|
|
CTextInputV1(SP<CZwpTextInputV1> resource);
|
|
|
|
|
~CTextInputV1();
|
|
|
|
|
|
|
|
|
|
void enter(SP<CWLSurfaceResource> surface);
|
|
|
|
|
void leave();
|
2023-03-14 12:57:50 +00:00
|
|
|
|
2024-07-29 11:14:19 -05:00
|
|
|
void preeditCursor(int32_t index);
|
|
|
|
|
void preeditStyling(uint32_t index, uint32_t length, zwpTextInputV1PreeditStyle style);
|
|
|
|
|
void preeditString(uint32_t serial, const char* text, const char* commit);
|
|
|
|
|
void commitString(uint32_t serial, const char* text);
|
|
|
|
|
void deleteSurroundingText(int32_t index, uint32_t length);
|
2023-03-14 12:57:50 +00:00
|
|
|
|
2024-07-29 11:14:19 -05:00
|
|
|
bool good();
|
|
|
|
|
wl_client* client();
|
2023-03-14 12:57:50 +00:00
|
|
|
|
2024-07-29 11:14:19 -05:00
|
|
|
private:
|
2025-05-04 19:21:36 +02:00
|
|
|
SP<CZwpTextInputV1> m_resource;
|
2023-03-14 12:57:50 +00:00
|
|
|
|
2025-05-04 19:21:36 +02:00
|
|
|
uint32_t m_serial = 0;
|
|
|
|
|
bool m_active = false;
|
2023-03-14 12:57:50 +00:00
|
|
|
|
2024-07-29 11:14:19 -05:00
|
|
|
struct {
|
2025-07-08 09:56:40 -07:00
|
|
|
CSignalT<> onCommit;
|
|
|
|
|
CSignalT<SP<CWLSurfaceResource>> enable;
|
|
|
|
|
CSignalT<> disable;
|
|
|
|
|
CSignalT<> reset;
|
|
|
|
|
CSignalT<> destroy;
|
2025-05-04 19:21:36 +02:00
|
|
|
} m_events;
|
2023-03-14 13:51:08 +00:00
|
|
|
|
2023-03-14 12:57:50 +00:00
|
|
|
struct SPendingSurr {
|
|
|
|
|
bool isPending = false;
|
|
|
|
|
std::string text = "";
|
|
|
|
|
uint32_t cursor = 0;
|
|
|
|
|
uint32_t anchor = 0;
|
2025-05-04 19:21:36 +02:00
|
|
|
} m_pendingSurrounding;
|
2023-03-14 12:57:50 +00:00
|
|
|
|
|
|
|
|
struct SPendingCT {
|
|
|
|
|
bool isPending = false;
|
|
|
|
|
uint32_t hint = 0;
|
|
|
|
|
uint32_t purpose = 0;
|
2025-05-04 19:21:36 +02:00
|
|
|
} m_pendingContentType;
|
2023-03-14 12:57:50 +00:00
|
|
|
|
2025-05-04 19:21:36 +02:00
|
|
|
CBox m_cursorRectangle = {0, 0, 0, 0};
|
2023-03-14 12:57:50 +00:00
|
|
|
|
2024-07-29 11:14:19 -05:00
|
|
|
friend class CTextInput;
|
|
|
|
|
friend class CTextInputV1Protocol;
|
2023-03-14 12:57:50 +00:00
|
|
|
};
|
|
|
|
|
|
2024-10-06 14:07:07 +01:00
|
|
|
class CTextInputV1Protocol : public IWaylandProtocol {
|
2023-03-14 12:57:50 +00:00
|
|
|
public:
|
2024-07-29 11:14:19 -05:00
|
|
|
CTextInputV1Protocol(const wl_interface* iface, const int& ver, const std::string& name);
|
|
|
|
|
|
|
|
|
|
virtual void bindManager(wl_client* client, void* data, uint32_t version, uint32_t id);
|
|
|
|
|
void destroyResource(CTextInputV1* resource);
|
|
|
|
|
void destroyResource(CZwpTextInputManagerV1* client);
|
|
|
|
|
|
|
|
|
|
struct {
|
2025-07-08 09:56:40 -07:00
|
|
|
CSignalT<WP<CTextInputV1>> newTextInput;
|
2025-05-04 19:21:36 +02:00
|
|
|
} m_events;
|
2023-03-14 12:57:50 +00:00
|
|
|
|
|
|
|
|
private:
|
2025-05-04 19:21:36 +02:00
|
|
|
std::vector<SP<CZwpTextInputManagerV1>> m_managers;
|
|
|
|
|
std::vector<SP<CTextInputV1>> m_clients;
|
2024-07-29 11:14:19 -05:00
|
|
|
|
|
|
|
|
friend class CTextInputV1;
|
|
|
|
|
};
|
2023-03-14 12:57:50 +00:00
|
|
|
|
2024-07-29 11:14:19 -05:00
|
|
|
namespace PROTO {
|
|
|
|
|
inline UP<CTextInputV1Protocol> textInputV1;
|
2024-07-24 12:07:36 -05:00
|
|
|
};
|