Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Side by Side Diff: ui/aura/root_window.cc

Issue 12423007: Short term workaround to deal with calculation error caused by inverted matrix. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: keep inside only for mouse event Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/aura/root_window.h" 5 #include "ui/aura/root_window.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 662
663 void RootWindow::ClearMouseHandlers() { 663 void RootWindow::ClearMouseHandlers() {
664 mouse_pressed_handler_ = NULL; 664 mouse_pressed_handler_ = NULL;
665 mouse_moved_handler_ = NULL; 665 mouse_moved_handler_ = NULL;
666 mouse_event_dispatch_target_ = NULL; 666 mouse_event_dispatch_target_ = NULL;
667 } 667 }
668 668
669 //////////////////////////////////////////////////////////////////////////////// 669 ////////////////////////////////////////////////////////////////////////////////
670 // RootWindow, private: 670 // RootWindow, private:
671 671
672 void RootWindow::TransformEventForDeviceScaleFactor(ui::LocatedEvent* event) { 672 void RootWindow::TransformEventForDeviceScaleFactor(ui::LocatedEvent* event,
673 bool keep_inside_root) {
673 event->UpdateForRootTransform(GetRootTransform()); 674 event->UpdateForRootTransform(GetRootTransform());
675 #if defined(OS_CHROMEOS)
676 const gfx::Rect& root_bounds = bounds();
677 if (keep_inside_root &
678 host_->GetBounds().Contains(event->system_location()) &&
679 !root_bounds.Contains(event->root_location())) {
680 // Make sure that the mouse location inside the host window gets
681 // translated inside root window.
682 // TODO(oshima): This is (hopefully) short term bandaid to deal
683 // with calculation error in inverted matrix. We'll try better
684 // alternative (crbug.com/222483) for m28.
685 int x = event->location().x();
686 int y = event->location().y();
687 x = std::min(std::max(x, root_bounds.x()), root_bounds.right());
688 y = std::min(std::max(y, root_bounds.y()), root_bounds.bottom());
689 const gfx::Point new_location(x, y);
690 event->set_location(new_location);
691 event->set_root_location(new_location);
692 }
693 #endif // defined(OS_CHROMEOS)
674 } 694 }
675 695
676 void RootWindow::HandleMouseMoved(const ui::MouseEvent& event, Window* target) { 696 void RootWindow::HandleMouseMoved(const ui::MouseEvent& event, Window* target) {
677 if (target == mouse_moved_handler_) 697 if (target == mouse_moved_handler_)
678 return; 698 return;
679 699
680 DispatchMouseEnterOrExit(event, ui::ET_MOUSE_EXITED); 700 DispatchMouseEnterOrExit(event, ui::ET_MOUSE_EXITED);
681 701
682 if (mouse_event_dispatch_target_ != target) { 702 if (mouse_event_dispatch_target_ != target) {
683 mouse_moved_handler_ = NULL; 703 mouse_moved_handler_ = NULL;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 held_mouse_move_.reset(); 897 held_mouse_move_.reset();
878 } 898 }
879 } 899 }
880 DispatchHeldEvents(); 900 DispatchHeldEvents();
881 return DispatchMouseEventImpl(event); 901 return DispatchMouseEventImpl(event);
882 } 902 }
883 903
884 bool RootWindow::OnHostScrollEvent(ui::ScrollEvent* event) { 904 bool RootWindow::OnHostScrollEvent(ui::ScrollEvent* event) {
885 DispatchHeldEvents(); 905 DispatchHeldEvents();
886 906
887 TransformEventForDeviceScaleFactor(event); 907 TransformEventForDeviceScaleFactor(event, false);
888 SetLastMouseLocation(this, event->location()); 908 SetLastMouseLocation(this, event->location());
889 synthesize_mouse_move_ = false; 909 synthesize_mouse_move_ = false;
890 910
891 Window* target = mouse_pressed_handler_ ? 911 Window* target = mouse_pressed_handler_ ?
892 mouse_pressed_handler_ : client::GetCaptureWindow(this); 912 mouse_pressed_handler_ : client::GetCaptureWindow(this);
893 913
894 if (!target) 914 if (!target)
895 target = GetEventHandlerForPoint(event->location()); 915 target = GetEventHandlerForPoint(event->location());
896 916
897 if (!target) 917 if (!target)
(...skipping 25 matching lines...) Expand all
923 // fallthrough 943 // fallthrough
924 case ui::ET_TOUCH_RELEASED: 944 case ui::ET_TOUCH_RELEASED:
925 touch_ids_down_ = (touch_ids_down_ | (1 << event->touch_id())) ^ 945 touch_ids_down_ = (touch_ids_down_ | (1 << event->touch_id())) ^
926 (1 << event->touch_id()); 946 (1 << event->touch_id());
927 Env::GetInstance()->set_touch_down(touch_ids_down_ != 0); 947 Env::GetInstance()->set_touch_down(touch_ids_down_ != 0);
928 break; 948 break;
929 949
930 default: 950 default:
931 break; 951 break;
932 } 952 }
933 TransformEventForDeviceScaleFactor(event); 953 TransformEventForDeviceScaleFactor(event, false);
934 bool handled = false; 954 bool handled = false;
935 Window* target = client::GetCaptureWindow(this); 955 Window* target = client::GetCaptureWindow(this);
936 if (!target) { 956 if (!target) {
937 target = ConsumerToWindow( 957 target = ConsumerToWindow(
938 gesture_recognizer_->GetTouchLockedTarget(event)); 958 gesture_recognizer_->GetTouchLockedTarget(event));
939 if (!target) { 959 if (!target) {
940 target = ConsumerToWindow( 960 target = ConsumerToWindow(
941 gesture_recognizer_->GetTargetForLocation(event->location())); 961 gesture_recognizer_->GetTargetForLocation(event->location()));
942 } 962 }
943 } 963 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 } 1044 }
1025 1045
1026 RootWindow* RootWindow::AsRootWindow() { 1046 RootWindow* RootWindow::AsRootWindow() {
1027 return this; 1047 return this;
1028 } 1048 }
1029 1049
1030 //////////////////////////////////////////////////////////////////////////////// 1050 ////////////////////////////////////////////////////////////////////////////////
1031 // RootWindow, private: 1051 // RootWindow, private:
1032 1052
1033 bool RootWindow::DispatchMouseEventImpl(ui::MouseEvent* event) { 1053 bool RootWindow::DispatchMouseEventImpl(ui::MouseEvent* event) {
1034 TransformEventForDeviceScaleFactor(event); 1054 TransformEventForDeviceScaleFactor(event, true);
1035 Window* target = mouse_pressed_handler_ ? 1055 Window* target = mouse_pressed_handler_ ?
1036 mouse_pressed_handler_ : client::GetCaptureWindow(this); 1056 mouse_pressed_handler_ : client::GetCaptureWindow(this);
1037 if (!target) 1057 if (!target)
1038 target = GetEventHandlerForPoint(event->location()); 1058 target = GetEventHandlerForPoint(event->location());
1039 return DispatchMouseEventToTarget(event, target); 1059 return DispatchMouseEventToTarget(event, target);
1040 } 1060 }
1041 1061
1042 bool RootWindow::DispatchMouseEventRepost(ui::MouseEvent* event) { 1062 bool RootWindow::DispatchMouseEventRepost(ui::MouseEvent* event) {
1043 if (event->type() != ui::ET_MOUSE_PRESSED) 1063 if (event->type() != ui::ET_MOUSE_PRESSED)
1044 return false; 1064 return false;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 1173
1154 gfx::Transform RootWindow::GetRootTransform() const { 1174 gfx::Transform RootWindow::GetRootTransform() const {
1155 float scale = ui::GetDeviceScaleFactor(layer()); 1175 float scale = ui::GetDeviceScaleFactor(layer());
1156 gfx::Transform transform; 1176 gfx::Transform transform;
1157 transform.Scale(scale, scale); 1177 transform.Scale(scale, scale);
1158 transform *= layer()->transform(); 1178 transform *= layer()->transform();
1159 return transform; 1179 return transform;
1160 } 1180 }
1161 1181
1162 } // namespace aura 1182 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698