aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/barrier/IClient.h
blob: d9b2194e63edeea070d7ac6ffd42499763ab198a (plain) (blame)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*
 * barrier -- mouse and keyboard sharing utility
 * Copyright (C) 2012-2016 Symless Ltd.
 * Copyright (C) 2002 Chris Schoeneman
 * 
 * This package is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * found in the file LICENSE that should have accompanied this file.
 * 
 * This package is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#include "barrier/clipboard_types.h"
#include "barrier/IScreen.h"
#include "barrier/key_types.h"
#include "barrier/mouse_types.h"
#include "barrier/option_types.h"
#include "base/String.h"

//! Client interface
/*!
This interface defines the methods necessary for the server to
communicate with a client.
*/
class IClient : public IScreen {
public:
    //! @name manipulators
    //@{

    //! Enter screen
    /*!
    Enter the screen.  The cursor should be warped to \p xAbs,yAbs.
    \p mask is the expected toggle button state and the client should
    update its state to match.  \p forScreensaver is true iff the
    screen is being entered because the screen saver is starting.
    Subsequent clipboard events should report \p seqNum.
    */
    virtual void        enter(SInt32 xAbs, SInt32 yAbs,
                            UInt32 seqNum, KeyModifierMask mask,
                            bool forScreensaver) = 0;

    //! Leave screen
    /*!
    Leave the screen.  Return false iff the user may not leave the
    client's screen (because, for example, a button is down).
    */
    virtual bool        leave() = 0;

    //! Set clipboard
    /*!
    Update the client's clipboard.  This implies that the client's
    clipboard is now up to date.  If the client's clipboard was
    already known to be up to date then this may do nothing.  \c data
    has marshalled clipboard data.
    */
    virtual void        setClipboard(ClipboardID, const IClipboard*) = 0;

    //! Grab clipboard
    /*!
    Grab (i.e. take ownership of) the client's clipboard.  Since this
    is called when another client takes ownership of the clipboard it
    implies that the client's clipboard is out of date.
    */
    virtual void        grabClipboard(ClipboardID) = 0;

    //! Mark clipboard dirty
    /*!
    Mark the client's clipboard as dirty (out of date) or clean (up to
    date).
    */
    virtual void        setClipboardDirty(ClipboardID, bool dirty) = 0;

    //! Notify of key press
    /*!
    Synthesize key events to generate a press of key \c id.  If possible
    match the given modifier mask.  The KeyButton identifies the physical
    key on the server that generated this key down.  The client must
    ensure that a key up or key repeat that uses the same KeyButton will
    synthesize an up or repeat for the same client key synthesized by
    keyDown().
    */
    virtual void        keyDown(KeyID id, KeyModifierMask, KeyButton) = 0;

    //! Notify of key repeat
    /*!
    Synthesize key events to generate a press and release of key \c id
    \c count times.  If possible match the given modifier mask.
    */
    virtual void        keyRepeat(KeyID id, KeyModifierMask,
                            SInt32 count, KeyButton) = 0;

    //! Notify of key release
    /*!
    Synthesize key events to generate a release of key \c id.  If possible
    match the given modifier mask.
    */
    virtual void        keyUp(KeyID id, KeyModifierMask, KeyButton) = 0;

    //! Notify of mouse press
    /*!
    Synthesize mouse events to generate a press of mouse button \c id.
    */
    virtual void        mouseDown(ButtonID id) = 0;

    //! Notify of mouse release
    /*!
    Synthesize mouse events to generate a release of mouse button \c id.
    */
    virtual void        mouseUp(ButtonID id) = 0;

    //! Notify of mouse motion
    /*!
    Synthesize mouse events to generate mouse motion to the absolute
    screen position \c xAbs,yAbs.
    */
    virtual void        mouseMove(SInt32 xAbs, SInt32 yAbs) = 0;

    //! Notify of mouse motion
    /*!
    Synthesize mouse events to generate mouse motion by the relative
    amount \c xRel,yRel.
    */
    virtual void        mouseRelativeMove(SInt32 xRel, SInt32 yRel) = 0;

    //! Notify of mouse wheel motion
    /*!
    Synthesize mouse events to generate mouse wheel motion of \c xDelta
    and \c yDelta.  Deltas are positive for motion away from the user or
    to the right and negative for motion towards the user or to the left.
    Each wheel click should generate a delta of +/-120.
    */
    virtual void        mouseWheel(SInt32 xDelta, SInt32 yDelta) = 0;

    //! Notify of screen saver change
    virtual void        screensaver(bool activate) = 0;

    //! Notify of options changes
    /*!
    Reset all options to their default values.
    */
    virtual void        resetOptions() = 0;

    //! Notify of options changes
    /*!
    Set options to given values.  Ignore unknown options and don't
    modify our options that aren't given in \c options.
    */
    virtual void        setOptions(const OptionsList& options) = 0;

    //@}
    //! @name accessors
    //@{

    //! Get client name
    /*!
    Return the client's name.
    */
    virtual String        getName() const = 0;

    //@}

    // IScreen overrides
    virtual void*        getEventTarget() const = 0;
    virtual bool        getClipboard(ClipboardID id, IClipboard*) const = 0;
    virtual void        getShape(SInt32& x, SInt32& y,
                            SInt32& width, SInt32& height) const = 0;
    virtual void        getCursorPos(SInt32& x, SInt32& y) const = 0;
};