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 // This has to be before any other includes, else default is picked up. | 5 // This has to be before any other includes, else default is picked up. |
6 // See base/logging for details on this. | 6 // See base/logging for details on this. |
7 #define NOTIMPLEMENTED_POLICY 5 | 7 #define NOTIMPLEMENTED_POLICY 5 |
8 | 8 |
9 #include "ui/views/mus/native_widget_mus.h" | 9 #include "ui/views/mus/native_widget_mus.h" |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 #include "ui/views/window/custom_frame_view.h" | 59 #include "ui/views/window/custom_frame_view.h" |
60 #include "ui/wm/core/base_focus_rules.h" | 60 #include "ui/wm/core/base_focus_rules.h" |
61 #include "ui/wm/core/capture_controller.h" | 61 #include "ui/wm/core/capture_controller.h" |
62 #include "ui/wm/core/cursor_manager.h" | 62 #include "ui/wm/core/cursor_manager.h" |
63 #include "ui/wm/core/default_screen_position_client.h" | 63 #include "ui/wm/core/default_screen_position_client.h" |
64 #include "ui/wm/core/focus_controller.h" | 64 #include "ui/wm/core/focus_controller.h" |
65 #include "ui/wm/core/native_cursor_manager.h" | 65 #include "ui/wm/core/native_cursor_manager.h" |
66 | 66 |
67 DECLARE_WINDOW_PROPERTY_TYPE(ui::Window*); | 67 DECLARE_WINDOW_PROPERTY_TYPE(ui::Window*); |
68 | 68 |
| 69 using PrimitiveType = aura::PropertyConverter::PrimitiveType; |
69 using ui::mojom::EventResult; | 70 using ui::mojom::EventResult; |
70 | 71 |
71 namespace views { | 72 namespace views { |
72 namespace { | 73 namespace { |
73 | 74 |
74 DEFINE_WINDOW_PROPERTY_KEY(ui::Window*, kMusWindow, nullptr); | 75 DEFINE_WINDOW_PROPERTY_KEY(ui::Window*, kMusWindow, nullptr); |
75 | 76 |
76 MUS_DEFINE_WINDOW_PROPERTY_KEY(NativeWidgetMus*, kNativeWidgetMusKey, nullptr); | 77 MUS_DEFINE_WINDOW_PROPERTY_KEY(NativeWidgetMus*, kNativeWidgetMusKey, nullptr); |
77 | 78 |
78 // This ensures that only the top-level aura Window can be activated. | 79 // This ensures that only the top-level aura Window can be activated. |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 quit_closure.Run(); | 370 quit_closure.Run(); |
370 } | 371 } |
371 | 372 |
372 ui::mojom::ShowState GetShowState(const ui::Window* window) { | 373 ui::mojom::ShowState GetShowState(const ui::Window* window) { |
373 if (!window || | 374 if (!window || |
374 !window->HasSharedProperty( | 375 !window->HasSharedProperty( |
375 ui::mojom::WindowManager::kShowState_Property)) { | 376 ui::mojom::WindowManager::kShowState_Property)) { |
376 return ui::mojom::ShowState::DEFAULT; | 377 return ui::mojom::ShowState::DEFAULT; |
377 } | 378 } |
378 | 379 |
379 return static_cast<ui::mojom::ShowState>(window->GetSharedProperty<int32_t>( | 380 return static_cast<ui::mojom::ShowState>( |
380 ui::mojom::WindowManager::kShowState_Property)); | 381 window->GetSharedProperty<PrimitiveType>( |
| 382 ui::mojom::WindowManager::kShowState_Property)); |
381 } | 383 } |
382 | 384 |
383 // Set the app or window icon property for the window. | 385 // Set the app or window icon property for the window. |
384 void SetIconProperty(ui::Window* window, | 386 void SetIconProperty(ui::Window* window, |
385 const char* const property, | 387 const char* const property, |
386 const gfx::ImageSkia& icon) { | 388 const gfx::ImageSkia& icon) { |
387 // TODO(crbug.com/667566): Support additional scales or gfx::Image[Skia]. | 389 // TODO(crbug.com/667566): Support additional scales or gfx::Image[Skia]. |
388 SkBitmap bitmap = icon.GetRepresentation(1.f).sk_bitmap(); | 390 SkBitmap bitmap = icon.GetRepresentation(1.f).sk_bitmap(); |
389 if (!bitmap.isNull()) | 391 if (!bitmap.isNull()) |
390 window->SetSharedProperty<SkBitmap>(property, bitmap); | 392 window->SetSharedProperty<SkBitmap>(property, bitmap); |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 if (!init_params.bounds.IsEmpty()) { | 661 if (!init_params.bounds.IsEmpty()) { |
660 (*properties)[ui::mojom::WindowManager::kUserSetBounds_Property] = | 662 (*properties)[ui::mojom::WindowManager::kUserSetBounds_Property] = |
661 mojo::ConvertTo<std::vector<uint8_t>>(init_params.bounds); | 663 mojo::ConvertTo<std::vector<uint8_t>>(init_params.bounds); |
662 } | 664 } |
663 if (!init_params.name.empty()) { | 665 if (!init_params.name.empty()) { |
664 (*properties)[ui::mojom::WindowManager::kName_Property] = | 666 (*properties)[ui::mojom::WindowManager::kName_Property] = |
665 mojo::ConvertTo<std::vector<uint8_t>>(init_params.name); | 667 mojo::ConvertTo<std::vector<uint8_t>>(init_params.name); |
666 } | 668 } |
667 (*properties)[ui::mojom::WindowManager::kAlwaysOnTop_Property] = | 669 (*properties)[ui::mojom::WindowManager::kAlwaysOnTop_Property] = |
668 mojo::ConvertTo<std::vector<uint8_t>>( | 670 mojo::ConvertTo<std::vector<uint8_t>>( |
669 static_cast<aura::PropertyConverter::PrimitiveType>( | 671 static_cast<PrimitiveType>(init_params.keep_on_top)); |
670 init_params.keep_on_top)); | 672 |
| 673 (*properties)[ui::mojom::WindowManager::kWindowType_Property] = |
| 674 mojo::ConvertTo<std::vector<uint8_t>>(static_cast<PrimitiveType>( |
| 675 mojo::ConvertTo<ui::mojom::WindowType>(init_params.type))); |
671 | 676 |
672 if (!Widget::RequiresNonClientView(init_params.type)) | 677 if (!Widget::RequiresNonClientView(init_params.type)) |
673 return; | 678 return; |
674 | 679 |
675 (*properties)[ui::mojom::WindowManager::kWindowType_Property] = | |
676 mojo::ConvertTo<std::vector<uint8_t>>( | |
677 static_cast<aura::PropertyConverter::PrimitiveType>( | |
678 mojo::ConvertTo<ui::mojom::WindowType>(init_params.type))); | |
679 | |
680 if (init_params.delegate) { | 680 if (init_params.delegate) { |
681 if (properties->count(ui::mojom::WindowManager::kResizeBehavior_Property) == | 681 if (properties->count(ui::mojom::WindowManager::kResizeBehavior_Property) == |
682 0) { | 682 0) { |
683 (*properties)[ui::mojom::WindowManager::kResizeBehavior_Property] = | 683 (*properties)[ui::mojom::WindowManager::kResizeBehavior_Property] = |
684 mojo::ConvertTo<std::vector<uint8_t>>( | 684 mojo::ConvertTo<std::vector<uint8_t>>(static_cast<PrimitiveType>( |
685 static_cast<aura::PropertyConverter::PrimitiveType>( | 685 init_params.delegate->GetResizeBehavior())); |
686 init_params.delegate->GetResizeBehavior())); | |
687 } | 686 } |
688 | 687 |
689 // TODO(crbug.com/667566): Support additional scales or gfx::Image[Skia]. | 688 // TODO(crbug.com/667566): Support additional scales or gfx::Image[Skia]. |
690 gfx::ImageSkia app_icon = init_params.delegate->GetWindowAppIcon(); | 689 gfx::ImageSkia app_icon = init_params.delegate->GetWindowAppIcon(); |
691 SkBitmap app_bitmap = app_icon.GetRepresentation(1.f).sk_bitmap(); | 690 SkBitmap app_bitmap = app_icon.GetRepresentation(1.f).sk_bitmap(); |
692 if (!app_bitmap.isNull()) { | 691 if (!app_bitmap.isNull()) { |
693 (*properties)[ui::mojom::WindowManager::kAppIcon_Property] = | 692 (*properties)[ui::mojom::WindowManager::kAppIcon_Property] = |
694 mojo::ConvertTo<std::vector<uint8_t>>(app_bitmap); | 693 mojo::ConvertTo<std::vector<uint8_t>>(app_bitmap); |
695 } | 694 } |
696 // TODO(crbug.com/667566): Support additional scales or gfx::Image[Skia]. | 695 // TODO(crbug.com/667566): Support additional scales or gfx::Image[Skia]. |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 return true; | 1323 return true; |
1325 } | 1324 } |
1326 | 1325 |
1327 void NativeWidgetMus::OnSizeConstraintsChanged() { | 1326 void NativeWidgetMus::OnSizeConstraintsChanged() { |
1328 if (!window_ || is_parallel_widget_in_window_manager()) | 1327 if (!window_ || is_parallel_widget_in_window_manager()) |
1329 return; | 1328 return; |
1330 | 1329 |
1331 int32_t behavior = ui::mojom::kResizeBehaviorNone; | 1330 int32_t behavior = ui::mojom::kResizeBehaviorNone; |
1332 if (GetWidget()->widget_delegate()) | 1331 if (GetWidget()->widget_delegate()) |
1333 behavior = GetWidget()->widget_delegate()->GetResizeBehavior(); | 1332 behavior = GetWidget()->widget_delegate()->GetResizeBehavior(); |
1334 window_->SetSharedProperty<int32_t>( | 1333 window_->SetSharedProperty<PrimitiveType>( |
1335 ui::mojom::WindowManager::kResizeBehavior_Property, behavior); | 1334 ui::mojom::WindowManager::kResizeBehavior_Property, behavior); |
1336 } | 1335 } |
1337 | 1336 |
1338 void NativeWidgetMus::RepostNativeEvent(gfx::NativeEvent native_event) { | 1337 void NativeWidgetMus::RepostNativeEvent(gfx::NativeEvent native_event) { |
1339 NOTIMPLEMENTED(); | 1338 NOTIMPLEMENTED(); |
1340 } | 1339 } |
1341 | 1340 |
1342 std::string NativeWidgetMus::GetName() const { | 1341 std::string NativeWidgetMus::GetName() const { |
1343 return window_->GetName(); | 1342 return window_->GetName(); |
1344 } | 1343 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1405 return native_widget_delegate_->HasHitTestMask(); | 1404 return native_widget_delegate_->HasHitTestMask(); |
1406 } | 1405 } |
1407 | 1406 |
1408 void NativeWidgetMus::GetHitTestMask(gfx::Path* mask) const { | 1407 void NativeWidgetMus::GetHitTestMask(gfx::Path* mask) const { |
1409 native_widget_delegate_->GetHitTestMask(mask); | 1408 native_widget_delegate_->GetHitTestMask(mask); |
1410 } | 1409 } |
1411 | 1410 |
1412 void NativeWidgetMus::SetShowState(ui::mojom::ShowState show_state) { | 1411 void NativeWidgetMus::SetShowState(ui::mojom::ShowState show_state) { |
1413 if (!window_) | 1412 if (!window_) |
1414 return; | 1413 return; |
1415 window_->SetSharedProperty<int32_t>( | 1414 window_->SetSharedProperty<PrimitiveType>( |
1416 ui::mojom::WindowManager::kShowState_Property, | 1415 ui::mojom::WindowManager::kShowState_Property, |
1417 static_cast<int32_t>(show_state)); | 1416 static_cast<PrimitiveType>(show_state)); |
1418 } | 1417 } |
1419 | 1418 |
1420 void NativeWidgetMus::OnKeyEvent(ui::KeyEvent* event) { | 1419 void NativeWidgetMus::OnKeyEvent(ui::KeyEvent* event) { |
1421 if (event->is_char()) { | 1420 if (event->is_char()) { |
1422 // If a ui::InputMethod object is attached to the root window, character | 1421 // If a ui::InputMethod object is attached to the root window, character |
1423 // events are handled inside the object and are not passed to this function. | 1422 // events are handled inside the object and are not passed to this function. |
1424 // If such object is not attached, character events might be sent (e.g. on | 1423 // If such object is not attached, character events might be sent (e.g. on |
1425 // Windows). In this case, we just skip these. | 1424 // Windows). In this case, we just skip these. |
1426 return; | 1425 return; |
1427 } | 1426 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1569 | 1568 |
1570 gfx::Path mask_path; | 1569 gfx::Path mask_path; |
1571 native_widget_delegate_->GetHitTestMask(&mask_path); | 1570 native_widget_delegate_->GetHitTestMask(&mask_path); |
1572 // TODO(jamescook): Use the full path for the mask. | 1571 // TODO(jamescook): Use the full path for the mask. |
1573 gfx::Rect mask_rect = | 1572 gfx::Rect mask_rect = |
1574 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); | 1573 gfx::ToEnclosingRect(gfx::SkRectToRectF(mask_path.getBounds())); |
1575 window_->SetHitTestMask(mask_rect); | 1574 window_->SetHitTestMask(mask_rect); |
1576 } | 1575 } |
1577 | 1576 |
1578 } // namespace views | 1577 } // namespace views |
OLD | NEW |