summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/accessibility/browser_views_accessibility_browsertest.cc2
-rw-r--r--chrome/browser/chromeos/frame/browser_view.cc6
-rw-r--r--chrome/browser/chromeos/frame/panel_controller.cc2
-rw-r--r--chrome/browser/chromeos/login/background_view.cc2
-rw-r--r--chrome/browser/chromeos/login/screen_locker.cc2
-rw-r--r--chrome/browser/chromeos/login/user_controller.cc2
-rw-r--r--chrome/browser/chromeos/login/user_controller_gtk.cc2
-rw-r--r--chrome/browser/chromeos/login/views_oobe_display.cc2
-rw-r--r--chrome/browser/chromeos/login/webui_login_display.cc2
-rw-r--r--chrome/browser/chromeos/native_dialog_window.cc2
-rw-r--r--chrome/browser/chromeos/notifications/notification_panel.cc2
-rw-r--r--chrome/browser/chromeos/options/network_config_view.cc2
-rw-r--r--chrome/browser/chromeos/panels/panel_scroller.cc2
-rw-r--r--chrome/browser/chromeos/status/input_method_menu_button.cc2
-rw-r--r--chrome/browser/ui/panels/panel_browser_view.cc2
-rw-r--r--chrome/browser/ui/touch/tabs/touch_tab_strip.cc2
-rw-r--r--chrome/browser/ui/views/accessibility_event_router_views.cc7
-rw-r--r--chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc2
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc8
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc4
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h2
-rw-r--r--chrome/browser/ui/views/browser_actions_container.cc4
-rw-r--r--chrome/browser/ui/views/browser_bubble_gtk.cc2
-rw-r--r--chrome/browser/ui/views/browser_dialogs.h3
-rw-r--r--chrome/browser/ui/views/bubble/bubble.cc2
-rw-r--r--chrome/browser/ui/views/first_run_search_engine_view.cc2
-rw-r--r--chrome/browser/ui/views/frame/browser_frame.cc4
-rw-r--r--chrome/browser/ui/views/frame/browser_frame.h2
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc36
-rw-r--r--chrome/browser/ui/views/frame/browser_view.h2
-rw-r--r--chrome/browser/ui/views/hung_renderer_view.cc2
-rw-r--r--chrome/browser/ui/views/infobars/after_translate_infobar.cc2
-rw-r--r--chrome/browser/ui/views/infobars/before_translate_infobar.cc2
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.cc2
-rw-r--r--chrome/browser/ui/views/menu_item_view_test.cc2
-rw-r--r--chrome/browser/ui/views/profile_menu_button.cc2
-rw-r--r--chrome/browser/ui/views/tabs/base_tab_strip.cc4
-rw-r--r--chrome/browser/ui/views/tabs/dragged_tab_controller.cc8
-rw-r--r--chrome/browser/ui/views/tabs/tab_strip.cc2
-rw-r--r--chrome/browser/ui/views/task_manager_view.cc4
-rw-r--r--chrome/browser/ui/views/toolbar_view.cc12
-rw-r--r--chrome/browser/ui/views/wrench_menu.cc2
-rw-r--r--views/controls/button/button_dropdown.cc4
-rw-r--r--views/desktop/desktop_window.cc2
-rw-r--r--views/mouse_watcher.cc6
-rw-r--r--views/view.cc11
-rw-r--r--views/view.h8
-rw-r--r--views/view_unittest.cc2
-rw-r--r--views/widget/native_widget.h11
-rw-r--r--views/widget/native_widget_delegate.h29
-rw-r--r--views/widget/native_widget_gtk.cc33
-rw-r--r--views/widget/native_widget_gtk.h3
-rw-r--r--views/widget/native_widget_test_utils_gtk.cc2
-rw-r--r--views/widget/native_widget_test_utils_win.cc2
-rw-r--r--views/widget/native_widget_view.cc2
-rw-r--r--views/widget/native_widget_views.cc14
-rw-r--r--views/widget/native_widget_views.h3
-rw-r--r--views/widget/native_widget_win.cc361
-rw-r--r--views/widget/native_widget_win.h35
-rw-r--r--views/widget/widget.cc149
-rw-r--r--views/widget/widget.h51
-rw-r--r--views/widget/widget_delegate.cc7
-rw-r--r--views/widget/widget_delegate.h5
-rw-r--r--views/window/client_view.cc10
-rw-r--r--views/window/client_view.h24
-rw-r--r--views/window/dialog_client_view.cc26
-rw-r--r--views/window/dialog_client_view.h12
-rw-r--r--views/window/dialog_delegate.cc4
-rw-r--r--views/window/dialog_delegate.h6
-rw-r--r--views/window/native_window.h16
-rw-r--r--views/window/native_window_delegate.h30
-rw-r--r--views/window/native_window_gtk.cc33
-rw-r--r--views/window/native_window_gtk.h7
-rw-r--r--views/window/native_window_views.cc14
-rw-r--r--views/window/native_window_views.h3
-rw-r--r--views/window/native_window_win.cc410
-rw-r--r--views/window/native_window_win.h66
-rw-r--r--views/window/non_client_view.cc6
-rw-r--r--views/window/window.cc153
-rw-r--r--views/window/window.h51
80 files changed, 797 insertions, 974 deletions
diff --git a/chrome/browser/accessibility/browser_views_accessibility_browsertest.cc b/chrome/browser/accessibility/browser_views_accessibility_browsertest.cc
index 3c46998..eaba29d 100644
--- a/chrome/browser/accessibility/browser_views_accessibility_browsertest.cc
+++ b/chrome/browser/accessibility/browser_views_accessibility_browsertest.cc
@@ -142,7 +142,7 @@ IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest,
// info.
IN_PROC_BROWSER_TEST_F(BrowserViewsAccessibilityTest, TestNonClientViewAccObj) {
views::View* non_client_view =
- GetBrowserView()->GetWindow()->non_client_view();
+ GetBrowserView()->GetWidget()->non_client_view();
TestViewAccessibilityObject(non_client_view,
UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)),
diff --git a/chrome/browser/chromeos/frame/browser_view.cc b/chrome/browser/chromeos/frame/browser_view.cc
index be541f3..b6d7e65 100644
--- a/chrome/browser/chromeos/frame/browser_view.cc
+++ b/chrome/browser/chromeos/frame/browser_view.cc
@@ -358,7 +358,7 @@ bool BrowserView::GetSavedWindowBounds(gfx::Rect* bounds) const {
// will snap us to full screen size. This results in an ugly
// resize/paint. To avoid this we always request a full screen size.
*bounds = views::Screen::GetMonitorWorkAreaNearestWindow(
- GTK_WIDGET(GetWindow()->GetNativeWindow()));
+ GTK_WIDGET(GetWidget()->GetNativeWindow()));
return true;
}
return ::BrowserView::GetSavedWindowBounds(bounds);
@@ -407,7 +407,7 @@ void BrowserView::ShowContextMenuForView(views::View* source,
if (hit_test == HTCAPTION || hit_test == HTNOWHERE) {
// rebuild menu so it reflects current application state
InitSystemMenu();
- system_menu_->RunMenuAt(source->GetWindow()->GetNativeWindow(), NULL,
+ system_menu_->RunMenuAt(source->GetWidget()->GetNativeWindow(), NULL,
gfx::Rect(p, gfx::Size(0,0)),
views::MenuItemView::TOPLEFT,
true);
@@ -427,7 +427,7 @@ Profile* BrowserView::GetProfile() const {
}
gfx::NativeWindow BrowserView::GetNativeWindow() const {
- return GetWindow()->GetNativeWindow();
+ return GetWidget()->GetNativeWindow();
}
bool BrowserView::ShouldOpenButtonOptions(
diff --git a/chrome/browser/chromeos/frame/panel_controller.cc b/chrome/browser/chromeos/frame/panel_controller.cc
index 2e82b3a..2bed72b 100644
--- a/chrome/browser/chromeos/frame/panel_controller.cc
+++ b/chrome/browser/chromeos/frame/panel_controller.cc
@@ -184,7 +184,7 @@ void PanelController::Init(bool initial_focus,
gfx::Rect title_bounds(0, 0, window_bounds.width(), kTitleHeight);
title_window_ = new views::Widget;
- views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
+ views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.transparent = true;
params.bounds = title_bounds;
title_window_->Init(params);
diff --git a/chrome/browser/chromeos/login/background_view.cc b/chrome/browser/chromeos/login/background_view.cc
index 5d2eb29..a253902 100644
--- a/chrome/browser/chromeos/login/background_view.cc
+++ b/chrome/browser/chromeos/login/background_view.cc
@@ -127,7 +127,7 @@ views::Widget* BackgroundView::CreateWindowContainingView(
const GURL& background_url,
BackgroundView** view) {
Widget* window = new Widget;
- Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
+ Widget::InitParams params(Widget::InitParams::TYPE_POPUP);
params.bounds = bounds;
window->Init(params);
*view = new BackgroundView();
diff --git a/chrome/browser/chromeos/login/screen_locker.cc b/chrome/browser/chromeos/login/screen_locker.cc
index 81133d3..06e6c6c 100644
--- a/chrome/browser/chromeos/login/screen_locker.cc
+++ b/chrome/browser/chromeos/login/screen_locker.cc
@@ -734,7 +734,7 @@ void ScreenLocker::Init() {
LockWindow* lock_window = new LockWindow();
lock_window_ = lock_window->GetWidget();
- views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
+ views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.bounds = init_bounds;
params.native_widget = lock_window;
lock_window_->Init(params);
diff --git a/chrome/browser/chromeos/login/user_controller.cc b/chrome/browser/chromeos/login/user_controller.cc
index d177faf..47fe14b 100644
--- a/chrome/browser/chromeos/login/user_controller.cc
+++ b/chrome/browser/chromeos/login/user_controller.cc
@@ -421,7 +421,7 @@ void UserController::CreateBorderWindow(int index,
}
border_window_ = new Widget;
- Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
+ Widget::InitParams params(Widget::InitParams::TYPE_POPUP);
params.transparent = true;
params.bounds = gfx::Rect(0, 0, width, height);
border_window_->Init(params);
diff --git a/chrome/browser/chromeos/login/user_controller_gtk.cc b/chrome/browser/chromeos/login/user_controller_gtk.cc
index fbcbb64..1c59130 100644
--- a/chrome/browser/chromeos/login/user_controller_gtk.cc
+++ b/chrome/browser/chromeos/login/user_controller_gtk.cc
@@ -58,7 +58,7 @@ class ClickNotifyingWidget : public NativeWidgetGtk {
views::Widget* InitWidget(views::WidgetDelegate* delegate,
views::NativeWidget* native_widget,
const gfx::Rect& bounds) {
- views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
+ views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.delegate = delegate;
params.transparent = true;
params.bounds = bounds;
diff --git a/chrome/browser/chromeos/login/views_oobe_display.cc b/chrome/browser/chromeos/login/views_oobe_display.cc
index 2350179a..5296f1f 100644
--- a/chrome/browser/chromeos/login/views_oobe_display.cc
+++ b/chrome/browser/chromeos/login/views_oobe_display.cc
@@ -216,7 +216,7 @@ views::Widget* ViewsOobeDisplay::CreateScreenWindow(
const gfx::Rect& bounds, bool initial_show) {
widget_ = new views::Widget;
views::Widget::InitParams widget_params(
- views::Widget::InitParams::TYPE_WINDOW);
+ views::Widget::InitParams::TYPE_POPUP);
// Window transparency makes background flicker through controls that
// are constantly updating its contents (like image view with video
// stream). Hence enabling double buffer.
diff --git a/chrome/browser/chromeos/login/webui_login_display.cc b/chrome/browser/chromeos/login/webui_login_display.cc
index da39596..336dcb5 100644
--- a/chrome/browser/chromeos/login/webui_login_display.cc
+++ b/chrome/browser/chromeos/login/webui_login_display.cc
@@ -64,7 +64,7 @@ void WebUILoginDisplay::Init(const std::vector<UserManager::User>& users,
DCHECK(delegate_);
users_ = users;
- views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
+ views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.bounds = background_bounds_;
login_window_ = new views::Widget;
diff --git a/chrome/browser/chromeos/native_dialog_window.cc b/chrome/browser/chromeos/native_dialog_window.cc
index 9e4665d..0bdd2e3 100644
--- a/chrome/browser/chromeos/native_dialog_window.cc
+++ b/chrome/browser/chromeos/native_dialog_window.cc
@@ -144,7 +144,7 @@ void NativeDialogHost::OnCheckResize(GtkWidget* widget) {
SizeToPreferredSize();
gfx::Size window_size = window()->non_client_view()->GetPreferredSize();
- gfx::Rect window_bounds = window()->GetBounds();
+ gfx::Rect window_bounds = window()->GetWindowScreenBounds();
window_bounds.set_width(window_size.width());
window_bounds.set_height(window_size.height());
window()->SetBoundsConstrained(window_bounds, NULL);
diff --git a/chrome/browser/chromeos/notifications/notification_panel.cc b/chrome/browser/chromeos/notifications/notification_panel.cc
index 81d55b0..197a865 100644
--- a/chrome/browser/chromeos/notifications/notification_panel.cc
+++ b/chrome/browser/chromeos/notifications/notification_panel.cc
@@ -426,7 +426,7 @@ void NotificationPanel::Show() {
panel_widget_ = new views::Widget;
// TODO(oshima): Using window because Popup widget behaves weird
// when resizing. This needs to be investigated.
- Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
+ Widget::InitParams params(Widget::InitParams::TYPE_POPUP);
// Enable double buffering because the panel has both pure views
// control and native controls (scroll bar).
params.double_buffer = true;
diff --git a/chrome/browser/chromeos/options/network_config_view.cc b/chrome/browser/chromeos/options/network_config_view.cc
index 97cedd4..1163d23 100644
--- a/chrome/browser/chromeos/options/network_config_view.cc
+++ b/chrome/browser/chromeos/options/network_config_view.cc
@@ -136,7 +136,7 @@ void NetworkConfigView::ShowAdvancedView() {
IDS_JOIN_WIFI_NETWORK_DIALOG_ADVANCED_WIDTH_CHARS,
IDS_JOIN_WIFI_NETWORK_DIALOG_ADVANCED_MINIMUM_HEIGHT_LINES);
// Get the new bounds with desired size at the same center point.
- gfx::Rect bounds = window()->GetBounds();
+ gfx::Rect bounds = window()->GetWindowScreenBounds();
int horiz_padding = bounds.width() - size.width();
int vert_padding = bounds.height() - size.height();
bounds.Inset(horiz_padding / 2, vert_padding / 2,
diff --git a/chrome/browser/chromeos/panels/panel_scroller.cc b/chrome/browser/chromeos/panels/panel_scroller.cc
index 5680da1..ee34659 100644
--- a/chrome/browser/chromeos/panels/panel_scroller.cc
+++ b/chrome/browser/chromeos/panels/panel_scroller.cc
@@ -81,7 +81,7 @@ PanelScroller::~PanelScroller() {
// static
PanelScroller* PanelScroller::CreateWindow() {
views::Widget* widget = new views::Widget;
- views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
+ views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.bounds = gfx::Rect(0, 0, 100, 800);
widget->Init(params);
diff --git a/chrome/browser/chromeos/status/input_method_menu_button.cc b/chrome/browser/chromeos/status/input_method_menu_button.cc
index 8b4fbc84..225627b 100644
--- a/chrome/browser/chromeos/status/input_method_menu_button.cc
+++ b/chrome/browser/chromeos/status/input_method_menu_button.cc
@@ -105,7 +105,7 @@ bool InputMethodMenuButton::WindowIsActive() {
return true;
}
BrowserWindow* active_window = active_browser->window();
- const views::Window* current_window = GetWindow();
+ const views::Widget* current_window = GetWidget();
if (!active_window || !current_window) {
// Can't get an active or current window. Just return true as well.
return true;
diff --git a/chrome/browser/ui/panels/panel_browser_view.cc b/chrome/browser/ui/panels/panel_browser_view.cc
index 6834ff4..840f39f 100644
--- a/chrome/browser/ui/panels/panel_browser_view.cc
+++ b/chrome/browser/ui/panels/panel_browser_view.cc
@@ -40,7 +40,7 @@ void PanelBrowserView::Init() {
BrowserView::Init();
GetWidget()->SetAlwaysOnTop(true);
- GetWindow()->non_client_view()->SetAccessibleName(
+ GetWidget()->non_client_view()->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
}
diff --git a/chrome/browser/ui/touch/tabs/touch_tab_strip.cc b/chrome/browser/ui/touch/tabs/touch_tab_strip.cc
index f914ef9..e2cc8bc 100644
--- a/chrome/browser/ui/touch/tabs/touch_tab_strip.cc
+++ b/chrome/browser/ui/touch/tabs/touch_tab_strip.cc
@@ -304,7 +304,7 @@ void TouchTabStrip::PaintChildren(gfx::Canvas* canvas) {
}
}
- if (GetWindow()->ShouldUseNativeFrame()) {
+ if (GetWidget()->ShouldUseNativeFrame()) {
// Make sure unselected tabs are somewhat transparent.
SkPaint paint;
paint.setColor(SkColorSetARGB(200, 255, 255, 255));
diff --git a/chrome/browser/ui/views/accessibility_event_router_views.cc b/chrome/browser/ui/views/accessibility_event_router_views.cc
index 34fb85e..84ecf45 100644
--- a/chrome/browser/ui/views/accessibility_event_router_views.cc
+++ b/chrome/browser/ui/views/accessibility_event_router_views.cc
@@ -126,11 +126,10 @@ void AccessibilityEventRouterViews::DispatchAccessibilityNotification(
// the most recent profile where accessibility events were sent, or
// the default profile.
Profile* profile = NULL;
- views::Window* window = view->GetWindow();
- if (window) {
+ views::Widget* widget = view->GetWidget();
+ if (widget) {
profile = reinterpret_cast<Profile*>(
- window->AsWidget()->native_widget()->GetNativeWindowProperty(
- Profile::kProfileKey));
+ widget->native_widget()->GetNativeWindowProperty(Profile::kProfileKey));
}
if (!profile)
profile = most_recent_profile_;
diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
index 9a411b7..510faf2 100644
--- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
+++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
@@ -704,7 +704,7 @@ void AutocompletePopupContentsView::UserPressedOptIn(bool opt_in) {
counter->Hide();
if (opt_in) {
browser::ShowInstantConfirmDialogIfNecessary(
- location_bar_->GetWindow()->GetNativeWindow(), model_->profile());
+ location_bar_->GetWidget()->GetNativeWindow(), model_->profile());
}
UpdatePopupAppearance();
}
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
index d62e0a9..7f1ca1d 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc
@@ -1061,7 +1061,7 @@ void BookmarkBarView::RunMenu(views::View* view, const gfx::Point& pt) {
}
bookmark_menu_ = new BookmarkMenuController(
- profile_, page_navigator_, GetWindow()->GetNativeWindow(), node,
+ profile_, page_navigator_, GetWidget()->GetNativeWindow(), node,
start_index);
bookmark_menu_->set_observer(this);
bookmark_menu_->RunMenuAt(this, false);
@@ -1095,7 +1095,7 @@ void BookmarkBarView::ButtonPressed(views::Button* sender,
page_navigator_->OpenURL(node->GetURL(), GURL(),
disposition_from_event_flags, PageTransition::AUTO_BOOKMARK);
} else {
- bookmark_utils::OpenAll(GetWindow()->GetNativeWindow(), profile_,
+ bookmark_utils::OpenAll(GetWidget()->GetNativeWindow(), profile_,
page_navigator_, node, disposition_from_event_flags);
}
UserMetrics::RecordAction(UserMetricsAction("ClickedBookmarkBarURLButton"));
@@ -1136,7 +1136,7 @@ void BookmarkBarView::ShowContextMenuForView(View* source,
bool close_on_remove =
(parent == profile_->GetBookmarkModel()->other_node() &&
parent->child_count() == 1);
- BookmarkContextMenu controller(GetWindow()->GetNativeWindow(), profile_,
+ BookmarkContextMenu controller(GetWidget()->GetNativeWindow(), profile_,
navigator, parent, nodes, close_on_remove);
controller.RunMenuAt(p);
}
@@ -1398,7 +1398,7 @@ void BookmarkBarView::ShowDropFolderForNode(const BookmarkNode* node) {
drop_info_->is_menu_showing = true;
bookmark_drop_menu_ = new BookmarkMenuController(
- profile_, page_navigator_, GetWindow()->GetNativeWindow(), node,
+ profile_, page_navigator_, GetWidget()->GetNativeWindow(), node,
start_index);
bookmark_drop_menu_->set_observer(this);
bookmark_drop_menu_->RunMenuAt(this, true);
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
index b1cc21b..736a2f1 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
@@ -54,7 +54,7 @@ static SkBitmap* kCloseImage = NULL;
namespace browser {
-void ShowBookmarkBubbleView(views::Window* parent,
+void ShowBookmarkBubbleView(views::Widget* parent,
const gfx::Rect& bounds,
BubbleDelegate* delegate,
Profile* profile,
@@ -79,7 +79,7 @@ bool IsBookmarkBubbleViewShowing() {
BookmarkBubbleView* BookmarkBubbleView::bookmark_bubble_ = NULL;
// static
-void BookmarkBubbleView::Show(views::Window* parent,
+void BookmarkBubbleView::Show(views::Widget* parent,
const gfx::Rect& bounds,
BubbleDelegate* delegate,
Profile* profile,
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h
index 433b198..45417b2 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h
@@ -36,7 +36,7 @@ class BookmarkBubbleView : public views::View,
public views::Combobox::Listener,
public BubbleDelegate {
public:
- static void Show(views::Window* window,
+ static void Show(views::Widget* widget,
const gfx::Rect& bounds,
BubbleDelegate* delegate,
Profile* profile,
diff --git a/chrome/browser/ui/views/browser_actions_container.cc b/chrome/browser/ui/views/browser_actions_container.cc
index ebec34e..6be1732 100644
--- a/chrome/browser/ui/views/browser_actions_container.cc
+++ b/chrome/browser/ui/views/browser_actions_container.cc
@@ -710,7 +710,7 @@ void BrowserActionsContainer::RunMenu(View* source, const gfx::Point& pt) {
overflow_menu_ = new BrowserActionOverflowMenuController(
this, chevron_, browser_action_views_, VisibleBrowserActions());
overflow_menu_->set_observer(this);
- overflow_menu_->RunMenu(GetWindow()->GetNativeWindow(), false);
+ overflow_menu_->RunMenu(GetWidget()->GetNativeWindow(), false);
}
}
@@ -1023,7 +1023,7 @@ void BrowserActionsContainer::ShowDropFolder() {
overflow_menu_ = new BrowserActionOverflowMenuController(
this, chevron_, browser_action_views_, VisibleBrowserActions());
overflow_menu_->set_observer(this);
- overflow_menu_->RunMenu(GetWindow()->GetNativeWindow(), true);
+ overflow_menu_->RunMenu(GetWidget()->GetNativeWindow(), true);
}
void BrowserActionsContainer::SetDropIndicator(int x_pos) {
diff --git a/chrome/browser/ui/views/browser_bubble_gtk.cc b/chrome/browser/ui/views/browser_bubble_gtk.cc
index 37d7c9d..090eb99 100644
--- a/chrome/browser/ui/views/browser_bubble_gtk.cc
+++ b/chrome/browser/ui/views/browser_bubble_gtk.cc
@@ -95,7 +95,7 @@ void BrowserBubble::InitPopup(const gfx::Insets& content_margins) {
// TODO(port)
BubbleWidget* bubble_widget = new BubbleWidget(this, content_margins);
popup_ = bubble_widget->GetWidget();
- views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW);
+ views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.transparent = true;
params.parent = frame_->GetNativeView();
params.native_widget = bubble_widget;
diff --git a/chrome/browser/ui/views/browser_dialogs.h b/chrome/browser/ui/views/browser_dialogs.h
index fb6ae34..21dda5c 100644
--- a/chrome/browser/ui/views/browser_dialogs.h
+++ b/chrome/browser/ui/views/browser_dialogs.h
@@ -34,13 +34,14 @@ class Size;
}
namespace views {
+class Widget;
class Window;
}
namespace browser {
// Shows or hides the global bookmark bubble for the star button.
-void ShowBookmarkBubbleView(views::Window* parent,
+void ShowBookmarkBubbleView(views::Widget* parent,
const gfx::Rect& bounds,
BubbleDelegate* delegate,
Profile* profile,
diff --git a/chrome/browser/ui/views/bubble/bubble.cc b/chrome/browser/ui/views/bubble/bubble.cc
index df1a022..91d077b 100644
--- a/chrome/browser/ui/views/bubble/bubble.cc
+++ b/chrome/browser/ui/views/bubble/bubble.cc
@@ -134,7 +134,7 @@ Bubble::Bubble()
show_status_(kOpen),
fade_away_on_close_(false),
#if defined(TOOLKIT_USES_GTK)
- type_(views::Widget::InitParams::TYPE_WINDOW),
+ type_(views::Widget::InitParams::TYPE_POPUP),
#endif
#if defined(OS_CHROMEOS)
show_while_screen_is_locked_(false),
diff --git a/chrome/browser/ui/views/first_run_search_engine_view.cc b/chrome/browser/ui/views/first_run_search_engine_view.cc
index 56238b2..f554420 100644
--- a/chrome/browser/ui/views/first_run_search_engine_view.cc
+++ b/chrome/browser/ui/views/first_run_search_engine_view.cc
@@ -349,7 +349,7 @@ void FirstRunSearchEngineView::SetupControls() {
void FirstRunSearchEngineView::Layout() {
// Disable the close button.
- GetWindow()->EnableClose(false);
+ GetWidget()->EnableClose(false);
gfx::Size pref_size = background_image_->GetPreferredSize();
background_image_->SetBounds(0, 0, GetPreferredSize().width(),
diff --git a/chrome/browser/ui/views/frame/browser_frame.cc b/chrome/browser/ui/views/frame/browser_frame.cc
index f50b539..1302436 100644
--- a/chrome/browser/ui/views/frame/browser_frame.cc
+++ b/chrome/browser/ui/views/frame/browser_frame.cc
@@ -124,7 +124,7 @@ ThemeProvider* BrowserFrame::GetThemeProvider() const {
browser_view_->browser()->profile());
}
-void BrowserFrame::OnNativeWindowActivationChanged(bool active) {
+void BrowserFrame::OnNativeWidgetActivationChanged(bool active) {
if (active) {
// When running under remote desktop, if the remote desktop client is not
// active on the users desktop, then none of the windows contained in the
@@ -134,6 +134,6 @@ void BrowserFrame::OnNativeWindowActivationChanged(bool active) {
// treated as such by the rest of Chrome.
BrowserList::SetLastActive(browser_view_->browser());
}
- Window::OnNativeWindowActivationChanged(active);
+ Window::OnNativeWidgetActivationChanged(active);
}
diff --git a/chrome/browser/ui/views/frame/browser_frame.h b/chrome/browser/ui/views/frame/browser_frame.h
index 5f661f4..2c5dc35 100644
--- a/chrome/browser/ui/views/frame/browser_frame.h
+++ b/chrome/browser/ui/views/frame/browser_frame.h
@@ -75,7 +75,7 @@ class BrowserFrame : public views::Window {
virtual bool GetAccelerator(int command_id,
ui::Accelerator* accelerator) OVERRIDE;
virtual ui::ThemeProvider* GetThemeProvider() const OVERRIDE;
- virtual void OnNativeWindowActivationChanged(bool active) OVERRIDE;
+ virtual void OnNativeWidgetActivationChanged(bool active) OVERRIDE;
private:
NativeBrowserFrame* native_browser_frame_;
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 260b954..55b9fca 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -254,8 +254,8 @@ class ResizeCorner : public views::View {
}
virtual void OnPaint(gfx::Canvas* canvas) {
- views::Window* window = GetWindow();
- if (!window || (window->IsMaximized() || window->IsFullscreen()))
+ views::Widget* widget = GetWidget();
+ if (!widget || (widget->IsMaximized() || widget->IsFullscreen()))
return;
SkBitmap* bitmap = ResourceBundle::GetSharedInstance().GetBitmapNamed(
@@ -274,8 +274,8 @@ class ResizeCorner : public views::View {
}
virtual gfx::Size GetPreferredSize() {
- views::Window* window = GetWindow();
- return (!window || window->IsMaximized() || window->IsFullscreen()) ?
+ views::Widget* widget = GetWidget();
+ return (!widget || widget->IsMaximized() || widget->IsFullscreen()) ?
gfx::Size() : GetSize();
}
@@ -291,13 +291,6 @@ class ResizeCorner : public views::View {
}
private:
- // Returns the NativeWindowWin we're displayed in. Returns NULL if we're not
- // currently in a window.
- views::Window* GetWindow() {
- views::Widget* widget = GetWidget();
- return widget ? widget->GetContainingWindow() : NULL;
- }
-
DISALLOW_COPY_AND_ASSIGN(ResizeCorner);
};
@@ -748,11 +741,11 @@ void BrowserView::SetStarredState(bool is_starred) {
}
gfx::Rect BrowserView::GetRestoredBounds() const {
- return frame_->GetNormalBounds();
+ return frame_->GetRestoredBounds();
}
gfx::Rect BrowserView::GetBounds() const {
- return frame_->GetBounds();
+ return frame_->GetWindowScreenBounds();
}
bool BrowserView::IsMaximized() const {
@@ -1001,7 +994,7 @@ void BrowserView::ConfirmSetDefaultSearchProvider(
void BrowserView::ConfirmAddSearchProvider(const TemplateURL* template_url,
Profile* profile) {
- browser::EditSearchEngine(GetWindow()->GetNativeWindow(), template_url, NULL,
+ browser::EditSearchEngine(GetWidget()->GetNativeWindow(), template_url, NULL,
profile);
}
@@ -1014,12 +1007,12 @@ void BrowserView::ShowAboutChromeDialog() {
}
views::Window* BrowserView::DoShowAboutChromeDialog() {
- return browser::ShowAboutChromeView(GetWindow()->GetNativeWindow(),
+ return browser::ShowAboutChromeView(GetWidget()->GetNativeWindow(),
browser_->profile());
}
void BrowserView::ShowUpdateChromeDialog() {
- UpdateRecommendedMessageBox::ShowMessageBox(GetWindow()->GetNativeWindow());
+ UpdateRecommendedMessageBox::ShowMessageBox(GetWidget()->GetNativeWindow());
}
void BrowserView::ShowCompactLocationBarUnderSelectedTab() {
@@ -1133,7 +1126,7 @@ void BrowserView::ShowPageInfo(Profile* profile,
const GURL& url,
const NavigationEntry::SSLStatus& ssl,
bool show_history) {
- gfx::NativeWindow parent = GetWindow()->GetNativeWindow();
+ gfx::NativeWindow parent = GetWidget()->GetNativeWindow();
browser::ShowPageInfoBubble(parent, profile, url, ssl, show_history);
}
@@ -1561,7 +1554,7 @@ bool BrowserView::ExecuteWindowsCommand(int command_id) {
// This function handles WM_SYSCOMMAND, WM_APPCOMMAND, and WM_COMMAND.
#if defined(OS_WIN)
if (command_id == IDC_DEBUG_FRAME_TOGGLE)
- GetWindow()->DebugToggleFrameType();
+ GetWidget()->DebugToggleFrameType();
#endif
// Translate WM_APPCOMMAND command ids into a command id that the browser
// knows how to handle.
@@ -1635,8 +1628,7 @@ views::View* BrowserView::GetContentsView() {
return contents_container_;
}
-views::ClientView* BrowserView::CreateClientView(views::Window* window) {
- set_window(window);
+views::ClientView* BrowserView::CreateClientView(views::Widget* widget) {
return this;
}
@@ -2568,7 +2560,7 @@ void BrowserView::ProcessTabSelected(TabContentsWrapper* new_contents,
// etc not result in sad tab.
new_contents->tab_contents()->DidBecomeSelected();
if (BrowserList::GetLastActive() == browser_ &&
- !browser_->tabstrip_model()->closing_all() && GetWindow()->IsVisible()) {
+ !browser_->tabstrip_model()->closing_all() && GetWidget()->IsVisible()) {
// We only restore focus if our window is visible, to avoid invoking blur
// handlers when we are eventually shown.
new_contents->view()->RestoreFocus();
@@ -2603,7 +2595,7 @@ BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
// so we don't need to do anything with the pointer.
BrowserView* view = new BrowserView(browser);
(new BrowserFrame(view))->InitBrowserFrame();
- view->GetWindow()->non_client_view()->SetAccessibleName(
+ view->GetWidget()->non_client_view()->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME));
return view;
}
diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h
index 24b585e..f45afeb 100644
--- a/chrome/browser/ui/views/frame/browser_view.h
+++ b/chrome/browser/ui/views/frame/browser_view.h
@@ -394,7 +394,7 @@ class BrowserView : public BrowserBubbleHost,
virtual bool GetSavedWindowBounds(gfx::Rect* bounds) const OVERRIDE;
virtual bool GetSavedMaximizedState(bool* maximized) const OVERRIDE;
virtual views::View* GetContentsView() OVERRIDE;
- virtual views::ClientView* CreateClientView(views::Window* window) OVERRIDE;
+ virtual views::ClientView* CreateClientView(views::Widget* widget) OVERRIDE;
virtual void OnWindowActivationChanged(bool active) OVERRIDE;
virtual void OnWindowBeginUserBoundsChange() OVERRIDE;
virtual void OnWidgetMove() OVERRIDE;
diff --git a/chrome/browser/ui/views/hung_renderer_view.cc b/chrome/browser/ui/views/hung_renderer_view.cc
index f1edc4e..652ec2b 100644
--- a/chrome/browser/ui/views/hung_renderer_view.cc
+++ b/chrome/browser/ui/views/hung_renderer_view.cc
@@ -447,7 +447,7 @@ gfx::Rect HungRendererDialogView::GetDisplayBounds(
RECT contents_bounds_rect;
GetWindowRect(contents_hwnd, &contents_bounds_rect);
gfx::Rect contents_bounds(contents_bounds_rect);
- gfx::Rect window_bounds = window()->GetBounds();
+ gfx::Rect window_bounds = window()->GetWindowScreenBounds();
int window_x = contents_bounds.x() +
(contents_bounds.width() - window_bounds.width()) / 2;
diff --git a/chrome/browser/ui/views/infobars/after_translate_infobar.cc b/chrome/browser/ui/views/infobars/after_translate_infobar.cc
index 5039615..2355093 100644
--- a/chrome/browser/ui/views/infobars/after_translate_infobar.cc
+++ b/chrome/browser/ui/views/infobars/after_translate_infobar.cc
@@ -178,6 +178,6 @@ void AfterTranslateInfoBar::RunMenu(View* source, const gfx::Point& pt) {
views::MenuModelAdapter menu_model_adapter(menu_model);
views::MenuItemView menu(&menu_model_adapter);
menu_model_adapter.BuildMenu(&menu);
- menu.RunMenuAt(source->GetWindow()->GetNativeWindow(), NULL,
+ menu.RunMenuAt(source->GetWidget()->GetNativeWindow(), NULL,
gfx::Rect(pt, gfx::Size()), views::MenuItemView::TOPRIGHT, true);
}
diff --git a/chrome/browser/ui/views/infobars/before_translate_infobar.cc b/chrome/browser/ui/views/infobars/before_translate_infobar.cc
index 88ca05d..4e89da5 100644
--- a/chrome/browser/ui/views/infobars/before_translate_infobar.cc
+++ b/chrome/browser/ui/views/infobars/before_translate_infobar.cc
@@ -199,6 +199,6 @@ void BeforeTranslateInfoBar::RunMenu(View* source, const gfx::Point& pt) {
views::MenuModelAdapter menu_model_adapter(menu_model);
views::MenuItemView menu(&menu_model_adapter);
menu_model_adapter.BuildMenu(&menu);
- menu.RunMenuAt(source->GetWindow()->GetNativeWindow(), NULL,
+ menu.RunMenuAt(source->GetWidget()->GetNativeWindow(), NULL,
gfx::Rect(pt, gfx::Size()), views::MenuItemView::TOPRIGHT, true);
}
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index 8a29a25..d882873 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -394,7 +394,7 @@ void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) {
gfx::Point origin(screen_bounds.origin());
views::View::ConvertPointToScreen(star_view_, &origin);
screen_bounds.set_origin(origin);
- browser::ShowBookmarkBubbleView(GetWindow(), screen_bounds, star_view_,
+ browser::ShowBookmarkBubbleView(GetWidget(), screen_bounds, star_view_,
profile_, url, newly_bookmarked);
}
diff --git a/chrome/browser/ui/views/menu_item_view_test.cc b/chrome/browser/ui/views/menu_item_view_test.cc
index 33ce6b6..c3f27d3 100644
--- a/chrome/browser/ui/views/menu_item_view_test.cc
+++ b/chrome/browser/ui/views/menu_item_view_test.cc
@@ -68,7 +68,7 @@ class MenuItemViewTestBase : public ViewEventTestBase,
views::View::ConvertPointToScreen(source, &screen_location);
gfx::Rect bounds(screen_location, source->size());
menu_->RunMenuAt(
- source->GetWindow()->GetNativeWindow(),
+ source->GetWidget()->GetNativeWindow(),
button_,
bounds,
views::MenuItemView::TOPLEFT,
diff --git a/chrome/browser/ui/views/profile_menu_button.cc b/chrome/browser/ui/views/profile_menu_button.cc
index ae7a123..684226f 100644
--- a/chrome/browser/ui/views/profile_menu_button.cc
+++ b/chrome/browser/ui/views/profile_menu_button.cc
@@ -55,7 +55,7 @@ void ProfileMenuButton::RunMenu(views::View* source, const gfx::Point &pt) {
menu_model_adapter.BuildMenu(&menu);
gfx::Point menu_point(pt.x(), pt.y() + kMenuDisplayOffset);
- menu.RunMenuAt(source->GetWindow()->GetNativeWindow(), NULL,
+ menu.RunMenuAt(source->GetWidget()->GetNativeWindow(), NULL,
gfx::Rect(pt, gfx::Size(0, 0)),
views::MenuItemView::TOPRIGHT,
true);
diff --git a/chrome/browser/ui/views/tabs/base_tab_strip.cc b/chrome/browser/ui/views/tabs/base_tab_strip.cc
index 7b5c683..a6de3a9 100644
--- a/chrome/browser/ui/views/tabs/base_tab_strip.cc
+++ b/chrome/browser/ui/views/tabs/base_tab_strip.cc
@@ -136,7 +136,7 @@ void BaseTabStrip::AddTabAt(int model_index, const TabRendererData& data) {
// Don't animate the first tab, it looks weird, and don't animate anything
// if the containing window isn't visible yet.
- if (tab_count() > 1 && GetWindow() && GetWindow()->IsVisible())
+ if (tab_count() > 1 && GetWidget() && GetWidget()->IsVisible())
StartInsertTabAnimation(model_index);
else
DoLayout();
@@ -160,7 +160,7 @@ void BaseTabStrip::SetTabData(int model_index, const TabRendererData& data) {
tab->SetData(data);
if (mini_state_changed) {
- if (GetWindow() && GetWindow()->IsVisible())
+ if (GetWidget() && GetWidget()->IsVisible())
StartMiniTabAnimation();
else
DoLayout();
diff --git a/chrome/browser/ui/views/tabs/dragged_tab_controller.cc b/chrome/browser/ui/views/tabs/dragged_tab_controller.cc
index 88c5086..e42f8e8 100644
--- a/chrome/browser/ui/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/ui/views/tabs/dragged_tab_controller.cc
@@ -926,7 +926,7 @@ void DraggedTabController::Attach(BaseTabStrip* attached_tabstrip,
}
// Move the corresponding window to the front.
- attached_tabstrip_->GetWindow()->Activate();
+ attached_tabstrip_->GetWidget()->Activate();
}
void DraggedTabController::Detach() {
@@ -1275,8 +1275,8 @@ void DraggedTabController::CompleteDrag() {
}
}
// Compel the model to construct a new window for the detached TabContents.
- views::Window* window = source_tabstrip_->GetWindow();
- gfx::Rect window_bounds(window->GetNormalBounds());
+ views::Widget* widget = source_tabstrip_->GetWidget();
+ gfx::Rect window_bounds(widget->GetRestoredBounds());
window_bounds.set_origin(GetWindowCreatePoint());
// When modifying the following if statement, please make sure not to
// introduce issue listed in http://crbug.com/6223 comment #11.
@@ -1290,7 +1290,7 @@ void DraggedTabController::CompleteDrag() {
Browser* new_browser =
GetModel(source_tabstrip_)->delegate()->CreateNewStripWithContents(
drag_data_[0].contents, window_bounds, dock_info_,
- window->IsMaximized());
+ widget->IsMaximized());
TabStripModel* new_model = new_browser->tabstrip_model();
new_model->SetTabPinned(
new_model->GetIndexOfTabContents(drag_data_[0].contents),
diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc
index 990bcec..04f7362 100644
--- a/chrome/browser/ui/views/tabs/tab_strip.cc
+++ b/chrome/browser/ui/views/tabs/tab_strip.cc
@@ -299,7 +299,7 @@ void TabStrip::PaintChildren(gfx::Canvas* canvas) {
}
}
- if (GetWindow()->ShouldUseNativeFrame()) {
+ if (GetWidget()->ShouldUseNativeFrame()) {
bool multiple_tabs_selected = (!selected_tabs.empty() ||
tabs_dragging.size() > 1);
// Make sure non-active tabs are somewhat transparent.
diff --git a/chrome/browser/ui/views/task_manager_view.cc b/chrome/browser/ui/views/task_manager_view.cc
index 91ab0ad..df8cbaf 100644
--- a/chrome/browser/ui/views/task_manager_view.cc
+++ b/chrome/browser/ui/views/task_manager_view.cc
@@ -613,7 +613,7 @@ bool TaskManagerView::ExecuteWindowsCommand(int command_id) {
is_always_on_top_ = !is_always_on_top_;
// Change the menu check state.
- HMENU system_menu = GetSystemMenu(GetWindow()->GetNativeWindow(), FALSE);
+ HMENU system_menu = GetSystemMenu(GetWidget()->GetNativeWindow(), FALSE);
MENUITEMINFO menu_info;
memset(&menu_info, 0, sizeof(MENUITEMINFO));
menu_info.cbSize = sizeof(MENUITEMINFO);
@@ -738,7 +738,7 @@ void TaskManagerView::AddAlwaysOnTopSystemMenuItem() {
UTF16ToWide(l10n_util::GetStringUTF16(IDS_ALWAYS_ON_TOP));
// Let's insert a menu to the window.
- HMENU system_menu = ::GetSystemMenu(GetWindow()->GetNativeWindow(), FALSE);
+ HMENU system_menu = ::GetSystemMenu(GetWidget()->GetNativeWindow(), FALSE);
int index = ::GetMenuItemCount(system_menu) - 1;
if (index < 0) {
// Paranoia check.
diff --git a/chrome/browser/ui/views/toolbar_view.cc b/chrome/browser/ui/views/toolbar_view.cc
index 281993e..9721b0b 100644
--- a/chrome/browser/ui/views/toolbar_view.cc
+++ b/chrome/browser/ui/views/toolbar_view.cc
@@ -462,7 +462,7 @@ gfx::Size ToolbarView::GetPreferredSize() {
}
int vertical_spacing = PopupTopSpacing() +
- (GetWindow()->ShouldUseNativeFrame() ?
+ (GetWidget()->ShouldUseNativeFrame() ?
kPopupBottomSpacingGlass : kPopupBottomSpacingNonGlass);
return gfx::Size(0, location_bar_->GetPreferredSize().height() +
vertical_spacing);
@@ -562,7 +562,7 @@ void ToolbarView::OnPaint(gfx::Canvas* canvas) {
// it from the content area. For non-glass, the NonClientView draws the
// toolbar background below the location bar for us.
// NOTE: Keep this in sync with BrowserView::GetInfoBarSeparatorColor()!
- if (GetWindow()->ShouldUseNativeFrame())
+ if (GetWidget()->ShouldUseNativeFrame())
canvas->FillRectInt(SK_ColorBLACK, 0, height() - 1, width(), 1);
}
@@ -633,16 +633,16 @@ bool ToolbarView::ShouldShowIncompatibilityWarning() {
}
int ToolbarView::PopupTopSpacing() const {
- // TODO(beng): For some reason GetWindow() returns NULL here in some
+ // TODO(beng): For some reason GetWidget() returns NULL here in some
// unidentified circumstances on ChromeOS. This means GetWidget()
// succeeded but we were (probably) unable to locate a
// NativeWidgetGtk* on it using
// NativeWidget::GetNativeWidgetForNativeView.
// I am throwing in a NULL check for now to stop the hurt, but
// it's possible the crash may just show up somewhere else.
- const views::Window* window = GetWindow();
- DCHECK(window) << "If you hit this please talk to beng";
- return window && window->ShouldUseNativeFrame() ?
+ const views::Widget* widget = GetWidget();
+ DCHECK(widget) << "If you hit this please talk to beng";
+ return widget && widget->ShouldUseNativeFrame() ?
0 : kPopupTopSpacingNonGlass;
}
diff --git a/chrome/browser/ui/views/wrench_menu.cc b/chrome/browser/ui/views/wrench_menu.cc
index 7af0292..7e7023a 100644
--- a/chrome/browser/ui/views/wrench_menu.cc
+++ b/chrome/browser/ui/views/wrench_menu.cc
@@ -602,7 +602,7 @@ void WrenchMenu::RunMenu(views::MenuButton* host) {
views::View::ConvertPointToScreen(host, &screen_loc);
gfx::Rect bounds(screen_loc, host->size());
UserMetrics::RecordAction(UserMetricsAction("ShowAppMenu"));
- root_->RunMenuAt(host->GetWindow()->GetNativeWindow(), host, bounds,
+ root_->RunMenuAt(host->GetWidget()->GetNativeWindow(), host, bounds,
MenuItemView::TOPRIGHT, true);
if (bookmark_menu_delegate_.get()) {
BookmarkModel* model = browser_->profile()->GetBookmarkModel();
diff --git a/views/controls/button/button_dropdown.cc b/views/controls/button/button_dropdown.cc
index 6590570..0eb6d2f 100644
--- a/views/controls/button/button_dropdown.cc
+++ b/views/controls/button/button_dropdown.cc
@@ -158,14 +158,14 @@ void ButtonDropDown::ShowDropDownMenu(gfx::NativeView window) {
MenuItemView menu(&menu_delegate);
menu_delegate.BuildMenu(&menu);
- menu.RunMenuAt(GetWindow()->GetNativeWindow(), NULL,
+ menu.RunMenuAt(GetWidget()->GetNativeWindow(), NULL,
gfx::Rect(menu_position, gfx::Size(0, 0)),
views::MenuItemView::TOPLEFT,
true);
} else {
MenuDelegate menu_delegate;
MenuItemView menu(&menu_delegate);
- menu.RunMenuAt(GetWindow()->GetNativeWindow(), NULL,
+ menu.RunMenuAt(GetWidget()->GetNativeWindow(), NULL,
gfx::Rect(menu_position, gfx::Size(0, 0)),
views::MenuItemView::TOPLEFT,
true);
diff --git a/views/desktop/desktop_window.cc b/views/desktop/desktop_window.cc
index 15c9860..b59fc5d 100644
--- a/views/desktop/desktop_window.cc
+++ b/views/desktop/desktop_window.cc
@@ -172,7 +172,7 @@ void DesktopWindow::CreateTestWindow(const std::wstring& title,
if (rotate) {
ui::Transform transform;
transform.SetRotate(90.0f);
- transform.SetTranslateX(window->GetBounds().width());
+ transform.SetTranslateX(window->GetWindowScreenBounds().width());
nwv->GetView()->SetTransform(transform);
}
}
diff --git a/views/mouse_watcher.cc b/views/mouse_watcher.cc
index 990e2f5..f5a4726 100644
--- a/views/mouse_watcher.cc
+++ b/views/mouse_watcher.cc
@@ -96,12 +96,12 @@ class MouseWatcher::Observer : public MessageLoopForUI::Observer {
// Returns true if the mouse is over the view's window.
bool IsMouseOverWindow() {
- Window* window = view()->GetWindow();
- if (!window)
+ Widget* widget = view()->GetWidget();
+ if (!widget)
return false;
return Screen::GetWindowAtCursorScreenPoint() ==
- window->GetNativeWindow();
+ widget->GetNativeWindow();
}
// Called from the message loop observer when a mouse movement has occurred.
diff --git a/views/view.cc b/views/view.cc
index c9fabb0..45c9a28 100644
--- a/views/view.cc
+++ b/views/view.cc
@@ -216,17 +216,6 @@ int View::GetIndexOf(const View* view) const {
}
// TODO(beng): remove
-const Window* View::GetWindow() const {
- const Widget* widget = GetWidget();
- return widget ? widget->GetContainingWindow() : NULL;
-}
-
-// TODO(beng): remove
-Window* View::GetWindow() {
- return const_cast<Window*>(const_cast<const View*>(this)->GetWindow());
-}
-
-// TODO(beng): remove
bool View::ContainsNativeView(gfx::NativeView native_view) const {
for (int i = 0, count = child_count(); i < count; ++i) {
if (GetChildViewAt(i)->ContainsNativeView(native_view))
diff --git a/views/view.h b/views/view.h
index 0f87437..caf0ea7 100644
--- a/views/view.h
+++ b/views/view.h
@@ -222,14 +222,6 @@ class View : public AcceleratorTarget {
// Returns the index of |view|, or -1 if |view| is not a child of this view.
int GetIndexOf(const View* view) const;
- // TODO(beng): REMOVE (Views need not know about Window).
- // Gets the Widget that most closely contains this View, if any.
- // NOTE: almost all views displayed on screen have a Widget, but not
- // necessarily a Window. This is due to widgets being able to create top
- // level windows (as is done for popups, bubbles and menus).
- virtual const Window* GetWindow() const;
- virtual Window* GetWindow();
-
// TODO(beng): REMOVE (TBD)
// Returns true if the native view |native_view| is contained in the view
// hierarchy beneath this view.
diff --git a/views/view_unittest.cc b/views/view_unittest.cc
index 8924acf..b72f13774 100644
--- a/views/view_unittest.cc
+++ b/views/view_unittest.cc
@@ -730,7 +730,7 @@ gfx::Point ConvertPointToView(View* view, const gfx::Point& p) {
TEST_F(ViewTest, HitTestMasks) {
Widget* widget = new Widget;
- widget->Init(Widget::InitParams(Widget::InitParams::TYPE_WINDOW));
+ widget->Init(Widget::InitParams(Widget::InitParams::TYPE_POPUP));
View* root_view = widget->GetRootView();
root_view->SetBounds(0, 0, 500, 500);
diff --git a/views/widget/native_widget.h b/views/widget/native_widget.h
index 6cb4147..3534f26 100644
--- a/views/widget/native_widget.h
+++ b/views/widget/native_widget.h
@@ -152,9 +152,11 @@ class NativeWidget {
virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) = 0;
virtual void SetAccessibleState(ui::AccessibilityTypes::State state) = 0;
- protected:
- friend class Widget;
- friend class NativeWidgetViews;
+ enum ShowState {
+ SHOW_RESTORED,
+ SHOW_MAXIMIZED,
+ SHOW_INACTIVE
+ };
// Returns a handle for the underlying native widget that can be used for
// accelerated drawing.
@@ -164,6 +166,7 @@ class NativeWidget {
// See method documentation in Widget.
virtual gfx::Rect GetWindowScreenBounds() const = 0;
virtual gfx::Rect GetClientAreaScreenBounds() const = 0;
+ virtual gfx::Rect GetRestoredBounds() const = 0;
virtual void SetBounds(const gfx::Rect& bounds) = 0;
virtual void SetSize(const gfx::Size& size) = 0;
virtual void SetBoundsConstrained(const gfx::Rect& bounds,
@@ -172,8 +175,10 @@ class NativeWidget {
virtual void SetShape(gfx::NativeRegion shape) = 0;
virtual void Close() = 0;
virtual void CloseNow() = 0;
+ virtual void EnableClose(bool enable) = 0;
virtual void Show() = 0;
virtual void Hide() = 0;
+ virtual void ShowNativeWidget(ShowState state) = 0;
virtual bool IsVisible() const = 0;
virtual void Activate() = 0;
virtual void Deactivate() = 0;
diff --git a/views/widget/native_widget_delegate.h b/views/widget/native_widget_delegate.h
index d39bd58..2417b9e 100644
--- a/views/widget/native_widget_delegate.h
+++ b/views/widget/native_widget_delegate.h
@@ -24,6 +24,15 @@ class NativeWidgetDelegate {
public:
virtual ~NativeWidgetDelegate() {}
+ // Returns true if the window can be activated.
+ virtual bool CanActivate() const = 0;
+
+ virtual bool IsInactiveRenderingDisabled() const = 0;
+ virtual void EnableInactiveRendering() = 0;
+
+ // Called when the activation state of a window has changed.
+ virtual void OnNativeWidgetActivationChanged(bool active) = 0;
+
// Called when native focus moves from one native view to another.
virtual void OnNativeFocus(gfx::NativeView focused_view) = 0;
virtual void OnNativeBlur(gfx::NativeView focused_view) = 0;
@@ -31,11 +40,22 @@ class NativeWidgetDelegate {
// Called when the native widget is created.
virtual void OnNativeWidgetCreated() = 0;
+ // Called just before the native widget is destroyed. This is the delegate's
+ // last chance to do anything with the native widget handle.
+ virtual void OnNativeWidgetDestroying() = 0;
+
// Called just after the native widget is destroyed.
virtual void OnNativeWidgetDestroyed() = 0;
+ // Returns the smallest size the window can be resized to by the user.
+ virtual gfx::Size GetMinimumSize() = 0;
+
// Called when the NativeWidget changed size to |new_size|.
- virtual void OnSizeChanged(const gfx::Size& new_size) = 0;
+ virtual void OnNativeWidgetSizeChanged(const gfx::Size& new_size) = 0;
+
+ // Called when the user begins/ends to change the bounds of the window.
+ virtual void OnNativeWidgetBeginUserBoundsChange() = 0;
+ virtual void OnNativeWidgetEndUserBoundsChange() = 0;
// Returns true if the delegate has a FocusManager.
virtual bool HasFocusManager() const = 0;
@@ -49,11 +69,18 @@ class NativeWidgetDelegate {
// tree if necessary when accelerated painting is enabled.
virtual void OnNativeWidgetPaint(gfx::Canvas* canvas) = 0;
+ // Returns the non-client component (see views/window/hit_test.h) containing
+ // |point|, in client coordinates.
+ virtual int GetNonClientComponent(const gfx::Point& point) = 0;
+
// Mouse and key event handlers.
virtual bool OnKeyEvent(const KeyEvent& event) = 0;
virtual bool OnMouseEvent(const MouseEvent& event) = 0;
virtual void OnMouseCaptureLost() = 0;
+ // Runs the specified native command. Returns true if the command is handled.
+ virtual bool ExecuteCommand(int command_id) = 0;
+
//
virtual Widget* AsWidget() = 0;
virtual const Widget* AsWidget() const = 0;
diff --git a/views/widget/native_widget_gtk.cc b/views/widget/native_widget_gtk.cc
index 91af0e3..801a8ec 100644
--- a/views/widget/native_widget_gtk.cc
+++ b/views/widget/native_widget_gtk.cc
@@ -445,7 +445,7 @@ void NativeWidgetGtk::DoDrag(const OSExchangeData& data, int operation) {
}
void NativeWidgetGtk::IsActiveChanged() {
- GetWidget()->widget_delegate()->OnWidgetActivated(IsActive());
+ delegate_->OnNativeWidgetActivationChanged(IsActive());
}
void NativeWidgetGtk::SetInitialFocus() {
@@ -927,6 +927,11 @@ gfx::Rect NativeWidgetGtk::GetClientAreaScreenBounds() const {
return gfx::Rect(x, y, w, h);
}
+gfx::Rect NativeWidgetGtk::GetRestoredBounds() const {
+ // We currently don't support tiling, so this doesn't matter.
+ return GetWindowScreenBounds();
+}
+
void NativeWidgetGtk::SetBounds(const gfx::Rect& bounds) {
if (child_) {
GtkWidget* parent = gtk_widget_get_parent(widget_);
@@ -1020,6 +1025,10 @@ void NativeWidgetGtk::CloseNow() {
}
}
+void NativeWidgetGtk::EnableClose(bool enable) {
+ gtk_window_set_deletable(GetNativeWindow(), enable);
+}
+
void NativeWidgetGtk::Show() {
if (widget_) {
gtk_widget_show(widget_);
@@ -1036,6 +1045,13 @@ void NativeWidgetGtk::Hide() {
}
}
+void NativeWidgetGtk::ShowNativeWidget(ShowState state) {
+ // No concept of maximization (yet) on ChromeOS.
+ if (state == NativeWidget::SHOW_INACTIVE)
+ gtk_window_set_focus_on_map(GetNativeWindow(), false);
+ gtk_widget_show(GetNativeView());
+}
+
bool NativeWidgetGtk::IsVisible() const {
return GTK_WIDGET_VISIBLE(GetNativeView());
}
@@ -1077,10 +1093,14 @@ bool NativeWidgetGtk::IsMinimized() const {
}
void NativeWidgetGtk::Restore() {
- if (IsMaximized())
- gtk_window_unmaximize(GetNativeWindow());
- else if (IsMinimized())
- gtk_window_deiconify(GetNativeWindow());
+ if (IsFullscreen()) {
+ SetFullscreen(false);
+ } else {
+ if (IsMaximized())
+ gtk_window_unmaximize(GetNativeWindow());
+ else if (IsMinimized())
+ gtk_window_deiconify(GetNativeWindow());
+ }
}
void NativeWidgetGtk::SetFullscreen(bool fullscreen) {
@@ -1174,7 +1194,7 @@ void NativeWidgetGtk::OnSizeAllocate(GtkWidget* widget,
if (new_size == size_)
return;
size_ = new_size;
- delegate_->OnSizeChanged(size_);
+ delegate_->OnNativeWidgetSizeChanged(size_);
}
gboolean NativeWidgetGtk::OnPaint(GtkWidget* widget, GdkEventExpose* event) {
@@ -1440,6 +1460,7 @@ void NativeWidgetGtk::OnGrabNotify(GtkWidget* widget, gboolean was_grabbed) {
}
void NativeWidgetGtk::OnDestroy(GtkWidget* object) {
+ delegate_->OnNativeWidgetDestroying();
if (!child_)
ActiveWindowWatcherX::RemoveObserver(this);
// Note that this handler is hooked to GtkObject::destroy.
diff --git a/views/widget/native_widget_gtk.h b/views/widget/native_widget_gtk.h
index f080b10..f641c64 100644
--- a/views/widget/native_widget_gtk.h
+++ b/views/widget/native_widget_gtk.h
@@ -190,6 +190,7 @@ class NativeWidgetGtk : public NativeWidget,
virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE;
virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE;
virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE;
+ virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
virtual void SetSize(const gfx::Size& size) OVERRIDE;
virtual void SetBoundsConstrained(const gfx::Rect& bounds,
@@ -198,8 +199,10 @@ class NativeWidgetGtk : public NativeWidget,
virtual void SetShape(gfx::NativeRegion shape) OVERRIDE;
virtual void Close() OVERRIDE;
virtual void CloseNow() OVERRIDE;
+ virtual void EnableClose(bool enable) OVERRIDE;
virtual void Show() OVERRIDE;
virtual void Hide() OVERRIDE;
+ virtual void ShowNativeWidget(ShowState state) OVERRIDE;
virtual bool IsVisible() const OVERRIDE;
virtual void Activate() OVERRIDE;
virtual void Deactivate() OVERRIDE;
diff --git a/views/widget/native_widget_test_utils_gtk.cc b/views/widget/native_widget_test_utils_gtk.cc
index 2f93ea6..cd84b56 100644
--- a/views/widget/native_widget_test_utils_gtk.cc
+++ b/views/widget/native_widget_test_utils_gtk.cc
@@ -17,7 +17,7 @@ NativeWidget* CreateNativeWidget() {
NativeWidget* CreateNativeWidgetWithContents(View* contents_view) {
Widget* widget = new Widget;
- Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
+ Widget::InitParams params(Widget::InitParams::TYPE_POPUP);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.bounds = gfx::Rect(10, 10, 200, 200);
widget->Init(params);
diff --git a/views/widget/native_widget_test_utils_win.cc b/views/widget/native_widget_test_utils_win.cc
index 8963f48..49cd063 100644
--- a/views/widget/native_widget_test_utils_win.cc
+++ b/views/widget/native_widget_test_utils_win.cc
@@ -17,7 +17,7 @@ NativeWidget* CreateNativeWidget() {
NativeWidget* CreateNativeWidgetWithContents(View* contents_view) {
Widget* widget = new Widget;
- Widget::InitParams params(Widget::InitParams::TYPE_WINDOW);
+ Widget::InitParams params(Widget::InitParams::TYPE_POPUP);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.bounds = gfx::Rect(10, 10, 200, 200);
widget->Init(params);
diff --git a/views/widget/native_widget_view.cc b/views/widget/native_widget_view.cc
index daaf2cc..75de2c1 100644
--- a/views/widget/native_widget_view.cc
+++ b/views/widget/native_widget_view.cc
@@ -36,7 +36,7 @@ void NativeWidgetView::ViewHierarchyChanged(bool is_add, View* parent,
}
void NativeWidgetView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
- delegate()->OnSizeChanged(size());
+ delegate()->OnNativeWidgetSizeChanged(size());
}
void NativeWidgetView::OnPaint(gfx::Canvas* canvas) {
diff --git a/views/widget/native_widget_views.cc b/views/widget/native_widget_views.cc
index d0eebe4..d2fa54f 100644
--- a/views/widget/native_widget_views.cc
+++ b/views/widget/native_widget_views.cc
@@ -80,11 +80,11 @@ gfx::NativeWindow NativeWidgetViews::GetNativeWindow() const {
}
Window* NativeWidgetViews::GetContainingWindow() {
- return view_->GetWindow();
+ return view_->GetWidget()->AsWindow();
}
const Window* NativeWidgetViews::GetContainingWindow() const {
- return view_->GetWindow();
+ return view_->GetWidget()->AsWindow();
}
void NativeWidgetViews::ViewRemoved(View* view) {
@@ -183,6 +183,10 @@ gfx::Rect NativeWidgetViews::GetClientAreaScreenBounds() const {
return GetWindowScreenBounds();
}
+gfx::Rect NativeWidgetViews::GetRestoredBounds() const {
+ return GetWindowScreenBounds();
+}
+
void NativeWidgetViews::SetBounds(const gfx::Rect& bounds) {
// |bounds| are supplied in the coordinates of the parent.
view_->SetBoundsRect(bounds);
@@ -219,6 +223,9 @@ void NativeWidgetViews::CloseNow() {
delete view_;
}
+void NativeWidgetViews::EnableClose(bool enable) {
+}
+
void NativeWidgetViews::Show() {
view_->SetVisible(true);
}
@@ -227,6 +234,9 @@ void NativeWidgetViews::Hide() {
view_->SetVisible(false);
}
+void NativeWidgetViews::ShowNativeWidget(ShowState state) {
+}
+
bool NativeWidgetViews::IsVisible() const {
return view_->IsVisible();
}
diff --git a/views/widget/native_widget_views.h b/views/widget/native_widget_views.h
index f6d445d..f8ab599 100644
--- a/views/widget/native_widget_views.h
+++ b/views/widget/native_widget_views.h
@@ -71,6 +71,7 @@ class NativeWidgetViews : public NativeWidget {
virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE;
virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE;
+ virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
virtual void SetSize(const gfx::Size& size) OVERRIDE;
virtual void SetBoundsConstrained(const gfx::Rect& bounds,
@@ -79,8 +80,10 @@ class NativeWidgetViews : public NativeWidget {
virtual void SetShape(gfx::NativeRegion shape) OVERRIDE;
virtual void Close() OVERRIDE;
virtual void CloseNow() OVERRIDE;
+ virtual void EnableClose(bool enable) OVERRIDE;
virtual void Show() OVERRIDE;
virtual void Hide() OVERRIDE;
+ virtual void ShowNativeWidget(ShowState state) OVERRIDE;
virtual bool IsVisible() const OVERRIDE;
virtual void Activate() OVERRIDE;
virtual void Deactivate() OVERRIDE;
diff --git a/views/widget/native_widget_win.cc b/views/widget/native_widget_win.cc
index cd6fc64..fe4d885 100644
--- a/views/widget/native_widget_win.cc
+++ b/views/widget/native_widget_win.cc
@@ -183,6 +183,22 @@ void SendFrameChanged(HWND window) {
SWP_NOSENDCHANGING | SWP_NOSIZE | SWP_NOZORDER);
}
+// Enables or disables the menu item for the specified command and menu.
+void EnableMenuItem(HMENU menu, UINT command, bool enabled) {
+ UINT flags = MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_DISABLED | MF_GRAYED);
+ EnableMenuItem(menu, command, flags);
+}
+
+BOOL CALLBACK EnumChildWindowsForRedraw(HWND hwnd, LPARAM lparam) {
+ DWORD process_id;
+ GetWindowThreadProcessId(hwnd, &process_id);
+ int flags = RDW_INVALIDATE | RDW_NOCHILDREN | RDW_FRAME;
+ if (process_id == GetCurrentProcessId())
+ flags |= RDW_UPDATENOW;
+ RedrawWindow(hwnd, NULL, NULL, flags);
+ return TRUE;
+}
+
// Links the HWND to its NativeWidget.
const char* const kNativeWidgetKey = "__VIEWS_NATIVE_WIDGET__";
@@ -202,6 +218,46 @@ const int kDragFrameWindowAlpha = 200;
// static
bool NativeWidgetWin::screen_reader_active_ = false;
+// A scoping class that prevents a window from being able to redraw in response
+// to invalidations that may occur within it for the lifetime of the object.
+//
+// Why would we want such a thing? Well, it turns out Windows has some
+// "unorthodox" behavior when it comes to painting its non-client areas.
+// Occasionally, Windows will paint portions of the default non-client area
+// right over the top of the custom frame. This is not simply fixed by handling
+// WM_NCPAINT/WM_PAINT, with some investigation it turns out that this
+// rendering is being done *inside* the default implementation of some message
+// handlers and functions:
+// . WM_SETTEXT
+// . WM_SETICON
+// . WM_NCLBUTTONDOWN
+// . EnableMenuItem, called from our WM_INITMENU handler
+// The solution is to handle these messages and call DefWindowProc ourselves,
+// but prevent the window from being able to update itself for the duration of
+// the call. We do this with this class, which automatically calls its
+// associated Window's lock and unlock functions as it is created and destroyed.
+// See documentation in those methods for the technique used.
+//
+// IMPORTANT: Do not use this scoping object for large scopes or periods of
+// time! IT WILL PREVENT THE WINDOW FROM BEING REDRAWN! (duh).
+//
+// I would love to hear Raymond Chen's explanation for all this. And maybe a
+// list of other messages that this applies to ;-)
+class NativeWidgetWin::ScopedRedrawLock {
+ public:
+ explicit ScopedRedrawLock(NativeWidgetWin* widget) : widget_(widget) {
+ widget_->LockUpdates();
+ }
+
+ ~ScopedRedrawLock() {
+ widget_->UnlockUpdates();
+ }
+
+ private:
+ // The widget having its style changed.
+ NativeWidgetWin* widget_;
+};
+
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetWin, public:
@@ -222,7 +278,9 @@ NativeWidgetWin::NativeWidgetWin(internal::NativeWidgetDelegate* delegate)
previous_cursor_(NULL),
is_input_method_win_(false),
fullscreen_(false),
- force_hidden_count_(0) {
+ force_hidden_count_(0),
+ lock_updates_(false),
+ saved_window_style_(0) {
}
NativeWidgetWin::~NativeWidgetWin() {
@@ -242,6 +300,29 @@ bool NativeWidgetWin::IsAeroGlassEnabled() {
return SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled;
}
+void NativeWidgetWin::Show(int show_state) {
+ ShowWindow(show_state);
+ // When launched from certain programs like bash and Windows Live Messenger,
+ // show_state is set to SW_HIDE, so we need to correct that condition. We
+ // don't just change show_state to SW_SHOWNORMAL because MSDN says we must
+ // always first call ShowWindow with the specified value from STARTUPINFO,
+ // otherwise all future ShowWindow calls will be ignored (!!#@@#!). Instead,
+ // we call ShowWindow again in this case.
+ if (show_state == SW_HIDE) {
+ show_state = SW_SHOWNORMAL;
+ ShowWindow(show_state);
+ }
+
+ // We need to explicitly activate the window if we've been shown with a state
+ // that should activate, because if we're opened from a desktop shortcut while
+ // an existing window is already running it doesn't seem to be enough to use
+ // one of these flags to activate the window.
+ if (show_state == SW_SHOWNORMAL || show_state == SW_SHOWMAXIMIZED)
+ Activate();
+
+ SetInitialFocus();
+}
+
View* NativeWidgetWin::GetAccessibilityViewEventAt(int id) {
// Convert from MSAA child id.
id = -(id + 1);
@@ -550,6 +631,17 @@ gfx::Rect NativeWidgetWin::GetClientAreaScreenBounds() const {
return gfx::Rect(point.x, point.y, r.right - r.left, r.bottom - r.top);
}
+gfx::Rect NativeWidgetWin::GetRestoredBounds() const {
+ // If we're in fullscreen mode, we've changed the normal bounds to the monitor
+ // rect, so return the saved bounds instead.
+ if (IsFullscreen())
+ return gfx::Rect(saved_window_info_.window_rect);
+
+ gfx::Rect bounds;
+ GetWindowBoundsAndMaximizedState(&bounds, NULL);
+ return bounds;
+}
+
void NativeWidgetWin::SetBounds(const gfx::Rect& bounds) {
LONG style = GetWindowLong(GWL_STYLE);
if (style & WS_MAXIMIZE)
@@ -627,6 +719,13 @@ void NativeWidgetWin::CloseNow() {
DestroyWindow(hwnd());
}
+void NativeWidgetWin::EnableClose(bool enable) {
+ // Disable the native frame's close button regardless of whether or not the
+ // native frame is in use, since this also affects the system menu.
+ EnableMenuItem(GetSystemMenu(GetNativeView(), false), SC_CLOSE, enable);
+ SendFrameChanged(GetNativeView());
+}
+
void NativeWidgetWin::Show() {
if (!IsWindow())
return;
@@ -647,6 +746,22 @@ void NativeWidgetWin::Hide() {
}
}
+void NativeWidgetWin::ShowNativeWidget(ShowState state) {
+ DWORD native_show_state;
+ switch (state) {
+ case SHOW_INACTIVE:
+ native_show_state = SW_SHOWNOACTIVATE;
+ break;
+ case SHOW_MAXIMIZED:
+ native_show_state = SW_SHOWMAXIMIZED;
+ break;
+ default:
+ native_show_state = GetShowState();
+ break;
+ }
+ Show(native_show_state);
+}
+
bool NativeWidgetWin::IsVisible() const {
return !!::IsWindowVisible(hwnd());
}
@@ -881,7 +996,15 @@ void NativeWidgetWin::OnActivate(UINT action, BOOL minimized, HWND window) {
}
void NativeWidgetWin::OnActivateApp(BOOL active, DWORD thread_id) {
- SetMsgHandled(FALSE);
+ if (GetWidget()->non_client_view() && !active &&
+ thread_id != GetCurrentThreadId()) {
+ // Another application was activated, we should reset any state that
+ // disables inactive rendering now.
+ delegate_->EnableInactiveRendering();
+ // Update the native frame too, since it could be rendering the non-client
+ // area.
+ CallDefaultNCActivateHandler(FALSE);
+ }
}
LRESULT NativeWidgetWin::OnAppCommand(HWND window,
@@ -974,6 +1097,7 @@ LRESULT NativeWidgetWin::OnCreate(CREATESTRUCT* create_struct) {
}
void NativeWidgetWin::OnDestroy() {
+ delegate_->OnNativeWidgetDestroying();
if (drop_target_.get()) {
RevokeDragDrop(hwnd());
drop_target_ = NULL;
@@ -989,7 +1113,18 @@ void NativeWidgetWin::OnDisplayChange(UINT bits_per_pixel, CSize screen_size) {
LRESULT NativeWidgetWin::OnDwmCompositionChanged(UINT msg,
WPARAM w_param,
LPARAM l_param) {
- SetMsgHandled(FALSE);
+ if (!GetWidget()->non_client_view()) {
+ SetMsgHandled(FALSE);
+ return 0;
+ }
+
+ // For some reason, we need to hide the window while we're changing the frame
+ // type only when we're changing it in response to WM_DWMCOMPOSITIONCHANGED.
+ // If we don't, the client area will be filled with black. I'm suspecting
+ // something skia-ey.
+ // Frame type toggling caused by the user (e.g. switching theme) doesn't seem
+ // to have this requirement.
+ FrameTypeChanged();
return 0;
}
@@ -998,6 +1133,7 @@ void NativeWidgetWin::OnEndSession(BOOL ending, UINT logoff) {
}
void NativeWidgetWin::OnEnterSizeMove() {
+ delegate_->OnNativeWidgetBeginUserBoundsChange();
SetMsgHandled(FALSE);
}
@@ -1011,6 +1147,7 @@ void NativeWidgetWin::OnExitMenuLoop(BOOL is_track_popup_menu) {
}
void NativeWidgetWin::OnExitSizeMove() {
+ delegate_->OnNativeWidgetEndUserBoundsChange();
SetMsgHandled(FALSE);
}
@@ -1044,6 +1181,9 @@ LRESULT NativeWidgetWin::OnGetObject(UINT uMsg,
}
void NativeWidgetWin::OnGetMinMaxInfo(MINMAXINFO* minmax_info) {
+ gfx::Size min_window_size(delegate_->GetMinimumSize());
+ minmax_info->ptMinTrackSize.x = min_window_size.width();
+ minmax_info->ptMinTrackSize.y = min_window_size.height();
SetMsgHandled(FALSE);
}
@@ -1095,7 +1235,29 @@ LRESULT NativeWidgetWin::OnImeMessages(UINT message,
}
void NativeWidgetWin::OnInitMenu(HMENU menu) {
- SetMsgHandled(FALSE);
+ // We only need to manually enable the system menu if we're not using a native
+ // frame.
+ if (GetWidget()->ShouldUseNativeFrame()) {
+ SetMsgHandled(FALSE);
+ return;
+ }
+
+ bool is_fullscreen = IsFullscreen();
+ bool is_minimized = IsMinimized();
+ bool is_maximized = IsMaximized();
+ bool is_restored = !is_fullscreen && !is_minimized && !is_maximized;
+
+ ScopedRedrawLock lock(this);
+ EnableMenuItem(menu, SC_RESTORE, is_minimized || is_maximized);
+ EnableMenuItem(menu, SC_MOVE, is_restored);
+ EnableMenuItem(menu, SC_SIZE,
+ GetWidget()->widget_delegate()->CanResize() && is_restored);
+ EnableMenuItem(menu, SC_MAXIMIZE,
+ GetWidget()->widget_delegate()->CanMaximize() &&
+ !is_fullscreen && !is_maximized);
+ EnableMenuItem(menu, SC_MINIMIZE,
+ GetWidget()->widget_delegate()->CanMaximize() &&
+ !is_minimized);
}
void NativeWidgetWin::OnInitMenuPopup(HMENU menu,
@@ -1134,6 +1296,10 @@ void NativeWidgetWin::OnKillFocus(HWND focused_window) {
LRESULT NativeWidgetWin::OnMouseActivate(UINT message,
WPARAM w_param,
LPARAM l_param) {
+ // TODO(beng): resolve this with the GetWindowLong() check on the subsequent
+ // line.
+ if (GetWidget()->non_client_view())
+ return delegate_->CanActivate() ? MA_ACTIVATE : MA_NOACTIVATEANDEAT;
if (GetWindowLong(GWL_EXSTYLE) & WS_EX_NOACTIVATE)
return MA_NOACTIVATE;
SetMsgHandled(FALSE);
@@ -1183,8 +1349,40 @@ void NativeWidgetWin::OnMoving(UINT param, const LPRECT new_bounds) {
}
LRESULT NativeWidgetWin::OnNCActivate(BOOL active) {
- SetMsgHandled(FALSE);
- return 0;
+ if (!GetWidget()->non_client_view()) {
+ SetMsgHandled(FALSE);
+ return 0;
+ }
+
+ if (!delegate_->CanActivate())
+ return TRUE;
+
+ delegate_->OnNativeWidgetActivationChanged(!!active);
+
+ // The frame may need to redraw as a result of the activation change.
+ // We can get WM_NCACTIVATE before we're actually visible. If we're not
+ // visible, no need to paint.
+ if (IsVisible())
+ GetWidget()->non_client_view()->SchedulePaint();
+
+ if (!GetWidget()->ShouldUseNativeFrame()) {
+ // TODO(beng, et al): Hack to redraw this window and child windows
+ // synchronously upon activation. Not all child windows are redrawing
+ // themselves leading to issues like http://crbug.com/74604
+ // We redraw out-of-process HWNDs asynchronously to avoid hanging the
+ // whole app if a child HWND belonging to a hung plugin is encountered.
+ RedrawWindow(GetNativeView(), NULL, NULL,
+ RDW_NOCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW);
+ EnumChildWindows(GetNativeView(), EnumChildWindowsForRedraw, NULL);
+ }
+
+ // If we're active again, we should be allowed to render as inactive, so
+ // tell the non-client view.
+ bool inactive_rendering_disabled = delegate_->IsInactiveRenderingDisabled();
+ if (IsActive())
+ delegate_->EnableInactiveRendering();
+
+ return CallDefaultNCActivateHandler(inactive_rendering_disabled || active);
}
LRESULT NativeWidgetWin::OnNCCalcSize(BOOL w_param, LPARAM l_param) {
@@ -1192,7 +1390,32 @@ LRESULT NativeWidgetWin::OnNCCalcSize(BOOL w_param, LPARAM l_param) {
return 0;
}
-LRESULT NativeWidgetWin::OnNCHitTest(const CPoint& pt) {
+LRESULT NativeWidgetWin::OnNCHitTest(const CPoint& point) {
+ if (!GetWidget()->non_client_view()) {
+ SetMsgHandled(FALSE);
+ return 0;
+ }
+
+ // If the DWM is rendering the window controls, we need to give the DWM's
+ // default window procedure first chance to handle hit testing.
+ if (GetWidget()->ShouldUseNativeFrame()) {
+ LRESULT result;
+ if (DwmDefWindowProc(GetNativeView(), WM_NCHITTEST, 0,
+ MAKELPARAM(point.x, point.y), &result)) {
+ return result;
+ }
+ }
+
+ // First, give the NonClientView a chance to test the point to see if it
+ // provides any of the non-client area.
+ POINT temp = point;
+ MapWindowPoints(HWND_DESKTOP, GetNativeView(), &temp, 1);
+ int component = delegate_->GetNonClientComponent(gfx::Point(temp));
+ if (component != HTNOWHERE)
+ return component;
+
+ // Otherwise, we let Windows do all the native frame non-client handling for
+ // us.
SetMsgHandled(FALSE);
return 0;
}
@@ -1204,14 +1427,18 @@ void NativeWidgetWin::OnNCPaint(HRGN rgn) {
LRESULT NativeWidgetWin::OnNCUAHDrawCaption(UINT msg,
WPARAM w_param,
LPARAM l_param) {
- SetMsgHandled(FALSE);
+ // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for
+ // an explanation about why we need to handle this message.
+ SetMsgHandled(!GetWidget()->ShouldUseNativeFrame());
return 0;
}
LRESULT NativeWidgetWin::OnNCUAHDrawFrame(UINT msg,
WPARAM w_param,
LPARAM l_param) {
- SetMsgHandled(FALSE);
+ // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for
+ // an explanation about why we need to handle this message.
+ SetMsgHandled(!GetWidget()->ShouldUseNativeFrame());
return 0;
}
@@ -1263,8 +1490,9 @@ LRESULT NativeWidgetWin::OnReflectedMessage(UINT msg,
LRESULT NativeWidgetWin::OnSetCursor(UINT message,
WPARAM w_param,
LPARAM l_param) {
- SetMsgHandled(FALSE);
- return 0;
+ // This shouldn't hurt even if we're using the native frame.
+ ScopedRedrawLock lock(this);
+ return DefWindowProc(GetNativeView(), message, w_param, l_param);
}
void NativeWidgetWin::OnSetFocus(HWND focused_window) {
@@ -1275,13 +1503,17 @@ void NativeWidgetWin::OnSetFocus(HWND focused_window) {
}
LRESULT NativeWidgetWin::OnSetIcon(UINT size_type, HICON new_icon) {
- SetMsgHandled(FALSE);
- return 0;
+ // This shouldn't hurt even if we're using the native frame.
+ ScopedRedrawLock lock(this);
+ return DefWindowProc(GetNativeView(), WM_SETICON, size_type,
+ reinterpret_cast<LPARAM>(new_icon));
}
LRESULT NativeWidgetWin::OnSetText(const wchar_t* text) {
- SetMsgHandled(FALSE);
- return 0;
+ // This shouldn't hurt even if we're using the native frame.
+ ScopedRedrawLock lock(this);
+ return DefWindowProc(GetNativeView(), WM_SETTEXT, NULL,
+ reinterpret_cast<LPARAM>(text));
}
void NativeWidgetWin::OnSettingChange(UINT flags, const wchar_t* section) {
@@ -1301,12 +1533,59 @@ void NativeWidgetWin::OnSettingChange(UINT flags, const wchar_t* section) {
}
void NativeWidgetWin::OnSize(UINT param, const CSize& size) {
+ RedrawWindow(GetNativeView(), NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN);
// ResetWindowRegion is going to trigger WM_NCPAINT. By doing it after we've
// invoked OnSize we ensure the RootView has been laid out.
ResetWindowRegion(false);
}
void NativeWidgetWin::OnSysCommand(UINT notification_code, CPoint click) {
+ if (!GetWidget()->non_client_view())
+ return;
+
+ // Windows uses the 4 lower order bits of |notification_code| for type-
+ // specific information so we must exclude this when comparing.
+ static const int sc_mask = 0xFFF0;
+ // Ignore size/move/maximize in fullscreen mode.
+ if (IsFullscreen() &&
+ (((notification_code & sc_mask) == SC_SIZE) ||
+ ((notification_code & sc_mask) == SC_MOVE) ||
+ ((notification_code & sc_mask) == SC_MAXIMIZE)))
+ return;
+ if (!GetWidget()->ShouldUseNativeFrame()) {
+ if ((notification_code & sc_mask) == SC_MINIMIZE ||
+ (notification_code & sc_mask) == SC_MAXIMIZE ||
+ (notification_code & sc_mask) == SC_RESTORE) {
+ GetWidget()->non_client_view()->ResetWindowControls();
+ } else if ((notification_code & sc_mask) == SC_MOVE ||
+ (notification_code & sc_mask) == SC_SIZE) {
+ if (lock_updates_) {
+ // We were locked, before entering a resize or move modal loop. Now that
+ // we've begun to move the window, we need to unlock updates so that the
+ // sizing/moving feedback can be continuous.
+ UnlockUpdates();
+ }
+ }
+ }
+
+ // Handle SC_KEYMENU, which means that the user has pressed the ALT
+ // key and released it, so we should focus the menu bar.
+ if ((notification_code & sc_mask) == SC_KEYMENU && click.x == 0) {
+ // Retrieve the status of shift and control keys to prevent consuming
+ // shift+alt keys, which are used by Windows to change input languages.
+ Accelerator accelerator(ui::KeyboardCodeForWindowsKeyCode(VK_MENU),
+ !!(GetKeyState(VK_SHIFT) & 0x8000),
+ !!(GetKeyState(VK_CONTROL) & 0x8000),
+ false);
+ GetWidget()->GetFocusManager()->ProcessAccelerator(accelerator);
+ return;
+ }
+
+ // If the delegate can't handle it, the system implementation will be called.
+ if (!delegate_->ExecuteCommand(notification_code)) {
+ DefWindowProc(GetNativeView(), WM_SYSCOMMAND, notification_code,
+ MAKELPARAM(click.x, click.y));
+ }
}
void NativeWidgetWin::OnThemeChanged() {
@@ -1345,6 +1624,37 @@ void NativeWidgetWin::OnFinalMessage(HWND window) {
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetWin, protected:
+int NativeWidgetWin::GetShowState() const {
+ return SW_SHOWNORMAL;
+}
+
+gfx::Insets NativeWidgetWin::GetClientAreaInsets() const {
+ // Returning an empty Insets object causes the default handling in
+ // NativeWidgetWin::OnNCCalcSize() to be invoked.
+ if (GetWidget()->ShouldUseNativeFrame())
+ return gfx::Insets();
+
+ if (IsMaximized()) {
+ // Windows automatically adds a standard width border to all sides when a
+ // window is maximized.
+ int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME);
+ return gfx::Insets(border_thickness, border_thickness, border_thickness,
+ border_thickness);
+ }
+ // This is weird, but highly essential. If we don't offset the bottom edge
+ // of the client rect, the window client area and window area will match,
+ // and when returning to glass rendering mode from non-glass, the client
+ // area will not paint black as transparent. This is because (and I don't
+ // know why) the client area goes from matching the window rect to being
+ // something else. If the client area is not the window rect in both
+ // modes, the blackness doesn't occur. Because of this, we need to tell
+ // the RootView to lay out to fit the window rect, rather than the client
+ // rect when using the opaque frame.
+ // Note: this is only required for non-fullscreen windows. Note that
+ // fullscreen windows are in restored state, not maximized.
+ return gfx::Insets(0, 0, IsFullscreen() ? 0 : 1, 0);
+}
+
void NativeWidgetWin::TrackMouseEvents(DWORD mouse_tracking_flags) {
// Begin tracking mouse events for this HWND so that we get WM_MOUSELEAVE
// when the user moves the mouse outside this HWND's bounds.
@@ -1525,6 +1835,17 @@ void NativeWidgetWin::RedrawLayeredWindowContents() {
skia::EndPlatformPaint(layered_window_contents_.get());
}
+void NativeWidgetWin::LockUpdates() {
+ lock_updates_ = true;
+ saved_window_style_ = GetWindowLong(GWL_STYLE);
+ SetWindowLong(GWL_STYLE, saved_window_style_ & ~WS_VISIBLE);
+}
+
+void NativeWidgetWin::UnlockUpdates() {
+ SetWindowLong(GWL_STYLE, saved_window_style_);
+ lock_updates_ = false;
+}
+
void NativeWidgetWin::ClientAreaSizeChanged() {
RECT r;
Window* window = GetWidget()->GetContainingWindow();
@@ -1534,7 +1855,7 @@ void NativeWidgetWin::ClientAreaSizeChanged() {
GetWindowRect(&r);
gfx::Size s(std::max(0, static_cast<int>(r.right - r.left)),
std::max(0, static_cast<int>(r.bottom - r.top)));
- delegate_->OnSizeChanged(s);
+ delegate_->OnNativeWidgetSizeChanged(s);
if (use_layered_buffer_) {
layered_window_contents_.reset(
new gfx::CanvasSkia(s.width(), s.height(), false));
@@ -1584,6 +1905,14 @@ void NativeWidgetWin::ResetWindowRegion(bool force) {
DeleteObject(current_rgn);
}
+LRESULT NativeWidgetWin::CallDefaultNCActivateHandler(BOOL active) {
+ // The DefWindowProc handling for WM_NCACTIVATE renders the classic-look
+ // window title bar directly, so we need to use a redraw lock here to prevent
+ // it from doing so.
+ ScopedRedrawLock lock(this);
+ return DefWindowProc(GetNativeView(), WM_NCACTIVATE, active, 0);
+}
+
gfx::AcceleratedWidget NativeWidgetWin::GetAcceleratedWidget() {
#if defined(VIEWS_COMPOSITOR)
return hwnd();
diff --git a/views/widget/native_widget_win.h b/views/widget/native_widget_win.h
index 7dd4995..3d98b24 100644
--- a/views/widget/native_widget_win.h
+++ b/views/widget/native_widget_win.h
@@ -88,6 +88,9 @@ class NativeWidgetWin : public ui::WindowImpl,
// enabled.
static bool IsAeroGlassEnabled();
+ // Show the window with the specified show command.
+ void Show(int show_state);
+
// Disable Layered Window updates by setting to false.
void set_can_update_layered_window(bool can_update_layered_window) {
can_update_layered_window_ = can_update_layered_window;
@@ -211,6 +214,7 @@ class NativeWidgetWin : public ui::WindowImpl,
virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE;
virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE;
virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE;
+ virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
virtual void SetSize(const gfx::Size& size) OVERRIDE;
virtual void SetBoundsConstrained(const gfx::Rect& bounds,
@@ -219,8 +223,10 @@ class NativeWidgetWin : public ui::WindowImpl,
virtual void SetShape(gfx::NativeRegion shape) OVERRIDE;
virtual void Close() OVERRIDE;
virtual void CloseNow() OVERRIDE;
+ virtual void EnableClose(bool enable) OVERRIDE;
virtual void Show() OVERRIDE;
virtual void Hide() OVERRIDE;
+ virtual void ShowNativeWidget(ShowState state) OVERRIDE;
virtual bool IsVisible() const OVERRIDE;
virtual void Activate() OVERRIDE;
virtual void Deactivate() OVERRIDE;
@@ -418,6 +424,18 @@ class NativeWidgetWin : public ui::WindowImpl,
// behavior.
virtual void OnFinalMessage(HWND window);
+ // Retrieve the show state of the window. This is one of the SW_SHOW* flags
+ // passed into Windows' ShowWindow method. For normal windows this defaults
+ // to SW_SHOWNORMAL, however windows (e.g. the main window) can override this
+ // method to provide different values (e.g. retrieve the user's specified
+ // show state from the shortcut starutp info).
+ virtual int GetShowState() const;
+
+ // Returns the insets of the client area relative to the non-client area of
+ // the window. Override this function instead of OnNCCalcSize, which is
+ // crazily complicated.
+ virtual gfx::Insets GetClientAreaInsets() const;
+
// Start tracking all mouse events so that this window gets sent mouse leave
// messages too.
void TrackMouseEvents(DWORD mouse_tracking_flags);
@@ -475,6 +493,12 @@ class NativeWidgetWin : public ui::WindowImpl,
// layered windows only.
void RedrawLayeredWindowContents();
+ // Lock or unlock the window from being able to redraw itself in response to
+ // updates to its invalid region.
+ class ScopedRedrawLock;
+ void LockUpdates();
+ void UnlockUpdates();
+
// Responds to the client area changing size, either at window creation time
// or subsequently.
void ClientAreaSizeChanged();
@@ -484,6 +508,11 @@ class NativeWidgetWin : public ui::WindowImpl,
// frame windows.
void ResetWindowRegion(bool force);
+ // Calls the default WM_NCACTIVATE handler with the specified activation
+ // value, safely wrapping the call in a ScopedRedrawLock to prevent frame
+ // flicker.
+ LRESULT CallDefaultNCActivateHandler(BOOL active);
+
// Overridden from NativeWidget.
virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
@@ -590,6 +619,12 @@ class NativeWidgetWin : public ui::WindowImpl,
DWORD drag_frame_saved_window_style_;
DWORD drag_frame_saved_window_ex_style_;
+ // True if updates to this window are currently locked.
+ bool lock_updates_;
+
+ // The window styles of the window before updates were locked.
+ DWORD saved_window_style_;
+
DISALLOW_COPY_AND_ASSIGN(NativeWidgetWin);
};
diff --git a/views/widget/widget.cc b/views/widget/widget.cc
index e2b2202..eeff786 100644
--- a/views/widget/widget.cc
+++ b/views/widget/widget.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "base/message_loop.h"
+#include "base/utf_string_conversions.h"
#include "ui/gfx/compositor/compositor.h"
#include "views/focus/view_storage.h"
#include "views/ime/input_method.h"
@@ -90,13 +91,14 @@ Widget::Widget()
: is_mouse_button_pressed_(false),
last_mouse_event_was_move_(false),
native_widget_(NULL),
- type_(InitParams::TYPE_WINDOW),
widget_delegate_(NULL),
non_client_view_(NULL),
dragged_view_(NULL),
ownership_(InitParams::NATIVE_WIDGET_OWNS_WIDGET),
is_secondary_widget_(true),
- frame_type_(FRAME_TYPE_DEFAULT) {
+ frame_type_(FRAME_TYPE_DEFAULT),
+ disable_inactive_rendering_(false),
+ widget_closed_(false) {
}
Widget::~Widget() {
@@ -124,7 +126,6 @@ Widget* Widget::GetWidgetForNativeView(gfx::NativeView native_view) {
}
void Widget::Init(const InitParams& params) {
- type_ = params.type;
widget_delegate_ =
params.delegate ? params.delegate : new DefaultWidgetDelegate;
ownership_ = params.ownership;
@@ -136,9 +137,13 @@ void Widget::Init(const InitParams& params) {
if (params.type == InitParams::TYPE_MENU)
is_mouse_button_pressed_ = native_widget_->IsMouseButtonDown();
native_widget_->InitNativeWidget(params);
- if (type_ == InitParams::TYPE_WINDOW) {
+ if (params.type == InitParams::TYPE_WINDOW) {
non_client_view_ = new NonClientView;
non_client_view_->SetFrameView(CreateNonClientFrameView());
+ // Create the ClientView, add it to the NonClientView and add the
+ // NonClientView to the RootView. This will cause everything to be parented.
+ non_client_view_->set_client_view(widget_delegate_->CreateClientView(this));
+ SetContentsView(non_client_view_);
}
}
@@ -189,6 +194,14 @@ void Widget::NotifyNativeViewHierarchyChanged(bool attached,
root_view_->NotifyNativeViewHierarchyChanged(attached, native_view);
}
+Window* Widget::AsWindow() {
+ return NULL;
+}
+
+const Window* Widget::AsWindow() const {
+ return NULL;
+}
+
// Converted methods (see header) ----------------------------------------------
Widget* Widget::GetTopLevelWidget() {
@@ -214,6 +227,10 @@ gfx::Rect Widget::GetClientAreaScreenBounds() const {
return native_widget_->GetClientAreaScreenBounds();
}
+gfx::Rect Widget::GetRestoredBounds() const {
+ return native_widget_->GetRestoredBounds();
+}
+
void Widget::SetBounds(const gfx::Rect& bounds) {
native_widget_->SetBounds(bounds);
}
@@ -240,13 +257,32 @@ void Widget::SetShape(gfx::NativeRegion shape) {
}
void Widget::Close() {
- native_widget_->Close();
+ if (widget_closed_) {
+ // It appears we can hit this code path if you close a modal dialog then
+ // close the last browser before the destructor is hit, which triggers
+ // invoking Close again.
+ return;
+ }
+
+ bool can_close = true;
+ if (non_client_view_)
+ can_close = non_client_view_->CanClose();
+ if (can_close) {
+ SaveWindowPosition();
+ native_widget_->Close();
+ widget_closed_ = true;
+ }
}
void Widget::CloseNow() {
native_widget_->CloseNow();
}
+void Widget::EnableClose(bool enable) {
+ non_client_view_->EnableClose(enable);
+ native_widget_->EnableClose(enable);
+}
+
void Widget::Show() {
native_widget_->Show();
}
@@ -255,6 +291,10 @@ void Widget::Hide() {
native_widget_->Hide();
}
+void Widget::ShowInactive() {
+ native_widget_->ShowNativeWidget(NativeWidget::SHOW_INACTIVE);
+}
+
void Widget::Activate() {
native_widget_->Activate();
}
@@ -267,6 +307,11 @@ bool Widget::IsActive() const {
return native_widget_->IsActive();
}
+void Widget::DisableInactiveRendering() {
+ disable_inactive_rendering_ = true;
+ non_client_view_->DisableInactiveRendering(disable_inactive_rendering_);
+}
+
void Widget::SetAlwaysOnTop(bool on_top) {
native_widget_->SetAlwaysOnTop(on_top);
}
@@ -387,6 +432,29 @@ void Widget::ResetLastMouseMoveFlag() {
last_mouse_event_was_move_ = false;
}
+void Widget::UpdateWindowTitle() {
+ // If the non-client view is rendering its own title, it'll need to relayout
+ // now.
+ non_client_view_->Layout();
+
+ // Update the native frame's text. We do this regardless of whether or not
+ // the native frame is being used, since this also updates the taskbar, etc.
+ string16 window_title;
+ if (native_widget_->IsScreenReaderActive()) {
+ window_title = WideToUTF16(widget_delegate_->GetAccessibleWindowTitle());
+ } else {
+ window_title = WideToUTF16(widget_delegate_->GetWindowTitle());
+ }
+ base::i18n::AdjustStringForLocaleDirection(&window_title);
+ native_widget_->SetWindowTitle(UTF16ToWide(window_title));
+}
+
+void Widget::UpdateWindowIcon() {
+ non_client_view_->UpdateWindowIcon();
+ native_widget_->SetWindowIcons(widget_delegate_->GetWindowIcon(),
+ widget_delegate_->GetWindowAppIcon());
+}
+
FocusTraversable* Widget::GetFocusTraversable() {
return static_cast<internal::RootView*>(root_view_.get());
}
@@ -454,6 +522,28 @@ void Widget::NotifyAccessibilityEvent(
////////////////////////////////////////////////////////////////////////////////
// Widget, NativeWidgetDelegate implementation:
+bool Widget::CanActivate() const {
+ return widget_delegate_->CanActivate();
+}
+
+bool Widget::IsInactiveRenderingDisabled() const {
+ return disable_inactive_rendering_;
+}
+
+void Widget::EnableInactiveRendering() {
+ disable_inactive_rendering_ = false;
+ non_client_view_->DisableInactiveRendering(false);
+}
+
+void Widget::OnNativeWidgetActivationChanged(bool active) {
+ if (!active)
+ SaveWindowPosition();
+
+ // TODO(beng): merge these two.
+ widget_delegate_->OnWidgetActivated(active);
+ widget_delegate_->OnWindowActivationChanged(active);
+}
+
void Widget::OnNativeFocus(gfx::NativeView focused_view) {
GetFocusManager()->GetWidgetFocusManager()->OnWidgetFocusEvent(
focused_view,
@@ -473,6 +563,17 @@ void Widget::OnNativeWidgetCreated() {
focus_manager_.reset(new FocusManager(this));
}
EnsureCompositor();
+
+ native_widget_->SetAccessibleRole(
+ widget_delegate_->GetAccessibleWindowRole());
+ native_widget_->SetAccessibleState(
+ widget_delegate_->GetAccessibleWindowState());
+}
+
+void Widget::OnNativeWidgetDestroying() {
+ if (non_client_view_)
+ non_client_view_->WindowClosing();
+ widget_delegate_->WindowClosing();
}
void Widget::OnNativeWidgetDestroyed() {
@@ -480,10 +581,22 @@ void Widget::OnNativeWidgetDestroyed() {
widget_delegate_ = NULL;
}
-void Widget::OnSizeChanged(const gfx::Size& new_size) {
+gfx::Size Widget::GetMinimumSize() {
+ return non_client_view_->GetMinimumSize();
+}
+
+void Widget::OnNativeWidgetSizeChanged(const gfx::Size& new_size) {
root_view_->SetSize(new_size);
}
+void Widget::OnNativeWidgetBeginUserBoundsChange() {
+ widget_delegate_->OnWindowBeginUserBoundsChange();
+}
+
+void Widget::OnNativeWidgetEndUserBoundsChange() {
+ widget_delegate_->OnWindowEndUserBoundsChange();
+}
+
bool Widget::HasFocusManager() const {
return !!focus_manager_.get();
}
@@ -514,6 +627,10 @@ void Widget::OnNativeWidgetPaint(gfx::Canvas* canvas) {
#endif
}
+int Widget::GetNonClientComponent(const gfx::Point& point) {
+ return non_client_view_->NonClientHitTest(point);
+}
+
bool Widget::OnKeyEvent(const KeyEvent& event) {
return static_cast<internal::RootView*>(GetRootView())->OnKeyEvent(event);
}
@@ -570,6 +687,10 @@ void Widget::OnMouseCaptureLost() {
is_mouse_button_pressed_ = false;
}
+bool Widget::ExecuteCommand(int command_id) {
+ return widget_delegate_->ExecuteWindowsCommand(command_id);
+}
+
Widget* Widget::AsWidget() {
return this;
}
@@ -642,4 +763,20 @@ bool Widget::ShouldReleaseCaptureOnMouseReleased() const {
return true;
}
+void Widget::SaveWindowPosition() {
+ // The window delegate does the actual saving for us. It seems like (judging
+ // by go/crash) that in some circumstances we can end up here after
+ // WM_DESTROY, at which point the window delegate is likely gone. So just
+ // bail.
+ if (!widget_delegate_)
+ return;
+
+ bool maximized;
+ gfx::Rect bounds;
+ native_widget_->GetWindowBoundsAndMaximizedState(&bounds, &maximized);
+ widget_delegate_->SaveWindowPlacement(bounds, maximized);
+}
+
+
+
} // namespace views
diff --git a/views/widget/widget.h b/views/widget/widget.h
index 19952eb..b2699de 100644
--- a/views/widget/widget.h
+++ b/views/widget/widget.h
@@ -220,6 +220,9 @@ class Widget : public internal::NativeWidgetDelegate,
// Returns the bounds of the Widget's client area in screen coordinates.
gfx::Rect GetClientAreaScreenBounds() const;
+ // Retrieves the restored bounds for the window.
+ gfx::Rect GetRestoredBounds() const;
+
// Sizes and/or places the widget to the specified bounds, size or position.
void SetBounds(const gfx::Rect& bounds);
void SetSize(const gfx::Size& size);
@@ -247,10 +250,17 @@ class Widget : public internal::NativeWidgetDelegate,
// any code that expects it to be valid beyond this call.
void CloseNow();
+ // Toggles the enable state for the Close button (and the Close menu item in
+ // the system menu).
+ void EnableClose(bool enable);
+
// Shows or hides the widget, without changing activation state.
virtual void Show();
void Hide();
+ // Like Show(), but does not activate the window.
+ void ShowInactive();
+
// Activates the widget, assuming it already exists and is visible.
void Activate();
@@ -261,6 +271,12 @@ class Widget : public internal::NativeWidgetDelegate,
// Returns whether the Widget is the currently active window.
virtual bool IsActive() const;
+ // Prevents the window from being rendered as deactivated the next time it is.
+ // This state is reset automatically as soon as the window becomes activated
+ // again. There is no ability to control the state through this API as this
+ // leads to sync problems.
+ void DisableInactiveRendering();
+
// Sets the widget to be on top of all other widgets in the windowing system.
void SetAlwaysOnTop(bool on_top);
@@ -349,6 +365,12 @@ class Widget : public internal::NativeWidgetDelegate,
// to cause the close button to highlight.
void ResetLastMouseMoveFlag();
+ // Tell the window to update its title from the delegate.
+ void UpdateWindowTitle();
+
+ // Tell the window to update its icon from the delegate.
+ void UpdateWindowIcon();
+
// Retrieves the focus traversable for this widget.
FocusTraversable* GetFocusTraversable();
@@ -418,19 +440,33 @@ class Widget : public internal::NativeWidgetDelegate,
const NativeWidget* native_widget() const { return native_widget_; }
NativeWidget* native_widget() { return native_widget_; }
+ // TODO(beng): remove once Window is folded in.
+ virtual Window* AsWindow();
+ virtual const Window* AsWindow() const;
+
// Overridden from NativeWidgetDelegate:
+ virtual bool CanActivate() const OVERRIDE;
+ virtual bool IsInactiveRenderingDisabled() const OVERRIDE;
+ virtual void EnableInactiveRendering() OVERRIDE;
+ virtual void OnNativeWidgetActivationChanged(bool active) OVERRIDE;
virtual void OnNativeFocus(gfx::NativeView focused_view) OVERRIDE;
virtual void OnNativeBlur(gfx::NativeView focused_view) OVERRIDE;
virtual void OnNativeWidgetCreated() OVERRIDE;
+ virtual void OnNativeWidgetDestroying() OVERRIDE;
virtual void OnNativeWidgetDestroyed() OVERRIDE;
- virtual void OnSizeChanged(const gfx::Size& new_size) OVERRIDE;
+ virtual gfx::Size GetMinimumSize() OVERRIDE;
+ virtual void OnNativeWidgetSizeChanged(const gfx::Size& new_size) OVERRIDE;
+ virtual void OnNativeWidgetBeginUserBoundsChange() OVERRIDE;
+ virtual void OnNativeWidgetEndUserBoundsChange() OVERRIDE;
virtual bool HasFocusManager() const OVERRIDE;
virtual bool OnNativeWidgetPaintAccelerated(
const gfx::Rect& dirty_region) OVERRIDE;
virtual void OnNativeWidgetPaint(gfx::Canvas* canvas) OVERRIDE;
+ virtual int GetNonClientComponent(const gfx::Point& point) OVERRIDE;
virtual bool OnKeyEvent(const KeyEvent& event) OVERRIDE;
virtual bool OnMouseEvent(const MouseEvent& event) OVERRIDE;
virtual void OnMouseCaptureLost() OVERRIDE;
+ virtual bool ExecuteCommand(int command_id) OVERRIDE;
virtual Widget* AsWidget() OVERRIDE;
virtual const Widget* AsWidget() const OVERRIDE;
@@ -476,9 +512,11 @@ class Widget : public internal::NativeWidgetDelegate,
// Returns whether capture should be released on mouse release.
virtual bool ShouldReleaseCaptureOnMouseReleased() const;
- NativeWidget* native_widget_;
+ // Persists the window's restored position and maximized state using the
+ // window delegate.
+ void SaveWindowPosition();
- InitParams::Type type_;
+ NativeWidget* native_widget_;
// Non-owned pointer to the Widget's delegate. May be NULL if no delegate is
// being used.
@@ -521,6 +559,13 @@ class Widget : public internal::NativeWidgetDelegate,
// FRAME_TYPE_DEFAULT.
FrameType frame_type_;
+ // True when the window should be rendered as active, regardless of whether
+ // or not it actually is.
+ bool disable_inactive_rendering_;
+
+ // Set to true if the widget is in the process of closing.
+ bool widget_closed_;
+
DISALLOW_COPY_AND_ASSIGN(Widget);
};
diff --git a/views/widget/widget_delegate.cc b/views/widget/widget_delegate.cc
index e63cbbb..f58e891 100644
--- a/views/widget/widget_delegate.cc
+++ b/views/widget/widget_delegate.cc
@@ -99,7 +99,6 @@ std::wstring WidgetDelegate::GetWindowName() const {
void WidgetDelegate::SaveWindowPlacement(const gfx::Rect& bounds,
bool maximized) {
- DCHECK(window_);
std::wstring window_name = GetWindowName();
if (!ViewsDelegate::views_delegate || window_name.empty())
return;
@@ -133,11 +132,11 @@ bool WidgetDelegate::ShouldRestoreWindowSize() const {
}
View* WidgetDelegate::GetContentsView() {
- return NULL;
+ return new View;
}
-ClientView* WidgetDelegate::CreateClientView(Window* window) {
- return new ClientView(window, GetContentsView());
+ClientView* WidgetDelegate::CreateClientView(Widget* widget) {
+ return new ClientView(widget, GetContentsView());
}
NonClientFrameView* WidgetDelegate::CreateNonClientFrameView() {
diff --git a/views/widget/widget_delegate.h b/views/widget/widget_delegate.h
index 0e34e5b..a985051 100644
--- a/views/widget/widget_delegate.h
+++ b/views/widget/widget_delegate.h
@@ -22,6 +22,7 @@ class ClientView;
class DialogDelegate;
class NonClientFrameView;
class View;
+class Widget;
class Window;
// WidgetDelegate interface
@@ -137,8 +138,8 @@ class WidgetDelegate {
virtual View* GetContentsView();
// Called by the Window to create the Client View used to host the contents
- // of the window.
- virtual ClientView* CreateClientView(Window* window);
+ // of the widget.
+ virtual ClientView* CreateClientView(Widget* widget);
// Called by the Widget to create the NonClient Frame View for this widget.
// Return NULL to use the default one.
diff --git a/views/window/client_view.cc b/views/window/client_view.cc
index c91a6ae..bbea28c 100644
--- a/views/window/client_view.cc
+++ b/views/window/client_view.cc
@@ -8,8 +8,8 @@
#if defined(OS_LINUX)
#include "views/window/hit_test.h"
#endif
-#include "views/window/window.h"
-#include "views/window/window_delegate.h"
+#include "views/widget/widget.h"
+#include "views/widget/widget_delegate.h"
namespace views {
@@ -20,8 +20,8 @@ const char ClientView::kViewClassName[] =
///////////////////////////////////////////////////////////////////////////////
// ClientView, public:
-ClientView::ClientView(Window* window, View* contents_view)
- : window_(window),
+ClientView::ClientView(Widget* widget, View* contents_view)
+ : widget_(widget),
contents_view_(contents_view) {
}
@@ -37,7 +37,7 @@ bool ClientView::CanClose() {
return true;
}
-void ClientView::WindowClosing() {
+void ClientView::WidgetClosing() {
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/views/window/client_view.h b/views/window/client_view.h
index cbfc3a6..de1ca7e 100644
--- a/views/window/client_view.h
+++ b/views/window/client_view.h
@@ -11,13 +11,13 @@
namespace views {
class DialogClientView;
-class Window;
+class Widget;
///////////////////////////////////////////////////////////////////////////////
// ClientView
//
// A ClientView is a View subclass that is used to occupy the "client area"
-// of a window. It provides basic information to the window that contains it
+// of a widget. It provides basic information to the widget that contains it
// such as non-client hit testing information, sizing etc. Sub-classes of
// ClientView are used to create more elaborate contents, e.g.
// "DialogClientView".
@@ -26,25 +26,25 @@ class ClientView : public View {
// Internal class name
static const char kViewClassName[];
- // Constructs a ClientView object for the specified window with the specified
+ // Constructs a ClientView object for the specified widget with the specified
// contents. Since this object is created during the process of creating
- // |window|, |contents_view| must be valid if you want the initial size of
- // the window to be based on |contents_view|'s preferred size.
- ClientView(Window* window, View* contents_view);
+ // |widget|, |contents_view| must be valid if you want the initial size of
+ // the widget to be based on |contents_view|'s preferred size.
+ ClientView(Widget* widget, View* contents_view);
virtual ~ClientView() {}
// Manual RTTI ftw.
virtual DialogClientView* AsDialogClientView();
- // Returns true to signal that the Window can be closed. Specialized
+ // Returns true to signal that the Widget can be closed. Specialized
// ClientView subclasses can override this default behavior to allow the
// close to be blocked until the user corrects mistakes, accepts a warning
// dialog, etc.
virtual bool CanClose();
- // Notification that the window is closing. The default implementation
+ // Notification that the widget is closing. The default implementation
// forwards the notification to the delegate.
- virtual void WindowClosing();
+ virtual void WidgetClosing();
// Tests to see if the specified point (in view coordinates) is within the
// bounds of this view. If so, it returns HTCLIENT in this default
@@ -70,16 +70,14 @@ class ClientView : public View {
virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
// Accessors for private data members.
- Window* window() const { return window_; }
- void set_window(Window* window) { window_ = window; }
View* contents_view() const { return contents_view_; }
void set_contents_view(View* contents_view) {
contents_view_ = contents_view;
}
private:
- // The Window that hosts this ClientView.
- Window* window_;
+ // The Widget that hosts this ClientView.
+ Widget* widget_;
// The View that this ClientView contains.
View* contents_view_;
diff --git a/views/window/dialog_client_view.cc b/views/window/dialog_client_view.cc
index 3320a58..f4a3985 100644
--- a/views/window/dialog_client_view.cc
+++ b/views/window/dialog_client_view.cc
@@ -24,8 +24,8 @@
#include "views/controls/button/native_button.h"
#include "views/layout/layout_constants.h"
#include "views/widget/root_view.h"
+#include "views/widget/widget.h"
#include "views/window/dialog_delegate.h"
-#include "views/window/window.h"
#if defined(OS_WIN)
#include "ui/gfx/native_theme.h"
@@ -68,7 +68,7 @@ void FillViewWithSysColor(gfx::Canvas* canvas, View* view, COLORREF color) {
class DialogButton : public NativeButton {
public:
DialogButton(ButtonListener* listener,
- Window* owner,
+ Widget* owner,
MessageBoxFlags::DialogButton type,
const std::wstring& title,
bool is_default)
@@ -80,7 +80,7 @@ class DialogButton : public NativeButton {
// Overridden to forward to the delegate.
virtual bool AcceleratorPressed(const Accelerator& accelerator) {
- if (!owner_->window_delegate()->AsDialogDelegate()->
+ if (!owner_->widget_delegate()->AsDialogDelegate()->
AreAcceleratorsEnabled(type_)) {
return false;
}
@@ -88,7 +88,7 @@ class DialogButton : public NativeButton {
}
private:
- Window* owner_;
+ Widget* owner_;
const MessageBoxFlags::DialogButton type_;
DISALLOW_COPY_AND_ASSIGN(DialogButton);
@@ -109,7 +109,7 @@ static const int kButtonGroup = 6666;
///////////////////////////////////////////////////////////////////////////////
// DialogClientView, public:
-DialogClientView::DialogClientView(Window* owner, View* contents_view)
+DialogClientView::DialogClientView(Widget* owner, View* contents_view)
: ClientView(owner, contents_view),
ok_button_(NULL),
cancel_button_(NULL),
@@ -136,7 +136,7 @@ void DialogClientView::ShowDialogButtons() {
label = UTF16ToWide(l10n_util::GetStringUTF16(IDS_APP_OK));
bool is_default_button =
(dd->GetDefaultDialogButton() & MessageBoxFlags::DIALOGBUTTON_OK) != 0;
- ok_button_ = new DialogButton(this, window(),
+ ok_button_ = new DialogButton(this, GetWidget(),
MessageBoxFlags::DIALOGBUTTON_OK, label,
is_default_button);
ok_button_->SetGroup(kButtonGroup);
@@ -160,7 +160,7 @@ void DialogClientView::ShowDialogButtons() {
bool is_default_button =
(dd->GetDefaultDialogButton() & MessageBoxFlags::DIALOGBUTTON_CANCEL)
!= 0;
- cancel_button_ = new DialogButton(this, window(),
+ cancel_button_ = new DialogButton(this, GetWidget(),
MessageBoxFlags::DIALOGBUTTON_CANCEL,
label, is_default_button);
cancel_button_->SetGroup(kButtonGroup);
@@ -284,7 +284,7 @@ bool DialogClientView::CanClose() {
return close;
}
-void DialogClientView::WindowClosing() {
+void DialogClientView::WidgetClosing() {
if (listening_to_focus_) {
DCHECK(saved_focus_manager_);
if (saved_focus_manager_)
@@ -321,7 +321,7 @@ void DialogClientView::OnPaint(gfx::Canvas* canvas) {
void DialogClientView::PaintChildren(gfx::Canvas* canvas) {
View::PaintChildren(canvas);
- if (!window()->IsMaximized() && !window()->IsMinimized())
+ if (!GetWidget()->IsMaximized() && !GetWidget()->IsMinimized())
PaintSizeBox(canvas);
}
@@ -426,8 +426,8 @@ void DialogClientView::ButtonPressed(
// DialogClientView, private:
void DialogClientView::PaintSizeBox(gfx::Canvas* canvas) {
- if (window()->window_delegate()->CanResize() ||
- window()->window_delegate()->CanMaximize()) {
+ if (GetWidget()->widget_delegate()->CanResize() ||
+ GetWidget()->widget_delegate()->CanMaximize()) {
#if defined(OS_WIN)
gfx::NativeTheme::ExtraParams extra;
gfx::Size gripper_size = gfx::NativeTheme::instance()->GetPartSize(
@@ -539,11 +539,11 @@ void DialogClientView::CreateExtraView() {
}
DialogDelegate* DialogClientView::GetDialogDelegate() const {
- return window()->window_delegate()->AsDialogDelegate();
+ return GetWidget()->widget_delegate()->AsDialogDelegate();
}
void DialogClientView::Close() {
- window()->Close();
+ GetWidget()->Close();
GetDialogDelegate()->OnClose();
}
diff --git a/views/window/dialog_client_view.h b/views/window/dialog_client_view.h
index 4a3155a..27365b5 100644
--- a/views/window/dialog_client_view.h
+++ b/views/window/dialog_client_view.h
@@ -15,7 +15,7 @@ namespace views {
class DialogDelegate;
class NativeButton;
-class Window;
+class Widget;
namespace internal {
class RootView;
}
@@ -36,15 +36,15 @@ class DialogClientView : public ClientView,
public ButtonListener,
public FocusChangeListener {
public:
- DialogClientView(Window* window, View* contents_view);
+ DialogClientView(Widget* widget, View* contents_view);
virtual ~DialogClientView();
- // Adds the dialog buttons required by the supplied WindowDelegate to the
+ // Adds the dialog buttons required by the supplied DialogDelegate to the
// view.
void ShowDialogButtons();
// Updates the enabled state and label of the buttons required by the
- // supplied WindowDelegate
+ // supplied DialogDelegate
void UpdateDialogButtons();
// Accept the changes made in the window that contains this ClientView.
@@ -70,7 +70,7 @@ class DialogClientView : public ClientView,
// Overridden from ClientView:
virtual bool CanClose() OVERRIDE;
- virtual void WindowClosing() OVERRIDE;
+ virtual void WidgetClosing() OVERRIDE;
virtual int NonClientHitTest(const gfx::Point& point) OVERRIDE;
virtual DialogClientView* AsDialogClientView() OVERRIDE;
@@ -116,7 +116,7 @@ class DialogClientView : public ClientView,
// Returns the DialogDelegate for the window.
DialogDelegate* GetDialogDelegate() const;
- // Closes the window.
+ // Closes the widget.
void Close();
// Updates focus listener.
diff --git a/views/window/dialog_delegate.cc b/views/window/dialog_delegate.cc
index aa94e87..ee22c12 100644
--- a/views/window/dialog_delegate.cc
+++ b/views/window/dialog_delegate.cc
@@ -90,8 +90,8 @@ View* DialogDelegate::GetInitiallyFocusedView() {
return NULL;
}
-ClientView* DialogDelegate::CreateClientView(Window* window) {
- return new DialogClientView(window, GetContentsView());
+ClientView* DialogDelegate::CreateClientView(Widget* widget) {
+ return new DialogClientView(widget, GetContentsView());
}
DialogClientView* DialogDelegate::GetDialogClientView() const {
diff --git a/views/window/dialog_delegate.h b/views/window/dialog_delegate.h
index 8e5c3e6..607132b 100644
--- a/views/window/dialog_delegate.h
+++ b/views/window/dialog_delegate.h
@@ -96,10 +96,8 @@ class DialogDelegate : public WindowDelegate {
virtual bool Accept();
// Overridden from WindowDelegate:
- virtual View* GetInitiallyFocusedView();
-
- // Overridden from WindowDelegate:
- virtual ClientView* CreateClientView(Window* window);
+ virtual View* GetInitiallyFocusedView() OVERRIDE;
+ virtual ClientView* CreateClientView(Widget* widget) OVERRIDE;
// Called when the window has been closed.
virtual void OnClose() {}
diff --git a/views/window/native_window.h b/views/window/native_window.h
index ca5c6fc..278a54f 100644
--- a/views/window/native_window.h
+++ b/views/window/native_window.h
@@ -29,12 +29,6 @@ class NonClientFrameView;
//
class NativeWindow {
public:
- enum ShowState {
- SHOW_RESTORED,
- SHOW_MAXIMIZED,
- SHOW_INACTIVE
- };
-
virtual ~NativeWindow() {}
// Creates an appropriate default NativeWindow implementation for the current
@@ -51,18 +45,8 @@ class NativeWindow {
protected:
friend class Window;
- // Returns the bounds of the window in screen coordinates for its non-
- // maximized state, regardless of whether or not it is currently maximized.
- virtual gfx::Rect GetRestoredBounds() const = 0;
-
- // Shows the window.
- virtual void ShowNativeWindow(ShowState state) = 0;
-
// Makes the NativeWindow modal.
virtual void BecomeModal() = 0;
-
- // Enables or disables the close button for the window.
- virtual void EnableClose(bool enable) = 0;
};
} // namespace views
diff --git a/views/window/native_window_delegate.h b/views/window/native_window_delegate.h
index e596120..a317f7d 100644
--- a/views/window/native_window_delegate.h
+++ b/views/window/native_window_delegate.h
@@ -23,45 +23,15 @@ class NativeWindowDelegate {
public:
virtual ~NativeWindowDelegate() {}
- // Returns true if the window can be activated.
- virtual bool CanActivate() const = 0;
-
- virtual bool IsInactiveRenderingDisabled() const = 0;
- virtual void EnableInactiveRendering() = 0;
-
// Returns true if the window is modal.
virtual bool IsModal() const = 0;
// Returns true if the window is a dialog box.
virtual bool IsDialogBox() const = 0;
- // Returns the smallest size the window can be resized to by the user.
- virtual gfx::Size GetMinimumSize() = 0;
-
- // Returns the non-client component (see views/window/hit_test.h) containing
- // |point|, in client coordinates.
- virtual int GetNonClientComponent(const gfx::Point& point) = 0;
-
- // Runs the specified native command. Returns true if the command is handled.
- virtual bool ExecuteCommand(int command_id) = 0;
-
// Called just after the NativeWindow has been created.
virtual void OnNativeWindowCreated(const gfx::Rect& bounds) = 0;
- // Called when the activation state of a window has changed.
- virtual void OnNativeWindowActivationChanged(bool active) = 0;
-
- // Called when the user begins/ends to change the bounds of the window.
- virtual void OnNativeWindowBeginUserBoundsChange() = 0;
- virtual void OnNativeWindowEndUserBoundsChange() = 0;
-
- // Called just before the native window is destroyed. This is the delegate's
- // last chance to do anything with the native window handle.
- virtual void OnNativeWindowDestroying() = 0;
-
- // Called when the native window's position or size has changed.
- virtual void OnNativeWindowBoundsChanged() = 0;
-
//
virtual Window* AsWindow() = 0;
diff --git a/views/window/native_window_gtk.cc b/views/window/native_window_gtk.cc
index dd944ad..99a4f8a 100644
--- a/views/window/native_window_gtk.cc
+++ b/views/window/native_window_gtk.cc
@@ -187,11 +187,6 @@ gboolean NativeWindowGtk::OnLeaveNotify(GtkWidget* widget,
return NativeWidgetGtk::OnLeaveNotify(widget, event);
}
-void NativeWindowGtk::IsActiveChanged() {
- NativeWidgetGtk::IsActiveChanged();
- delegate_->OnNativeWindowActivationChanged(IsActive());
-}
-
void NativeWindowGtk::InitNativeWidget(const Widget::InitParams& params) {
NativeWidgetGtk::InitNativeWidget(params);
@@ -210,26 +205,10 @@ const NativeWidget* NativeWindowGtk::AsNativeWidget() const {
return this;
}
-gfx::Rect NativeWindowGtk::GetRestoredBounds() const {
- // We currently don't support tiling, so this doesn't matter.
- return GetWindowScreenBounds();
-}
-
-void NativeWindowGtk::ShowNativeWindow(ShowState state) {
- // No concept of maximization (yet) on ChromeOS.
- if (state == NativeWindow::SHOW_INACTIVE)
- gtk_window_set_focus_on_map(GetNativeWindow(), false);
- gtk_widget_show(GetNativeView());
-}
-
void NativeWindowGtk::BecomeModal() {
gtk_window_set_modal(GetNativeWindow(), true);
}
-void NativeWindowGtk::EnableClose(bool enable) {
- gtk_window_set_deletable(GetNativeWindow(), enable);
-}
-
Window* NativeWindowGtk::GetWindow() {
return delegate_->AsWindow();
}
@@ -241,13 +220,6 @@ const Window* NativeWindowGtk::GetWindow() const {
////////////////////////////////////////////////////////////////////////////////
// NativeWindowGtk, NativeWidgetGtk overrides:
-void NativeWindowGtk::Restore() {
- if (IsFullscreen())
- SetFullscreen(false);
- else
- NativeWidgetGtk::Restore();
-}
-
gboolean NativeWindowGtk::OnWindowStateEvent(GtkWidget* widget,
GdkEventWindowState* event) {
if (!(event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN))
@@ -276,11 +248,6 @@ void NativeWindowGtk::SaveWindowPosition() {
maximized);
}
-void NativeWindowGtk::OnDestroy(GtkWidget* widget) {
- delegate_->OnNativeWindowDestroying();
- NativeWidgetGtk::OnDestroy(widget);
-}
-
////////////////////////////////////////////////////////////////////////////////
// NativeWindow, public:
diff --git a/views/window/native_window_gtk.h b/views/window/native_window_gtk.h
index 3ea4c25..e3e5799 100644
--- a/views/window/native_window_gtk.h
+++ b/views/window/native_window_gtk.h
@@ -40,7 +40,6 @@ class NativeWindowGtk : public NativeWidgetGtk, public NativeWindow {
virtual gboolean OnMotionNotify(GtkWidget* widget, GdkEventMotion* event);
virtual void OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation);
virtual gboolean OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event);
- virtual void IsActiveChanged();
protected:
virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE;
@@ -48,21 +47,15 @@ class NativeWindowGtk : public NativeWidgetGtk, public NativeWindow {
// Overridden from NativeWindow:
virtual NativeWidget* AsNativeWidget() OVERRIDE;
virtual const NativeWidget* AsNativeWidget() const OVERRIDE;
- virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
- virtual void ShowNativeWindow(ShowState state) OVERRIDE;
virtual void BecomeModal() OVERRIDE;
- virtual void EnableClose(bool enable) OVERRIDE;
// Overridden from NativeWidgetGtk:
- virtual void Restore() OVERRIDE;
virtual gboolean OnWindowStateEvent(GtkWidget* widget,
GdkEventWindowState* event) OVERRIDE;
// For the constructor.
friend class Window;
- virtual void OnDestroy(GtkWidget* widget);
-
private:
static gboolean CallConfigureEvent(GtkWidget* widget,
GdkEventConfigure* event,
diff --git a/views/window/native_window_views.cc b/views/window/native_window_views.cc
index 26bc697..409380c 100644
--- a/views/window/native_window_views.cc
+++ b/views/window/native_window_views.cc
@@ -39,22 +39,8 @@ const NativeWidget* NativeWindowViews::AsNativeWidget() const {
return this;
}
-gfx::Rect NativeWindowViews::GetRestoredBounds() const {
- NOTIMPLEMENTED();
- return GetView()->bounds();
-}
-
-void NativeWindowViews::ShowNativeWindow(ShowState state) {
- NOTIMPLEMENTED();
- GetView()->SetVisible(true);
-}
-
void NativeWindowViews::BecomeModal() {
NOTIMPLEMENTED();
}
-
-void NativeWindowViews::EnableClose(bool enable) {
-}
-
} // namespace views
diff --git a/views/window/native_window_views.h b/views/window/native_window_views.h
index 1489d08..f944c00 100644
--- a/views/window/native_window_views.h
+++ b/views/window/native_window_views.h
@@ -29,10 +29,7 @@ class NativeWindowViews : public NativeWidgetViews,
virtual const Window* GetWindow() const OVERRIDE;
virtual NativeWidget* AsNativeWidget() OVERRIDE;
virtual const NativeWidget* AsNativeWidget() const OVERRIDE;
- virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
- virtual void ShowNativeWindow(ShowState state) OVERRIDE;
virtual void BecomeModal() OVERRIDE;
- virtual void EnableClose(bool enable) OVERRIDE;
internal::NativeWindowDelegate* delegate_;
diff --git a/views/window/native_window_win.cc b/views/window/native_window_win.cc
index df35437..611b6fe 100644
--- a/views/window/native_window_win.cc
+++ b/views/window/native_window_win.cc
@@ -66,20 +66,6 @@ HWND GetOwner(HWND window) {
return ::GetWindow(window, GW_OWNER);
}
-// Tells the window its frame (non-client area) has changed.
-void SendFrameChanged(HWND window) {
- SetWindowPos(window, NULL, 0, 0, 0, 0,
- SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOCOPYBITS |
- SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREPOSITION |
- SWP_NOSENDCHANGING | SWP_NOSIZE | SWP_NOZORDER);
-}
-
-// Enables or disables the menu item for the specified command and menu.
-void EnableMenuItem(HMENU menu, UINT command, bool enabled) {
- UINT flags = MF_BYCOMMAND | (enabled ? MF_ENABLED : MF_DISABLED | MF_GRAYED);
- EnableMenuItem(menu, command, flags);
-}
-
} // namespace
namespace internal {
@@ -123,46 +109,6 @@ void EnsureRectIsVisibleInRect(const gfx::Rect& parent_rect,
} // namespace internal
-// A scoping class that prevents a window from being able to redraw in response
-// to invalidations that may occur within it for the lifetime of the object.
-//
-// Why would we want such a thing? Well, it turns out Windows has some
-// "unorthodox" behavior when it comes to painting its non-client areas.
-// Occasionally, Windows will paint portions of the default non-client area
-// right over the top of the custom frame. This is not simply fixed by handling
-// WM_NCPAINT/WM_PAINT, with some investigation it turns out that this
-// rendering is being done *inside* the default implementation of some message
-// handlers and functions:
-// . WM_SETTEXT
-// . WM_SETICON
-// . WM_NCLBUTTONDOWN
-// . EnableMenuItem, called from our WM_INITMENU handler
-// The solution is to handle these messages and call DefWindowProc ourselves,
-// but prevent the window from being able to update itself for the duration of
-// the call. We do this with this class, which automatically calls its
-// associated Window's lock and unlock functions as it is created and destroyed.
-// See documentation in those methods for the technique used.
-//
-// IMPORTANT: Do not use this scoping object for large scopes or periods of
-// time! IT WILL PREVENT THE WINDOW FROM BEING REDRAWN! (duh).
-//
-// I would love to hear Raymond Chen's explanation for all this. And maybe a
-// list of other messages that this applies to ;-)
-class NativeWindowWin::ScopedRedrawLock {
- public:
- explicit ScopedRedrawLock(NativeWindowWin* window) : window_(window) {
- window_->LockUpdates();
- }
-
- ~ScopedRedrawLock() {
- window_->UnlockUpdates();
- }
-
- private:
- // The window having its style changed.
- NativeWindowWin* window_;
-};
-
////////////////////////////////////////////////////////////////////////////////
// NativeWindowWin, public:
@@ -170,9 +116,6 @@ NativeWindowWin::NativeWindowWin(internal::NativeWindowDelegate* delegate)
: NativeWidgetWin(delegate->AsNativeWidgetDelegate()),
delegate_(delegate),
restored_enabled_(false),
- is_active_(false),
- lock_updates_(false),
- saved_window_style_(0),
ignore_window_pos_changes_(false),
ignore_pos_changes_factory_(this),
is_right_mouse_pressed_on_caption_(false),
@@ -187,29 +130,6 @@ NativeWindowWin::NativeWindowWin(internal::NativeWindowDelegate* delegate)
NativeWindowWin::~NativeWindowWin() {
}
-void NativeWindowWin::Show(int show_state) {
- ShowWindow(show_state);
- // When launched from certain programs like bash and Windows Live Messenger,
- // show_state is set to SW_HIDE, so we need to correct that condition. We
- // don't just change show_state to SW_SHOWNORMAL because MSDN says we must
- // always first call ShowWindow with the specified value from STARTUPINFO,
- // otherwise all future ShowWindow calls will be ignored (!!#@@#!). Instead,
- // we call ShowWindow again in this case.
- if (show_state == SW_HIDE) {
- show_state = SW_SHOWNORMAL;
- ShowWindow(show_state);
- }
-
- // We need to explicitly activate the window if we've been shown with a state
- // that should activate, because if we're opened from a desktop shortcut while
- // an existing window is already running it doesn't seem to be enough to use
- // one of these flags to activate the window.
- if (show_state == SW_SHOWNORMAL || show_state == SW_SHOWMAXIMIZED)
- Activate();
-
- SetInitialFocus();
-}
-
// static
gfx::Font NativeWindowWin::GetWindowTitleFont() {
NONCLIENTMETRICS ncm;
@@ -220,40 +140,6 @@ gfx::Font NativeWindowWin::GetWindowTitleFont() {
}
///////////////////////////////////////////////////////////////////////////////
-// NativeWindowWin, protected:
-
-gfx::Insets NativeWindowWin::GetClientAreaInsets() const {
- // Returning an empty Insets object causes the default handling in
- // NativeWidgetWin::OnNCCalcSize() to be invoked.
- if (GetWindow()->ShouldUseNativeFrame())
- return gfx::Insets();
-
- if (IsMaximized()) {
- // Windows automatically adds a standard width border to all sides when a
- // window is maximized.
- int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME);
- return gfx::Insets(border_thickness, border_thickness, border_thickness,
- border_thickness);
- }
- // This is weird, but highly essential. If we don't offset the bottom edge
- // of the client rect, the window client area and window area will match,
- // and when returning to glass rendering mode from non-glass, the client
- // area will not paint black as transparent. This is because (and I don't
- // know why) the client area goes from matching the window rect to being
- // something else. If the client area is not the window rect in both
- // modes, the blackness doesn't occur. Because of this, we need to tell
- // the RootView to lay out to fit the window rect, rather than the client
- // rect when using the opaque frame.
- // Note: this is only required for non-fullscreen windows. Note that
- // fullscreen windows are in restored state, not maximized.
- return gfx::Insets(0, 0, IsFullscreen() ? 0 : 1, 0);
-}
-
-int NativeWindowWin::GetShowState() const {
- return SW_SHOWNORMAL;
-}
-
-///////////////////////////////////////////////////////////////////////////////
// NativeWindowWin, NativeWidgetWin overrides:
void NativeWindowWin::InitNativeWidget(const Widget::InitParams& params) {
@@ -268,83 +154,11 @@ void NativeWindowWin::InitNativeWidget(const Widget::InitParams& params) {
NativeWidgetWin::InitNativeWidget(params);
}
-void NativeWindowWin::OnActivateApp(BOOL active, DWORD thread_id) {
- if (!active && thread_id != GetCurrentThreadId()) {
- // Another application was activated, we should reset any state that
- // disables inactive rendering now.
- delegate_->EnableInactiveRendering();
- // Update the native frame too, since it could be rendering the non-client
- // area.
- CallDefaultNCActivateHandler(FALSE);
- }
-}
-
void NativeWindowWin::OnDestroy() {
- delegate_->OnNativeWindowDestroying();
RestoreEnabledIfNecessary();
NativeWidgetWin::OnDestroy();
}
-LRESULT NativeWindowWin::OnDwmCompositionChanged(UINT msg,
- WPARAM w_param,
- LPARAM l_param) {
- // For some reason, we need to hide the window while we're changing the frame
- // type only when we're changing it in response to WM_DWMCOMPOSITIONCHANGED.
- // If we don't, the client area will be filled with black. I'm suspecting
- // something skia-ey.
- // Frame type toggling caused by the user (e.g. switching theme) doesn't seem
- // to have this requirement.
- FrameTypeChanged();
- return 0;
-}
-
-void NativeWindowWin::OnEnterSizeMove() {
- NativeWidgetWin::OnEnterSizeMove();
- delegate_->OnNativeWindowBeginUserBoundsChange();
-}
-
-void NativeWindowWin::OnExitSizeMove() {
- NativeWidgetWin::OnExitSizeMove();
- delegate_->OnNativeWindowEndUserBoundsChange();
-}
-
-void NativeWindowWin::OnGetMinMaxInfo(MINMAXINFO* minmax_info) {
- gfx::Size min_window_size(delegate_->GetMinimumSize());
- minmax_info->ptMinTrackSize.x = min_window_size.width();
- minmax_info->ptMinTrackSize.y = min_window_size.height();
- NativeWidgetWin::OnGetMinMaxInfo(minmax_info);
-}
-
-void NativeWindowWin::OnInitMenu(HMENU menu) {
- // We only need to manually enable the system menu if we're not using a native
- // frame.
- if (GetWindow()->ShouldUseNativeFrame())
- NativeWidgetWin::OnInitMenu(menu);
-
- bool is_fullscreen = IsFullscreen();
- bool is_minimized = IsMinimized();
- bool is_maximized = IsMaximized();
- bool is_restored = !is_fullscreen && !is_minimized && !is_maximized;
-
- ScopedRedrawLock lock(this);
- EnableMenuItem(menu, SC_RESTORE, is_minimized || is_maximized);
- EnableMenuItem(menu, SC_MOVE, is_restored);
- EnableMenuItem(menu, SC_SIZE,
- GetWindow()->window_delegate()->CanResize() && is_restored);
- EnableMenuItem(menu, SC_MAXIMIZE,
- GetWindow()->window_delegate()->CanMaximize() &&
- !is_fullscreen && !is_maximized);
- EnableMenuItem(menu, SC_MINIMIZE,
- GetWindow()->window_delegate()->CanMaximize() &&
- !is_minimized);
-}
-
-LRESULT NativeWindowWin::OnMouseActivate(UINT message,
- WPARAM w_param,
- LPARAM l_param) {
- return delegate_->CanActivate() ? MA_ACTIVATE : MA_NOACTIVATEANDEAT;
-}
-
LRESULT NativeWindowWin::OnMouseRange(UINT message,
WPARAM w_param,
LPARAM l_param) {
@@ -421,51 +235,6 @@ LRESULT NativeWindowWin::OnMouseRange(UINT message,
return 0;
}
-namespace {
-BOOL CALLBACK EnumChildWindowsForRedraw(HWND hwnd, LPARAM lparam) {
- DWORD process_id;
- GetWindowThreadProcessId(hwnd, &process_id);
- int flags = RDW_INVALIDATE | RDW_NOCHILDREN | RDW_FRAME;
- if (process_id == GetCurrentProcessId())
- flags |= RDW_UPDATENOW;
- RedrawWindow(hwnd, NULL, NULL, flags);
- return TRUE;
-}
-} // namespace
-
-LRESULT NativeWindowWin::OnNCActivate(BOOL active) {
- if (!delegate_->CanActivate())
- return TRUE;
-
- is_active_ = !!active;
- delegate_->OnNativeWindowActivationChanged(is_active_);
-
- // The frame may need to redraw as a result of the activation change.
- // We can get WM_NCACTIVATE before we're actually visible. If we're not
- // visible, no need to paint.
- if (IsVisible())
- GetWindow()->non_client_view()->SchedulePaint();
-
- if (!GetWindow()->ShouldUseNativeFrame()) {
- // TODO(beng, et al): Hack to redraw this window and child windows
- // synchronously upon activation. Not all child windows are redrawing
- // themselves leading to issues like http://crbug.com/74604
- // We redraw out-of-process HWNDs asynchronously to avoid hanging the
- // whole app if a child HWND belonging to a hung plugin is encountered.
- RedrawWindow(GetNativeView(), NULL, NULL,
- RDW_NOCHILDREN | RDW_INVALIDATE | RDW_UPDATENOW);
- EnumChildWindows(GetNativeView(), EnumChildWindowsForRedraw, NULL);
- }
-
- // If we're active again, we should be allowed to render as inactive, so
- // tell the non-client view.
- bool inactive_rendering_disabled = delegate_->IsInactiveRenderingDisabled();
- if (IsActive())
- delegate_->EnableInactiveRendering();
-
- return CallDefaultNCActivateHandler(inactive_rendering_disabled || active);
-}
-
LRESULT NativeWindowWin::OnNCCalcSize(BOOL mode, LPARAM l_param) {
// We only override the default handling if we need to specify a custom
// non-client edge width. Note that in most cases "no insets" means no
@@ -546,30 +315,6 @@ LRESULT NativeWindowWin::OnNCCalcSize(BOOL mode, LPARAM l_param) {
return mode ? WVR_REDRAW : 0;
}
-LRESULT NativeWindowWin::OnNCHitTest(const CPoint& point) {
- // If the DWM is rendering the window controls, we need to give the DWM's
- // default window procedure first chance to handle hit testing.
- if (GetWindow()->ShouldUseNativeFrame()) {
- LRESULT result;
- if (DwmDefWindowProc(GetNativeView(), WM_NCHITTEST, 0,
- MAKELPARAM(point.x, point.y), &result)) {
- return result;
- }
- }
-
- // First, give the NonClientView a chance to test the point to see if it
- // provides any of the non-client area.
- POINT temp = point;
- MapWindowPoints(HWND_DESKTOP, GetNativeView(), &temp, 1);
- int component = delegate_->GetNonClientComponent(gfx::Point(temp));
- if (component != HTNOWHERE)
- return component;
-
- // Otherwise, we let Windows do all the native frame non-client handling for
- // us.
- return NativeWidgetWin::OnNCHitTest(point);
-}
-
namespace {
struct ClipState {
// The window being painted.
@@ -681,99 +426,6 @@ void NativeWindowWin::OnNCPaint(HRGN rgn) {
SetMsgHandled(!GetWindow()->ShouldUseNativeFrame());
}
-LRESULT NativeWindowWin::OnNCUAHDrawCaption(UINT msg,
- WPARAM w_param,
- LPARAM l_param) {
- // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for
- // an explanation about why we need to handle this message.
- SetMsgHandled(!GetWindow()->ShouldUseNativeFrame());
- return 0;
-}
-
-LRESULT NativeWindowWin::OnNCUAHDrawFrame(UINT msg,
- WPARAM w_param,
- LPARAM l_param) {
- // See comment in widget_win.h at the definition of WM_NCUAHDRAWCAPTION for
- // an explanation about why we need to handle this message.
- SetMsgHandled(!GetWindow()->ShouldUseNativeFrame());
- return 0;
-}
-
-LRESULT NativeWindowWin::OnSetCursor(UINT msg,
- WPARAM w_param,
- LPARAM l_param) {
- // This shouldn't hurt even if we're using the native frame.
- ScopedRedrawLock lock(this);
- return DefWindowProc(GetNativeView(), msg, w_param, l_param);
-}
-
-LRESULT NativeWindowWin::OnSetIcon(UINT size_type, HICON new_icon) {
- // This shouldn't hurt even if we're using the native frame.
- ScopedRedrawLock lock(this);
- return DefWindowProc(GetNativeView(), WM_SETICON, size_type,
- reinterpret_cast<LPARAM>(new_icon));
-}
-
-LRESULT NativeWindowWin::OnSetText(const wchar_t* text) {
- // This shouldn't hurt even if we're using the native frame.
- ScopedRedrawLock lock(this);
- return DefWindowProc(GetNativeView(), WM_SETTEXT, NULL,
- reinterpret_cast<LPARAM>(text));
-}
-
-void NativeWindowWin::OnSize(UINT size_param, const CSize& new_size) {
- delegate_->OnNativeWindowBoundsChanged();
- RedrawWindow(GetNativeView(), NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN);
- NativeWidgetWin::OnSize(size_param, new_size);
-}
-
-void NativeWindowWin::OnSysCommand(UINT notification_code, CPoint click) {
- // Windows uses the 4 lower order bits of |notification_code| for type-
- // specific information so we must exclude this when comparing.
- static const int sc_mask = 0xFFF0;
- // Ignore size/move/maximize in fullscreen mode.
- if (IsFullscreen() &&
- (((notification_code & sc_mask) == SC_SIZE) ||
- ((notification_code & sc_mask) == SC_MOVE) ||
- ((notification_code & sc_mask) == SC_MAXIMIZE)))
- return;
- if (!GetWindow()->ShouldUseNativeFrame()) {
- if ((notification_code & sc_mask) == SC_MINIMIZE ||
- (notification_code & sc_mask) == SC_MAXIMIZE ||
- (notification_code & sc_mask) == SC_RESTORE) {
- GetWindow()->non_client_view()->ResetWindowControls();
- } else if ((notification_code & sc_mask) == SC_MOVE ||
- (notification_code & sc_mask) == SC_SIZE) {
- if (lock_updates_) {
- // We were locked, before entering a resize or move modal loop. Now that
- // we've begun to move the window, we need to unlock updates so that the
- // sizing/moving feedback can be continuous.
- UnlockUpdates();
- }
- }
- }
-
- // Handle SC_KEYMENU, which means that the user has pressed the ALT
- // key and released it, so we should focus the menu bar.
- if ((notification_code & sc_mask) == SC_KEYMENU && click.x == 0) {
- // Retrieve the status of shift and control keys to prevent consuming
- // shift+alt keys, which are used by Windows to change input languages.
- Accelerator accelerator(ui::KeyboardCodeForWindowsKeyCode(VK_MENU),
- !!(GetKeyState(VK_SHIFT) & 0x8000),
- !!(GetKeyState(VK_CONTROL) & 0x8000),
- false);
- AsNativeWidget()->GetWidget()->GetFocusManager()->
- ProcessAccelerator(accelerator);
- return;
- }
-
- // If the delegate can't handle it, the system implementation will be called.
- if (!delegate_->ExecuteCommand(notification_code)) {
- DefWindowProc(GetNativeView(), WM_SYSCOMMAND, notification_code,
- MAKELPARAM(click.x, click.y));
- }
-}
-
void NativeWindowWin::OnWindowPosChanging(WINDOWPOS* window_pos) {
if (ignore_window_pos_changes_) {
// If somebody's trying to toggle our visibility, change the nonclient area,
@@ -858,33 +510,6 @@ const NativeWidget* NativeWindowWin::AsNativeWidget() const {
return this;
}
-gfx::Rect NativeWindowWin::GetRestoredBounds() const {
- // If we're in fullscreen mode, we've changed the normal bounds to the monitor
- // rect, so return the saved bounds instead.
- if (IsFullscreen())
- return gfx::Rect(saved_window_info_.window_rect);
-
- gfx::Rect bounds;
- GetWindowBoundsAndMaximizedState(&bounds, NULL);
- return bounds;
-}
-
-void NativeWindowWin::ShowNativeWindow(ShowState state) {
- DWORD native_show_state;
- switch (state) {
- case SHOW_INACTIVE:
- native_show_state = SW_SHOWNOACTIVATE;
- break;
- case SHOW_MAXIMIZED:
- native_show_state = SW_SHOWMAXIMIZED;
- break;
- default:
- native_show_state = GetShowState();
- break;
- }
- Show(native_show_state);
-}
-
void NativeWindowWin::BecomeModal() {
// We implement modality by crawling up the hierarchy of windows starting
// at the owner, disabling all of them so that they don't receive input
@@ -896,22 +521,6 @@ void NativeWindowWin::BecomeModal() {
}
}
-void NativeWindowWin::EnableClose(bool enable) {
- // Disable the native frame's close button regardless of whether or not the
- // native frame is in use, since this also affects the system menu.
- EnableMenuItem(GetSystemMenu(GetNativeView(), false), SC_CLOSE, enable);
- SendFrameChanged(GetNativeView());
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// NativeWindowWin, NativeWidgetWin overrides:
-
-bool NativeWindowWin::IsActive() const {
- // TODO(beng): evaluate whether or not this is needed. NativeWidgetWin checks
- // active-state with the OS using GetWindowInfo().
- return is_active_;
-}
-
////////////////////////////////////////////////////////////////////////////////
// NativeWindowWin, private:
@@ -953,25 +562,6 @@ DWORD NativeWindowWin::CalculateWindowExStyle() {
return delegate_->IsDialogBox() ? WS_EX_DLGMODALFRAME : 0;
}
-void NativeWindowWin::LockUpdates() {
- lock_updates_ = true;
- saved_window_style_ = GetWindowLong(GWL_STYLE);
- SetWindowLong(GWL_STYLE, saved_window_style_ & ~WS_VISIBLE);
-}
-
-void NativeWindowWin::UnlockUpdates() {
- SetWindowLong(GWL_STYLE, saved_window_style_);
- lock_updates_ = false;
-}
-
-LRESULT NativeWindowWin::CallDefaultNCActivateHandler(BOOL active) {
- // The DefWindowProc handling for WM_NCACTIVATE renders the classic-look
- // window title bar directly, so we need to use a redraw lock here to prevent
- // it from doing so.
- ScopedRedrawLock lock(this);
- return DefWindowProc(GetNativeView(), WM_NCACTIVATE, active, 0);
-}
-
////////////////////////////////////////////////////////////////////////////////
// NativeWindow, public:
diff --git a/views/window/native_window_win.h b/views/window/native_window_win.h
index 8652c42..3243739 100644
--- a/views/window/native_window_win.h
+++ b/views/window/native_window_win.h
@@ -47,9 +47,6 @@ class NativeWindowWin : public NativeWidgetWin,
explicit NativeWindowWin(internal::NativeWindowDelegate* delegate);
virtual ~NativeWindowWin();
- // Show the window with the specified show command.
- void Show(int show_state);
-
// Returns the system set window title font.
static gfx::Font GetWindowTitleFont();
@@ -60,63 +57,20 @@ class NativeWindowWin : public NativeWidgetWin,
protected:
friend Window;
- // Returns the insets of the client area relative to the non-client area of
- // the window. Override this function instead of OnNCCalcSize, which is
- // crazily complicated.
- virtual gfx::Insets GetClientAreaInsets() const;
-
- // Retrieve the show state of the window. This is one of the SW_SHOW* flags
- // passed into Windows' ShowWindow method. For normal windows this defaults
- // to SW_SHOWNORMAL, however windows (e.g. the main window) can override this
- // method to provide different values (e.g. retrieve the user's specified
- // show state from the shortcut starutp info).
- virtual int GetShowState() const;
-
// Overridden from NativeWidgetWin:
virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE;
- virtual void OnActivateApp(BOOL active, DWORD thread_id) OVERRIDE;
virtual void OnDestroy() OVERRIDE;
- virtual LRESULT OnDwmCompositionChanged(UINT msg,
- WPARAM w_param,
- LPARAM l_param) OVERRIDE;
- virtual void OnEnterSizeMove() OVERRIDE;
- virtual void OnExitSizeMove() OVERRIDE;
- virtual void OnGetMinMaxInfo(MINMAXINFO* minmax_info) OVERRIDE;
- virtual void OnInitMenu(HMENU menu) OVERRIDE;
- virtual LRESULT OnMouseActivate(UINT message, WPARAM w_param, LPARAM l_param)
- OVERRIDE;
virtual LRESULT OnMouseRange(UINT message,
WPARAM w_param,
LPARAM l_param) OVERRIDE;
- virtual LRESULT OnNCActivate(BOOL active) OVERRIDE;
LRESULT OnNCCalcSize(BOOL mode, LPARAM l_param); // Don't override.
- virtual LRESULT OnNCHitTest(const CPoint& point) OVERRIDE;
virtual void OnNCPaint(HRGN rgn) OVERRIDE;
- virtual LRESULT OnNCUAHDrawCaption(UINT msg,
- WPARAM w_param,
- LPARAM l_param) OVERRIDE;
- virtual LRESULT OnNCUAHDrawFrame(UINT msg,
- WPARAM w_param,
- LPARAM l_param) OVERRIDE;
- virtual LRESULT OnSetCursor(UINT message,
- WPARAM w_param,
- LPARAM l_param) OVERRIDE;
- virtual LRESULT OnSetIcon(UINT size_type, HICON new_icon) OVERRIDE;
- virtual LRESULT OnSetText(const wchar_t* text) OVERRIDE;
- virtual void OnSize(UINT size_param, const CSize& new_size) OVERRIDE;
- virtual void OnSysCommand(UINT notification_code, CPoint click) OVERRIDE;
virtual void OnWindowPosChanging(WINDOWPOS* window_pos) OVERRIDE;
// Overridden from NativeWindow:
virtual NativeWidget* AsNativeWidget() OVERRIDE;
virtual const NativeWidget* AsNativeWidget() const OVERRIDE;
- virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
- virtual void ShowNativeWindow(ShowState state) OVERRIDE;
virtual void BecomeModal() OVERRIDE;
- virtual void EnableClose(bool enable) OVERRIDE;
-
- // Overridden from NativeWidgetWin:
- virtual bool IsActive() const OVERRIDE;
private:
// If necessary, enables all ancestors.
@@ -126,12 +80,6 @@ class NativeWindowWin : public NativeWidgetWin,
DWORD CalculateWindowStyle();
DWORD CalculateWindowExStyle();
- // Lock or unlock the window from being able to redraw itself in response to
- // updates to its invalid region.
- class ScopedRedrawLock;
- void LockUpdates();
- void UnlockUpdates();
-
// Stops ignoring SetWindowPos() requests (see below).
void StopIgnoringPosChanges() { ignore_window_pos_changes_ = false; }
@@ -140,11 +88,6 @@ class NativeWindowWin : public NativeWidgetWin,
void UpdateAccessibleRole();
void UpdateAccessibleState();
- // Calls the default WM_NCACTIVATE handler with the specified activation
- // value, safely wrapping the call in a ScopedRedrawLock to prevent frame
- // flicker.
- LRESULT CallDefaultNCActivateHandler(BOOL active);
-
// A delegate implementation that handles events received here.
internal::NativeWindowDelegate* delegate_;
@@ -152,15 +95,6 @@ class NativeWindowWin : public NativeWidgetWin,
// true.
bool restored_enabled_;
- // True if this window is the active top level window.
- bool is_active_;
-
- // True if updates to this window are currently locked.
- bool lock_updates_;
-
- // The window styles of the window before updates were locked.
- DWORD saved_window_style_;
-
// When true, this flag makes us discard incoming SetWindowPos() requests that
// only change our position/size. (We still allow changes to Z-order,
// activation, etc.)
diff --git a/views/window/non_client_view.cc b/views/window/non_client_view.cc
index 48675c7..fdf4230 100644
--- a/views/window/non_client_view.cc
+++ b/views/window/non_client_view.cc
@@ -60,7 +60,7 @@ bool NonClientView::CanClose() {
}
void NonClientView::WindowClosing() {
- client_view_->WindowClosing();
+ client_view_->WidgetClosing();
}
void NonClientView::UpdateFrame() {
@@ -190,7 +190,7 @@ views::View* NonClientView::GetEventHandlerForPoint(const gfx::Point& point) {
bool NonClientFrameView::HitTest(const gfx::Point& l) const {
// For the default case, we assume the non-client frame view never overlaps
// the client view.
- return !GetWindow()->client_view()->bounds().Contains(l);
+ return !GetWidget()->client_view()->bounds().Contains(l);
}
////////////////////////////////////////////////////////////////////////////////
@@ -246,7 +246,7 @@ int NonClientFrameView::GetHTComponentForFrame(const gfx::Point& point,
}
bool NonClientFrameView::ShouldPaintAsActive() const {
- return GetWindow()->IsActive() || paint_as_active_;
+ return GetWidget()->IsActive() || paint_as_active_;
}
void NonClientFrameView::GetAccessibleState(ui::AccessibleViewState* state) {
diff --git a/views/window/window.cc b/views/window/window.cc
index 4dc8fd8..d16ff6c 100644
--- a/views/window/window.cc
+++ b/views/window/window.cc
@@ -5,7 +5,6 @@
#include "views/window/window.h"
#include "base/string_util.h"
-#include "base/utf_string_conversions.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/l10n/l10n_font_util.h"
#include "ui/base/resource/resource_bundle.h"
@@ -32,9 +31,7 @@ Window::InitParams::InitParams(WindowDelegate* window_delegate)
Window::Window()
: native_window_(NULL),
saved_maximized_state_(false),
- minimum_size_(100, 100),
- disable_inactive_rendering_(false),
- window_closed_(false) {
+ minimum_size_(100, 100) {
}
Window::~Window() {
@@ -88,96 +85,30 @@ void Window::InitWindow(const InitParams& params) {
OnNativeWindowCreated(modified_params.widget_init_params.bounds);
}
-gfx::Rect Window::GetBounds() const {
- return GetWindowScreenBounds();
-}
-
-gfx::Rect Window::GetNormalBounds() const {
- return native_window_->GetRestoredBounds();
-}
-
-void Window::ShowInactive() {
- native_window_->ShowNativeWindow(NativeWindow::SHOW_INACTIVE);
-}
-
-void Window::DisableInactiveRendering() {
- disable_inactive_rendering_ = true;
- non_client_view()->DisableInactiveRendering(disable_inactive_rendering_);
-}
-
-void Window::EnableClose(bool enable) {
- non_client_view()->EnableClose(enable);
- native_window_->EnableClose(enable);
-}
-
-void Window::UpdateWindowTitle() {
- // If the non-client view is rendering its own title, it'll need to relayout
- // now.
- non_client_view()->Layout();
-
- // Update the native frame's text. We do this regardless of whether or not
- // the native frame is being used, since this also updates the taskbar, etc.
- string16 window_title;
- if (native_window_->AsNativeWidget()->IsScreenReaderActive()) {
- window_title = WideToUTF16(widget_delegate()->GetAccessibleWindowTitle());
- } else {
- window_title = WideToUTF16(widget_delegate()->GetWindowTitle());
- }
- base::i18n::AdjustStringForLocaleDirection(&window_title);
- native_window_->AsNativeWidget()->SetWindowTitle(UTF16ToWide(window_title));
-}
-
-void Window::UpdateWindowIcon() {
- non_client_view()->UpdateWindowIcon();
- native_window_->AsNativeWidget()->SetWindowIcons(
- widget_delegate()->GetWindowIcon(),
- widget_delegate()->GetWindowAppIcon());
-}
-
////////////////////////////////////////////////////////////////////////////////
// Window, Widget overrides:
void Window::Show() {
- native_window_->ShowNativeWindow(
- saved_maximized_state_ ? NativeWindow::SHOW_MAXIMIZED
- : NativeWindow::SHOW_RESTORED);
+ native_window_->AsNativeWidget()->ShowNativeWidget(
+ saved_maximized_state_ ? NativeWidget::SHOW_MAXIMIZED
+ : NativeWidget::SHOW_RESTORED);
// |saved_maximized_state_| only applies the first time the window is shown.
// If we don't reset the value the window will be shown maximized every time
// it is subsequently shown after being hidden.
saved_maximized_state_ = false;
}
-void Window::Close() {
- if (window_closed_) {
- // It appears we can hit this code path if you close a modal dialog then
- // close the last browser before the destructor is hit, which triggers
- // invoking Close again.
- return;
- }
+Window* Window::AsWindow() {
+ return this;
+}
- if (non_client_view()->CanClose()) {
- SaveWindowPosition();
- Widget::Close();
- window_closed_ = true;
- }
+const Window* Window::AsWindow() const {
+ return this;
}
////////////////////////////////////////////////////////////////////////////////
// Window, internal::NativeWindowDelegate implementation:
-bool Window::CanActivate() const {
- return widget_delegate()->CanActivate();
-}
-
-bool Window::IsInactiveRenderingDisabled() const {
- return disable_inactive_rendering_;
-}
-
-void Window::EnableInactiveRendering() {
- disable_inactive_rendering_ = false;
- non_client_view()->DisableInactiveRendering(false);
-}
-
bool Window::IsModal() const {
return widget_delegate()->IsModal();
}
@@ -186,64 +117,14 @@ bool Window::IsDialogBox() const {
return !!widget_delegate()->AsDialogDelegate();
}
-gfx::Size Window::GetMinimumSize() {
- return non_client_view()->GetMinimumSize();
-}
-
-int Window::GetNonClientComponent(const gfx::Point& point) {
- return non_client_view()->NonClientHitTest(point);
-}
-
-bool Window::ExecuteCommand(int command_id) {
- return widget_delegate()->ExecuteWindowsCommand(command_id);
-}
-
void Window::OnNativeWindowCreated(const gfx::Rect& bounds) {
if (widget_delegate()->IsModal())
native_window_->BecomeModal();
- // Create the ClientView, add it to the NonClientView and add the
- // NonClientView to the RootView. This will cause everything to be parented.
- non_client_view()->set_client_view(
- widget_delegate()->CreateClientView(this));
- SetContentsView(non_client_view());
-
UpdateWindowTitle();
- native_window_->AsNativeWidget()->SetAccessibleRole(
- widget_delegate()->GetAccessibleWindowRole());
- native_window_->AsNativeWidget()->SetAccessibleState(
- widget_delegate()->GetAccessibleWindowState());
-
SetInitialBounds(bounds);
}
-void Window::OnNativeWindowActivationChanged(bool active) {
- if (!active)
- SaveWindowPosition();
- widget_delegate()->OnWindowActivationChanged(active);
-}
-
-void Window::OnNativeWindowBeginUserBoundsChange() {
- widget_delegate()->OnWindowBeginUserBoundsChange();
-}
-
-void Window::OnNativeWindowEndUserBoundsChange() {
- widget_delegate()->OnWindowEndUserBoundsChange();
-}
-
-void Window::OnNativeWindowDestroying() {
- non_client_view()->WindowClosing();
- widget_delegate()->WindowClosing();
-}
-
-void Window::OnNativeWindowBoundsChanged() {
- SaveWindowPosition();
-}
-
-Window* Window::AsWindow() {
- return this;
-}
-
internal::NativeWidgetDelegate* Window::AsNativeWidgetDelegate() {
return this;
}
@@ -299,20 +180,4 @@ void Window::SetInitialBounds(const gfx::Rect& bounds) {
}
}
-void Window::SaveWindowPosition() {
- // The window delegate does the actual saving for us. It seems like (judging
- // by go/crash) that in some circumstances we can end up here after
- // WM_DESTROY, at which point the window delegate is likely gone. So just
- // bail.
- if (!widget_delegate())
- return;
-
- bool maximized;
- gfx::Rect bounds;
- native_window_->AsNativeWidget()->GetWindowBoundsAndMaximizedState(
- &bounds,
- &maximized);
- widget_delegate()->SaveWindowPlacement(bounds, maximized);
-}
-
} // namespace views
diff --git a/views/window/window.h b/views/window/window.h
index d659686..4fb8321 100644
--- a/views/window/window.h
+++ b/views/window/window.h
@@ -64,34 +64,10 @@ class Window : public Widget,
// operations are performed.
void InitWindow(const InitParams& params);
- // Retrieves the window's bounds, including its frame.
- gfx::Rect GetBounds() const;
-
- // Retrieves the restored bounds for the window.
- gfx::Rect GetNormalBounds() const;
-
- // Like Show(), but does not activate the window.
- void ShowInactive();
-
- // Prevents the window from being rendered as deactivated the next time it is.
- // This state is reset automatically as soon as the window becomes activated
- // again. There is no ability to control the state through this API as this
- // leads to sync problems.
- void DisableInactiveRendering();
-
- // Toggles the enable state for the Close button (and the Close menu item in
- // the system menu).
- void EnableClose(bool enable);
-
- // Tell the window to update its title from the delegate.
- void UpdateWindowTitle();
-
- // Tell the window to update its icon from the delegate.
- void UpdateWindowIcon();
-
// Overridden from Widget:
virtual void Show() OVERRIDE;
- virtual void Close() OVERRIDE;
+ virtual Window* AsWindow() OVERRIDE;
+ virtual const Window* AsWindow() const OVERRIDE;
WindowDelegate* window_delegate() {
return const_cast<WindowDelegate*>(
@@ -105,31 +81,15 @@ class Window : public Widget,
protected:
// Overridden from NativeWindowDelegate:
- virtual bool CanActivate() const OVERRIDE;
- virtual bool IsInactiveRenderingDisabled() const OVERRIDE;
- virtual void EnableInactiveRendering() OVERRIDE;
virtual bool IsModal() const OVERRIDE;
virtual bool IsDialogBox() const OVERRIDE;
- virtual gfx::Size GetMinimumSize() OVERRIDE;
- virtual int GetNonClientComponent(const gfx::Point& point) OVERRIDE;
- virtual bool ExecuteCommand(int command_id) OVERRIDE;
virtual void OnNativeWindowCreated(const gfx::Rect& bounds) OVERRIDE;
- virtual void OnNativeWindowActivationChanged(bool active) OVERRIDE;
- virtual void OnNativeWindowBeginUserBoundsChange() OVERRIDE;
- virtual void OnNativeWindowEndUserBoundsChange() OVERRIDE;
- virtual void OnNativeWindowDestroying() OVERRIDE;
- virtual void OnNativeWindowBoundsChanged() OVERRIDE;
- virtual Window* AsWindow() OVERRIDE;
virtual internal::NativeWidgetDelegate* AsNativeWidgetDelegate() OVERRIDE;
private:
// Sizes and positions the window just after it is created.
void SetInitialBounds(const gfx::Rect& bounds);
- // Persists the window's restored position and maximized state using the
- // window delegate.
- void SaveWindowPosition();
-
NativeWindow* native_window_;
// The saved maximized state for this window. See note in SetInitialBounds
@@ -139,13 +99,6 @@ class Window : public Widget,
// The smallest size the window can be.
gfx::Size minimum_size_;
- // True when the window should be rendered as active, regardless of whether
- // or not it actually is.
- bool disable_inactive_rendering_;
-
- // Set to true if the window is in the process of closing .
- bool window_closed_;
-
DISALLOW_COPY_AND_ASSIGN(Window);
};