app_server: Fixed some send fake mouse event issues.
* Activating a window never send a faked mouse message. This was noticeable when switching windows using the keyboard; if you then scrolled with the mouse wheel you could scroll in the previous window still. * Also, using MouseEventWindow() in _SendFakeMouseMoved() doesn't work when you click the window to send it to behind: it's moved on button press, but the mouse event window is only released on button release, ie. too late. * This is fixed by always using the current window under the mouse as target for the fake event.
This commit is contained in:
+32
-12
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2013, Haiku.
|
* Copyright 2001-2015, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Desktop.h"
|
#include "Desktop.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
@@ -1051,7 +1052,7 @@ Desktop::ActivateWindow(Window* window)
|
|||||||
if (window->Workspaces() == 0 && window->IsNormal())
|
if (window->Workspaces() == 0 && window->IsNormal())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AutoWriteLocker _(fWindowLock);
|
AutoWriteLocker allWindowLocker(fWindowLock);
|
||||||
|
|
||||||
NotifyWindowActivated(window);
|
NotifyWindowActivated(window);
|
||||||
|
|
||||||
@@ -1123,6 +1124,7 @@ Desktop::ActivateWindow(Window* window)
|
|||||||
|
|
||||||
WindowList windows(kWorkingList);
|
WindowList windows(kWorkingList);
|
||||||
Window* frontmost = window->Frontmost();
|
Window* frontmost = window->Frontmost();
|
||||||
|
const Window* lastWindowUnderMouse = fWindowUnderMouse;
|
||||||
|
|
||||||
CurrentWindows().RemoveWindow(window);
|
CurrentWindows().RemoveWindow(window);
|
||||||
windows.AddWindow(window);
|
windows.AddWindow(window);
|
||||||
@@ -1152,6 +1154,13 @@ Desktop::ActivateWindow(Window* window)
|
|||||||
|
|
||||||
if ((window->Flags() & B_AVOID_FOCUS) == 0)
|
if ((window->Flags() & B_AVOID_FOCUS) == 0)
|
||||||
SetFocusWindow(window);
|
SetFocusWindow(window);
|
||||||
|
|
||||||
|
bool sendFakeMouseMoved = _CheckSendFakeMouseMoved(lastWindowUnderMouse);
|
||||||
|
|
||||||
|
allWindowLocker.Unlock();
|
||||||
|
|
||||||
|
if (sendFakeMouseMoved)
|
||||||
|
_SendFakeMouseMoved();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1184,6 +1193,7 @@ Desktop::SendWindowBehind(Window* window, Window* behindOf, bool sendStack)
|
|||||||
BRegion dirty(window->VisibleRegion());
|
BRegion dirty(window->VisibleRegion());
|
||||||
|
|
||||||
Window* backmost = window->Backmost(behindOf);
|
Window* backmost = window->Backmost(behindOf);
|
||||||
|
const Window* lastWindowUnderMouse = fWindowUnderMouse;
|
||||||
|
|
||||||
CurrentWindows().RemoveWindow(window);
|
CurrentWindows().RemoveWindow(window);
|
||||||
CurrentWindows().AddWindow(window, backmost
|
CurrentWindows().AddWindow(window, backmost
|
||||||
@@ -1206,10 +1216,6 @@ Desktop::SendWindowBehind(Window* window, Window* behindOf, bool sendStack)
|
|||||||
else if (fSettings->NormalMouse())
|
else if (fSettings->NormalMouse())
|
||||||
SetFocusWindow(NULL);
|
SetFocusWindow(NULL);
|
||||||
|
|
||||||
bool sendFakeMouseMoved = false;
|
|
||||||
if (FocusWindow() != window)
|
|
||||||
sendFakeMouseMoved = true;
|
|
||||||
|
|
||||||
_WindowChanged(window);
|
_WindowChanged(window);
|
||||||
|
|
||||||
if (sendStack && stack != NULL) {
|
if (sendStack && stack != NULL) {
|
||||||
@@ -1221,6 +1227,7 @@ Desktop::SendWindowBehind(Window* window, Window* behindOf, bool sendStack)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool sendFakeMouseMoved = _CheckSendFakeMouseMoved(lastWindowUnderMouse);
|
||||||
NotifyWindowSentBehind(orgWindow, behindOf);
|
NotifyWindowSentBehind(orgWindow, behindOf);
|
||||||
|
|
||||||
UnlockAllWindows();
|
UnlockAllWindows();
|
||||||
@@ -3058,8 +3065,7 @@ Desktop::_ChangeWindowWorkspaces(Window* window, uint32 oldWorkspaces,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Desktop::_BringWindowsToFront(WindowList& windows, int32 list,
|
Desktop::_BringWindowsToFront(WindowList& windows, int32 list, bool wereVisible)
|
||||||
bool wereVisible)
|
|
||||||
{
|
{
|
||||||
// we don't need to redraw what is currently
|
// we don't need to redraw what is currently
|
||||||
// visible of the window
|
// visible of the window
|
||||||
@@ -3118,11 +3124,27 @@ Desktop::_LastFocusSubsetWindow(Window* window)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! \brief Checks whether or not a fake mouse moved message needs to be sent
|
||||||
|
to the previous mouse window.
|
||||||
|
|
||||||
|
You need to have the all window lock held when calling this method.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
Desktop::_CheckSendFakeMouseMoved(const Window* lastWindowUnderMouse)
|
||||||
|
{
|
||||||
|
Window* window = WindowAt(fLastMousePosition);
|
||||||
|
return window != lastWindowUnderMouse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Sends a fake B_MOUSE_MOVED event to the window under the mouse,
|
/*! \brief Sends a fake B_MOUSE_MOVED event to the window under the mouse,
|
||||||
and also updates the current view under the mouse.
|
and also updates the current view under the mouse.
|
||||||
|
|
||||||
This has only to be done in case the view changed without user interaction,
|
This has only to be done in case the view changed without mouse movement,
|
||||||
ie. because of a workspace change or a closing window.
|
ie. because of a workspace change, a closing window, or programmatic window
|
||||||
|
movement.
|
||||||
|
|
||||||
|
You must not have locked any windows when calling this method.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
Desktop::_SendFakeMouseMoved(Window* window)
|
Desktop::_SendFakeMouseMoved(Window* window)
|
||||||
@@ -3132,8 +3154,6 @@ Desktop::_SendFakeMouseMoved(Window* window)
|
|||||||
|
|
||||||
LockAllWindows();
|
LockAllWindows();
|
||||||
|
|
||||||
if (window == NULL)
|
|
||||||
window = MouseEventWindow();
|
|
||||||
if (window == NULL)
|
if (window == NULL)
|
||||||
window = WindowAt(fLastMousePosition);
|
window = WindowAt(fLastMousePosition);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2013, Haiku.
|
* Copyright 2001-2015, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -283,6 +283,8 @@ private:
|
|||||||
void _BringWindowsToFront(WindowList& windows,
|
void _BringWindowsToFront(WindowList& windows,
|
||||||
int32 list, bool wereVisible);
|
int32 list, bool wereVisible);
|
||||||
Window* _LastFocusSubsetWindow(Window* window);
|
Window* _LastFocusSubsetWindow(Window* window);
|
||||||
|
bool _CheckSendFakeMouseMoved(
|
||||||
|
const Window* lastWindowUnderMouse);
|
||||||
void _SendFakeMouseMoved(Window* window = NULL);
|
void _SendFakeMouseMoved(Window* window = NULL);
|
||||||
|
|
||||||
Screen* _DetermineScreenFor(BRect frame);
|
Screen* _DetermineScreenFor(BRect frame);
|
||||||
|
|||||||
Reference in New Issue
Block a user