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

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

class CInputManager;
struct STextInputV1;

class CInputMethodRelay {
  public:
    CInputMethodRelay();

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

    wlr_input_method_v2* m_pWLRIME = nullptr;

    void                 commitIMEState(STextInput* pInput);
    void                 removeTextInput(STextInput* pInput);

    void                 onKeyboardFocus(wlr_surface*);

    STextInput*          getFocusedTextInput();

    SIMEKbGrab*          getIMEKeyboardGrab(SKeyboard*);

    void                 setIMEPopupFocus(SIMEPopup*, wlr_surface*);
    void                 updateInputPopup(SIMEPopup*);
    void                 damagePopup(SIMEPopup*);
    void                 removePopup(SIMEPopup*);

  private:
    std::unique_ptr<SIMEKbGrab> m_pKeyboardGrab;

    std::list<STextInput>       m_lTextInputs;
    std::list<SIMEPopup>        m_lIMEPopups;

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

    void                                          createNewTextInput(wlr_text_input_v3*, STextInputV1* tiv1 = nullptr);

    wlr_surface*                                  focusedSurface(STextInput* pInput);
    wlr_surface*                                  m_pFocusedSurface;
    void                                          onTextInputLeave(wlr_surface* pSurface);
    void                                          onTextInputEnter(wlr_surface* pSurface);

    std::unordered_map<wlr_surface*, STextInput*> m_mSurfaceToTextInput;
    void                                          setSurfaceToPTI(wlr_surface* pSurface, STextInput* pInput);
    STextInput*                                   getTextInput(wlr_surface* pSurface);
    void                                          removeSurfaceToPTI(STextInput* pInput);

    std::unordered_map<wl_client*, int>           m_mClientTextInputVersion;
    int                                           setTextInputVersion(wl_client* pClient, int version);
    int                                           getTextInputVersion(wl_client* pClient);
    void                                          removeTextInputVersion(wl_client* pClient);

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