summaryrefslogtreecommitdiff
path: root/src/managers/input/InputMethodRelay.hpp
blob: eb7c9f6419666011bc18b9b11358795185e817f8 (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
#pragma once

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

class CInputManager;
class CHyprRenderer;
struct STextInputV1;

class CInputMethodRelay {
  public:
    CInputMethodRelay();

    void                 onNewIME(wlr_input_method_v2*);
    void                 onNewTextInput(wlr_text_input_v3*);
    void                 onNewTextInput(STextInputV1* pTIV1);

    wlr_input_method_v2* m_pWLRIME = nullptr;

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

    void                 onKeyboardFocus(wlr_surface*);

    CTextInput*          getFocusedTextInput();

    SIMEKbGrab*          getIMEKeyboardGrab(SKeyboard*);

    void                 setIMEPopupFocus(CInputPopup*, wlr_surface*);
    void                 removePopup(CInputPopup*);

    CInputPopup*         popupFromCoords(const Vector2D& point);

    void                 updateAllPopups();

  private:
    std::unique_ptr<SIMEKbGrab>               m_pKeyboardGrab;

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

    wlr_surface*                              m_pLastKbFocus = nullptr;

    DYNLISTENER(textInputNew);
    DYNLISTENER(IMECommit);
    DYNLISTENER(IMEDestroy);
    DYNLISTENER(IMEGrab);
    DYNLISTENER(IMENewPopup);

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