1 /* 2 * synergy -- mouse and keyboard sharing utility 3 * Copyright (C) 2012-2016 Symless Ltd. 4 * Copyright (C) 2002 Chris Schoeneman 5 * 6 * This package is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * found in the file LICENSE that should have accompanied this file. 9 * 10 * This package is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #pragma once 20 21 #include "synergy/clipboard_types.h" 22 #include "synergy/IScreen.h" 23 #include "synergy/key_types.h" 24 #include "synergy/mouse_types.h" 25 #include "synergy/option_types.h" 26 #include "base/String.h" 27 28 //! Client interface 29 /*! 30 This interface defines the methods necessary for the server to 31 communicate with a client. 32 */ 33 class IClient : public IScreen { 34 public: 35 //! @name manipulators 36 //@{ 37 38 //! Enter screen 39 /*! 40 Enter the screen. The cursor should be warped to \p xAbs,yAbs. 41 \p mask is the expected toggle button state and the client should 42 update its state to match. \p forScreensaver is true iff the 43 screen is being entered because the screen saver is starting. 44 Subsequent clipboard events should report \p seqNum. 45 */ 46 virtual void enter(SInt32 xAbs, SInt32 yAbs, 47 UInt32 seqNum, KeyModifierMask mask, 48 bool forScreensaver) = 0; 49 50 //! Leave screen 51 /*! 52 Leave the screen. Return false iff the user may not leave the 53 client's screen (because, for example, a button is down). 54 */ 55 virtual bool leave() = 0; 56 57 //! Set clipboard 58 /*! 59 Update the client's clipboard. This implies that the client's 60 clipboard is now up to date. If the client's clipboard was 61 already known to be up to date then this may do nothing. \c data 62 has marshalled clipboard data. 63 */ 64 virtual void setClipboard(ClipboardID, const IClipboard*) = 0; 65 66 //! Grab clipboard 67 /*! 68 Grab (i.e. take ownership of) the client's clipboard. Since this 69 is called when another client takes ownership of the clipboard it 70 implies that the client's clipboard is out of date. 71 */ 72 virtual void grabClipboard(ClipboardID) = 0; 73 74 //! Mark clipboard dirty 75 /*! 76 Mark the client's clipboard as dirty (out of date) or clean (up to 77 date). 78 */ 79 virtual void setClipboardDirty(ClipboardID, bool dirty) = 0; 80 81 //! Notify of key press 82 /*! 83 Synthesize key events to generate a press of key \c id. If possible 84 match the given modifier mask. The KeyButton identifies the physical 85 key on the server that generated this key down. The client must 86 ensure that a key up or key repeat that uses the same KeyButton will 87 synthesize an up or repeat for the same client key synthesized by 88 keyDown(). 89 */ 90 virtual void keyDown(KeyID id, KeyModifierMask, KeyButton) = 0; 91 92 //! Notify of key repeat 93 /*! 94 Synthesize key events to generate a press and release of key \c id 95 \c count times. If possible match the given modifier mask. 96 */ 97 virtual void keyRepeat(KeyID id, KeyModifierMask, 98 SInt32 count, KeyButton) = 0; 99 100 //! Notify of key release 101 /*! 102 Synthesize key events to generate a release of key \c id. If possible 103 match the given modifier mask. 104 */ 105 virtual void keyUp(KeyID id, KeyModifierMask, KeyButton) = 0; 106 107 //! Notify of mouse press 108 /*! 109 Synthesize mouse events to generate a press of mouse button \c id. 110 */ 111 virtual void mouseDown(ButtonID id) = 0; 112 113 //! Notify of mouse release 114 /*! 115 Synthesize mouse events to generate a release of mouse button \c id. 116 */ 117 virtual void mouseUp(ButtonID id) = 0; 118 119 //! Notify of mouse motion 120 /*! 121 Synthesize mouse events to generate mouse motion to the absolute 122 screen position \c xAbs,yAbs. 123 */ 124 virtual void mouseMove(SInt32 xAbs, SInt32 yAbs) = 0; 125 126 //! Notify of mouse motion 127 /*! 128 Synthesize mouse events to generate mouse motion by the relative 129 amount \c xRel,yRel. 130 */ 131 virtual void mouseRelativeMove(SInt32 xRel, SInt32 yRel) = 0; 132 133 //! Notify of mouse wheel motion 134 /*! 135 Synthesize mouse events to generate mouse wheel motion of \c xDelta 136 and \c yDelta. Deltas are positive for motion away from the user or 137 to the right and negative for motion towards the user or to the left. 138 Each wheel click should generate a delta of +/-120. 139 */ 140 virtual void mouseWheel(SInt32 xDelta, SInt32 yDelta) = 0; 141 142 //! Notify of screen saver change 143 virtual void screensaver(bool activate) = 0; 144 145 //! Notify of options changes 146 /*! 147 Reset all options to their default values. 148 */ 149 virtual void resetOptions() = 0; 150 151 //! Notify of options changes 152 /*! 153 Set options to given values. Ignore unknown options and don't 154 modify our options that aren't given in \c options. 155 */ 156 virtual void setOptions(const OptionsList& options) = 0; 157 158 //@} 159 //! @name accessors 160 //@{ 161 162 //! Get client name 163 /*! 164 Return the client's name. 165 */ 166 virtual String getName() const = 0; 167 168 //@} 169 170 // IScreen overrides 171 virtual void* getEventTarget() const = 0; 172 virtual bool getClipboard(ClipboardID id, IClipboard*) const = 0; 173 virtual void getShape(SInt32& x, SInt32& y, 174 SInt32& width, SInt32& height) const = 0; 175 virtual void getCursorPos(SInt32& x, SInt32& y) const = 0; 176 }; 177