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
|
|
|
|
|
2004-03-21 23:01:41 +03:00
|
|
|
#include "CPlatformScreen.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;
|
2004-03-21 23:01:41 +03:00
|
|
|
class CXWindowsKeyState;
|
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
|
2004-03-21 23:01:41 +03:00
|
|
|
class CXWindowsScreen : public CPlatformScreen {
|
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
|
|
|
//@}
|
|
|
|
|
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-02-14 17:04:36 +03:00
|
|
|
virtual void getCursorCenter(SInt32& x, SInt32& y) const;
|
2003-09-03 02:05:47 +04:00
|
|
|
|
|
|
|
// ISecondaryScreen overrides
|
|
|
|
virtual void fakeMouseButton(ButtonID id, bool press) const;
|
|
|
|
virtual void fakeMouseMove(SInt32 x, SInt32 y) const;
|
2004-05-01 19:18:59 +04:00
|
|
|
virtual void fakeMouseRelativeMove(SInt32 dx, SInt32 dy) const;
|
2003-09-03 02:05:47 +04:00
|
|
|
virtual void fakeMouseWheel(SInt32 delta) const;
|
2004-03-21 23:01:41 +03: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-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);
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
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
|
2004-03-21 23:01:41 +03:00
|
|
|
CXWindowsKeyState* m_keyState;
|
2003-09-03 02:05:47 +04:00
|
|
|
|
|
|
|
// 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
|