Improved handling of active window on win32. Synergy no longer
takes activation so the previously active window doesn't pop to the top of the window stack when it regains activation. One drawback of this is that the mouse cursor isn't shown when a window (other than synergy's) is activated. However, synergy does detect mouse motion as before and shows the cursor when it sees any.
This commit is contained in:
parent
83713c6235
commit
03dc45972b
|
@ -1685,25 +1685,22 @@ LRESULT CALLBACK
|
||||||
CMSWindowsScreen::secondaryDeskProc(
|
CMSWindowsScreen::secondaryDeskProc(
|
||||||
HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
|
// would like to detect any local user input and hide the hider
|
||||||
|
// window but for now we just detect mouse motion.
|
||||||
|
bool hide = false;
|
||||||
switch (msg) {
|
switch (msg) {
|
||||||
case WM_MOUSEMOVE:
|
case WM_MOUSEMOVE:
|
||||||
// hide window
|
if (LOWORD(lParam) != 0 || HIWORD(lParam) != 0) {
|
||||||
ShowWindow(hwnd, SW_HIDE);
|
hide = true;
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_ACTIVATE:
|
|
||||||
// hide window
|
|
||||||
if (LOWORD(wParam) == WA_INACTIVE) {
|
|
||||||
ShowWindow(hwnd, SW_HIDE);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_ACTIVATEAPP:
|
|
||||||
// hide window
|
|
||||||
if (!(BOOL)wParam) {
|
|
||||||
ShowWindow(hwnd, SW_HIDE);
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
if (hide && IsWindowVisible(hwnd)) {
|
||||||
|
ReleaseCapture();
|
||||||
|
SetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0,
|
||||||
|
SWP_NOMOVE | SWP_NOSIZE |
|
||||||
|
SWP_NOACTIVATE | SWP_HIDEWINDOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProc(hwnd, msg, wParam, lParam);
|
return DefWindowProc(hwnd, msg, wParam, lParam);
|
||||||
|
@ -1789,15 +1786,19 @@ CMSWindowsScreen::deskMouseMove(SInt32 x, SInt32 y) const
|
||||||
void
|
void
|
||||||
CMSWindowsScreen::deskEnter(CDesk* desk)
|
CMSWindowsScreen::deskEnter(CDesk* desk)
|
||||||
{
|
{
|
||||||
if (m_isPrimary) {
|
if (!m_isPrimary) {
|
||||||
ShowCursor(TRUE);
|
ReleaseCapture();
|
||||||
}
|
}
|
||||||
ShowWindow(desk->m_window, SW_HIDE);
|
ShowCursor(TRUE);
|
||||||
|
SetWindowPos(desk->m_window, HWND_BOTTOM, 0, 0, 0, 0,
|
||||||
|
SWP_NOMOVE | SWP_NOSIZE |
|
||||||
|
SWP_NOACTIVATE | SWP_HIDEWINDOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CMSWindowsScreen::deskLeave(CDesk* desk, HKL keyLayout)
|
CMSWindowsScreen::deskLeave(CDesk* desk, HKL keyLayout)
|
||||||
{
|
{
|
||||||
|
ShowCursor(FALSE);
|
||||||
if (m_isPrimary) {
|
if (m_isPrimary) {
|
||||||
// map a window to hide the cursor and to use whatever keyboard
|
// map a window to hide the cursor and to use whatever keyboard
|
||||||
// layout we choose rather than the keyboard layout of the last
|
// layout we choose rather than the keyboard layout of the last
|
||||||
|
@ -1820,19 +1821,23 @@ CMSWindowsScreen::deskLeave(CDesk* desk, HKL keyLayout)
|
||||||
w = m_w;
|
w = m_w;
|
||||||
h = m_h;
|
h = m_h;
|
||||||
}
|
}
|
||||||
SetWindowPos(desk->m_window, HWND_TOPMOST, x, y, w, h, SWP_NOACTIVATE);
|
SetWindowPos(desk->m_window, HWND_TOPMOST, x, y, w, h,
|
||||||
ShowWindow(desk->m_window, SW_SHOW);
|
SWP_NOACTIVATE | SWP_SHOWWINDOW);
|
||||||
ShowCursor(FALSE);
|
|
||||||
|
|
||||||
// switch to requested keyboard layout
|
// switch to requested keyboard layout
|
||||||
ActivateKeyboardLayout(keyLayout, 0);
|
ActivateKeyboardLayout(keyLayout, 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// move hider window under the cursor center
|
// move hider window under the cursor center, raise, and show it
|
||||||
MoveWindow(desk->m_window, m_xCenter, m_yCenter, 1, 1, FALSE);
|
SetWindowPos(desk->m_window, HWND_TOPMOST,
|
||||||
|
m_xCenter, m_yCenter, 1, 1,
|
||||||
|
SWP_NOACTIVATE | SWP_SHOWWINDOW);
|
||||||
|
|
||||||
// raise and show the hider window
|
// watch for mouse motion. if we see any then we hide the
|
||||||
ShowWindow(desk->m_window, SW_SHOWNA);
|
// hider window so the user can use the physically attached
|
||||||
|
// mouse if desired. we'd rather not capture the mouse but
|
||||||
|
// we aren't notified when the mouse leaves our window.
|
||||||
|
SetCapture(desk->m_window);
|
||||||
|
|
||||||
// warp the mouse to the cursor center
|
// warp the mouse to the cursor center
|
||||||
deskMouseMove(m_xCenter, m_yCenter);
|
deskMouseMove(m_xCenter, m_yCenter);
|
||||||
|
|
Loading…
Reference in New Issue