diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-01 02:12:12 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-01 02:12:12 +0000 |
commit | 29c6bb325b65ce953ed11cc344455e67be697b84 (patch) | |
tree | d4ac0993b658735b2f31717c133d2349a4215f79 /chrome | |
parent | 654512b4c7e02401af2ce207d678c683841eedb6 (diff) | |
download | chromium_src-29c6bb325b65ce953ed11cc344455e67be697b84.zip chromium_src-29c6bb325b65ce953ed11cc344455e67be697b84.tar.gz chromium_src-29c6bb325b65ce953ed11cc344455e67be697b84.tar.bz2 |
Wait to compute mouse event offset until the info bubble is mapped.
The destination widget's geometry returns -1,-1 when requested
right after it's been created. I guess this is regression by WidgetGtk resize fix, but the old way was probably wrong anyway.
This CL fixes the issue by deferring the offset computation until
widget's location becomes available.
BUG=chromium-os:6250
TEST=manually tested on the device.
Review URL: http://codereview.chromium.org/3258005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58109 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/chromeos/login/screen_locker.cc | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/chrome/browser/chromeos/login/screen_locker.cc b/chrome/browser/chromeos/login/screen_locker.cc index c8f1f06..ef1ac10 100644 --- a/chrome/browser/chromeos/login/screen_locker.cc +++ b/chrome/browser/chromeos/login/screen_locker.cc @@ -342,23 +342,30 @@ ScreenLocker* ScreenLocker::screen_locker_ = NULL; // See screen_locker.h for more details. class MouseEventRelay : public MessageLoopForUI::Observer { public: - MouseEventRelay(GdkWindow* src, GdkWindow* dest) : src_(src), dest_(dest) { + MouseEventRelay(GdkWindow* src, GdkWindow* dest) + : src_(src), + dest_(dest), + initialized_(false) { DCHECK(src_); DCHECK(dest_); - gint src_x, src_y, dest_x, dest_y, width, height, depth; - gdk_window_get_geometry(src_, &src_x, &src_y, &width, &height, &depth); - gdk_window_get_geometry(dest_, &dest_x, &dest_y, &width, &height, &depth); - - offset_.SetPoint(dest_x - src_x, dest_y - src_y); } virtual void WillProcessEvent(GdkEvent* event) {} virtual void DidProcessEvent(GdkEvent* event) { - if (event->any.window != src_) { + if (event->any.window != src_) return; + if (!initialized_) { + gint src_x, src_y, dest_x, dest_y, width, height, depth; + gdk_window_get_geometry(dest_, &dest_x, &dest_y, &width, &height, &depth); + // wait to compute offset until the info bubble widget's location + // is available. + if (dest_x < 0 || dest_y < 0) + return; + gdk_window_get_geometry(src_, &src_x, &src_y, &width, &height, &depth); + offset_.SetPoint(dest_x - src_x, dest_y - src_y); + initialized_ = true; } - if (event->type == GDK_BUTTON_PRESS || event->type == GDK_BUTTON_RELEASE) { GdkEvent* copy = gdk_event_copy(event); @@ -371,8 +378,8 @@ class MouseEventRelay : public MessageLoopForUI::Observer { gdk_event_free(copy); } else if (event->type == GDK_MOTION_NOTIFY) { GdkEvent* copy = gdk_event_copy(event); - copy->button.window = dest_; - g_object_ref(copy->button.window); + copy->motion.window = dest_; + g_object_ref(copy->motion.window); copy->motion.x -= offset_.x(); copy->motion.y -= offset_.y(); @@ -384,6 +391,7 @@ class MouseEventRelay : public MessageLoopForUI::Observer { private: GdkWindow* src_; GdkWindow* dest_; + bool initialized_; // Offset from src_'s origin to dest_'s origin. gfx::Point offset_; |