| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 | 382 |
| 389 DestroyCompositor(); | 383 DestroyCompositor(); |
| 390 desktop_native_widget_aura_->OnHostClosed(); | 384 desktop_native_widget_aura_->OnHostClosed(); |
| 391 } | 385 } |
| 392 | 386 |
| 393 aura::WindowTreeHost* DesktopWindowTreeHostMus::AsWindowTreeHost() { | 387 aura::WindowTreeHost* DesktopWindowTreeHostMus::AsWindowTreeHost() { |
| 394 return this; | 388 return this; |
| 395 } | 389 } |
| 396 | 390 |
| 397 void DesktopWindowTreeHostMus::ShowWindowWithState(ui::WindowShowState state) { | 391 void DesktopWindowTreeHostMus::ShowWindowWithState(ui::WindowShowState state) { |
| 398 // TODO(afakhry): Remove Docked Windows in M58. | 392 if (state == ui::SHOW_STATE_MAXIMIZED || state == ui::SHOW_STATE_FULLSCREEN) |
| 399 if (state == ui::SHOW_STATE_MAXIMIZED || state == ui::SHOW_STATE_FULLSCREEN || | |
| 400 state == ui::SHOW_STATE_DOCKED) { | |
| 401 window()->SetProperty(aura::client::kShowStateKey, state); | 393 window()->SetProperty(aura::client::kShowStateKey, state); |
| 402 } | |
| 403 window()->Show(); | 394 window()->Show(); |
| 404 if (compositor()) | 395 if (compositor()) |
| 405 compositor()->SetVisible(true); | 396 compositor()->SetVisible(true); |
| 406 | 397 |
| 407 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true); | 398 native_widget_delegate_->OnNativeWidgetVisibilityChanged(true); |
| 408 | 399 |
| 409 if (native_widget_delegate_->CanActivate()) { | 400 if (native_widget_delegate_->CanActivate()) { |
| 410 if (state != ui::SHOW_STATE_INACTIVE) | 401 if (state != ui::SHOW_STATE_INACTIVE) |
| 411 Activate(); | 402 Activate(); |
| 412 | 403 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 } | 485 } |
| 495 | 486 |
| 496 gfx::Rect DesktopWindowTreeHostMus::GetClientAreaBoundsInScreen() const { | 487 gfx::Rect DesktopWindowTreeHostMus::GetClientAreaBoundsInScreen() const { |
| 497 // View-to-screen coordinate system transformations depend on this returning | 488 // View-to-screen coordinate system transformations depend on this returning |
| 498 // the full window bounds, for example View::ConvertPointToScreen(). | 489 // the full window bounds, for example View::ConvertPointToScreen(). |
| 499 return GetWindowBoundsInScreen(); | 490 return GetWindowBoundsInScreen(); |
| 500 } | 491 } |
| 501 | 492 |
| 502 gfx::Rect DesktopWindowTreeHostMus::GetRestoredBounds() const { | 493 gfx::Rect DesktopWindowTreeHostMus::GetRestoredBounds() const { |
| 503 // Restored bounds should only be relevant if the window is minimized, | 494 // Restored bounds should only be relevant if the window is minimized, |
| 504 // maximized, fullscreen or docked. However, in some places the code expects | 495 // maximized, or fullscreen. However, in some places the code expects |
| 505 // GetRestoredBounds() to return the current window bounds if the window is | 496 // GetRestoredBounds() to return the current window bounds if the window is |
| 506 // not in either state. | 497 // not in either state. |
| 507 if (IsMinimized() || IsMaximized() || IsFullscreen()) { | 498 if (IsMinimized() || IsMaximized() || IsFullscreen()) { |
| 508 // Restore bounds are in screen coordinates, no need to convert. | 499 // Restore bounds are in screen coordinates, no need to convert. |
| 509 gfx::Rect* restore_bounds = | 500 gfx::Rect* restore_bounds = |
| 510 window()->GetProperty(aura::client::kRestoreBoundsKey); | 501 window()->GetProperty(aura::client::kRestoreBoundsKey); |
| 511 if (restore_bounds) | 502 if (restore_bounds) |
| 512 return *restore_bounds; | 503 return *restore_bounds; |
| 513 } | 504 } |
| 514 gfx::Rect bounds = GetWindowBoundsInScreen(); | 505 return GetWindowBoundsInScreen(); |
| 515 if (IsDocked()) { | |
| 516 // Restore bounds are in screen coordinates, no need to convert. | |
| 517 gfx::Rect* restore_bounds = | |
| 518 window()->GetProperty(aura::client::kRestoreBoundsKey); | |
| 519 // Use current window horizontal offset origin in order to preserve docked | |
| 520 // alignment but preserve restored size and vertical offset for the time | |
| 521 // when the |window_| gets undocked. | |
| 522 if (restore_bounds) { | |
| 523 bounds.set_size(restore_bounds->size()); | |
| 524 bounds.set_y(restore_bounds->y()); | |
| 525 } | |
| 526 } | |
| 527 return bounds; | |
| 528 } | 506 } |
| 529 | 507 |
| 530 std::string DesktopWindowTreeHostMus::GetWorkspace() const { | 508 std::string DesktopWindowTreeHostMus::GetWorkspace() const { |
| 531 // Only used on x11. | 509 // Only used on x11. |
| 532 return std::string(); | 510 return std::string(); |
| 533 } | 511 } |
| 534 | 512 |
| 535 gfx::Rect DesktopWindowTreeHostMus::GetWorkAreaBoundsInScreen() const { | 513 gfx::Rect DesktopWindowTreeHostMus::GetWorkAreaBoundsInScreen() const { |
| 536 // TODO(sky): GetDisplayNearestWindow() should take a const aura::Window*. | 514 // TODO(sky): GetDisplayNearestWindow() should take a const aura::Window*. |
| 537 return display::Screen::GetScreen() | 515 return display::Screen::GetScreen() |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 aura::client::FocusClient* focus_client, | 793 aura::client::FocusClient* focus_client, |
| 816 aura::Window* window) { | 794 aura::Window* window) { |
| 817 if (window == this->window()) { | 795 if (window == this->window()) { |
| 818 desktop_native_widget_aura_->HandleActivationChanged(true); | 796 desktop_native_widget_aura_->HandleActivationChanged(true); |
| 819 } else if (is_active_) { | 797 } else if (is_active_) { |
| 820 desktop_native_widget_aura_->HandleActivationChanged(false); | 798 desktop_native_widget_aura_->HandleActivationChanged(false); |
| 821 } | 799 } |
| 822 } | 800 } |
| 823 | 801 |
| 824 } // namespace views | 802 } // namespace views |
| OLD | NEW |