aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/managers/input/InputMethodRelay.hpp
blob: 5ecc11a2b3fa64f5852d3251919e11ea8e29181c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once

#include <list>
#include "../../defines.hpp"
#include "../../helpers/WLClasses.hpp"
#include "../../helpers/signal/Signal.hpp"
#include "TextInput.hpp"
#include "InputMethodPopup.hpp"
#include <any>

class CInputManager;
class CHyprRenderer;
class CTextInputV1;
class CInputMethodV2;

class CInputMethodRelay {
  public:
    CInputMethodRelay();

    void               onNewIME(SP<CInputMethodV2>);
    void               onNewTextInput(WP<CTextInputV3> tiv3);
    void               onNewTextInput(WP<CTextInputV1> pTIV1);

    void               activateIME(CTextInput* pInput);
    void               deactivateIME(CTextInput* pInput);
    void               commitIMEState(CTextInput* pInput);
    void               removeTextInput(CTextInput* pInput);

    void               onKeyboardFocus(SP<CWLSurfaceResource>);

    CTextInput*        getFocusedTextInput();

    void               setIMEPopupFocus(CInputPopup*, SP<CWLSurfaceResource>);
    void               removePopup(CInputPopup*);

    CInputPopup*       popupFromCoords(const Vector2D& point);
    CInputPopup*       popupFromSurface(const SP<CWLSurfaceResource> surface);

    void               updateAllPopups();

    WP<CInputMethodV2> m_pIME;

  private:
    std::vector<std::unique_ptr<CTextInput>>  m_vTextInputs;
    std::vector<std::unique_ptr<CInputPopup>> m_vIMEPopups;

    WP<CWLSurfaceResource>                    m_pLastKbFocus;

    struct {
        CHyprSignalListener newTIV3;
        CHyprSignalListener newTIV1;
        CHyprSignalListener newIME;
        CHyprSignalListener commitIME;
        CHyprSignalListener destroyIME;
        CHyprSignalListener newPopup;
    } listeners;

    friend class CHyprRenderer;
    friend class CInputManager;
    friend class CTextInputV1ProtocolManager;
    friend class CTextInput;
    friend class CHyprRenderer;
};