mirror of
https://github.com/debauchee/barrier.git
synced 2026-11-25 05:12:16 +08:00
Added switch delay and double-tap options to win32 and added a
tray icon to the client and server that gives status feedback to the user and allows the user to kill the app.
This commit is contained in:
@@ -112,6 +112,12 @@ CMSWindowsPrimaryScreen::setOptions(const COptionsList& /*options*/)
|
||||
// no options
|
||||
}
|
||||
|
||||
UInt32
|
||||
CMSWindowsPrimaryScreen::addOneShotTimer(double timeout)
|
||||
{
|
||||
return m_screen->addOneShotTimer(timeout);
|
||||
}
|
||||
|
||||
KeyModifierMask
|
||||
CMSWindowsPrimaryScreen::getToggleMask() const
|
||||
{
|
||||
@@ -376,6 +382,12 @@ CMSWindowsPrimaryScreen::onEvent(CEvent* event)
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsPrimaryScreen::onOneShotTimerExpired(UInt32 id)
|
||||
{
|
||||
m_receiver->onOneShotTimerExpired(id);
|
||||
}
|
||||
|
||||
SInt32
|
||||
CMSWindowsPrimaryScreen::getJumpZoneSize() const
|
||||
{
|
||||
|
||||
@@ -39,6 +39,7 @@ public:
|
||||
virtual void warpCursor(SInt32 x, SInt32 y);
|
||||
virtual void resetOptions();
|
||||
virtual void setOptions(const COptionsList& options);
|
||||
virtual UInt32 addOneShotTimer(double timeout);
|
||||
virtual KeyModifierMask getToggleMask() const;
|
||||
virtual bool isLockedToScreen() const;
|
||||
virtual IScreen* getScreen() const;
|
||||
@@ -47,6 +48,7 @@ public:
|
||||
virtual void onScreensaver(bool activated);
|
||||
virtual bool onPreDispatch(const CEvent* event);
|
||||
virtual bool onEvent(CEvent* event);
|
||||
virtual void onOneShotTimerExpired(UInt32 id);
|
||||
virtual SInt32 getJumpZoneSize() const;
|
||||
virtual void postCreateWindow(HWND);
|
||||
virtual void preDestroyWindow(HWND);
|
||||
|
||||
@@ -122,6 +122,11 @@ CMSWindowsScreen::closeDesktop()
|
||||
// remove timer
|
||||
if (m_timer != 0) {
|
||||
KillTimer(NULL, m_timer);
|
||||
m_timer = 0;
|
||||
}
|
||||
if (m_oneShotTimer != 0) {
|
||||
KillTimer(NULL, m_oneShotTimer);
|
||||
m_oneShotTimer = 0;
|
||||
}
|
||||
|
||||
// disconnect from desktop
|
||||
@@ -134,6 +139,18 @@ CMSWindowsScreen::closeDesktop()
|
||||
assert(m_desk == NULL);
|
||||
}
|
||||
|
||||
UInt32
|
||||
CMSWindowsScreen::addOneShotTimer(double timeout)
|
||||
{
|
||||
// FIXME -- support multiple one-shot timers
|
||||
if (m_oneShotTimer != 0) {
|
||||
KillTimer(NULL, m_oneShotTimer);
|
||||
}
|
||||
m_oneShotTimer = SetTimer(NULL, 0,
|
||||
static_cast<UINT>(1000.0 * timeout), NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
CMSWindowsScreen::isMultimon() const
|
||||
{
|
||||
@@ -205,8 +222,12 @@ CMSWindowsScreen::mainLoop()
|
||||
event.m_result = 0;
|
||||
for (;;) {
|
||||
// wait for an event in a cancellable way
|
||||
CThread::waitForEvent();
|
||||
GetMessage(&event.m_msg, NULL, 0, 0);
|
||||
if (CThread::getCurrentThread().waitForEvent(-1.0) != CThread::kEvent) {
|
||||
continue;
|
||||
}
|
||||
if (!PeekMessage(&event.m_msg, NULL, 0, 0, PM_REMOVE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// handle quit message
|
||||
if (event.m_msg.message == WM_QUIT) {
|
||||
@@ -467,27 +488,35 @@ CMSWindowsScreen::onPreDispatch(const CEvent* event)
|
||||
}
|
||||
|
||||
case WM_TIMER:
|
||||
// if current desktop is not the input desktop then switch to it.
|
||||
// windows 95 doesn't support multiple desktops so don't bother
|
||||
// to check under it.
|
||||
if (!m_is95Family) {
|
||||
HDESK desk = openInputDesktop();
|
||||
if (desk != NULL) {
|
||||
if (isCurrentDesktop(desk)) {
|
||||
CloseDesktop(desk);
|
||||
}
|
||||
else if (!m_screensaver->isActive()) {
|
||||
// don't switch desktops when the screensaver is
|
||||
// active. we'd most likely switch to the
|
||||
// screensaver desktop which would have the side
|
||||
// effect of forcing the screensaver to stop.
|
||||
switchDesktop(desk);
|
||||
}
|
||||
else {
|
||||
CloseDesktop(desk);
|
||||
if (msg->wParam == m_timer) {
|
||||
// if current desktop is not the input desktop then switch to it.
|
||||
// windows 95 doesn't support multiple desktops so don't bother
|
||||
// to check under it.
|
||||
if (!m_is95Family) {
|
||||
HDESK desk = openInputDesktop();
|
||||
if (desk != NULL) {
|
||||
if (isCurrentDesktop(desk)) {
|
||||
CloseDesktop(desk);
|
||||
}
|
||||
else if (!m_screensaver->isActive()) {
|
||||
// don't switch desktops when the screensaver is
|
||||
// active. we'd most likely switch to the
|
||||
// screensaver desktop which would have the side
|
||||
// effect of forcing the screensaver to stop.
|
||||
switchDesktop(desk);
|
||||
}
|
||||
else {
|
||||
CloseDesktop(desk);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (msg->wParam == m_oneShotTimer) {
|
||||
// one shot timer expired
|
||||
KillTimer(NULL, m_oneShotTimer);
|
||||
m_oneShotTimer = 0;
|
||||
m_eventHandler->onOneShotTimerExpired(0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,6 +64,14 @@ public:
|
||||
*/
|
||||
void closeDesktop();
|
||||
|
||||
//! Install a one-shot timer
|
||||
/*!
|
||||
Installs a one-shot timer for \c timeout seconds and returns the
|
||||
id of the timer (which will be passed to the receiver's
|
||||
\c onTimerExpired()).
|
||||
*/
|
||||
UInt32 addOneShotTimer(double timeout);
|
||||
|
||||
//@}
|
||||
//! @name accessors
|
||||
//@{
|
||||
@@ -169,6 +177,9 @@ private:
|
||||
// the timer used to check for desktop switching
|
||||
UINT m_timer;
|
||||
|
||||
// the one shot timer
|
||||
UINT m_oneShotTimer;
|
||||
|
||||
// the current desk and it's name
|
||||
HDESK m_desk;
|
||||
CString m_deskName;
|
||||
|
||||
@@ -262,6 +262,12 @@ CMSWindowsSecondaryScreen::onEvent(CEvent* event)
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
CMSWindowsSecondaryScreen::onOneShotTimerExpired(UInt32)
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
SInt32
|
||||
CMSWindowsSecondaryScreen::getJumpZoneSize() const
|
||||
{
|
||||
@@ -272,6 +278,11 @@ void
|
||||
CMSWindowsSecondaryScreen::postCreateWindow(HWND window)
|
||||
{
|
||||
m_window = window;
|
||||
|
||||
// update key state
|
||||
updateKeys();
|
||||
|
||||
// hide cursor if this screen isn't active
|
||||
if (!isActive()) {
|
||||
showWindow();
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ public:
|
||||
virtual void onScreensaver(bool activated);
|
||||
virtual bool onPreDispatch(const CEvent* event);
|
||||
virtual bool onEvent(CEvent* event);
|
||||
virtual void onOneShotTimerExpired(UInt32 id);
|
||||
virtual SInt32 getJumpZoneSize() const;
|
||||
virtual void postCreateWindow(HWND);
|
||||
virtual void preDestroyWindow(HWND);
|
||||
@@ -69,6 +70,7 @@ protected:
|
||||
virtual void hideWindow();
|
||||
virtual void warpCursor(SInt32 x, SInt32 y);
|
||||
virtual void updateKeys();
|
||||
virtual void releaseKeys();
|
||||
virtual void setToggleState(KeyModifierMask);
|
||||
virtual KeyModifierMask getToggleState() const;
|
||||
|
||||
@@ -98,7 +100,6 @@ private:
|
||||
KeyModifierMask, EKeyAction) const;
|
||||
void doKeystrokes(const Keystrokes&, SInt32 count);
|
||||
|
||||
void releaseKeys();
|
||||
void toggleKey(UINT virtualKey, KeyModifierMask mask);
|
||||
UINT virtualKeyToScanCode(UINT& virtualKey) const;
|
||||
bool isExtendedKey(UINT virtualKey) const;
|
||||
|
||||
@@ -260,6 +260,12 @@ mouseHook(int code, WPARAM wParam, LPARAM lParam)
|
||||
PostThreadMessage(g_threadID, SYNERGY_MSG_MOUSE_MOVE, x, y);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
x += g_xScreen;
|
||||
y += g_yScreen;
|
||||
PostThreadMessage(g_threadID, SYNERGY_MSG_MOUSE_MOVE, x, y);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -356,7 +356,7 @@ CXWindowsSecondaryScreen::destroyWindow()
|
||||
CDisplayLock display(m_screen);
|
||||
if (display != NULL) {
|
||||
// release keys that are still pressed
|
||||
releaseKeys(display);
|
||||
doReleaseKeys(display);
|
||||
|
||||
// no longer impervious to server grabs
|
||||
XTestGrabControl(display, False);
|
||||
@@ -901,7 +901,7 @@ CXWindowsSecondaryScreen::maskToX(KeyModifierMask inMask) const
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::releaseKeys(Display* display)
|
||||
CXWindowsSecondaryScreen::doReleaseKeys(Display* display)
|
||||
{
|
||||
assert(display != NULL);
|
||||
|
||||
@@ -969,6 +969,15 @@ CXWindowsSecondaryScreen::updateKeys()
|
||||
updateModifiers(display);
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::releaseKeys()
|
||||
{
|
||||
CDisplayLock display(m_screen);
|
||||
if (display != NULL) {
|
||||
doReleaseKeys(display);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsSecondaryScreen::updateModifiers(Display* display)
|
||||
{
|
||||
|
||||
@@ -67,6 +67,7 @@ protected:
|
||||
virtual void hideWindow();
|
||||
virtual void warpCursor(SInt32 x, SInt32 y);
|
||||
virtual void updateKeys();
|
||||
virtual void releaseKeys();
|
||||
virtual void setToggleState(KeyModifierMask);
|
||||
virtual KeyModifierMask getToggleState() const;
|
||||
|
||||
@@ -97,14 +98,10 @@ private:
|
||||
|
||||
unsigned int mapKey(Keystrokes&, KeyCode&, KeyID,
|
||||
KeyModifierMask, EKeyAction) const;
|
||||
/*
|
||||
bool findKeyCode(KeyCode&, unsigned int&,
|
||||
KeyID id, unsigned int) const;
|
||||
*/
|
||||
void doKeystrokes(const Keystrokes&, SInt32 count);
|
||||
unsigned int maskToX(KeyModifierMask) const;
|
||||
|
||||
void releaseKeys(Display*);
|
||||
void doReleaseKeys(Display*);
|
||||
void updateKeycodeMap(Display* display);
|
||||
void updateModifiers(Display* display);
|
||||
void updateModifierMap(Display* display);
|
||||
|
||||
Reference in New Issue
Block a user