OLD | NEW |
---|---|
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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 touch_ids_down_(0), | 142 touch_ids_down_(0), |
143 last_cursor_(ui::kCursorNull), | 143 last_cursor_(ui::kCursorNull), |
144 mouse_pressed_handler_(NULL), | 144 mouse_pressed_handler_(NULL), |
145 mouse_moved_handler_(NULL), | 145 mouse_moved_handler_(NULL), |
146 event_dispatch_target_(NULL), | 146 event_dispatch_target_(NULL), |
147 synthesize_mouse_move_(false), | 147 synthesize_mouse_move_(false), |
148 move_hold_count_(0), | 148 move_hold_count_(0), |
149 event_factory_(this), | 149 event_factory_(this), |
150 held_event_factory_(this), | 150 held_event_factory_(this), |
151 repostable_event_factory_(this) { | 151 repostable_event_factory_(this) { |
152 set_dispatcher(this); | |
sky
2013/10/24 20:59:46
You need to set this to NULL in the destructor, ot
| |
152 SetName("RootWindow"); | 153 SetName("RootWindow"); |
153 | 154 |
154 compositor_.reset(new ui::Compositor(host_->GetAcceleratedWidget())); | 155 compositor_.reset(new ui::Compositor(host_->GetAcceleratedWidget())); |
155 DCHECK(compositor_.get()); | 156 DCHECK(compositor_.get()); |
156 | 157 |
157 prop_.reset(new ui::ViewProp(host_->GetAcceleratedWidget(), | 158 prop_.reset(new ui::ViewProp(host_->GetAcceleratedWidget(), |
158 kRootWindowForAcceleratedWidget, | 159 kRootWindowForAcceleratedWidget, |
159 this)); | 160 this)); |
160 ui::GestureRecognizer::Get()->AddGestureEventHelper(this); | 161 ui::GestureRecognizer::Get()->AddGestureEventHelper(this); |
161 } | 162 } |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
606 } | 607 } |
607 | 608 |
608 void RootWindow::OnWindowAddedToRootWindow(Window* attached) { | 609 void RootWindow::OnWindowAddedToRootWindow(Window* attached) { |
609 if (attached->IsVisible() && | 610 if (attached->IsVisible() && |
610 attached->ContainsPointInRoot(GetLastMouseLocationInRoot())) { | 611 attached->ContainsPointInRoot(GetLastMouseLocationInRoot())) { |
611 PostMouseMoveEventAfterWindowChange(); | 612 PostMouseMoveEventAfterWindowChange(); |
612 } | 613 } |
613 } | 614 } |
614 | 615 |
615 void RootWindow::OnWindowRemovedFromRootWindow(Window* detached, | 616 void RootWindow::OnWindowRemovedFromRootWindow(Window* detached, |
616 RootWindow* new_root) { | 617 Window* new_root) { |
617 DCHECK(aura::client::GetCaptureWindow(this) != this); | 618 DCHECK(aura::client::GetCaptureWindow(this) != this); |
618 | 619 |
619 DispatchMouseExitToHidingWindow(detached); | 620 DispatchMouseExitToHidingWindow(detached); |
620 OnWindowHidden(detached, new_root ? WINDOW_MOVING : WINDOW_HIDDEN); | 621 OnWindowHidden(detached, new_root ? WINDOW_MOVING : WINDOW_HIDDEN); |
621 | 622 |
622 if (detached->IsVisible() && | 623 if (detached->IsVisible() && |
623 detached->ContainsPointInRoot(GetLastMouseLocationInRoot())) { | 624 detached->ContainsPointInRoot(GetLastMouseLocationInRoot())) { |
624 PostMouseMoveEventAfterWindowChange(); | 625 PostMouseMoveEventAfterWindowChange(); |
625 } | 626 } |
626 } | 627 } |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
925 mouse_pressed_handler_ : client::GetCaptureWindow(this); | 926 mouse_pressed_handler_ : client::GetCaptureWindow(this); |
926 if (!target) | 927 if (!target) |
927 target = GetEventHandlerForPoint(event->location()); | 928 target = GetEventHandlerForPoint(event->location()); |
928 return DispatchMouseEventToTarget(event, target); | 929 return DispatchMouseEventToTarget(event, target); |
929 } | 930 } |
930 | 931 |
931 void RootWindow::DispatchMouseEventRepost(ui::MouseEvent* event) { | 932 void RootWindow::DispatchMouseEventRepost(ui::MouseEvent* event) { |
932 if (event->type() != ui::ET_MOUSE_PRESSED) | 933 if (event->type() != ui::ET_MOUSE_PRESSED) |
933 return; | 934 return; |
934 Window* target = client::GetCaptureWindow(this); | 935 Window* target = client::GetCaptureWindow(this); |
935 RootWindow* root = this; | 936 WindowEventDispatcher* dispatcher = this; |
936 if (!target) { | 937 if (!target) { |
937 target = GetEventHandlerForPoint(event->location()); | 938 target = GetEventHandlerForPoint(event->location()); |
938 } else { | 939 } else { |
939 root = target->GetRootWindow(); | 940 dispatcher = target->GetDispatcher(); |
940 CHECK(root); // Capture window better be in valid root. | 941 CHECK(dispatcher); // Capture window better be in valid root. |
941 } | 942 } |
942 root->mouse_pressed_handler_ = NULL; | 943 dispatcher->mouse_pressed_handler_ = NULL; |
943 root->DispatchMouseEventToTarget(event, target); | 944 dispatcher->DispatchMouseEventToTarget(event, target); |
944 } | 945 } |
945 | 946 |
946 bool RootWindow::DispatchMouseEventToTarget(ui::MouseEvent* event, | 947 bool RootWindow::DispatchMouseEventToTarget(ui::MouseEvent* event, |
947 Window* target) { | 948 Window* target) { |
948 client::CursorClient* cursor_client = client::GetCursorClient(this); | 949 client::CursorClient* cursor_client = client::GetCursorClient(this); |
949 if (cursor_client && | 950 if (cursor_client && |
950 !cursor_client->IsMouseEventsEnabled() && | 951 !cursor_client->IsMouseEventsEnabled() && |
951 (event->flags() & ui::EF_IS_SYNTHESIZED)) | 952 (event->flags() & ui::EF_IS_SYNTHESIZED)) |
952 return false; | 953 return false; |
953 | 954 |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1180 } | 1181 } |
1181 | 1182 |
1182 gfx::Transform RootWindow::GetInverseRootTransform() const { | 1183 gfx::Transform RootWindow::GetInverseRootTransform() const { |
1183 float scale = ui::GetDeviceScaleFactor(layer()); | 1184 float scale = ui::GetDeviceScaleFactor(layer()); |
1184 gfx::Transform transform; | 1185 gfx::Transform transform; |
1185 transform.Scale(1.0f / scale, 1.0f / scale); | 1186 transform.Scale(1.0f / scale, 1.0f / scale); |
1186 return transformer_->GetInverseTransform() * transform; | 1187 return transformer_->GetInverseTransform() * transform; |
1187 } | 1188 } |
1188 | 1189 |
1189 } // namespace aura | 1190 } // namespace aura |
OLD | NEW |