2002-08-02 19:57:46 +00:00
|
|
|
/*
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
|
|
|
* 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 COPYING 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.
|
|
|
|
*/
|
|
|
|
|
2001-11-11 21:15:30 +00:00
|
|
|
#ifndef CXWINDOWSSCREEN_H
|
|
|
|
#define CXWINDOWSSCREEN_H
|
|
|
|
|
2004-03-21 20:01:41 +00:00
|
|
|
#include "CPlatformScreen.h"
|
2004-11-04 21:26:43 +00:00
|
|
|
#include "stdset.h"
|
2002-06-23 15:43:40 +00:00
|
|
|
#include "stdvector.h"
|
2004-10-28 21:40:56 +00:00
|
|
|
#if X_DISPLAY_MISSING
|
2002-06-19 11:23:49 +00:00
|
|
|
# error X11 is required to build synergy
|
|
|
|
#else
|
|
|
|
# include <X11/Xlib.h>
|
|
|
|
#endif
|
2001-11-11 21:15:30 +00:00
|
|
|
|
2002-05-27 16:22:59 +00:00
|
|
|
class CXWindowsClipboard;
|
2004-03-21 20:01:41 +00:00
|
|
|
class CXWindowsKeyState;
|
2002-06-22 19:20:21 +00:00
|
|
|
class CXWindowsScreenSaver;
|
2001-11-11 21:15:30 +00:00
|
|
|
|
2003-09-02 22:05:47 +00:00
|
|
|
//! Implementation of IPlatformScreen for X11
|
2004-03-21 20:01:41 +00:00
|
|
|
class CXWindowsScreen : public CPlatformScreen {
|
2002-04-29 14:40:01 +00:00
|
|
|
public:
|
2004-11-02 20:43:55 +00:00
|
|
|
CXWindowsScreen(const char* displayName, bool isPrimary);
|
2001-11-11 21:15:30 +00:00
|
|
|
virtual ~CXWindowsScreen();
|
|
|
|
|
2002-07-29 17:03:55 +00:00
|
|
|
//! @name manipulators
|
|
|
|
//@{
|
2002-06-23 15:43:40 +00:00
|
|
|
|
2002-07-29 17:03:55 +00:00
|
|
|
//@}
|
|
|
|
|
2004-02-14 14:04:36 +00:00
|
|
|
// IScreen overrides
|
|
|
|
virtual void* getEventTarget() const;
|
|
|
|
virtual bool getClipboard(ClipboardID id, IClipboard*) const;
|
|
|
|
virtual void getShape(SInt32& x, SInt32& y,
|
|
|
|
SInt32& width, SInt32& height) const;
|
|
|
|
virtual void getCursorPos(SInt32& x, SInt32& y) const;
|
2003-09-02 22:05:47 +00:00
|
|
|
|
|
|
|
// IPrimaryScreen overrides
|
|
|
|
virtual void reconfigure(UInt32 activeSides);
|
|
|
|
virtual void warpCursor(SInt32 x, SInt32 y);
|
2007-06-17 11:19:18 +00:00
|
|
|
virtual UInt32 registerHotKey(KeyID key, KeyModifierMask mask);
|
|
|
|
virtual void unregisterHotKey(UInt32 id);
|
|
|
|
virtual void fakeInputBegin();
|
|
|
|
virtual void fakeInputEnd();
|
2003-09-02 22:05:47 +00:00
|
|
|
virtual SInt32 getJumpZoneSize() const;
|
|
|
|
virtual bool isAnyMouseButtonDown() const;
|
2004-02-14 14:04:36 +00:00
|
|
|
virtual void getCursorCenter(SInt32& x, SInt32& y) const;
|
2003-09-02 22:05:47 +00:00
|
|
|
|
|
|
|
// ISecondaryScreen overrides
|
|
|
|
virtual void fakeMouseButton(ButtonID id, bool press) const;
|
|
|
|
virtual void fakeMouseMove(SInt32 x, SInt32 y) const;
|
2004-05-01 15:18:59 +00:00
|
|
|
virtual void fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const;
|
2007-06-17 11:19:18 +00:00
|
|
|
virtual void fakeMouseWheel(SInt32 xDelta, SInt32 yDelta) const;
|
2004-03-21 20:01:41 +00:00
|
|
|
|
|
|
|
// IPlatformScreen overrides
|
|
|
|
virtual void enable();
|
|
|
|
virtual void disable();
|
|
|
|
virtual void enter();
|
|
|
|
virtual bool leave();
|
|
|
|
virtual bool setClipboard(ClipboardID, const IClipboard*);
|
|
|
|
virtual void checkClipboards();
|
|
|
|
virtual void openScreensaver(bool notify);
|
|
|
|
virtual void closeScreensaver();
|
|
|
|
virtual void screensaver(bool activate);
|
|
|
|
virtual void resetOptions();
|
|
|
|
virtual void setOptions(const COptionsList& options);
|
|
|
|
virtual void setSequenceNumber(UInt32);
|
|
|
|
virtual bool isPrimary() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// IPlatformScreen overrides
|
|
|
|
virtual void handleSystemEvent(const CEvent&, void*);
|
|
|
|
virtual void updateButtons();
|
|
|
|
virtual IKeyState* getKeyState() const;
|
2002-07-12 20:41:23 +00:00
|
|
|
|
2002-07-13 22:00:38 +00:00
|
|
|
private:
|
2004-02-14 14:04:36 +00:00
|
|
|
// event sending
|
|
|
|
void sendEvent(CEvent::Type, void* = NULL);
|
|
|
|
void sendClipboardEvent(CEvent::Type, ClipboardID);
|
|
|
|
|
2002-07-11 18:58:49 +00:00
|
|
|
// create the transparent cursor
|
2003-09-02 22:05:47 +00:00
|
|
|
Cursor createBlankCursor() const;
|
2002-07-11 18:58:49 +00:00
|
|
|
|
2002-05-27 16:22:59 +00:00
|
|
|
// determine the clipboard from the X selection. returns
|
|
|
|
// kClipboardEnd if no such clipboard.
|
|
|
|
ClipboardID getClipboardID(Atom selection) const;
|
2002-05-01 15:31:47 +00:00
|
|
|
|
2002-05-27 16:22:59 +00:00
|
|
|
// continue processing a selection request
|
|
|
|
void processClipboardRequest(Window window,
|
2002-06-10 22:06:45 +00:00
|
|
|
Time time, Atom property);
|
2002-05-01 15:31:47 +00:00
|
|
|
|
2002-05-27 16:22:59 +00:00
|
|
|
// terminate a selection request
|
|
|
|
void destroyClipboardRequest(Window window);
|
2002-04-27 14:19:53 +00:00
|
|
|
|
2002-06-03 13:45:30 +00:00
|
|
|
// X I/O error handler
|
2004-02-14 14:04:36 +00:00
|
|
|
void onError();
|
2002-06-03 13:45:30 +00:00
|
|
|
static int ioErrorHandler(Display*);
|
|
|
|
|
2002-05-27 16:22:59 +00:00
|
|
|
private:
|
2004-02-15 17:32:11 +00:00
|
|
|
class CKeyEventFilter {
|
2003-09-02 22:05:47 +00:00
|
|
|
public:
|
|
|
|
int m_event;
|
|
|
|
Window m_window;
|
|
|
|
Time m_time;
|
|
|
|
KeyCode m_keycode;
|
|
|
|
};
|
2002-06-23 15:43:40 +00:00
|
|
|
|
2007-06-17 11:19:18 +00:00
|
|
|
Display* openDisplay(const char* displayName);
|
2004-02-14 14:04:36 +00:00
|
|
|
void saveShape();
|
|
|
|
Window openWindow() const;
|
2003-09-02 22:05:47 +00:00
|
|
|
void openIM();
|
|
|
|
|
|
|
|
bool grabMouseAndKeyboard();
|
|
|
|
void onKeyPress(XKeyEvent&);
|
2004-03-14 17:55:53 +00:00
|
|
|
void onKeyRelease(XKeyEvent&, bool isRepeat);
|
2007-06-17 11:19:18 +00:00
|
|
|
bool onHotKey(XKeyEvent&, bool isRepeat);
|
2003-09-02 22:05:47 +00:00
|
|
|
void onMousePress(const XButtonEvent&);
|
|
|
|
void onMouseRelease(const XButtonEvent&);
|
|
|
|
void onMouseMove(const XMotionEvent&);
|
|
|
|
|
|
|
|
void selectEvents(Window) const;
|
|
|
|
void doSelectEvents(Window) const;
|
2002-07-13 22:00:38 +00:00
|
|
|
|
2003-09-02 22:05:47 +00:00
|
|
|
KeyID mapKeyFromX(XKeyEvent*) const;
|
|
|
|
ButtonID mapButtonFromX(const XButtonEvent*) const;
|
|
|
|
unsigned int mapButtonToX(ButtonID id) const;
|
|
|
|
|
|
|
|
void warpCursorNoFlush(SInt32 x, SInt32 y);
|
|
|
|
|
2007-06-17 11:19:18 +00:00
|
|
|
void refreshKeyboard(XEvent*);
|
|
|
|
|
2003-09-02 22:05:47 +00:00
|
|
|
static Bool findKeyEvent(Display*, XEvent* xevent, XPointer arg);
|
|
|
|
|
|
|
|
private:
|
2007-06-17 11:19:18 +00:00
|
|
|
struct CHotKeyItem {
|
|
|
|
public:
|
|
|
|
CHotKeyItem(int, unsigned int);
|
|
|
|
|
|
|
|
bool operator<(const CHotKeyItem&) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
int m_keycode;
|
|
|
|
unsigned int m_mask;
|
|
|
|
};
|
2004-11-04 21:26:43 +00:00
|
|
|
typedef std::set<bool> CFilteredKeycodes;
|
2007-06-17 11:19:18 +00:00
|
|
|
typedef std::vector<std::pair<int, unsigned int> > HotKeyList;
|
|
|
|
typedef std::map<UInt32, HotKeyList> HotKeyMap;
|
|
|
|
typedef std::vector<UInt32> HotKeyIDList;
|
|
|
|
typedef std::map<CHotKeyItem, UInt32> HotKeyToIDMap;
|
|
|
|
|
2003-09-02 22:05:47 +00:00
|
|
|
// true if screen is being used as a primary screen, false otherwise
|
|
|
|
bool m_isPrimary;
|
|
|
|
|
2001-11-11 21:15:30 +00:00
|
|
|
Display* m_display;
|
|
|
|
Window m_root;
|
2003-09-02 22:05:47 +00:00
|
|
|
Window m_window;
|
2002-07-13 22:00:38 +00:00
|
|
|
|
2003-09-02 22:05:47 +00:00
|
|
|
// true if mouse has entered the screen
|
|
|
|
bool m_isOnScreen;
|
2002-07-13 22:00:38 +00:00
|
|
|
|
2003-09-02 22:05:47 +00:00
|
|
|
// screen shape stuff
|
2002-06-19 17:03:29 +00:00
|
|
|
SInt32 m_x, m_y;
|
2001-11-11 21:15:30 +00:00
|
|
|
SInt32 m_w, m_h;
|
2003-04-14 22:15:56 +00:00
|
|
|
SInt32 m_xCenter, m_yCenter;
|
2001-11-11 21:15:30 +00:00
|
|
|
|
2003-09-02 22:05:47 +00:00
|
|
|
// last mouse position
|
|
|
|
SInt32 m_xCursor, m_yCursor;
|
|
|
|
|
|
|
|
// keyboard stuff
|
2004-03-21 20:01:41 +00:00
|
|
|
CXWindowsKeyState* m_keyState;
|
2003-09-02 22:05:47 +00:00
|
|
|
|
2007-06-17 11:19:18 +00:00
|
|
|
// hot key stuff
|
|
|
|
HotKeyMap m_hotKeys;
|
|
|
|
HotKeyIDList m_oldHotKeyIDs;
|
|
|
|
HotKeyToIDMap m_hotKeyToIDMap;
|
|
|
|
|
2004-05-12 20:28:00 +00:00
|
|
|
// input focus stuff
|
|
|
|
Window m_lastFocus;
|
|
|
|
int m_lastFocusRevert;
|
|
|
|
|
2003-09-02 22:05:47 +00:00
|
|
|
// input method stuff
|
|
|
|
XIM m_im;
|
|
|
|
XIC m_ic;
|
|
|
|
KeyCode m_lastKeycode;
|
2004-11-04 21:26:43 +00:00
|
|
|
CFilteredKeycodes m_filtered;
|
2003-09-02 22:05:47 +00:00
|
|
|
|
2002-05-27 16:22:59 +00:00
|
|
|
// clipboards
|
|
|
|
CXWindowsClipboard* m_clipboard[kClipboardEnd];
|
2004-02-14 14:04:36 +00:00
|
|
|
UInt32 m_sequenceNumber;
|
2002-07-11 18:58:49 +00:00
|
|
|
|
2002-07-13 22:00:38 +00:00
|
|
|
// screen saver stuff
|
|
|
|
CXWindowsScreenSaver* m_screensaver;
|
|
|
|
bool m_screensaverNotify;
|
2002-06-23 15:43:40 +00:00
|
|
|
|
2003-09-02 22:05:47 +00:00
|
|
|
// logical to physical button mapping. m_buttons[i] gives the
|
|
|
|
// physical button for logical button i+1.
|
|
|
|
std::vector<unsigned char> m_buttons;
|
2001-11-11 21:15:30 +00:00
|
|
|
|
2003-09-02 22:05:47 +00:00
|
|
|
// true if global auto-repeat was enabled before we turned it off
|
|
|
|
bool m_autoRepeat;
|
2002-07-13 22:00:38 +00:00
|
|
|
|
2003-09-02 22:05:47 +00:00
|
|
|
// stuff to workaround xtest being xinerama unaware. attempting
|
|
|
|
// to fake a mouse motion under xinerama may behave strangely,
|
|
|
|
// especially if screen 0 is not at 0,0 or if faking a motion on
|
|
|
|
// a screen other than screen 0.
|
|
|
|
bool m_xtestIsXineramaUnaware;
|
|
|
|
bool m_xinerama;
|
2002-07-13 22:00:38 +00:00
|
|
|
|
2007-06-17 11:19:18 +00:00
|
|
|
// XKB extension stuff
|
|
|
|
bool m_xkb;
|
|
|
|
int m_xkbEventBase;
|
|
|
|
|
2003-09-02 22:05:47 +00:00
|
|
|
// pointer to (singleton) screen. this is only needed by
|
|
|
|
// ioErrorHandler().
|
|
|
|
static CXWindowsScreen* s_screen;
|
2002-07-13 22:00:38 +00:00
|
|
|
};
|
|
|
|
|
2001-11-11 21:15:30 +00:00
|
|
|
#endif
|