1 /* 2 * barrier -- mouse and keyboard sharing utility 3 * Copyright (C) 2012-2016 Symless Ltd. 4 * Copyright (C) 2003 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 "barrier/key_types.h" 22 #include "barrier/mouse_types.h" 23 #include "base/Event.h" 24 #include "base/EventTypes.h" 25 #include "common/IInterface.h" 26 27 //! Primary screen interface 28 /*! 29 This interface defines the methods common to all platform dependent 30 primary screen implementations. 31 */ 32 class IPrimaryScreen : public IInterface { 33 public: 34 //! Button event data 35 class ButtonInfo { 36 public: 37 static ButtonInfo* alloc(ButtonID, KeyModifierMask); 38 static ButtonInfo* alloc(const ButtonInfo&); 39 40 static bool equal(const ButtonInfo*, const ButtonInfo*); 41 42 public: 43 ButtonID m_button; 44 KeyModifierMask m_mask; 45 }; 46 //! Motion event data 47 class MotionInfo { 48 public: 49 static MotionInfo* alloc(SInt32 x, SInt32 y); 50 51 public: 52 SInt32 m_x; 53 SInt32 m_y; 54 }; 55 //! Wheel motion event data 56 class WheelInfo { 57 public: 58 static WheelInfo* alloc(SInt32 xDelta, SInt32 yDelta); 59 60 public: 61 SInt32 m_xDelta; 62 SInt32 m_yDelta; 63 }; 64 //! Hot key event data 65 class HotKeyInfo { 66 public: 67 static HotKeyInfo* alloc(UInt32 id); 68 69 public: 70 UInt32 m_id; 71 }; 72 73 //! @name manipulators 74 //@{ 75 76 //! Update configuration 77 /*! 78 This is called when the configuration has changed. \c activeSides 79 is a bitmask of EDirectionMask indicating which sides of the 80 primary screen are linked to clients. Override to handle the 81 possible change in jump zones. 82 */ 83 virtual void reconfigure(UInt32 activeSides) = 0; 84 85 //! Warp cursor 86 /*! 87 Warp the cursor to the absolute coordinates \c x,y. Also 88 discard input events up to and including the warp before 89 returning. 90 */ 91 virtual void warpCursor(SInt32 x, SInt32 y) = 0; 92 93 //! Register a system hotkey 94 /*! 95 Registers a system-wide hotkey. The screen should arrange for an event 96 to be delivered to itself when the hot key is pressed or released. When 97 that happens the screen should post a \c getHotKeyDownEvent() or 98 \c getHotKeyUpEvent(), respectively. The hot key is key \p key with 99 exactly the modifiers \p mask. Returns 0 on failure otherwise an id 100 that can be used to unregister the hotkey. 101 102 A hot key is a set of modifiers and a key, which may itself be a modifier. 103 The hot key is pressed when the hot key's modifiers and only those 104 modifiers are logically down (active) and the key is pressed. The hot 105 key is released when the key is released, regardless of the modifiers. 106 107 The hot key event should be generated no matter what window or application 108 has the focus. No other window or application should receive the key 109 press or release events (they can and should see the modifier key events). 110 When the key is a modifier, it's acceptable to allow the user to press 111 the modifiers in any order or to require the user to press the given key 112 last. 113 */ 114 virtual UInt32 registerHotKey(KeyID key, KeyModifierMask mask) = 0; 115 116 //! Unregister a system hotkey 117 /*! 118 Unregisters a previously registered hot key. 119 */ 120 virtual void unregisterHotKey(UInt32 id) = 0; 121 122 //! Prepare to synthesize input on primary screen 123 /*! 124 Prepares the primary screen to receive synthesized input. We do not 125 want to receive this synthesized input as user input so this method 126 ensures that we ignore it. Calls to \c fakeInputBegin() may not be 127 nested. 128 */ 129 virtual void fakeInputBegin() = 0; 130 131 //! Done synthesizing input on primary screen 132 /*! 133 Undoes whatever \c fakeInputBegin() did. 134 */ 135 virtual void fakeInputEnd() = 0; 136 137 //@} 138 //! @name accessors 139 //@{ 140 141 //! Get jump zone size 142 /*! 143 Return the jump zone size, the size of the regions on the edges of 144 the screen that cause the cursor to jump to another screen. 145 */ 146 virtual SInt32 getJumpZoneSize() const = 0; 147 148 //! Test if mouse is pressed 149 /*! 150 Return true if any mouse button is currently pressed. Ideally, 151 "current" means up to the last processed event but it can mean 152 the current physical mouse button state. 153 */ 154 virtual bool isAnyMouseButtonDown(UInt32& buttonID) const = 0; 155 156 //! Get cursor center position 157 /*! 158 Return the cursor center position which is where we park the 159 cursor to compute cursor motion deltas and should be far from 160 the edges of the screen, typically the center. 161 */ 162 virtual void getCursorCenter(SInt32& x, SInt32& y) const = 0; 163 164 //@} 165 }; 166