Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(288)

Side by Side Diff: ui/views/widget/native_widget_aura.cc

Issue 1221193009: [Docking] Persists docked state for tab-less browser windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [Docking] Persists docked state for tab-less browser windows (nits) Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/widget/native_widget_aura.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/widget/native_widget_aura.h" 5 #include "ui/views/widget/native_widget_aura.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "third_party/skia/include/core/SkRegion.h" 9 #include "third_party/skia/include/core/SkRegion.h"
10 #include "ui/aura/client/aura_constants.h" 10 #include "ui/aura/client/aura_constants.h"
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 gfx::Rect NativeWidgetAura::GetClientAreaBoundsInScreen() const { 357 gfx::Rect NativeWidgetAura::GetClientAreaBoundsInScreen() const {
358 // View-to-screen coordinate system transformations depend on this returning 358 // View-to-screen coordinate system transformations depend on this returning
359 // the full window bounds, for example View::ConvertPointToScreen(). 359 // the full window bounds, for example View::ConvertPointToScreen().
360 return window_ ? window_->GetBoundsInScreen() : gfx::Rect(); 360 return window_ ? window_->GetBoundsInScreen() : gfx::Rect();
361 } 361 }
362 362
363 gfx::Rect NativeWidgetAura::GetRestoredBounds() const { 363 gfx::Rect NativeWidgetAura::GetRestoredBounds() const {
364 if (!window_) 364 if (!window_)
365 return gfx::Rect(); 365 return gfx::Rect();
366 366
367 // Restored bounds should only be relevant if the window is minimized or 367 // Restored bounds should only be relevant if the window is minimized,
368 // maximized. However, in some places the code expects GetRestoredBounds() 368 // maximized, fullscreen or docked. However, in some places the code expects
369 // to return the current window bounds if the window is not in either state. 369 // GetRestoredBounds() to return the current window bounds if the window is
370 // not in either state.
370 if (IsMinimized() || IsMaximized() || IsFullscreen()) { 371 if (IsMinimized() || IsMaximized() || IsFullscreen()) {
371 // Restore bounds are in screen coordinates, no need to convert. 372 // Restore bounds are in screen coordinates, no need to convert.
372 gfx::Rect* restore_bounds = 373 gfx::Rect* restore_bounds =
373 window_->GetProperty(aura::client::kRestoreBoundsKey); 374 window_->GetProperty(aura::client::kRestoreBoundsKey);
374 if (restore_bounds) 375 if (restore_bounds)
375 return *restore_bounds; 376 return *restore_bounds;
376 } 377 }
377 return window_->GetBoundsInScreen(); 378 gfx::Rect bounds = window_->GetBoundsInScreen();
379 if (IsDocked()) {
380 // Restore bounds are in screen coordinates, no need to convert.
381 gfx::Rect* restore_bounds =
382 window_->GetProperty(aura::client::kRestoreBoundsKey);
383 // Use current window horizontal offset origin in order to preserve docked
384 // alignment but preserve restored size and vertical offset for the time
385 // when the |window_| gets undocked.
386 if (restore_bounds) {
387 bounds.set_size(restore_bounds->size());
388 bounds.set_y(restore_bounds->y());
389 }
390 }
391 return bounds;
378 } 392 }
379 393
380 void NativeWidgetAura::SetBounds(const gfx::Rect& bounds) { 394 void NativeWidgetAura::SetBounds(const gfx::Rect& bounds) {
381 if (!window_) 395 if (!window_)
382 return; 396 return;
383 397
384 aura::Window* root = window_->GetRootWindow(); 398 aura::Window* root = window_->GetRootWindow();
385 if (root) { 399 if (root) {
386 aura::client::ScreenPositionClient* screen_position_client = 400 aura::client::ScreenPositionClient* screen_position_client =
387 aura::client::GetScreenPositionClient(root); 401 aura::client::GetScreenPositionClient(root);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 void NativeWidgetAura::ShowMaximizedWithBounds( 474 void NativeWidgetAura::ShowMaximizedWithBounds(
461 const gfx::Rect& restored_bounds) { 475 const gfx::Rect& restored_bounds) {
462 SetRestoreBounds(window_, restored_bounds); 476 SetRestoreBounds(window_, restored_bounds);
463 ShowWithWindowState(ui::SHOW_STATE_MAXIMIZED); 477 ShowWithWindowState(ui::SHOW_STATE_MAXIMIZED);
464 } 478 }
465 479
466 void NativeWidgetAura::ShowWithWindowState(ui::WindowShowState state) { 480 void NativeWidgetAura::ShowWithWindowState(ui::WindowShowState state) {
467 if (!window_) 481 if (!window_)
468 return; 482 return;
469 483
470 if (state == ui::SHOW_STATE_MAXIMIZED || state == ui::SHOW_STATE_FULLSCREEN) 484 if (state == ui::SHOW_STATE_MAXIMIZED || state == ui::SHOW_STATE_FULLSCREEN ||
485 state == ui::SHOW_STATE_DOCKED) {
471 window_->SetProperty(aura::client::kShowStateKey, state); 486 window_->SetProperty(aura::client::kShowStateKey, state);
487 }
472 window_->Show(); 488 window_->Show();
473 if (delegate_->CanActivate()) { 489 if (delegate_->CanActivate()) {
474 if (state != ui::SHOW_STATE_INACTIVE) 490 if (state != ui::SHOW_STATE_INACTIVE)
475 Activate(); 491 Activate();
476 // SetInitialFocus() should be always be called, even for 492 // SetInitialFocus() should be always be called, even for
477 // SHOW_STATE_INACTIVE. If the window has to stay inactive, the method will 493 // SHOW_STATE_INACTIVE. If the window has to stay inactive, the method will
478 // do the right thing. 494 // do the right thing.
479 SetInitialFocus(state); 495 SetInitialFocus(state);
480 } 496 }
481 } 497 }
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 destroying_ = true; 967 destroying_ = true;
952 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET) 968 if (ownership_ == Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET)
953 delete delegate_; 969 delete delegate_;
954 else 970 else
955 CloseNow(); 971 CloseNow();
956 } 972 }
957 973
958 //////////////////////////////////////////////////////////////////////////////// 974 ////////////////////////////////////////////////////////////////////////////////
959 // NativeWidgetAura, private: 975 // NativeWidgetAura, private:
960 976
977 bool NativeWidgetAura::IsDocked() const {
978 return window_ &&
979 window_->GetProperty(aura::client::kShowStateKey) ==
980 ui::SHOW_STATE_DOCKED;
981 }
982
961 void NativeWidgetAura::SetInitialFocus(ui::WindowShowState show_state) { 983 void NativeWidgetAura::SetInitialFocus(ui::WindowShowState show_state) {
962 // The window does not get keyboard messages unless we focus it. 984 // The window does not get keyboard messages unless we focus it.
963 if (!GetWidget()->SetInitialFocus(show_state)) 985 if (!GetWidget()->SetInitialFocus(show_state))
964 window_->Focus(); 986 window_->Focus();
965 } 987 }
966 988
967 //////////////////////////////////////////////////////////////////////////////// 989 ////////////////////////////////////////////////////////////////////////////////
968 // Widget, public: 990 // Widget, public:
969 991
970 namespace { 992 namespace {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont)); 1163 l10n_util::AdjustUIFont(&(ncm.lfCaptionFont));
1142 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont))); 1164 base::win::ScopedHFONT caption_font(CreateFontIndirect(&(ncm.lfCaptionFont)));
1143 return gfx::FontList(gfx::Font(caption_font)); 1165 return gfx::FontList(gfx::Font(caption_font));
1144 #else 1166 #else
1145 return gfx::FontList(); 1167 return gfx::FontList();
1146 #endif 1168 #endif
1147 } 1169 }
1148 1170
1149 } // namespace internal 1171 } // namespace internal
1150 } // namespace views 1172 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/native_widget_aura.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698