| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/views/mus/native_widget_mus.h" | 5 #include "ui/views/mus/native_widget_mus.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "components/mus/public/cpp/property_type_converters.h" | 11 #include "components/mus/public/cpp/property_type_converters.h" |
| 12 #include "components/mus/public/cpp/window.h" | 12 #include "components/mus/public/cpp/window.h" |
| 13 #include "components/mus/public/cpp/window_observer.h" | 13 #include "components/mus/public/cpp/window_observer.h" |
| 14 #include "components/mus/public/cpp/window_property.h" | 14 #include "components/mus/public/cpp/window_property.h" |
| 15 #include "components/mus/public/cpp/window_tree_connection.h" | 15 #include "components/mus/public/cpp/window_tree_connection.h" |
| 16 #include "components/mus/public/interfaces/cursor.mojom.h" | 16 #include "components/mus/public/interfaces/cursor.mojom.h" |
| 17 #include "components/mus/public/interfaces/window_manager.mojom.h" | 17 #include "components/mus/public/interfaces/window_manager.mojom.h" |
| 18 #include "components/mus/public/interfaces/window_manager_constants.mojom.h" | 18 #include "components/mus/public/interfaces/window_manager_constants.mojom.h" |
| 19 #include "components/mus/public/interfaces/window_tree.mojom.h" | 19 #include "components/mus/public/interfaces/window_tree.mojom.h" |
| 20 #include "ui/aura/client/default_capture_client.h" | 20 #include "ui/aura/client/default_capture_client.h" |
| 21 #include "ui/aura/client/window_tree_client.h" | 21 #include "ui/aura/client/window_tree_client.h" |
| 22 #include "ui/aura/env.h" | 22 #include "ui/aura/env.h" |
| 23 #include "ui/aura/env_input_state_controller.h" |
| 23 #include "ui/aura/layout_manager.h" | 24 #include "ui/aura/layout_manager.h" |
| 24 #include "ui/aura/mus/mus_util.h" | 25 #include "ui/aura/mus/mus_util.h" |
| 25 #include "ui/aura/window.h" | 26 #include "ui/aura/window.h" |
| 26 #include "ui/aura/window_property.h" | 27 #include "ui/aura/window_property.h" |
| 27 #include "ui/base/hit_test.h" | 28 #include "ui/base/hit_test.h" |
| 28 #include "ui/events/event.h" | 29 #include "ui/events/event.h" |
| 29 #include "ui/gfx/canvas.h" | 30 #include "ui/gfx/canvas.h" |
| 30 #include "ui/gfx/path.h" | 31 #include "ui/gfx/path.h" |
| 31 #include "ui/native_theme/native_theme_aura.h" | 32 #include "ui/native_theme/native_theme_aura.h" |
| 32 #include "ui/platform_window/platform_window_delegate.h" | 33 #include "ui/platform_window/platform_window_delegate.h" |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 shell::Connector* connector, | 479 shell::Connector* connector, |
| 479 mus::Window* window, | 480 mus::Window* window, |
| 480 mus::mojom::SurfaceType surface_type) | 481 mus::mojom::SurfaceType surface_type) |
| 481 : window_(window), | 482 : window_(window), |
| 482 last_cursor_(mus::mojom::Cursor::CURSOR_NULL), | 483 last_cursor_(mus::mojom::Cursor::CURSOR_NULL), |
| 483 native_widget_delegate_(delegate), | 484 native_widget_delegate_(delegate), |
| 484 surface_type_(surface_type), | 485 surface_type_(surface_type), |
| 485 show_state_before_fullscreen_(mus::mojom::ShowState::DEFAULT), | 486 show_state_before_fullscreen_(mus::mojom::ShowState::DEFAULT), |
| 486 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), | 487 ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
| 487 content_(new aura::Window(this)), | 488 content_(new aura::Window(this)), |
| 489 aura_env_controller_(new aura::EnvInputStateController), |
| 488 close_widget_factory_(this) { | 490 close_widget_factory_(this) { |
| 489 window_->set_input_event_handler(this); | 491 window_->set_input_event_handler(this); |
| 490 mus_window_observer_.reset(new MusWindowObserver(this)); | 492 mus_window_observer_.reset(new MusWindowObserver(this)); |
| 491 | 493 |
| 492 // TODO(fsamuel): Figure out lifetime of |window_|. | 494 // TODO(fsamuel): Figure out lifetime of |window_|. |
| 493 aura::SetMusWindow(content_, window_); | 495 aura::SetMusWindow(content_, window_); |
| 494 | 496 |
| 495 window->SetLocalProperty(kNativeWidgetMusKey, this); | 497 window->SetLocalProperty(kNativeWidgetMusKey, this); |
| 496 // WindowTreeHost creates the compositor using the ContextFactory from | 498 // WindowTreeHost creates the compositor using the ContextFactory from |
| 497 // aura::Env. Install |context_factory_| there so that |context_factory_| is | 499 // aura::Env. Install |context_factory_| there so that |context_factory_| is |
| (...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1310 } | 1312 } |
| 1311 | 1313 |
| 1312 void NativeWidgetMus::OnWindowInputEvent( | 1314 void NativeWidgetMus::OnWindowInputEvent( |
| 1313 mus::Window* view, | 1315 mus::Window* view, |
| 1314 const ui::Event& event_in, | 1316 const ui::Event& event_in, |
| 1315 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) { | 1317 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) { |
| 1316 // Take ownership of the callback, indicating that we will handle it. | 1318 // Take ownership of the callback, indicating that we will handle it. |
| 1317 EventAckHandler ack_handler(std::move(*ack_callback)); | 1319 EventAckHandler ack_handler(std::move(*ack_callback)); |
| 1318 | 1320 |
| 1319 std::unique_ptr<ui::Event> event = ui::Event::Clone(event_in); | 1321 std::unique_ptr<ui::Event> event = ui::Event::Clone(event_in); |
| 1320 // TODO(markdittmer): This should be this->OnEvent(event.get()), but that | 1322 |
| 1321 // can't happen until IME is refactored out of in WindowTreeHostMus. | 1323 if (!event->IsKeyEvent()) { |
| 1322 platform_window_delegate()->DispatchEvent(event.get()); | 1324 if (event->IsMouseEvent()) |
| 1325 aura_env_controller_->PreDispatchMouseEvent(event->AsMouseEvent()); |
| 1326 OnEvent(event.get()); |
| 1327 } else { |
| 1328 // TODO(markdittmer): This should be this->OnEvent(event.get()), but that |
| 1329 // can't happen until IME is refactored out of in WindowTreeHostMus. |
| 1330 platform_window_delegate()->DispatchEvent(event.get()); |
| 1331 } |
| 1323 // NOTE: |this| may be deleted. | 1332 // NOTE: |this| may be deleted. |
| 1324 | 1333 |
| 1325 ack_handler.set_handled(event->handled()); | 1334 ack_handler.set_handled(event->handled()); |
| 1326 // |ack_handler| acks the event on destruction if necessary. | 1335 // |ack_handler| acks the event on destruction if necessary. |
| 1327 } | 1336 } |
| 1328 | 1337 |
| 1329 void NativeWidgetMus::OnMusWindowVisibilityChanging(mus::Window* window) { | 1338 void NativeWidgetMus::OnMusWindowVisibilityChanging(mus::Window* window) { |
| 1330 if (window == window_) { | 1339 if (window == window_) { |
| 1331 native_widget_delegate_->OnNativeWidgetVisibilityChanging( | 1340 native_widget_delegate_->OnNativeWidgetVisibilityChanging( |
| 1332 !window->visible()); | 1341 !window->visible()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1360 | 1369 |
| 1361 gfx::Path mask_path; | 1370 gfx::Path mask_path; |
| 1362 native_widget_delegate_->GetHitTestMask(&mask_path); | 1371 native_widget_delegate_->GetHitTestMask(&mask_path); |
| 1363 // TODO(jamescook): Use the full path for the mask. | 1372 // TODO(jamescook): Use the full path for the mask. |
| 1364 gfx::Rect mask_rect = | 1373 gfx::Rect mask_rect = |
| 1365 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); | 1374 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); |
| 1366 window_->SetHitTestMask(mask_rect); | 1375 window_->SetHitTestMask(mask_rect); |
| 1367 } | 1376 } |
| 1368 | 1377 |
| 1369 } // namespace views | 1378 } // namespace views |
| OLD | NEW |