2002-08-02 23:57:46 +04: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-12 00:15:30 +03:00
|
|
|
#ifndef CXWINDOWSSCREEN_H
|
|
|
|
#define CXWINDOWSSCREEN_H
|
|
|
|
|
2003-09-03 02:05:47 +04:00
|
|
|
#include "IPlatformScreen.h"
|
|
|
|
#include "CXWindowsKeyMapper.h"
|
2002-06-23 19:43:40 +04:00
|
|
|
#include "stdvector.h"
|
2002-06-19 15:23:49 +04:00
|
|
|
#if defined(X_DISPLAY_MISSING)
|
|
|
|
# error X11 is required to build synergy
|
|
|
|
#else
|
|
|
|
# include <X11/Xlib.h>
|
|
|
|
#endif
|
2001-11-12 00:15:30 +03:00
|
|
|
|
2002-05-27 20:22:59 +04:00
|
|
|
class CXWindowsClipboard;
|
2002-06-22 23:20:21 +04:00
|
|
|
class CXWindowsScreenSaver;
|
2001-11-12 00:15:30 +03:00
|
|
|
|
2003-09-03 02:05:47 +04:00
|
|
|
//! Implementation of IPlatformScreen for X11
|
|
|
|
class CXWindowsScreen : public IPlatformScreen {
|
2002-04-29 18:40:01 +04:00
|
|
|
public:
|
2004-02-14 17:04:36 +03:00
|
|
|
CXWindowsScreen(bool isPrimary);
|
2001-11-12 00:15:30 +03:00
|
|
|
virtual ~CXWindowsScreen();
|
|
|
|
|
2002-07-29 21:03:55 +04:00
|
|
|
//! @name manipulators
|
|
|
|
//@{
|
2002-06-23 19:43:40 +04:00
|
|
|
|
2002-07-29 21:03:55 +04:00
|
|
|
//@}
|
|
|
|
|
2003-09-03 02:05:47 +04:00
|
|
|
// IPlatformScreen overrides
|
2004-02-14 17:04:36 +03:00
|
|
|
virtual void setKeyState(IKeyState*);
|
2003-09-03 02:05:47 +04:00
|
|
|
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 updateKeys();
|
2004-02-14 17:04:36 +03:00
|
|
|
virtual void setSequenceNumber(UInt32);
|
2003-09-03 02:05:47 +04:00
|
|
|
virtual bool isPrimary() const;
|
2004-02-14 17:04:36 +03: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-03 02:05:47 +04:00
|
|
|
|
|
|
|
// IPrimaryScreen overrides
|
|
|
|
virtual void reconfigure(UInt32 activeSides);
|
|
|
|
virtual void warpCursor(SInt32 x, SInt32 y);
|
|
|
|
virtual SInt32 getJumpZoneSize() const;
|
|
|
|
virtual bool isAnyMouseButtonDown() const;
|
2004-03-14 20:55:53 +03:00
|
|
|
virtual KeyModifierMask getActiveModifiers() const;
|
2004-02-14 17:04:36 +03:00
|
|
|
virtual void getCursorCenter(SInt32& x, SInt32& y) const;
|
2003-09-03 02:05:47 +04:00
|
|
|
virtual const char* getKeyName(KeyButton) const;
|
|
|
|
|
|
|
|
// ISecondaryScreen overrides
|
|
|
|
virtual void fakeKeyEvent(KeyButton id, bool press) const;
|
|
|
|
virtual bool fakeCtrlAltDel() const;
|
|
|
|
virtual void fakeMouseButton(ButtonID id, bool press) const;
|
|
|
|
virtual void fakeMouseMove(SInt32 x, SInt32 y) const;
|
|
|
|
virtual void fakeMouseWheel(SInt32 delta) const;
|
|
|
|
virtual KeyButton mapKey(IKeyState::Keystrokes&,
|
|
|
|
const IKeyState& keyState, KeyID id,
|
|
|
|
KeyModifierMask desiredMask,
|
|
|
|
bool isAutoRepeat) const;
|
2002-07-13 00:41:23 +04:00
|
|
|
|
2002-07-14 02:00:38 +04:00
|
|
|
private:
|
2004-02-14 17:04:36 +03:00
|
|
|
// event sending
|
|
|
|
void sendEvent(CEvent::Type, void* = NULL);
|
|
|
|
void sendClipboardEvent(CEvent::Type, ClipboardID);
|
|
|
|
|
|
|
|
// event handling
|
|
|
|
void handleSystemEvent(const CEvent&, void*);
|
2002-05-27 20:22:59 +04:00
|
|
|
|
2002-07-11 22:58:49 +04:00
|
|
|
// create the transparent cursor
|
2003-09-03 02:05:47 +04:00
|
|
|
Cursor createBlankCursor() const;
|
2002-07-11 22:58:49 +04:00
|
|
|
|
2002-05-27 20:22:59 +04:00
|
|
|
// determine the clipboard from the X selection. returns
|
|
|
|
// kClipboardEnd if no such clipboard.
|
|
|
|
ClipboardID getClipboardID(Atom selection) const;
|
2002-05-01 19:31:47 +04:00
|
|
|
|
2002-05-27 20:22:59 +04:00
|
|
|
// continue processing a selection request
|
|
|
|
void processClipboardRequest(Window window,
|
2002-06-11 02:06:45 +04:00
|
|
|
Time time, Atom property);
|
2002-05-01 19:31:47 +04:00
|
|
|
|
2002-05-27 20:22:59 +04:00
|
|
|
// terminate a selection request
|
|
|
|
void destroyClipboardRequest(Window window);
|
2002-04-27 18:19:53 +04:00
|
|
|
|
2002-06-03 17:45:30 +04:00
|
|
|
// X I/O error handler
|
2004-02-14 17:04:36 +03:00
|
|
|
void onError();
|
2002-06-03 17:45:30 +04:00
|
|
|
static int ioErrorHandler(Display*);
|
|
|
|
|
2002-05-27 20:22:59 +04:00
|
|
|
private:
|
2004-02-15 20:32:11 +03:00
|
|
|
class CKeyEventFilter {
|
2003-09-03 02:05:47 +04:00
|
|
|
public:
|
|
|
|
int m_event;
|
|
|
|
Window m_window;
|
|
|
|
Time m_time;
|
|
|
|
KeyCode m_keycode;
|
|
|
|
};
|
2002-06-23 19:43:40 +04:00
|
|
|
|
2004-02-14 17:04:36 +03:00
|
|
|
Display* openDisplay() const;
|
|
|
|
void saveShape();
|
|
|
|
Window openWindow() const;
|
2003-09-03 02:05:47 +04:00
|
|
|
void openIM();
|
|
|
|
|
|
|
|
bool grabMouseAndKeyboard();
|
|
|
|
void onKeyPress(XKeyEvent&);
|
2004-03-14 20:55:53 +03:00
|
|
|
void onKeyRelease(XKeyEvent&, bool isRepeat);
|
2003-09-03 02:05:47 +04:00
|
|
|
void onMousePress(const XButtonEvent&);
|
|
|
|
void onMouseRelease(const XButtonEvent&);
|
|
|
|
void onMouseMove(const XMotionEvent&);
|
|
|
|
|
|
|
|
void selectEvents(Window) const;
|
|
|
|
void doSelectEvents(Window) const;
|
2002-07-14 02:00:38 +04:00
|
|
|
|
2003-09-03 02:05:47 +04:00
|
|
|
KeyID mapKeyFromX(XKeyEvent*) const;
|
|
|
|
ButtonID mapButtonFromX(const XButtonEvent*) const;
|
|
|
|
unsigned int mapButtonToX(ButtonID id) const;
|
|
|
|
|
|
|
|
void warpCursorNoFlush(SInt32 x, SInt32 y);
|
|
|
|
|
|
|
|
void updateButtons();
|
|
|
|
|
|
|
|
static Bool findKeyEvent(Display*, XEvent* xevent, XPointer arg);
|
|
|
|
|
|
|
|
private:
|
|
|
|
// true if screen is being used as a primary screen, false otherwise
|
|
|
|
bool m_isPrimary;
|
|
|
|
|
2001-11-12 00:15:30 +03:00
|
|
|
Display* m_display;
|
|
|
|
Window m_root;
|
2003-09-03 02:05:47 +04:00
|
|
|
Window m_window;
|
2002-07-14 02:00:38 +04:00
|
|
|
|
2003-09-03 02:05:47 +04:00
|
|
|
// true if mouse has entered the screen
|
|
|
|
bool m_isOnScreen;
|
2002-07-14 02:00:38 +04:00
|
|
|
|
2003-09-03 02:05:47 +04:00
|
|
|
// screen shape stuff
|
2002-06-19 21:03:29 +04:00
|
|
|
SInt32 m_x, m_y;
|
2001-11-12 00:15:30 +03:00
|
|
|
SInt32 m_w, m_h;
|
2003-04-15 02:15:56 +04:00
|
|
|
SInt32 m_xCenter, m_yCenter;
|
2001-11-12 00:15:30 +03:00
|
|
|
|
2003-09-03 02:05:47 +04:00
|
|
|
// last mouse position
|
|
|
|
SInt32 m_xCursor, m_yCursor;
|
|
|
|
|
|
|
|
// keyboard stuff
|
|
|
|
IKeyState* m_keyState;
|
|
|
|
CXWindowsKeyMapper m_keyMapper;
|
|
|
|
|
|
|
|
// input method stuff
|
|
|
|
XIM m_im;
|
|
|
|
XIC m_ic;
|
|
|
|
KeyCode m_lastKeycode;
|
|
|
|
|
2002-05-27 20:22:59 +04:00
|
|
|
// clipboards
|
|
|
|
CXWindowsClipboard* m_clipboard[kClipboardEnd];
|
2004-02-14 17:04:36 +03:00
|
|
|
UInt32 m_sequenceNumber;
|
2002-07-11 22:58:49 +04:00
|
|
|
|
2002-07-14 02:00:38 +04:00
|
|
|
// screen saver stuff
|
|
|
|
CXWindowsScreenSaver* m_screensaver;
|
|
|
|
bool m_screensaverNotify;
|
2002-06-23 19:43:40 +04:00
|
|
|
|
2003-09-03 02:05:47 +04: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-12 00:15:30 +03:00
|
|
|
|
2003-09-03 02:05:47 +04:00
|
|
|
// true if global auto-repeat was enabled before we turned it off
|
|
|
|
bool m_autoRepeat;
|
2002-07-14 02:00:38 +04:00
|
|
|
|
2003-09-03 02:05:47 +04: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-14 02:00:38 +04:00
|
|
|
|
2003-09-03 02:05:47 +04:00
|
|
|
// pointer to (singleton) screen. this is only needed by
|
|
|
|
// ioErrorHandler().
|
|
|
|
static CXWindowsScreen* s_screen;
|
2002-07-14 02:00:38 +04:00
|
|
|
};
|
|
|
|
|
2001-11-12 00:15:30 +03:00
|
|
|
#endif
|