| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/desktop_window_tree_host_mus.h" | 5 #include "ui/views/mus/desktop_window_tree_host_mus.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 // the cursor-client needs to be unset on the root-window before | 209 // the cursor-client needs to be unset on the root-window before |
| 210 // |cursor_manager_| is destroyed. | 210 // |cursor_manager_| is destroyed. |
| 211 aura::client::SetCursorClient(window(), nullptr); | 211 aura::client::SetCursorClient(window(), nullptr); |
| 212 desktop_native_widget_aura_->content_window()->RemoveObserver(this); | 212 desktop_native_widget_aura_->content_window()->RemoveObserver(this); |
| 213 native_widget_delegate_->AsWidget()->RemoveObserver(this); | 213 native_widget_delegate_->AsWidget()->RemoveObserver(this); |
| 214 MusClient::Get()->RemoveObserver(this); | 214 MusClient::Get()->RemoveObserver(this); |
| 215 aura::Env::GetInstance()->RemoveObserver(this); | 215 aura::Env::GetInstance()->RemoveObserver(this); |
| 216 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); | 216 desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this); |
| 217 } | 217 } |
| 218 | 218 |
| 219 // TODO(afakhry): Remove Docked Windows in M58. | |
| 220 bool DesktopWindowTreeHostMus::IsDocked() const { | |
| 221 return window()->GetProperty(aura::client::kShowStateKey) == | |
| 222 ui::SHOW_STATE_DOCKED; | |
| 223 } | |
| 224 | |
| 225 void DesktopWindowTreeHostMus::SendClientAreaToServer() { | 219 void DesktopWindowTreeHostMus::SendClientAreaToServer() { |
| 226 if (!ShouldSendClientAreaToServer()) | 220 if (!ShouldSendClientAreaToServer()) |
| 227 return; | 221 return; |
| 228 | 222 |
| 229 NonClientView* non_client_view = | 223 NonClientView* non_client_view = |
| 230 native_widget_delegate_->AsWidget()->non_client_view(); | 224 native_widget_delegate_->AsWidget()->non_client_view(); |
| 231 if (!non_client_view || !non_client_view->client_view()) | 225 if (!non_client_view || !non_client_view->client_view()) |
| 232 return; | 226 return; |
| 233 | 227 |
| 234 const gfx::Rect client_area_rect(non_client_view->client_view()->bounds()); | 228 const gfx::Rect client_area_rect(non_client_view->client_view()->bounds()); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 | 370 |
| 377 DestroyCompositor(); | 371 DestroyCompositor(); |
| 378 desktop_native_widget_aura_->OnHostClosed(); | 372 desktop_native_widget_aura_->OnHostClosed(); |
| 379 } | 373 } |
| 380 | 374 |
| 381 aura::WindowTreeHost* DesktopWindowTreeHostMus::AsWindowTreeHost() { | 375 aura::WindowTreeHost* DesktopWindowTreeHostMus::AsWindowTreeHost() { |
| 382 return this; | 376 return this; |
| 383 } | 377 } |
| 384 | 378 |
| 385 void DesktopWindowTreeHostMus::ShowWindowWithState(ui::WindowShowState state) { | 379 void DesktopWindowTreeHostMus::ShowWindowWithState(ui::WindowShowState state) { |
| 386 // TODO(afakhry): Remove Docked Windows in M58. | 380 if (state == ui::SHOW_STATE_MAXIMIZED || state == ui::SHOW_STATE_FULLSCREEN) |
| 387 if (state == ui::SHOW_STATE_MAXIMIZED || state == ui::SHOW_STATE_FULLSCREEN || | |
| 388 state == ui::SHOW_STATE_DOCKED) { | |
| 389 window()->SetProperty(aura::client::kShowStateKey, state); | 381 window()->SetProperty(aura::client::kShowStateKey, state); |
| 390 } | |
| 391 window()->Show(); | 382 window()->Show(); |
| 392 if (compositor()) | 383 if (compositor()) |
| 393 compositor()->SetVisible(true); | 384 compositor()->SetVisible(true); |
| 394 | 385 |
| 395 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true); | 386 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true); |
| 396 | 387 |
| 397 if (native_widget_delegate_->CanActivate()) { | 388 if (native_widget_delegate_->CanActivate()) { |
| 398 if (state != ui::SHOW_STATE_INACTIVE) | 389 if (state != ui::SHOW_STATE_INACTIVE) |
| 399 Activate(); | 390 Activate(); |
| 400 | 391 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 // maximized, fullscreen or docked. However, in some places the code expects | 483 // maximized, fullscreen or docked. However, in some places the code expects |
| 493 // GetRestoredBounds() to return the current window bounds if the window is | 484 // GetRestoredBounds() to return the current window bounds if the window is |
| 494 // not in either state. | 485 // not in either state. |
| 495 if (IsMinimized() || IsMaximized() || IsFullscreen()) { | 486 if (IsMinimized() || IsMaximized() || IsFullscreen()) { |
| 496 // Restore bounds are in screen coordinates, no need to convert. | 487 // Restore bounds are in screen coordinates, no need to convert. |
| 497 gfx::Rect* restore_bounds = | 488 gfx::Rect* restore_bounds = |
| 498 window()->GetProperty(aura::client::kRestoreBoundsKey); | 489 window()->GetProperty(aura::client::kRestoreBoundsKey); |
| 499 if (restore_bounds) | 490 if (restore_bounds) |
| 500 return *restore_bounds; | 491 return *restore_bounds; |
| 501 } | 492 } |
| 502 gfx::Rect bounds = GetWindowBoundsInScreen(); | 493 return GetWindowBoundsInScreen(); |
| 503 if (IsDocked()) { | |
| 504 // Restore bounds are in screen coordinates, no need to convert. | |
| 505 gfx::Rect* restore_bounds = | |
| 506 window()->GetProperty(aura::client::kRestoreBoundsKey); | |
| 507 // Use current window horizontal offset origin in order to preserve docked | |
| 508 // alignment but preserve restored size and vertical offset for the time | |
| 509 // when the |window_| gets undocked. | |
| 510 if (restore_bounds) { | |
| 511 bounds.set_size(restore_bounds->size()); | |
| 512 bounds.set_y(restore_bounds->y()); | |
| 513 } | |
| 514 } | |
| 515 return bounds; | |
| 516 } | 494 } |
| 517 | 495 |
| 518 std::string DesktopWindowTreeHostMus::GetWorkspace() const { | 496 std::string DesktopWindowTreeHostMus::GetWorkspace() const { |
| 519 // Only used on x11. | 497 // Only used on x11. |
| 520 return std::string(); | 498 return std::string(); |
| 521 } | 499 } |
| 522 | 500 |
| 523 gfx::Rect DesktopWindowTreeHostMus::GetWorkAreaBoundsInScreen() const { | 501 gfx::Rect DesktopWindowTreeHostMus::GetWorkAreaBoundsInScreen() const { |
| 524 // TODO(sky): GetDisplayNearestWindow() should take a const aura::Window*. | 502 // TODO(sky): GetDisplayNearestWindow() should take a const aura::Window*. |
| 525 return display::Screen::GetScreen() | 503 return display::Screen::GetScreen() |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 aura::client::FocusClient* focus_client, | 781 aura::client::FocusClient* focus_client, |
| 804 aura::Window* window) { | 782 aura::Window* window) { |
| 805 if (window == this->window()) { | 783 if (window == this->window()) { |
| 806 desktop_native_widget_aura_->HandleActivationChanged(true); | 784 desktop_native_widget_aura_->HandleActivationChanged(true); |
| 807 } else if (is_active_) { | 785 } else if (is_active_) { |
| 808 desktop_native_widget_aura_->HandleActivationChanged(false); | 786 desktop_native_widget_aura_->HandleActivationChanged(false); |
| 809 } | 787 } |
| 810 } | 788 } |
| 811 | 789 |
| 812 } // namespace views | 790 } // namespace views |
| OLD | NEW |