fix: gate leave() with canLeave(), allowing cleanup
This commit is contained in:
parent
f906ee50c8
commit
835dc4ec25
12 changed files with 49 additions and 20 deletions
|
|
@ -5,6 +5,7 @@ Bug fixes:
|
||||||
- #7522 Fix broken CI caused by renaming project to Deskflow
|
- #7522 Fix broken CI caused by renaming project to Deskflow
|
||||||
- #7524 Restore protocol compatibility with Synergy
|
- #7524 Restore protocol compatibility with Synergy
|
||||||
- #7525 Remove Google Drive upload from CI
|
- #7525 Remove Google Drive upload from CI
|
||||||
|
- #7520 Fix stuck keys on leave by separating check/leave logic
|
||||||
|
|
||||||
Enhancements:
|
Enhancements:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,12 +67,19 @@ public:
|
||||||
|
|
||||||
//! Leave screen
|
//! Leave screen
|
||||||
/*!
|
/*!
|
||||||
Called when the user navigates off the screen. Returns true on
|
Called when the user navigates off the screen. Returns true if
|
||||||
success, false on failure. A typical reason for failure is being
|
the leave can proceed. A typical reason for failure is being
|
||||||
unable to install the keyboard and mouse snoopers on a primary
|
unable to install the keyboard and mouse snoopers on a primary
|
||||||
screen. Secondary screens should not fail.
|
screen. Secondary screens should not fail.
|
||||||
*/
|
*/
|
||||||
virtual bool leave() = 0;
|
virtual bool canLeave() = 0;
|
||||||
|
|
||||||
|
//! Leave screen
|
||||||
|
/*!
|
||||||
|
Called when the user navigates off the screen. Should be gated
|
||||||
|
by canLeave().
|
||||||
|
*/
|
||||||
|
virtual void leave() = 0;
|
||||||
|
|
||||||
//! Set clipboard
|
//! Set clipboard
|
||||||
/*!
|
/*!
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,8 @@ public:
|
||||||
virtual void enable() = 0;
|
virtual void enable() = 0;
|
||||||
virtual void disable() = 0;
|
virtual void disable() = 0;
|
||||||
virtual void enter() = 0;
|
virtual void enter() = 0;
|
||||||
virtual bool leave() = 0;
|
virtual bool canLeave() = 0;
|
||||||
|
virtual void leave() = 0;
|
||||||
virtual bool setClipboard(ClipboardID, const IClipboard *) = 0;
|
virtual bool setClipboard(ClipboardID, const IClipboard *) = 0;
|
||||||
virtual void checkClipboards() = 0;
|
virtual void checkClipboards() = 0;
|
||||||
virtual void openScreensaver(bool notify) = 0;
|
virtual void openScreensaver(bool notify) = 0;
|
||||||
|
|
|
||||||
|
|
@ -137,15 +137,18 @@ bool Screen::leave() {
|
||||||
assert(m_entered == true);
|
assert(m_entered == true);
|
||||||
LOG((CLOG_INFO "leaving screen"));
|
LOG((CLOG_INFO "leaving screen"));
|
||||||
|
|
||||||
if (!m_screen->leave()) {
|
if (!m_screen->canLeave()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_isPrimary) {
|
if (m_isPrimary) {
|
||||||
leavePrimary();
|
leavePrimary();
|
||||||
} else {
|
} else {
|
||||||
leaveSecondary();
|
leaveSecondary();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_screen->leave();
|
||||||
|
|
||||||
// make sure our idea of clipboard ownership is correct
|
// make sure our idea of clipboard ownership is correct
|
||||||
m_screen->checkClipboards();
|
m_screen->checkClipboards();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -345,7 +345,9 @@ void EiScreen::enter() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EiScreen::leave() {
|
bool EiScreen::canLeave() { return true; }
|
||||||
|
|
||||||
|
void EiScreen::leave() {
|
||||||
if (!is_primary_) {
|
if (!is_primary_) {
|
||||||
if (ei_pointer_) {
|
if (ei_pointer_) {
|
||||||
ei_device_stop_emulating(ei_pointer_);
|
ei_device_stop_emulating(ei_pointer_);
|
||||||
|
|
@ -359,7 +361,6 @@ bool EiScreen::leave() {
|
||||||
}
|
}
|
||||||
|
|
||||||
is_on_screen_ = false;
|
is_on_screen_ = false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EiScreen::setClipboard(ClipboardID id, const IClipboard *clipboard) {
|
bool EiScreen::setClipboard(ClipboardID id, const IClipboard *clipboard) {
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,8 @@ public:
|
||||||
void enable() override;
|
void enable() override;
|
||||||
void disable() override;
|
void disable() override;
|
||||||
void enter() override;
|
void enter() override;
|
||||||
bool leave() override;
|
bool canLeave() override;
|
||||||
|
void leave() override;
|
||||||
bool setClipboard(ClipboardID, const IClipboard *) override;
|
bool setClipboard(ClipboardID, const IClipboard *) override;
|
||||||
void checkClipboards() override;
|
void checkClipboards() override;
|
||||||
void openScreensaver(bool notify) override;
|
void openScreensaver(bool notify) override;
|
||||||
|
|
|
||||||
|
|
@ -308,7 +308,7 @@ void MSWindowsScreen::enter() {
|
||||||
forceShowCursor();
|
forceShowCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MSWindowsScreen::leave() {
|
bool MSWindowsScreen::canLeave() {
|
||||||
POINT pos;
|
POINT pos;
|
||||||
if (!getThisCursorPos(&pos)) {
|
if (!getThisCursorPos(&pos)) {
|
||||||
LOG((CLOG_DEBUG "unable to leave screen as windows security has disabled "
|
LOG((CLOG_DEBUG "unable to leave screen as windows security has disabled "
|
||||||
|
|
@ -317,6 +317,11 @@ bool MSWindowsScreen::leave() {
|
||||||
// leaves the screen
|
// leaves the screen
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MSWindowsScreen::leave() {
|
||||||
// get keyboard layout of foreground window. we'll use this
|
// get keyboard layout of foreground window. we'll use this
|
||||||
// keyboard layout for translating keys sent to clients.
|
// keyboard layout for translating keys sent to clients.
|
||||||
m_keyLayout = AppUtilWindows::instance().getCurrentKeyboardLayout();
|
m_keyLayout = AppUtilWindows::instance().getCurrentKeyboardLayout();
|
||||||
|
|
@ -367,8 +372,6 @@ bool MSWindowsScreen::leave() {
|
||||||
m_sendDragThread = new Thread(new TMethodJob<MSWindowsScreen>(
|
m_sendDragThread = new Thread(new TMethodJob<MSWindowsScreen>(
|
||||||
this, &MSWindowsScreen::sendDragThread));
|
this, &MSWindowsScreen::sendDragThread));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MSWindowsScreen::sendDragThread(void *) {
|
void MSWindowsScreen::sendDragThread(void *) {
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,8 @@ public:
|
||||||
virtual void enable();
|
virtual void enable();
|
||||||
virtual void disable();
|
virtual void disable();
|
||||||
virtual void enter();
|
virtual void enter();
|
||||||
virtual bool leave();
|
virtual bool canLeave();
|
||||||
|
virtual void leave();
|
||||||
virtual bool setClipboard(ClipboardID, const IClipboard *);
|
virtual bool setClipboard(ClipboardID, const IClipboard *);
|
||||||
virtual void checkClipboards();
|
virtual void checkClipboards();
|
||||||
virtual void openScreensaver(bool notify);
|
virtual void openScreensaver(bool notify);
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,8 @@ public:
|
||||||
void enable() override;
|
void enable() override;
|
||||||
void disable() override;
|
void disable() override;
|
||||||
void enter() override;
|
void enter() override;
|
||||||
bool leave() override;
|
bool canLeave() override;
|
||||||
|
void leave() override;
|
||||||
bool setClipboard(ClipboardID, const IClipboard *) override;
|
bool setClipboard(ClipboardID, const IClipboard *) override;
|
||||||
void checkClipboards() override;
|
void checkClipboards() override;
|
||||||
void openScreensaver(bool notify) override;
|
void openScreensaver(bool notify) override;
|
||||||
|
|
|
||||||
|
|
@ -883,6 +883,12 @@ OSXScreen::enter()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
OSXScreen::canLeave()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
OSXScreen::leave()
|
OSXScreen::leave()
|
||||||
{
|
{
|
||||||
hideCursor();
|
hideCursor();
|
||||||
|
|
@ -920,8 +926,6 @@ OSXScreen::leave()
|
||||||
|
|
||||||
// now off screen
|
// now off screen
|
||||||
m_isOnScreen = false;
|
m_isOnScreen = false;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
|
|
||||||
|
|
@ -326,7 +326,15 @@ void XWindowsScreen::enter() {
|
||||||
m_isOnScreen = true;
|
m_isOnScreen = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XWindowsScreen::leave() {
|
bool XWindowsScreen::canLeave() {
|
||||||
|
// raise and show the window, required to grab mouse and keyboard
|
||||||
|
XMapRaised(m_display, m_window);
|
||||||
|
|
||||||
|
// see if grabbing the mouse and keyboard, if primary, is possible
|
||||||
|
return !(m_isPrimary && !grabMouseAndKeyboard());
|
||||||
|
}
|
||||||
|
|
||||||
|
void XWindowsScreen::leave() {
|
||||||
if (!m_isPrimary) {
|
if (!m_isPrimary) {
|
||||||
// restore the previous keyboard auto-repeat state. if the user
|
// restore the previous keyboard auto-repeat state. if the user
|
||||||
// changed the auto-repeat configuration while on the client then
|
// changed the auto-repeat configuration while on the client then
|
||||||
|
|
@ -347,7 +355,6 @@ bool XWindowsScreen::leave() {
|
||||||
// grab the mouse and keyboard, if primary and possible
|
// grab the mouse and keyboard, if primary and possible
|
||||||
if (m_isPrimary && !grabMouseAndKeyboard()) {
|
if (m_isPrimary && !grabMouseAndKeyboard()) {
|
||||||
XUnmapWindow(m_display, m_window);
|
XUnmapWindow(m_display, m_window);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// save current focus
|
// save current focus
|
||||||
|
|
@ -376,8 +383,6 @@ bool XWindowsScreen::leave() {
|
||||||
|
|
||||||
// now off screen
|
// now off screen
|
||||||
m_isOnScreen = false;
|
m_isOnScreen = false;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XWindowsScreen::setClipboard(ClipboardID id, const IClipboard *clipboard) {
|
bool XWindowsScreen::setClipboard(ClipboardID id, const IClipboard *clipboard) {
|
||||||
|
|
|
||||||
|
|
@ -79,7 +79,8 @@ public:
|
||||||
void enable() override;
|
void enable() override;
|
||||||
void disable() override;
|
void disable() override;
|
||||||
void enter() override;
|
void enter() override;
|
||||||
bool leave() override;
|
bool canLeave() override;
|
||||||
|
void leave() override;
|
||||||
bool setClipboard(ClipboardID, const IClipboard *) override;
|
bool setClipboard(ClipboardID, const IClipboard *) override;
|
||||||
void checkClipboards() override;
|
void checkClipboards() override;
|
||||||
void openScreensaver(bool notify) override;
|
void openScreensaver(bool notify) override;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue