diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-19 18:39:32 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-19 18:39:32 +0000 |
commit | 9ba7ecff6a57698997034078f958e8c1939d1305 (patch) | |
tree | ddd8135e87ba0cdb47d84e42a98ab144092a59db /ui | |
parent | 02b07597e4f57acdb199fae72a0e776bbc490fb4 (diff) | |
download | chromium_src-9ba7ecff6a57698997034078f958e8c1939d1305.zip chromium_src-9ba7ecff6a57698997034078f958e8c1939d1305.tar.gz chromium_src-9ba7ecff6a57698997034078f958e8c1939d1305.tar.bz2 |
aura: Requery pointer position after host window resize.
This makes us requery the pointer position so we can
constrain the cached position within the host window.
BUG=100087
TEST=none
Review URL: http://codereview.chromium.org/8344032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106337 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/aura/desktop.cc | 2 | ||||
-rw-r--r-- | ui/aura/desktop_host.h | 3 | ||||
-rw-r--r-- | ui/aura/desktop_host_linux.cc | 8 | ||||
-rw-r--r-- | ui/aura/desktop_host_win.cc | 9 |
4 files changed, 18 insertions, 4 deletions
diff --git a/ui/aura/desktop.cc b/ui/aura/desktop.cc index 92ec22d..d48f0d0 100644 --- a/ui/aura/desktop.cc +++ b/ui/aura/desktop.cc @@ -84,6 +84,8 @@ void Desktop::ShowDesktop() { void Desktop::SetHostSize(const gfx::Size& size) { host_->SetSize(size); + // Requery the location to constrain it within the new desktop size. + last_mouse_location_ = host_->QueryMouseLocation(); } gfx::Size Desktop::GetHostSize() const { diff --git a/ui/aura/desktop_host.h b/ui/aura/desktop_host.h index 7752ffb..b8318d2 100644 --- a/ui/aura/desktop_host.h +++ b/ui/aura/desktop_host.h @@ -47,6 +47,9 @@ class DesktopHost : public MessageLoop::Dispatcher { virtual void SetCursor(gfx::NativeCursor cursor) = 0; // Queries the mouse's current position relative to the host window. + // The position is constrained within the host window. + // You should probably call Desktop::last_mouse_location() instead; this + // method can be expensive. virtual gfx::Point QueryMouseLocation() = 0; }; diff --git a/ui/aura/desktop_host_linux.cc b/ui/aura/desktop_host_linux.cc index 57c506e..e09e5fc 100644 --- a/ui/aura/desktop_host_linux.cc +++ b/ui/aura/desktop_host_linux.cc @@ -4,6 +4,7 @@ #include "ui/aura/desktop_host.h" +#include <X11/cursorfont.h> #include <X11/Xlib.h> // Get rid of a macro from Xlib.h that conflicts with Aura's RootWindow class. @@ -19,8 +20,8 @@ #include "ui/base/touch/touch_factory.h" #include "ui/base/x/x11_util.h" -#include <X11/cursorfont.h> -#include <X11/Xlib.h> +using std::max; +using std::min; namespace aura { @@ -315,7 +316,8 @@ gfx::Point DesktopHostLinux::QueryMouseLocation() { &root_x_return, &root_y_return, &win_x_return, &win_y_return, &mask_return); - return gfx::Point(win_x_return, win_y_return); + return gfx::Point(max(0, min(bounds_.width(), win_x_return)), + max(0, min(bounds_.height(), win_y_return))); } } // namespace diff --git a/ui/aura/desktop_host_win.cc b/ui/aura/desktop_host_win.cc index 6d9908c..2a3e64a 100644 --- a/ui/aura/desktop_host_win.cc +++ b/ui/aura/desktop_host_win.cc @@ -6,10 +6,15 @@ #include <windows.h> +#include <algorithm> + #include "base/message_loop.h" #include "ui/aura/desktop.h" #include "ui/aura/event.h" +using std::max; +using std::min; + namespace aura { namespace { @@ -158,7 +163,9 @@ gfx::Point DesktopHostWin::QueryMouseLocation() { POINT pt; GetCursorPos(&pt); ScreenToClient(hwnd(), &pt); - return gfx::Point(pt); + const gfx::Size size = GetSize(); + return gfx::Point(max(0, min(size.width(), static_cast<int>(pt.x))), + max(0, min(size.height(), static_cast<int>(pt.y)))); } void DesktopHostWin::OnClose() { |