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 "ash/mus/window_manager.h" | 5 #include "ash/mus/window_manager.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "ash/common/drag_drop/drag_image_view.h" | |
11 #include "ash/common/session/session_controller.h" | 12 #include "ash/common/session/session_controller.h" |
12 #include "ash/common/wm/container_finder.h" | 13 #include "ash/common/wm/container_finder.h" |
13 #include "ash/common/wm/window_state.h" | 14 #include "ash/common/wm/window_state.h" |
14 #include "ash/common/wm_window.h" | 15 #include "ash/common/wm_window.h" |
15 #include "ash/mus/accelerators/accelerator_handler.h" | 16 #include "ash/mus/accelerators/accelerator_handler.h" |
16 #include "ash/mus/accelerators/accelerator_ids.h" | 17 #include "ash/mus/accelerators/accelerator_ids.h" |
17 #include "ash/mus/bridge/wm_shell_mus.h" | 18 #include "ash/mus/bridge/wm_shell_mus.h" |
18 #include "ash/mus/move_event_handler.h" | 19 #include "ash/mus/move_event_handler.h" |
19 #include "ash/mus/non_client_frame_controller.h" | 20 #include "ash/mus/non_client_frame_controller.h" |
20 #include "ash/mus/property_util.h" | 21 #include "ash/mus/property_util.h" |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 return CreateAndParentTopLevelWindow(this, window_type, properties); | 360 return CreateAndParentTopLevelWindow(this, window_type, properties); |
360 } | 361 } |
361 | 362 |
362 void WindowManager::OnWmClientJankinessChanged( | 363 void WindowManager::OnWmClientJankinessChanged( |
363 const std::set<aura::Window*>& client_windows, | 364 const std::set<aura::Window*>& client_windows, |
364 bool janky) { | 365 bool janky) { |
365 for (auto* window : client_windows) | 366 for (auto* window : client_windows) |
366 window->SetProperty(kWindowIsJanky, janky); | 367 window->SetProperty(kWindowIsJanky, janky); |
367 } | 368 } |
368 | 369 |
370 void WindowManager::OnWmBuildDragImage( | |
371 const gfx::Point& location_in_screen_coordinates, | |
372 const SkBitmap& drag_image, | |
373 const gfx::Vector2d& drag_image_offset, | |
374 ui::mojom::DragEventSource source) { | |
375 if (drag_image.isNull()) | |
376 return; | |
377 | |
378 // TODO(erg): Get the right display for this drag image. Right now, none of | |
379 // the drag drop code is multidisplay aware. | |
380 | |
381 // TODO(erg): SkBitmap is the wrong data type for the drag image; we should | |
382 // be passing ImageSkias once http://crbug.com/655874 is implemented. | |
383 | |
384 WmWindow* root_window = | |
385 WmWindow::Get((*GetRootWindowControllers().begin())->GetRootWindow()); | |
386 | |
387 ui::DragDropTypes::DragEventSource ui_source = | |
388 source == ui::mojom::DragEventSource::MOUSE | |
389 ? ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE | |
390 : ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH; | |
391 drag_image_.reset(new DragImageView(root_window, ui_source)); | |
sky
2017/03/23 00:05:35
MakeUnique.
Elliot Glaysher
2017/03/23 19:58:43
Done.
| |
392 drag_image_->SetImage(gfx::ImageSkia::CreateFrom1xBitmap(drag_image)); | |
393 gfx::Size size = drag_image_->GetPreferredSize(); | |
394 gfx::Rect drag_image_bounds( | |
395 location_in_screen_coordinates - drag_image_offset, size); | |
396 drag_image_->SetBoundsInScreen(drag_image_bounds); | |
397 drag_image_->SetWidgetVisible(true); | |
398 | |
399 drag_image_offset_ = drag_image_offset; | |
400 } | |
401 | |
402 void WindowManager::OnWmMoveDragImage(const gfx::Point& cursor_location) { | |
403 if (drag_image_) | |
404 drag_image_->SetScreenPosition(cursor_location - drag_image_offset_); | |
405 } | |
406 | |
407 void WindowManager::OnWmDestroyDragImage() { | |
408 drag_image_.reset(); | |
409 drag_image_offset_ = gfx::Vector2d(0, 0); | |
410 } | |
411 | |
369 void WindowManager::OnWmWillCreateDisplay(const display::Display& display) { | 412 void WindowManager::OnWmWillCreateDisplay(const display::Display& display) { |
370 // A call to this function means a new display is being added, so the | 413 // A call to this function means a new display is being added, so the |
371 // DisplayList needs to be updated. Calling AddDisplay() results in | 414 // DisplayList needs to be updated. Calling AddDisplay() results in |
372 // notifying DisplayObservers. Ash code assumes when this happens there is | 415 // notifying DisplayObservers. Ash code assumes when this happens there is |
373 // a valid RootWindowController for the new display. Suspend notifying | 416 // a valid RootWindowController for the new display. Suspend notifying |
374 // observers, add the Display. The RootWindowController is created in | 417 // observers, add the Display. The RootWindowController is created in |
375 // OnWmNewDisplay(), which is called immediately after this function. | 418 // OnWmNewDisplay(), which is called immediately after this function. |
376 std::unique_ptr<display::DisplayListObserverLock> display_lock = | 419 std::unique_ptr<display::DisplayListObserverLock> display_lock = |
377 screen_->display_list().SuspendObserverUpdates(); | 420 screen_->display_list().SuspendObserverUpdates(); |
378 const bool is_first_display = screen_->display_list().displays().empty(); | 421 const bool is_first_display = screen_->display_list().displays().empty(); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
477 bool WindowManager::IsWindowActive(aura::Window* window) { | 520 bool WindowManager::IsWindowActive(aura::Window* window) { |
478 return Shell::GetInstance()->activation_client()->GetActiveWindow() == window; | 521 return Shell::GetInstance()->activation_client()->GetActiveWindow() == window; |
479 } | 522 } |
480 | 523 |
481 void WindowManager::OnWmDeactivateWindow(aura::Window* window) { | 524 void WindowManager::OnWmDeactivateWindow(aura::Window* window) { |
482 Shell::GetInstance()->activation_client()->DeactivateWindow(window); | 525 Shell::GetInstance()->activation_client()->DeactivateWindow(window); |
483 } | 526 } |
484 | 527 |
485 } // namespace mus | 528 } // namespace mus |
486 } // namespace ash | 529 } // namespace ash |
OLD | NEW |