Changeset 2771 for trunk/synergy/lib/platform/CPMScreen.h
- Timestamp:
- Aug 20, 2006, 8:17:41 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/synergy/lib/platform/CPMScreen.h
r2763 r2771 37 37 class CPMScreen : public CPlatformScreen { 38 38 public: 39 40 41 42 43 virtual void*getEventTarget() const;44 virtual boolgetClipboard(ClipboardID id, IClipboard*) const;45 virtual voidgetShape(SInt32& x, SInt32& y, SInt32& cx, SInt32& cy) const;46 virtual voidgetCursorPos(SInt32& x, SInt32& y) const;47 48 49 virtual voidreconfigure(UInt32 activeSides);50 virtual voidwarpCursor(SInt32 x, SInt32 y);51 virtual UInt32registerHotKey(KeyID key,52 53 virtual voidunregisterHotKey(UInt32 id);54 virtual voidfakeInputBegin();55 virtual voidfakeInputEnd();56 virtual SInt32getJumpZoneSize() const;57 virtual boolisAnyMouseButtonDown() const;58 virtual voidgetCursorCenter(SInt32& x, SInt32& y) const;59 60 61 virtual voidfakeMouseButton(ButtonID id, bool press) const;62 virtual voidfakeMouseMove(SInt32 x, SInt32 y) const;63 virtual voidfakeMouseRelativeMove(SInt32 dx, SInt32 dy) const;64 virtual voidfakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const;65 66 67 virtual voidupdateKeys();68 virtual voidfakeKeyDown(KeyID id, KeyModifierMask mask,69 70 virtual voidfakeKeyRepeat(KeyID id, KeyModifierMask mask,71 72 virtual voidfakeKeyUp(KeyButton button);73 virtual voidfakeAllKeysUp();74 75 76 virtual voidenable();77 virtual voiddisable();78 virtual voidenter();79 virtual boolleave();80 virtual boolsetClipboard(ClipboardID, const IClipboard*);81 virtual voidcheckClipboards();82 virtual voidopenScreensaver(bool notify);83 virtual voidcloseScreensaver();84 virtual voidscreensaver(bool activate);85 virtual voidresetOptions();86 virtual voidsetOptions(const COptionsList& options);87 virtual voidsetSequenceNumber(UInt32);88 virtual boolisPrimary() const;39 CPMScreen(bool isPrimary); 40 virtual ~CPMScreen(); 41 42 // IScreen overrides 43 virtual void* getEventTarget() const; 44 virtual bool getClipboard(ClipboardID id, IClipboard*) const; 45 virtual void getShape(SInt32& x, SInt32& y, SInt32& cx, SInt32& cy) const; 46 virtual void getCursorPos(SInt32& x, SInt32& y) const; 47 48 // IPrimaryScreen overrides 49 virtual void reconfigure(UInt32 activeSides); 50 virtual void warpCursor(SInt32 x, SInt32 y); 51 virtual UInt32 registerHotKey(KeyID key, 52 KeyModifierMask mask); 53 virtual void unregisterHotKey(UInt32 id); 54 virtual void fakeInputBegin(); 55 virtual void fakeInputEnd(); 56 virtual SInt32 getJumpZoneSize() const; 57 virtual bool isAnyMouseButtonDown() const; 58 virtual void getCursorCenter(SInt32& x, SInt32& y) const; 59 60 // ISecondaryScreen overrides 61 virtual void fakeMouseButton(ButtonID id, bool press) const; 62 virtual void fakeMouseMove(SInt32 x, SInt32 y) const; 63 virtual void fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const; 64 virtual void fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const; 65 66 // IKeyState overrides 67 virtual void updateKeys(); 68 virtual void fakeKeyDown(KeyID id, KeyModifierMask mask, 69 KeyButton button); 70 virtual void fakeKeyRepeat(KeyID id, KeyModifierMask mask, 71 SInt32 count, KeyButton button); 72 virtual void fakeKeyUp(KeyButton button); 73 virtual void fakeAllKeysUp(); 74 75 // IPlatformScreen overrides 76 virtual void enable(); 77 virtual void disable(); 78 virtual void enter(); 79 virtual bool leave(); 80 virtual bool setClipboard(ClipboardID, const IClipboard*); 81 virtual void checkClipboards(); 82 virtual void openScreensaver(bool notify); 83 virtual void closeScreensaver(); 84 virtual void screensaver(bool activate); 85 virtual void resetOptions(); 86 virtual void setOptions(const COptionsList& options); 87 virtual void setSequenceNumber(UInt32); 88 virtual bool isPrimary() const; 89 89 90 90 protected: 91 92 virtual voidhandleSystemEvent(const CEvent&, void*);93 virtual voidupdateButtons();94 virtual IKeyState*getKeyState() const;91 // IPlatformScreen overrides 92 virtual void handleSystemEvent(const CEvent&, void*); 93 virtual void updateButtons(); 94 virtual IKeyState* getKeyState() const; 95 95 96 96 private: 97 98 HMODULEopenHookLibrary(const char* name);99 voidcloseHookLibrary(HMODULE hookLibrary) const;100 HWNDcreateWindow(const char* name);101 voiddestroyWindow(HWND) const;102 97 // initialization and shutdown operations 98 HMODULE openHookLibrary(const char* name); 99 void closeHookLibrary(HMODULE hookLibrary) const; 100 HWND createWindow(const char* name); 101 void destroyWindow(HWND) const; 102 103 103 // fake message injection 104 104 void fakeMessage(ULONG msg, MPARAM mp1, MPARAM mp2) const; 105 105 void fakeMouseMessage(ULONG msg, MPARAM mp1) const; 106 106 107 108 voidsendEvent(CEvent::Type type, void* = NULL);109 voidsendClipboardEvent(CEvent::Type type, ClipboardID id);110 111 112 113 boolonPreDispatch(HWND, ULONG, MPARAM, MPARAM);114 115 116 117 boolonPreDispatchPrimary(HWND, ULONG, MPARAM, MPARAM);118 119 120 121 boolonEvent(HWND, ULONG, MPARAM, MPARAM, MRESULT*);122 123 124 boolonMark(UInt32 mark);125 boolonKey(USHORT fsFlags, UCHAR ucRepeat, UCHAR ucScanCode, USHORT usch, USHORT usvk);126 boolonHotKey(MPARAM, MPARAM);127 boolonMouseButton(ULONG msg, SInt32 ax, SInt32 ay);128 boolonMouseMove(ULONG msg, SInt32 ax, SInt32 ay);129 boolonClipboardChange();130 131 132 voidwarpCursorNoFlush(SInt32 x, SInt32 y);133 134 135 voidnextMark();136 137 138 boolignore() const;139 140 141 voidupdateScreenShape();142 143 144 voidhandleFixes(const CEvent&, void*);145 146 147 voidenableSpecialKeys(bool) const;148 149 150 ButtonIDmapButtonFromEvent(ULONG msg) const;151 152 153 boolmapPressFromEvent(ULONG msg) const;154 155 156 voidupdateKeysCB(void*);157 158 159 160 voidforceShowCursor();161 162 163 164 165 166 voidupdateForceShowCursor();167 168 169 107 // convenience function to send events 108 void sendEvent(CEvent::Type type, void* = NULL); 109 void sendClipboardEvent(CEvent::Type type, ClipboardID id); 110 111 // handle message before it gets dispatched. returns true iff 112 // the message should not be dispatched. 113 bool onPreDispatch(HWND, ULONG, MPARAM, MPARAM); 114 115 // handle message before it gets dispatched. returns true iff 116 // the message should not be dispatched. 117 bool onPreDispatchPrimary(HWND, ULONG, MPARAM, MPARAM); 118 119 // handle message. returns true iff handled and optionally sets 120 // \c *result (which defaults to 0). 121 bool onEvent(HWND, ULONG, MPARAM, MPARAM, MRESULT*); 122 123 // message handlers 124 bool onMark(UInt32 mark); 125 bool onKey(USHORT fsFlags, UCHAR ucRepeat, UCHAR ucScanCode, USHORT usch, USHORT usvk); 126 bool onHotKey(MPARAM, MPARAM); 127 bool onMouseButton(ULONG msg, SInt32 ax, SInt32 ay); 128 bool onMouseMove(ULONG msg, SInt32 ax, SInt32 ay); 129 bool onClipboardChange(); 130 131 // warp cursor without discarding queued events 132 void warpCursorNoFlush(SInt32 x, SInt32 y); 133 134 // discard posted messages 135 void nextMark(); 136 137 // test if event should be ignored 138 bool ignore() const; 139 140 // update screen size cache 141 void updateScreenShape(); 142 143 // fix timer callback 144 void handleFixes(const CEvent&, void*); 145 146 // enable/disable special key combinations so we can catch/pass them 147 void enableSpecialKeys(bool) const; 148 149 // map a button event to a button ID 150 ButtonID mapButtonFromEvent(ULONG msg) const; 151 152 // map a button event to a press (true) or release (false) 153 bool mapPressFromEvent(ULONG msg) const; 154 155 // job to update the key state 156 void updateKeysCB(void*); 157 158 // determine whether the mouse is hidden by the system and force 159 // it to be displayed if user has entered this secondary screen. 160 void forceShowCursor(); 161 162 // forceShowCursor uses MouseKeys to show the cursor. since we 163 // don't actually want MouseKeys behavior we have to make sure 164 // it applies when NumLock is in whatever state it's not in now. 165 // this method does that. 166 void updateForceShowCursor(); 167 168 // our window proc 169 static MRESULT EXPENTRY wndProc(HWND, ULONG, MPARAM, MPARAM); 170 170 171 171 private: 172 173 174 175 176 ULONGgetVirtualKey() const;177 178 booloperator<(const CHotKeyItem&) const;179 180 181 ULONGm_keycode;182 ULONGm_mask;183 184 185 186 187 188 189 boolm_isPrimary;190 boolm_isOnScreen;191 192 193 SInt32m_x, m_y;194 SInt32m_cx, m_cy;195 SInt32m_xCenter, m_yCenter;196 197 198 boolm_multimon;199 200 201 SInt32m_xCursor, m_yCursor;202 203 204 UInt32m_sequenceNumber;205 206 207 UInt32m_mark;208 UInt32m_markReceived;209 210 211 intm_threadID;212 HABm_hab;213 214 215 216 CPMScreenSaver*m_screensaver;217 boolm_screensaverNotify;218 boolm_screensaverActive;219 220 221 222 HWNDm_window;223 HWNDm_nextClipboardWindow;224 boolm_ownClipboard;225 226 227 HMODULEm_hmodHook;228 InitFuncm_init;229 CleanupFuncm_cleanup;230 SetSidesFuncm_setSides;231 SetZoneFuncm_setZone;232 SetModeFuncm_setMode;233 FakeMsgFuncm_fakeMsg;234 235 236 CPMKeyState*m_keyState;237 238 239 HotKeyMapm_hotKeys;240 HotKeyIDListm_oldHotKeyIDs;241 HotKeyToIDMapm_hotKeyToIDMap;242 243 244 boolm_buttons[1 + kButtonExtra0 + 1];245 246 boolm_hasMouse;247 boolm_showingMouse;248 249 static CPMScreen*s_screen;172 struct CHotKeyItem { 173 public: 174 CHotKeyItem(ULONG vk, ULONG modifiers); 175 176 ULONG getVirtualKey() const; 177 178 bool operator<(const CHotKeyItem&) const; 179 180 private: 181 ULONG m_keycode; 182 ULONG m_mask; 183 }; 184 typedef std::map<UInt32, CHotKeyItem> HotKeyMap; 185 typedef std::vector<UInt32> HotKeyIDList; 186 typedef std::map<CHotKeyItem, UInt32> HotKeyToIDMap; 187 188 // true if screen is being used as a primary screen, false otherwise 189 bool m_isPrimary; 190 bool m_isOnScreen; 191 192 // screen shape stuff 193 SInt32 m_x, m_y; 194 SInt32 m_cx, m_cy; 195 SInt32 m_xCenter, m_yCenter; 196 197 // true if system appears to have multiple monitors 198 bool m_multimon; 199 200 // last mouse position 201 SInt32 m_xCursor, m_yCursor; 202 203 // last clipboard 204 UInt32 m_sequenceNumber; 205 206 // used to discard queued messages that are no longer needed 207 UInt32 m_mark; 208 UInt32 m_markReceived; 209 210 // the main loop's thread id, anchor block and message queue. 211 int m_threadID; 212 HAB m_hab; 213 HMQ m_hmq; 214 215 // screen saver stuff 216 CPMScreenSaver* m_screensaver; 217 bool m_screensaverNotify; 218 bool m_screensaverActive; 219 220 // clipboard stuff. our window is used mainly as a clipboard 221 // owner and as a link in the clipboard viewer chain. 222 HWND m_window; 223 HWND m_nextClipboardWindow; 224 bool m_ownClipboard; 225 226 // hook library stuff 227 HMODULE m_hmodHook; 228 InitFunc m_init; 229 CleanupFunc m_cleanup; 230 SetSidesFunc m_setSides; 231 SetZoneFunc m_setZone; 232 SetModeFunc m_setMode; 233 FakeMsgFunc m_fakeMsg; 234 235 // keyboard stuff 236 CPMKeyState* m_keyState; 237 238 // hot key stuff 239 HotKeyMap m_hotKeys; 240 HotKeyIDList m_oldHotKeyIDs; 241 HotKeyToIDMap m_hotKeyToIDMap; 242 243 // map of button state 244 bool m_buttons[1 + kButtonExtra0 + 1]; 245 246 bool m_hasMouse; 247 bool m_showingMouse; 248 249 static CPMScreen* s_screen; 250 250 }; 251 251 … … 256 256 * c-basic-offset: 4 257 257 * tab-width: 4 258 * indent-tabs-mode: t258 * indent-tabs-mode: s 259 259 * End: 260 260 */
Note:
See TracChangeset
for help on using the changeset viewer.