Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/widget.h" | 5 #include "ui/views/widget/widget.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 624 } | 624 } |
| 625 | 625 |
| 626 void Widget::Show() { | 626 void Widget::Show() { |
| 627 const ui::Layer* layer = GetLayer(); | 627 const ui::Layer* layer = GetLayer(); |
| 628 TRACE_EVENT1("views", "Widget::Show", "layer", | 628 TRACE_EVENT1("views", "Widget::Show", "layer", |
| 629 layer ? layer->name() : "none"); | 629 layer ? layer->name() : "none"); |
| 630 if (non_client_view_) { | 630 if (non_client_view_) { |
| 631 // While initializing, the kiosk mode will go to full screen before the | 631 // While initializing, the kiosk mode will go to full screen before the |
| 632 // widget gets shown. In that case we stay in full screen mode, regardless | 632 // widget gets shown. In that case we stay in full screen mode, regardless |
| 633 // of the |saved_show_state_| member. | 633 // of the |saved_show_state_| member. |
| 634 if (saved_show_state_ == ui::SHOW_STATE_MAXIMIZED && | 634 if (((saved_show_state_ == ui::SHOW_STATE_MAXIMIZED && !IsFullscreen()) || |
| 635 !initial_restored_bounds_.IsEmpty() && | 635 IsMaximized()) && |
| 636 !IsFullscreen()) { | 636 !initial_restored_bounds_.IsEmpty()) { |
| 637 native_widget_->ShowMaximizedWithBounds(initial_restored_bounds_); | 637 native_widget_->ShowMaximizedWithBounds(initial_restored_bounds_); |
| 638 } else { | 638 } else { |
| 639 ui::WindowShowState show_state = | 639 ShowWithCurrentState(); |
| 640 IsFullscreen() ? ui::SHOW_STATE_FULLSCREEN : | |
| 641 IsMinimized() ? ui::SHOW_STATE_MINIMIZED : saved_show_state_; | |
| 642 native_widget_->ShowWithWindowState(show_state); | |
| 643 } | 640 } |
| 644 // |saved_show_state_| only applies the first time the window is shown. | 641 // |saved_show_state_| only applies the first time the window is shown. |
| 645 // If we don't reset the value the window may be shown maximized every time | 642 // If we don't reset the value the window may be shown maximized every time |
| 646 // it is subsequently shown after being hidden. | 643 // it is subsequently shown after being hidden. |
| 647 saved_show_state_ = ui::SHOW_STATE_NORMAL; | 644 saved_show_state_ = ui::SHOW_STATE_NORMAL; |
| 648 } else { | 645 } else { |
| 649 CanActivate() | 646 CanActivate() |
| 650 ? native_widget_->Show() | 647 ? ShowWithCurrentState() |
|
oshima
2015/12/01 23:00:06
This is necessary to honor show_state in the widge
| |
| 651 : native_widget_->ShowWithWindowState(ui::SHOW_STATE_INACTIVE); | 648 : native_widget_->ShowWithWindowState(ui::SHOW_STATE_INACTIVE); |
| 652 } | 649 } |
| 653 } | 650 } |
| 654 | 651 |
| 655 void Widget::Hide() { | 652 void Widget::Hide() { |
| 656 native_widget_->Hide(); | 653 native_widget_->Hide(); |
| 657 } | 654 } |
| 658 | 655 |
| 659 void Widget::ShowInactive() { | 656 void Widget::ShowInactive() { |
| 660 // If this gets called with saved_show_state_ == ui::SHOW_STATE_MAXIMIZED, | 657 // If this gets called with saved_show_state_ == ui::SHOW_STATE_MAXIMIZED, |
| (...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1446 // If the saved bounds are valid, use them. | 1443 // If the saved bounds are valid, use them. |
| 1447 SetBounds(saved_bounds); | 1444 SetBounds(saved_bounds); |
| 1448 } | 1445 } |
| 1449 } else { | 1446 } else { |
| 1450 if (bounds.IsEmpty()) { | 1447 if (bounds.IsEmpty()) { |
| 1451 // No initial bounds supplied, so size the window to its content and | 1448 // No initial bounds supplied, so size the window to its content and |
| 1452 // center over its parent. | 1449 // center over its parent. |
| 1453 native_widget_->CenterWindow(non_client_view_->GetPreferredSize()); | 1450 native_widget_->CenterWindow(non_client_view_->GetPreferredSize()); |
| 1454 } else { | 1451 } else { |
| 1455 // Use the supplied initial bounds. | 1452 // Use the supplied initial bounds. |
| 1453 if (IsMaximized()) | |
| 1454 initial_restored_bounds_ = bounds; | |
| 1456 SetBoundsConstrained(bounds); | 1455 SetBoundsConstrained(bounds); |
| 1457 } | 1456 } |
| 1458 } | 1457 } |
| 1459 } | 1458 } |
| 1460 | 1459 |
| 1461 void Widget::SetInitialBoundsForFramelessWindow(const gfx::Rect& bounds) { | 1460 void Widget::SetInitialBoundsForFramelessWindow(const gfx::Rect& bounds) { |
| 1462 if (bounds.IsEmpty()) { | 1461 if (bounds.IsEmpty()) { |
| 1463 View* contents_view = GetContentsView(); | 1462 View* contents_view = GetContentsView(); |
| 1464 DCHECK(contents_view); | 1463 DCHECK(contents_view); |
| 1465 // No initial bounds supplied, so size the window to its content and | 1464 // No initial bounds supplied, so size the window to its content and |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 1493 bounds->set_width(minimum_size.width()); | 1492 bounds->set_width(minimum_size.width()); |
| 1494 | 1493 |
| 1495 if (bounds->height() < minimum_size.height()) | 1494 if (bounds->height() < minimum_size.height()) |
| 1496 bounds->set_height(minimum_size.height()); | 1495 bounds->set_height(minimum_size.height()); |
| 1497 } | 1496 } |
| 1498 return true; | 1497 return true; |
| 1499 } | 1498 } |
| 1500 return false; | 1499 return false; |
| 1501 } | 1500 } |
| 1502 | 1501 |
| 1502 void Widget::ShowWithCurrentState() { | |
| 1503 ui::WindowShowState show_state = | |
| 1504 IsFullscreen() | |
| 1505 ? ui::SHOW_STATE_FULLSCREEN | |
| 1506 : (IsMaximized() ? ui::SHOW_STATE_MAXIMIZED | |
| 1507 : (IsMinimized() ? ui::SHOW_STATE_MINIMIZED | |
| 1508 : saved_show_state_)); | |
| 1509 native_widget_->ShowWithWindowState(show_state); | |
| 1510 } | |
| 1511 | |
| 1503 namespace internal { | 1512 namespace internal { |
| 1504 | 1513 |
| 1505 //////////////////////////////////////////////////////////////////////////////// | 1514 //////////////////////////////////////////////////////////////////////////////// |
| 1506 // internal::NativeWidgetPrivate, NativeWidget implementation: | 1515 // internal::NativeWidgetPrivate, NativeWidget implementation: |
| 1507 | 1516 |
| 1508 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { | 1517 internal::NativeWidgetPrivate* NativeWidgetPrivate::AsNativeWidgetPrivate() { |
| 1509 return this; | 1518 return this; |
| 1510 } | 1519 } |
| 1511 | 1520 |
| 1512 } // namespace internal | 1521 } // namespace internal |
| 1513 } // namespace views | 1522 } // namespace views |
| OLD | NEW |