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