summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-10 19:15:19 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-10 19:15:19 +0000
commit7f729513cbb985144d02fd6ff431f65807ef6422 (patch)
tree4943ed018a590e95692b6947d5854f43dff1be3f
parent83b0abca5bdf7f765a5dc5c9cb114f5745f82a72 (diff)
downloadchromium_src-7f729513cbb985144d02fd6ff431f65807ef6422.zip
chromium_src-7f729513cbb985144d02fd6ff431f65807ef6422.tar.gz
chromium_src-7f729513cbb985144d02fd6ff431f65807ef6422.tar.bz2
Build out NativeWindow interface for Window method pass-thrus.
BUG=72040 TEST=none TBR=sky Review URL: http://codereview.chromium.org/6659035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@77671 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/frame/bubble_frame_view.cc2
-rw-r--r--chrome/browser/chromeos/native_dialog_window.cc2
-rw-r--r--chrome/browser/first_run/first_run_win.cc2
-rw-r--r--chrome/browser/ui/input_window_dialog_win.cc2
-rw-r--r--chrome/browser/ui/views/accessibility_event_router_views.cc7
-rw-r--r--chrome/browser/ui/views/accessibility_event_router_views_unittest.cc3
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc2
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc4
-rw-r--r--chrome/browser/ui/views/chrome_views_delegate.cc6
-rw-r--r--chrome/browser/ui/views/clear_browsing_data_view.cc2
-rw-r--r--chrome/browser/ui/views/clear_data_view.cc4
-rw-r--r--chrome/browser/ui/views/constrained_window_win.cc2
-rw-r--r--chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc2
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc9
-rw-r--r--chrome/browser/ui/views/frame/opaque_browser_frame_view.cc2
-rw-r--r--chrome/browser/ui/views/html_dialog_view.cc2
-rw-r--r--chrome/browser/ui/views/hung_renderer_view.cc2
-rw-r--r--chrome/browser/ui/views/importer/import_dialog_view.cc2
-rw-r--r--chrome/browser/ui/views/importer/import_progress_dialog_view.cc2
-rw-r--r--chrome/browser/ui/views/js_modal_dialog_views.cc2
-rw-r--r--chrome/browser/ui/views/keyword_editor_view.cc2
-rw-r--r--chrome/browser/ui/views/options/options_window_view.cc5
-rw-r--r--chrome/browser/ui/views/task_manager_view.cc2
-rw-r--r--chrome/browser/ui/views/url_picker.cc8
-rw-r--r--chrome/test/interactive_ui/view_event_test_base.cc2
-rw-r--r--views/controls/tabbed_pane/tabbed_pane_unittest.cc2
-rw-r--r--views/controls/table/table_view_unittest.cc4
-rw-r--r--views/focus/accelerator_handler_gtk_unittest.cc2
-rw-r--r--views/focus/focus_manager_unittest.cc6
-rw-r--r--views/widget/native_widget.h6
-rw-r--r--views/window/custom_frame_view.cc2
-rw-r--r--views/window/dialog_client_view.cc2
-rw-r--r--views/window/native_window.h28
-rw-r--r--views/window/window.cc49
-rw-r--r--views/window/window.h66
-rw-r--r--views/window/window_gtk.cc204
-rw-r--r--views/window/window_gtk.h47
-rw-r--r--views/window/window_win.cc412
-rw-r--r--views/window/window_win.h57
39 files changed, 502 insertions, 465 deletions
diff --git a/chrome/browser/chromeos/frame/bubble_frame_view.cc b/chrome/browser/chromeos/frame/bubble_frame_view.cc
index 37acb39..49c9281 100644
--- a/chrome/browser/chromeos/frame/bubble_frame_view.cc
+++ b/chrome/browser/chromeos/frame/bubble_frame_view.cc
@@ -227,7 +227,7 @@ void BubbleFrameView::OnPaint(gfx::Canvas* canvas) {
void BubbleFrameView::ButtonPressed(views::Button* sender,
const views::Event& event) {
if (close_button_ != NULL && sender == close_button_)
- frame_->Close();
+ frame_->CloseWindow();
}
} // namespace chromeos
diff --git a/chrome/browser/chromeos/native_dialog_window.cc b/chrome/browser/chromeos/native_dialog_window.cc
index 7960580..61ed3c8 100644
--- a/chrome/browser/chromeos/native_dialog_window.cc
+++ b/chrome/browser/chromeos/native_dialog_window.cc
@@ -155,7 +155,7 @@ void NativeDialogHost::OnCheckResize(GtkWidget* widget) {
void NativeDialogHost::OnDialogDestroy(GtkWidget* widget) {
dialog_ = NULL;
destroy_signal_id_ = 0;
- window()->Close();
+ window()->CloseWindow();
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/first_run/first_run_win.cc b/chrome/browser/first_run/first_run_win.cc
index 0f6a0f5..ec71c80 100644
--- a/chrome/browser/first_run/first_run_win.cc
+++ b/chrome/browser/first_run/first_run_win.cc
@@ -431,7 +431,7 @@ void FirstRun::ShowFirstRunDialog(Profile* profile,
search_engine_dialog->Show();
views::AcceleratorHandler accelerator_handler;
MessageLoopForUI::current()->Run(&accelerator_handler);
- search_engine_dialog->Close();
+ search_engine_dialog->CloseWindow();
}
// static
diff --git a/chrome/browser/ui/input_window_dialog_win.cc b/chrome/browser/ui/input_window_dialog_win.cc
index 7012d10..058ffd1 100644
--- a/chrome/browser/ui/input_window_dialog_win.cc
+++ b/chrome/browser/ui/input_window_dialog_win.cc
@@ -220,7 +220,7 @@ void WinInputWindowDialog::Show() {
}
void WinInputWindowDialog::Close() {
- window_->Close();
+ window_->CloseWindow();
}
// static
diff --git a/chrome/browser/ui/views/accessibility_event_router_views.cc b/chrome/browser/ui/views/accessibility_event_router_views.cc
index 48e5514..c99022b 100644
--- a/chrome/browser/ui/views/accessibility_event_router_views.cc
+++ b/chrome/browser/ui/views/accessibility_event_router_views.cc
@@ -24,6 +24,8 @@
#include "views/controls/menu/submenu_view.h"
#include "views/controls/textfield/textfield.h"
#include "views/view.h"
+#include "views/widget/native_widget.h"
+#include "views/widget/widget.h"
#include "views/window/window.h"
using views::FocusManager;
@@ -124,8 +126,9 @@ void AccessibilityEventRouterViews::DispatchAccessibilityNotification(
Profile* profile = NULL;
views::Window* window = view->GetWindow();
if (window) {
- profile = reinterpret_cast<Profile*>(window->GetNativeWindowProperty(
- Profile::kProfileKey));
+ profile = reinterpret_cast<Profile*>(
+ window->AsWidget()->native_widget()->GetNativeWindowProperty(
+ Profile::kProfileKey));
}
if (!profile)
profile = most_recent_profile_;
diff --git a/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc b/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc
index 93e5c24..6aae653 100644
--- a/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc
+++ b/chrome/browser/ui/views/accessibility_event_router_views_unittest.cc
@@ -16,6 +16,7 @@
#include "views/controls/button/native_button.h"
#include "views/layout/grid_layout.h"
#include "views/views_delegate.h"
+#include "views/widget/native_widget.h"
#include "views/widget/root_view.h"
#include "views/widget/widget.h"
#include "views/window/window.h"
@@ -158,7 +159,7 @@ TEST_F(AccessibilityEventRouterViewsTest, TestFocusNotification) {
// Create a profile and associate it with this window.
TestingProfile profile;
- window->SetNativeWindowProperty(
+ window->AsWidget()->native_widget()->SetNativeWindowProperty(
Profile::kProfileKey, &profile);
// Change the accessible name of button3.
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
index ffb3579..949bd40 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc
@@ -1361,7 +1361,7 @@ class BookmarkBarViewTest16 : public BookmarkBarViewEventTestBase {
ASSERT_TRUE(button->state() == views::CustomButton::BS_PUSHED);
// Close the window.
- window_->Close();
+ window_->CloseWindow();
window_ = NULL;
}
};
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc
index 897c92d..4433a54 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_editor_view.cc
@@ -237,7 +237,7 @@ void BookmarkEditorView::Show(HWND parent_hwnd) {
void BookmarkEditorView::Close() {
DCHECK(window());
- window()->Close();
+ window()->CloseWindow();
}
void BookmarkEditorView::ShowContextMenuForView(View* source,
@@ -391,7 +391,7 @@ void BookmarkEditorView::BookmarkNodeRemoved(BookmarkModel* model,
details_.existing_node->HasAncestor(node)) ||
(parent_ && parent_->HasAncestor(node))) {
// The node, or its parent was removed. Close the dialog.
- window()->Close();
+ window()->CloseWindow();
} else {
Reset();
}
diff --git a/chrome/browser/ui/views/chrome_views_delegate.cc b/chrome/browser/ui/views/chrome_views_delegate.cc
index 959e4e2..9216388 100644
--- a/chrome/browser/ui/views/chrome_views_delegate.cc
+++ b/chrome/browser/ui/views/chrome_views_delegate.cc
@@ -15,6 +15,8 @@
#include "chrome/common/pref_names.h"
#include "ui/base/clipboard/clipboard.h"
#include "ui/gfx/rect.h"
+#include "views/widget/native_widget.h"
+#include "views/widget/widget.h"
#include "views/window/window.h"
#if defined(OS_WIN)
@@ -30,8 +32,8 @@ namespace {
// TODO(mirandac): This function will also separate windows by profile in a
// multi-profile environment.
PrefService* GetPrefsForWindow(views::Window* window) {
- Profile* profile =
- reinterpret_cast<Profile*>(window->GetNativeWindowProperty(
+ Profile* profile = reinterpret_cast<Profile*>(
+ window->AsWidget()->native_widget()->GetNativeWindowProperty(
Profile::kProfileKey));
if (!profile) {
// Use local state for windows that have no explicit profile.
diff --git a/chrome/browser/ui/views/clear_browsing_data_view.cc b/chrome/browser/ui/views/clear_browsing_data_view.cc
index 86c74d6..e7b007b 100644
--- a/chrome/browser/ui/views/clear_browsing_data_view.cc
+++ b/chrome/browser/ui/views/clear_browsing_data_view.cc
@@ -481,5 +481,5 @@ void ClearBrowsingDataView::OnBrowsingDataRemoverDone() {
// No need to remove ourselves as an observer as BrowsingDataRemover deletes
// itself after we return.
remover_ = NULL;
- window()->Close();
+ window()->CloseWindow();
}
diff --git a/chrome/browser/ui/views/clear_data_view.cc b/chrome/browser/ui/views/clear_data_view.cc
index c5d3b33..82c7a34 100644
--- a/chrome/browser/ui/views/clear_data_view.cc
+++ b/chrome/browser/ui/views/clear_data_view.cc
@@ -78,7 +78,7 @@ void ClearDataView::StartClearingBrowsingData() {
}
void ClearDataView::StopClearingBrowsingData() {
- window()->Close();
+ window()->CloseWindow();
}
void ClearDataView::StartClearingServerData() {
@@ -90,7 +90,7 @@ void ClearDataView::StartClearingServerData() {
}
void ClearDataView::SucceededClearingServerData() {
- window()->Close();
+ window()->CloseWindow();
}
void ClearDataView::FailedClearingServerData() {
diff --git a/chrome/browser/ui/views/constrained_window_win.cc b/chrome/browser/ui/views/constrained_window_win.cc
index e0630d6..3f6f678 100644
--- a/chrome/browser/ui/views/constrained_window_win.cc
+++ b/chrome/browser/ui/views/constrained_window_win.cc
@@ -592,7 +592,7 @@ void ConstrainedWindowWin::CloseConstrainedWindow() {
Source<ConstrainedWindow>(this),
NotificationService::NoDetails());
- Window::Close();
+ Window::CloseWindow();
}
std::wstring ConstrainedWindowWin::GetWindowTitle() const {
diff --git a/chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc b/chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc
index 631d4ba..c6494b9 100644
--- a/chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/app_panel_browser_frame_view.cc
@@ -241,7 +241,7 @@ void AppPanelBrowserFrameView::Layout() {
void AppPanelBrowserFrameView::ButtonPressed(views::Button* sender,
const views::Event& event) {
if (sender == close_button_)
- frame_->GetWindow()->Close();
+ frame_->GetWindow()->CloseWindow();
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index dcaa1403..f878ca4 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -90,6 +90,7 @@
#include "chrome/browser/jumplist_win.h"
#include "ui/base/message_box_win.h"
#include "ui/base/view_prop.h"
+#include "views/window/window_win.h"
#elif defined(OS_LINUX)
#include "chrome/browser/ui/views/accelerator_table_gtk.h"
#include "views/window/hit_test.h"
@@ -722,7 +723,7 @@ void BrowserView::SetBounds(const gfx::Rect& bounds) {
void BrowserView::Close() {
BrowserBubbleHost::Close();
- frame_->GetWindow()->Close();
+ frame_->GetWindow()->CloseWindow();
}
void BrowserView::Activate() {
@@ -2192,7 +2193,8 @@ void BrowserView::ProcessFullscreen(bool fullscreen) {
#endif
}
#if defined(OS_WIN)
- frame_->GetWindow()->PushForceHidden();
+ static_cast<views::WindowWin*>(
+ frame_->GetWindow()->native_window())->PushForceHidden();
#endif
// Notify bookmark bar, so it can set itself to the appropriate drawing state.
@@ -2233,7 +2235,8 @@ void BrowserView::ProcessFullscreen(bool fullscreen) {
ignore_layout_ = false;
Layout();
#if defined(OS_WIN)
- frame_->GetWindow()->PopForceHidden();
+ static_cast<views::WindowWin*>(
+ frame_->GetWindow()->native_window())->PopForceHidden();
#endif
}
diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
index 2622b03..f4c8832 100644
--- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
+++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc
@@ -421,7 +421,7 @@ void OpaqueBrowserFrameView::ButtonPressed(views::Button* sender,
else if (sender == restore_button_)
window->Restore();
else if (sender == close_button_)
- window->Close();
+ window->CloseWindow();
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/ui/views/html_dialog_view.cc b/chrome/browser/ui/views/html_dialog_view.cc
index 1659c5a..b9c704c 100644
--- a/chrome/browser/ui/views/html_dialog_view.cc
+++ b/chrome/browser/ui/views/html_dialog_view.cc
@@ -144,7 +144,7 @@ void HtmlDialogView::OnDialogClosed(const std::string& json_retval) {
delegate_ = NULL; // We will not communicate further with the delegate.
dialog_delegate->OnDialogClosed(json_retval);
}
- window()->Close();
+ window()->CloseWindow();
}
void HtmlDialogView::OnCloseContents(TabContents* source,
diff --git a/chrome/browser/ui/views/hung_renderer_view.cc b/chrome/browser/ui/views/hung_renderer_view.cc
index ef774bb..8c41726 100644
--- a/chrome/browser/ui/views/hung_renderer_view.cc
+++ b/chrome/browser/ui/views/hung_renderer_view.cc
@@ -261,7 +261,7 @@ void HungRendererDialogView::EndForTabContents(TabContents* contents) {
DCHECK(contents);
if (contents_ && contents_->GetRenderProcessHost() ==
contents->GetRenderProcessHost()) {
- window()->Close();
+ window()->CloseWindow();
// Since we're closing, we no longer need this TabContents.
contents_ = NULL;
}
diff --git a/chrome/browser/ui/views/importer/import_dialog_view.cc b/chrome/browser/ui/views/importer/import_dialog_view.cc
index 7d2a73f..ef7b49c 100644
--- a/chrome/browser/ui/views/importer/import_dialog_view.cc
+++ b/chrome/browser/ui/views/importer/import_dialog_view.cc
@@ -291,7 +291,7 @@ void ImportDialogView::SourceProfilesLoaded() {
void ImportDialogView::ImportCompleted() {
// Now close this window since the import completed or was canceled.
- window()->Close();
+ window()->CloseWindow();
}
void ImportDialogView::ImportCanceled() {
diff --git a/chrome/browser/ui/views/importer/import_progress_dialog_view.cc b/chrome/browser/ui/views/importer/import_progress_dialog_view.cc
index 36657e2..1baefe7 100644
--- a/chrome/browser/ui/views/importer/import_progress_dialog_view.cc
+++ b/chrome/browser/ui/views/importer/import_progress_dialog_view.cc
@@ -276,7 +276,7 @@ void ImportProgressDialogView::ImportEnded() {
// In every case, we need to close the UI now.
importing_ = false;
importer_host_->SetObserver(NULL);
- window()->Close();
+ window()->CloseWindow();
if (importer_observer_)
importer_observer_->ImportCompleted();
}
diff --git a/chrome/browser/ui/views/js_modal_dialog_views.cc b/chrome/browser/ui/views/js_modal_dialog_views.cc
index f6ae4d6..b4fac4c 100644
--- a/chrome/browser/ui/views/js_modal_dialog_views.cc
+++ b/chrome/browser/ui/views/js_modal_dialog_views.cc
@@ -53,7 +53,7 @@ void JSModalDialogViews::ActivateAppModalDialog() {
}
void JSModalDialogViews::CloseAppModalDialog() {
- window()->Close();
+ window()->CloseWindow();
}
void JSModalDialogViews::AcceptAppModalDialog() {
diff --git a/chrome/browser/ui/views/keyword_editor_view.cc b/chrome/browser/ui/views/keyword_editor_view.cc
index 38e0dee..d8125e1 100644
--- a/chrome/browser/ui/views/keyword_editor_view.cc
+++ b/chrome/browser/ui/views/keyword_editor_view.cc
@@ -70,7 +70,7 @@ void KeywordEditorView::ShowAndObserve(Profile* profile,
return;
if (open_window != NULL)
- open_window->Close();
+ open_window->CloseWindow();
DCHECK(!open_window);
// Both of these will be deleted when the dialog closes.
diff --git a/chrome/browser/ui/views/options/options_window_view.cc b/chrome/browser/ui/views/options/options_window_view.cc
index 7126f7d..aef8719 100644
--- a/chrome/browser/ui/views/options/options_window_view.cc
+++ b/chrome/browser/ui/views/options/options_window_view.cc
@@ -20,6 +20,8 @@
#include "ui/base/l10n/l10n_util.h"
#include "views/controls/tabbed_pane/tabbed_pane.h"
#include "views/widget/root_view.h"
+#include "views/widget/widget.h"
+#include "views/widget/native_widget.h"
#include "views/window/dialog_delegate.h"
#include "views/window/window.h"
@@ -223,7 +225,8 @@ void OptionsWindowView::Init() {
// Bind the profile to the window so that the ChromeViewsDelegate can find
// the user preferences to store and retrieve window placement settings.
- window()->SetNativeWindowProperty(Profile::kProfileKey, profile_);
+ window()->AsWidget()->native_widget()->SetNativeWindowProperty(
+ Profile::kProfileKey, profile_);
DCHECK(tabs_->GetTabCount() == OPTIONS_PAGE_COUNT);
}
diff --git a/chrome/browser/ui/views/task_manager_view.cc b/chrome/browser/ui/views/task_manager_view.cc
index 489194c..0d291ea 100644
--- a/chrome/browser/ui/views/task_manager_view.cc
+++ b/chrome/browser/ui/views/task_manager_view.cc
@@ -559,7 +559,7 @@ void TaskManagerView::Show(bool highlight_background_resources) {
if (instance_) {
if (instance_->highlight_background_resources_ !=
highlight_background_resources) {
- instance_->window()->Close();
+ instance_->window()->CloseWindow();
} else {
// If there's a Task manager window open already, just activate it.
instance_->window()->Activate();
diff --git a/chrome/browser/ui/views/url_picker.cc b/chrome/browser/ui/views/url_picker.cc
index 7d6060b..36d9411 100644
--- a/chrome/browser/ui/views/url_picker.cc
+++ b/chrome/browser/ui/views/url_picker.cc
@@ -128,7 +128,7 @@ void UrlPicker::Show(HWND parent) {
void UrlPicker::Close() {
DCHECK(window());
- window()->Close();
+ window()->CloseWindow();
}
std::wstring UrlPicker::GetWindowTitle() const {
@@ -193,7 +193,7 @@ gfx::Size UrlPicker::GetPreferredSize() {
bool UrlPicker::AcceleratorPressed(
const views::Accelerator& accelerator) {
if (accelerator.GetKeyCode() == VK_ESCAPE) {
- window()->Close();
+ window()->CloseWindow();
} else if (accelerator.GetKeyCode() == VK_RETURN) {
views::FocusManager* fm = GetFocusManager();
if (fm->GetFocusedView() == url_table_) {
@@ -205,7 +205,7 @@ bool UrlPicker::AcceleratorPressed(
if (GetInputURL().is_valid()) {
PerformModelChange();
if (window())
- window()->Close();
+ window()->CloseWindow();
} else {
url_field_->SelectAll();
}
@@ -237,7 +237,7 @@ void UrlPicker::OnDoubleClick() {
OnSelectionChanged();
PerformModelChange();
if (window())
- window()->Close();
+ window()->CloseWindow();
}
}
diff --git a/chrome/test/interactive_ui/view_event_test_base.cc b/chrome/test/interactive_ui/view_event_test_base.cc
index e717497..027c93f 100644
--- a/chrome/test/interactive_ui/view_event_test_base.cc
+++ b/chrome/test/interactive_ui/view_event_test_base.cc
@@ -88,7 +88,7 @@ void ViewEventTestBase::TearDown() {
#if defined(OS_WIN)
DestroyWindow(window_->GetNativeWindow());
#else
- window_->Close();
+ window_->CloseWindow();
MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask());
ui_test_utils::RunMessageLoop();
#endif
diff --git a/views/controls/tabbed_pane/tabbed_pane_unittest.cc b/views/controls/tabbed_pane/tabbed_pane_unittest.cc
index 1ceef86..1cd1621 100644
--- a/views/controls/tabbed_pane/tabbed_pane_unittest.cc
+++ b/views/controls/tabbed_pane/tabbed_pane_unittest.cc
@@ -44,7 +44,7 @@ class TabbedPaneTest : public testing::Test, WindowDelegate {
}
virtual void TearDown() {
- window_->Close();
+ window_->CloseWindow();
message_loop_.RunAllPending();
}
diff --git a/views/controls/table/table_view_unittest.cc b/views/controls/table/table_view_unittest.cc
index 8ed5457..aa7d29d 100644
--- a/views/controls/table/table_view_unittest.cc
+++ b/views/controls/table/table_view_unittest.cc
@@ -189,7 +189,7 @@ void TableViewTest::SetUp() {
}
void TableViewTest::TearDown() {
- window_->Close();
+ window_->CloseWindow();
// Temporary workaround to avoid leak of RootView::pending_paint_task_.
message_loop_.RunAllPending();
OleUninitialize();
@@ -511,7 +511,7 @@ void TableView2Test::SetUp() {
}
void TableView2Test::TearDown() {
- window_->Close();
+ window_->CloseWindow();
// Temporary workaround to avoid leak of RootView::pending_paint_task_.
message_loop_.RunAllPending();
#if defined(OS_WIN)
diff --git a/views/focus/accelerator_handler_gtk_unittest.cc b/views/focus/accelerator_handler_gtk_unittest.cc
index e7215ee..031226b 100644
--- a/views/focus/accelerator_handler_gtk_unittest.cc
+++ b/views/focus/accelerator_handler_gtk_unittest.cc
@@ -37,7 +37,7 @@ class AcceleratorHandlerGtkTest
}
virtual void TearDown() {
- window_->Close();
+ window_->CloseWindow();
// Flush the message loop to make Purify happy.
message_loop_.RunAllPending();
diff --git a/views/focus/focus_manager_unittest.cc b/views/focus/focus_manager_unittest.cc
index 240d941..a90da38 100644
--- a/views/focus/focus_manager_unittest.cc
+++ b/views/focus/focus_manager_unittest.cc
@@ -132,7 +132,7 @@ class FocusManagerTest : public testing::Test, public WindowDelegate {
virtual void TearDown() {
if (focus_change_listener_)
GetFocusManager()->RemoveFocusChangeListener(focus_change_listener_);
- window_->Close();
+ window_->CloseWindow();
// Flush the message loop to make Purify happy.
message_loop()->RunAllPending();
@@ -1702,7 +1702,7 @@ class FocusManagerDtorTest : public FocusManagerTest {
virtual void TearDown() {
if (window_) {
- window_->Close();
+ window_->CloseWindow();
message_loop()->RunAllPending();
}
}
@@ -1720,7 +1720,7 @@ TEST_F(FocusManagerDtorTest, FocusManagerDestructedLast) {
tabbed_pane->AddTab(L"Awesome tab", button);
// Close the window.
- window_->Close();
+ window_->CloseWindow();
message_loop()->RunAllPending();
// Test window, button and focus manager should all be destructed.
diff --git a/views/widget/native_widget.h b/views/widget/native_widget.h
index 7da2fb7..26dbd9b 100644
--- a/views/widget/native_widget.h
+++ b/views/widget/native_widget.h
@@ -8,10 +8,16 @@
#include <set>
+#include "ui/gfx/native_widget_types.h"
+
namespace gfx {
class Rect;
}
+namespace ui {
+class OSExchangeData;
+}
+
namespace views {
class TooltipManager;
diff --git a/views/window/custom_frame_view.cc b/views/window/custom_frame_view.cc
index 4a42c1f..97e7f21 100644
--- a/views/window/custom_frame_view.cc
+++ b/views/window/custom_frame_view.cc
@@ -237,7 +237,7 @@ gfx::Size CustomFrameView::GetPreferredSize() {
void CustomFrameView::ButtonPressed(Button* sender, const views::Event& event) {
if (sender == close_button_)
- frame_->Close();
+ frame_->CloseWindow();
else if (sender == minimize_button_)
frame_->Minimize();
else if (sender == maximize_button_)
diff --git a/views/window/dialog_client_view.cc b/views/window/dialog_client_view.cc
index 81e8685..99512cb 100644
--- a/views/window/dialog_client_view.cc
+++ b/views/window/dialog_client_view.cc
@@ -540,7 +540,7 @@ DialogDelegate* DialogClientView::GetDialogDelegate() const {
}
void DialogClientView::Close() {
- window()->Close();
+ window()->CloseWindow();
GetDialogDelegate()->OnClose();
}
diff --git a/views/window/native_window.h b/views/window/native_window.h
index 8e5ac66..6275e1a 100644
--- a/views/window/native_window.h
+++ b/views/window/native_window.h
@@ -10,6 +10,8 @@
namespace views {
+class NonClientFrameView;
+
////////////////////////////////////////////////////////////////////////////////
// NativeWindow interface
//
@@ -64,6 +66,32 @@ class NativeWindow {
virtual NativeWidget* AsNativeWidget() = 0;
virtual const NativeWidget* AsNativeWidget() const = 0;
+
+ // Window pass-thrus ---------------------------------------------------------
+ // See documentation in window.h
+
+ virtual void SetWindowBounds(const gfx::Rect& bounds,
+ gfx::NativeWindow other_window) = 0;
+ virtual void HideWindow() = 0;
+ virtual void Activate() = 0;
+ virtual void Deactivate() = 0;
+ virtual void Maximize() = 0;
+ virtual void Minimize() = 0;
+ virtual void Restore() = 0;
+ virtual bool IsActive() const = 0;
+ virtual bool IsVisible() const = 0;
+ virtual bool IsMaximized() const = 0;
+ virtual bool IsMinimized() const = 0;
+ virtual void SetFullscreen(bool fullscreen) = 0;
+ virtual bool IsFullscreen() const = 0;
+ virtual void SetAlwaysOnTop(bool always_on_top) = 0;
+ virtual bool IsAppWindow() const = 0;
+ virtual void SetUseDragFrame(bool use_drag_frame) = 0;
+ virtual NonClientFrameView* CreateFrameViewForWindow() = 0;
+ virtual void UpdateFrameAfterFrameChange() = 0;
+ virtual gfx::NativeWindow GetNativeWindow() const = 0;
+ virtual bool ShouldUseNativeFrame() const = 0;
+ virtual void FrameTypeChanged() = 0;
};
} // namespace views
diff --git a/views/window/window.cc b/views/window/window.cc
index ee4883f..ed321c1 100644
--- a/views/window/window.cc
+++ b/views/window/window.cc
@@ -66,7 +66,7 @@ void Window::CloseSecondaryWidget(Widget* widget) {
Window* window = widget->GetWindow();
if (window) {
if (!window->IsAppWindow())
- window->Close();
+ window->CloseWindow();
} else {
// If it's not a Window, then close it anyway since it probably is
// secondary.
@@ -85,6 +85,7 @@ gfx::Rect Window::GetNormalBounds() const {
void Window::SetWindowBounds(const gfx::Rect& bounds,
gfx::NativeWindow other_window) {
+ native_window_->SetWindowBounds(bounds, other_window);
}
void Window::Show() {
@@ -98,13 +99,7 @@ void Window::Show() {
}
void Window::HideWindow() {
-}
-
-void Window::SetNativeWindowProperty(const char* name, void* value) {
-}
-
-void* Window::GetNativeWindowProperty(const char* name) {
- return NULL;
+ native_window_->HideWindow();
}
void Window::DisableInactiveRendering() {
@@ -113,12 +108,14 @@ void Window::DisableInactiveRendering() {
}
void Window::Activate() {
+ native_window_->Activate();
}
void Window::Deactivate() {
+ native_window_->Deactivate();
}
-void Window::Close() {
+void Window::CloseWindow() {
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
@@ -136,42 +133,47 @@ void Window::Close() {
}
void Window::Maximize() {
+ native_window_->Maximize();
}
void Window::Minimize() {
+ native_window_->Minimize();
}
void Window::Restore() {
+ native_window_->Restore();
}
bool Window::IsActive() const {
- return false;
+ return native_window_->IsActive();
}
bool Window::IsVisible() const {
- return false;
+ return native_window_->IsVisible();
}
bool Window::IsMaximized() const {
- return false;
+ return native_window_->IsMaximized();
}
bool Window::IsMinimized() const {
- return false;
+ return native_window_->IsMinimized();
}
void Window::SetFullscreen(bool fullscreen) {
+ native_window_->SetFullscreen(fullscreen);
}
bool Window::IsFullscreen() const {
- return false;
+ return native_window_->IsFullscreen();
}
void Window::SetUseDragFrame(bool use_drag_frame) {
+ native_window_->SetUseDragFrame(use_drag_frame);
}
bool Window::IsAppWindow() const {
- return false;
+ return native_window_->IsAppWindow();
}
void Window::EnableClose(bool enable) {
@@ -202,24 +204,35 @@ void Window::UpdateWindowIcon() {
}
void Window::SetIsAlwaysOnTop(bool always_on_top) {
+ native_window_->SetAlwaysOnTop(always_on_top);
}
NonClientFrameView* Window::CreateFrameViewForWindow() {
- return NULL;
+ return native_window_->CreateFrameViewForWindow();
}
void Window::UpdateFrameAfterFrameChange() {
+ native_window_->UpdateFrameAfterFrameChange();
}
gfx::NativeWindow Window::GetNativeWindow() const {
- return NULL;
+ return native_window_->GetNativeWindow();
}
bool Window::ShouldUseNativeFrame() const {
- return false;
+ return native_window_->ShouldUseNativeFrame();
}
void Window::FrameTypeChanged() {
+ native_window_->FrameTypeChanged();
+}
+
+Widget* Window::AsWidget() {
+ return const_cast<Widget*>(const_cast<const Window*>(this)->AsWidget());
+}
+
+const Widget* Window::AsWidget() const {
+ return native_window_->AsNativeWidget()->GetWidget();
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/views/window/window.h b/views/window/window.h
index dcdef3b..5bd270b 100644
--- a/views/window/window.h
+++ b/views/window/window.h
@@ -74,14 +74,13 @@ class Window : public internal::NativeWindowDelegate {
gfx::Rect GetBounds() const;
// Retrieves the restored bounds for the window.
- virtual gfx::Rect GetNormalBounds() const;
+ gfx::Rect GetNormalBounds() const;
// Sets the Window's bounds. The window is inserted after |other_window| in
// the window Z-order. If this window is not yet visible, other_window's
// monitor is used as the constraining rectangle, rather than this window's
// monitor.
- virtual void SetWindowBounds(const gfx::Rect& bounds,
- gfx::NativeWindow other_window);
+ void SetWindowBounds(const gfx::Rect& bounds, gfx::NativeWindow other_window);
// Makes the window visible.
void Show();
@@ -91,25 +90,6 @@ class Window : public internal::NativeWindowDelegate {
// Push/PopForceHidden.
virtual void HideWindow();
- // Sets/Gets a native window property on the underlying native window object.
- // Returns NULL if the property does not exist. Setting the property value to
- // NULL removes the property.
- virtual void SetNativeWindowProperty(const char* name, void* value);
- virtual void* GetNativeWindowProperty(const char* name);
-
-#if defined(OS_WIN)
- // TODO(beng): remove these platform-specific methods.
-
- // Hides the window if it hasn't already been force-hidden. The force hidden
- // count is tracked, so calling multiple times is allowed, you just have to
- // be sure to call PopForceHidden the same number of times.
- virtual void PushForceHidden() = 0;
-
- // Decrements the force hidden count, showing the window if we have reached
- // the top of the stack. See PushForceHidden.
- virtual void PopForceHidden() = 0;
-#endif
-
// 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
@@ -117,39 +97,39 @@ class Window : public internal::NativeWindowDelegate {
void DisableInactiveRendering();
// Activates the window, assuming it already exists and is visible.
- virtual void Activate();
+ void Activate();
// Deactivates the window, making the next window in the Z order the active
// window.
- virtual void Deactivate();
+ void Deactivate();
// Closes the window, ultimately destroying it. The window hides immediately,
// and is destroyed after a return to the message loop. Close() can be called
// multiple times.
- void Close();
+ void CloseWindow();
// Maximizes/minimizes/restores the window.
- virtual void Maximize();
- virtual void Minimize();
- virtual void Restore();
+ void Maximize();
+ void Minimize();
+ void Restore();
// Whether or not the window is currently active.
- virtual bool IsActive() const;
+ bool IsActive() const;
// Whether or not the window is currently visible.
- virtual bool IsVisible() const;
+ bool IsVisible() const;
// Whether or not the window is maximized or minimized.
- virtual bool IsMaximized() const;
- virtual bool IsMinimized() const;
+ bool IsMaximized() const;
+ bool IsMinimized() const;
// Accessors for fullscreen state.
- virtual void SetFullscreen(bool fullscreen);
- virtual bool IsFullscreen() const;
+ void SetFullscreen(bool fullscreen);
+ bool IsFullscreen() const;
// Sets whether or not the window should show its frame as a "transient drag
// frame" - slightly transparent and without the standard window controls.
- virtual void SetUseDragFrame(bool use_drag_frame);
+ void SetUseDragFrame(bool use_drag_frame);
// Returns true if the Window is considered to be an "app window" - i.e.
// any window which when it is the last of its type closed causes the
@@ -158,7 +138,7 @@ class Window : public internal::NativeWindowDelegate {
// Toggles the enable state for the Close button (and the Close menu item in
// the system menu).
- virtual void EnableClose(bool enable);
+ void EnableClose(bool enable);
// Tell the window to update its title from the delegate.
void UpdateWindowTitle();
@@ -167,7 +147,7 @@ class Window : public internal::NativeWindowDelegate {
void UpdateWindowIcon();
// Sets whether or not the window is always-on-top.
- virtual void SetIsAlwaysOnTop(bool always_on_top);
+ void SetIsAlwaysOnTop(bool always_on_top);
// Creates an appropriate NonClientFrameView for this window.
virtual NonClientFrameView* CreateFrameViewForWindow();
@@ -176,13 +156,17 @@ class Window : public internal::NativeWindowDelegate {
virtual void UpdateFrameAfterFrameChange();
// Retrieves the Window's native window handle.
- virtual gfx::NativeWindow GetNativeWindow() const;
+ gfx::NativeWindow GetNativeWindow() const;
// Whether we should be using a native frame.
- virtual bool ShouldUseNativeFrame() const;
+ bool ShouldUseNativeFrame() const;
// Tell the window that something caused the frame type to change.
- virtual void FrameTypeChanged();
+ void FrameTypeChanged();
+
+ // TODO(beng): remove once Window subclasses Widget.
+ Widget* AsWidget();
+ const Widget* AsWidget() const;
WindowDelegate* window_delegate() {
return const_cast<WindowDelegate*>(
@@ -208,6 +192,8 @@ class Window : public internal::NativeWindowDelegate {
return non_client_view()->client_view();
}
+ NativeWindow* native_window() { return native_window_; }
+
protected:
// TODO(beng): Temporarily provided as a way to associate the subclass'
// implementation of NativeWidget with this.
diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc
index d708e2d..a24ce61 100644
--- a/views/window/window_gtk.cc
+++ b/views/window/window_gtk.cc
@@ -104,110 +104,6 @@ void Window::CloseAllSecondaryWindows() {
g_list_free(windows);
}
-void WindowGtk::SetWindowBounds(const gfx::Rect& bounds,
- gfx::NativeWindow other_window) {
- // TODO: need to deal with other_window.
- WidgetGtk::SetBounds(bounds);
-}
-
-void WindowGtk::HideWindow() {
- Hide();
-}
-
-void WindowGtk::SetNativeWindowProperty(const char* name, void* value) {
- WidgetGtk::SetNativeWindowProperty(name, value);
-}
-
-void* WindowGtk::GetNativeWindowProperty(const char* name) {
- return WidgetGtk::GetNativeWindowProperty(name);
-}
-
-void WindowGtk::Activate() {
- gtk_window_present(GTK_WINDOW(GetNativeView()));
-}
-
-void WindowGtk::Deactivate() {
- gdk_window_lower(GTK_WIDGET(GetNativeView())->window);
-}
-
-void WindowGtk::Maximize() {
- gtk_window_maximize(GetNativeWindow());
-}
-
-void WindowGtk::Minimize() {
- gtk_window_iconify(GetNativeWindow());
-}
-
-void WindowGtk::Restore() {
- if (IsMaximized())
- gtk_window_unmaximize(GetNativeWindow());
- else if (IsMinimized())
- gtk_window_deiconify(GetNativeWindow());
- else if (IsFullscreen())
- SetFullscreen(false);
-}
-
-bool WindowGtk::IsActive() const {
- return WidgetGtk::IsActive();
-}
-
-bool WindowGtk::IsVisible() const {
- return GTK_WIDGET_VISIBLE(GetNativeView());
-}
-
-bool WindowGtk::IsMaximized() const {
- return window_state_ & GDK_WINDOW_STATE_MAXIMIZED;
-}
-
-bool WindowGtk::IsMinimized() const {
- return window_state_ & GDK_WINDOW_STATE_ICONIFIED;
-}
-
-void WindowGtk::SetFullscreen(bool fullscreen) {
- if (fullscreen)
- gtk_window_fullscreen(GetNativeWindow());
- else
- gtk_window_unfullscreen(GetNativeWindow());
-}
-
-bool WindowGtk::IsFullscreen() const {
- return window_state_ & GDK_WINDOW_STATE_FULLSCREEN;
-}
-
-void WindowGtk::SetUseDragFrame(bool use_drag_frame) {
- NOTIMPLEMENTED();
-}
-
-void WindowGtk::SetIsAlwaysOnTop(bool always_on_top) {
- gtk_window_set_keep_above(GetNativeWindow(), always_on_top);
-}
-
-NonClientFrameView* WindowGtk::CreateFrameViewForWindow() {
- // TODO(erg): Always use a custom frame view? Are there cases where we let
- // the window manager deal with the X11 equivalent of the "non-client" area?
- return new CustomFrameView(this);
-}
-
-void WindowGtk::UpdateFrameAfterFrameChange() {
- // We currently don't support different frame types on Gtk, so we don't
- // need to implement this.
- NOTIMPLEMENTED();
-}
-
-gfx::NativeWindow WindowGtk::GetNativeWindow() const {
- return GTK_WINDOW(GetNativeView());
-}
-
-bool WindowGtk::ShouldUseNativeFrame() const {
- return false;
-}
-
-void WindowGtk::FrameTypeChanged() {
- // This is called when the Theme has changed, so forward the event to the root
- // widget.
- ThemeChanged();
-}
-
Window* WindowGtk::AsWindow() {
return this;
}
@@ -404,6 +300,106 @@ const NativeWidget* WindowGtk::AsNativeWidget() const {
return this;
}
+void WindowGtk::SetWindowBounds(const gfx::Rect& bounds,
+ gfx::NativeWindow other_window) {
+ // TODO: need to deal with other_window.
+ WidgetGtk::SetBounds(bounds);
+}
+
+void WindowGtk::HideWindow() {
+ Hide();
+}
+
+void WindowGtk::Activate() {
+ gtk_window_present(GTK_WINDOW(GetNativeView()));
+}
+
+void WindowGtk::Deactivate() {
+ gdk_window_lower(GTK_WIDGET(GetNativeView())->window);
+}
+
+void WindowGtk::Maximize() {
+ gtk_window_maximize(GetNativeWindow());
+}
+
+void WindowGtk::Minimize() {
+ gtk_window_iconify(GetNativeWindow());
+}
+
+void WindowGtk::Restore() {
+ if (IsMaximized())
+ gtk_window_unmaximize(GetNativeWindow());
+ else if (IsMinimized())
+ gtk_window_deiconify(GetNativeWindow());
+ else if (IsFullscreen())
+ SetFullscreen(false);
+}
+
+bool WindowGtk::IsActive() const {
+ return WidgetGtk::IsActive();
+}
+
+bool WindowGtk::IsVisible() const {
+ return GTK_WIDGET_VISIBLE(GetNativeView());
+}
+
+bool WindowGtk::IsMaximized() const {
+ return window_state_ & GDK_WINDOW_STATE_MAXIMIZED;
+}
+
+bool WindowGtk::IsMinimized() const {
+ return window_state_ & GDK_WINDOW_STATE_ICONIFIED;
+}
+
+void WindowGtk::SetFullscreen(bool fullscreen) {
+ if (fullscreen)
+ gtk_window_fullscreen(GetNativeWindow());
+ else
+ gtk_window_unfullscreen(GetNativeWindow());
+}
+
+bool WindowGtk::IsFullscreen() const {
+ return window_state_ & GDK_WINDOW_STATE_FULLSCREEN;
+}
+
+void WindowGtk::SetUseDragFrame(bool use_drag_frame) {
+ NOTIMPLEMENTED();
+}
+
+void WindowGtk::SetAlwaysOnTop(bool always_on_top) {
+ gtk_window_set_keep_above(GetNativeWindow(), always_on_top);
+}
+
+bool WindowGtk::IsAppWindow() const {
+ return false;
+}
+
+NonClientFrameView* WindowGtk::CreateFrameViewForWindow() {
+ // TODO(erg): Always use a custom frame view? Are there cases where we let
+ // the window manager deal with the X11 equivalent of the "non-client" area?
+ return new CustomFrameView(this);
+}
+
+void WindowGtk::UpdateFrameAfterFrameChange() {
+ // We currently don't support different frame types on Gtk, so we don't
+ // need to implement this.
+ NOTIMPLEMENTED();
+}
+
+gfx::NativeWindow WindowGtk::GetNativeWindow() const {
+ return GTK_WINDOW(GetNativeView());
+}
+
+bool WindowGtk::ShouldUseNativeFrame() const {
+ return false;
+}
+
+void WindowGtk::FrameTypeChanged() {
+ // This is called when the Theme has changed, so forward the event to the root
+ // widget.
+ ThemeChanged();
+}
+
////////////////////////////////////////////////////////////////////////////////
// WindowGtk, protected:
diff --git a/views/window/window_gtk.h b/views/window/window_gtk.h
index 91399e8..1797bf8 100644
--- a/views/window/window_gtk.h
+++ b/views/window/window_gtk.h
@@ -29,31 +29,6 @@ class WindowGtk : public WidgetGtk, public NativeWindow, public Window {
public:
virtual ~WindowGtk();
- // Overridden from Window:
- virtual void SetWindowBounds(const gfx::Rect& bounds,
- gfx::NativeWindow other_window);
- virtual void HideWindow();
- virtual void SetNativeWindowProperty(const char* name, void* value);
- virtual void* GetNativeWindowProperty(const char* name);
- virtual void Activate();
- virtual void Deactivate();
- virtual void Maximize();
- virtual void Minimize();
- virtual void Restore();
- virtual bool IsActive() const;
- virtual bool IsVisible() const;
- virtual bool IsMaximized() const;
- virtual bool IsMinimized() const;
- virtual void SetFullscreen(bool fullscreen);
- virtual bool IsFullscreen() const;
- virtual void SetUseDragFrame(bool use_drag_frame);
- virtual void SetIsAlwaysOnTop(bool always_on_top);
- virtual NonClientFrameView* CreateFrameViewForWindow();
- virtual void UpdateFrameAfterFrameChange();
- virtual gfx::NativeWindow GetNativeWindow() const;
- virtual bool ShouldUseNativeFrame() const;
- virtual void FrameTypeChanged();
-
virtual Window* AsWindow();
virtual const Window* AsWindow() const;
@@ -85,6 +60,28 @@ class WindowGtk : public WidgetGtk, public NativeWindow, public Window {
virtual void SetAccessibleState(AccessibilityTypes::State state) OVERRIDE;
virtual NativeWidget* AsNativeWidget() OVERRIDE;
virtual const NativeWidget* AsNativeWidget() const OVERRIDE;
+ virtual void SetWindowBounds(const gfx::Rect& bounds,
+ gfx::NativeWindow other_window) OVERRIDE;
+ virtual void HideWindow() OVERRIDE;
+ virtual void Activate() OVERRIDE;
+ virtual void Deactivate() OVERRIDE;
+ virtual void Maximize() OVERRIDE;
+ virtual void Minimize() OVERRIDE;
+ virtual void Restore() OVERRIDE;
+ virtual bool IsActive() const OVERRIDE;
+ virtual bool IsVisible() const OVERRIDE;
+ virtual bool IsMaximized() const OVERRIDE;
+ virtual bool IsMinimized() const OVERRIDE;
+ virtual void SetFullscreen(bool fullscreen) OVERRIDE;
+ virtual bool IsFullscreen() const OVERRIDE;
+ virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE;
+ virtual bool IsAppWindow() const OVERRIDE;
+ virtual void SetUseDragFrame(bool use_drag_frame) OVERRIDE;
+ virtual NonClientFrameView* CreateFrameViewForWindow() OVERRIDE;
+ virtual void UpdateFrameAfterFrameChange() OVERRIDE;
+ virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE;
+ virtual bool ShouldUseNativeFrame() const OVERRIDE;
+ virtual void FrameTypeChanged() OVERRIDE;
// For the constructor.
friend class Window;
diff --git a/views/window/window_win.cc b/views/window/window_win.cc
index 96709ba..46cb97b 100644
--- a/views/window/window_win.cc
+++ b/views/window/window_win.cc
@@ -128,6 +128,13 @@ void SendFrameChanged(HWND window) {
SWP_NOSENDCHANGING | SWP_NOSIZE | SWP_NOZORDER);
}
+// Callback used to notify child windows that the top level window received a
+// DWMCompositionChanged message.
+BOOL CALLBACK SendDwmCompositionChanged(HWND window, LPARAM param) {
+ SendMessage(window, WM_DWMCOMPOSITIONCHANGED, 0, 0);
+ return TRUE;
+}
+
// 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);
@@ -241,12 +248,6 @@ Window* Window::CreateChromeWindow(gfx::NativeWindow parent,
return window;
}
-void WindowWin::SetWindowBounds(const gfx::Rect& bounds,
- gfx::NativeWindow other_window) {
- SetChildBounds(GetNativeView(), GetParent(), other_window, bounds,
- kMonitorEdgePadding, 0);
-}
-
void WindowWin::Show(int show_state) {
ShowWindow(show_state);
// When launched from certain programs like bash and Windows Live Messenger,
@@ -270,19 +271,6 @@ void WindowWin::Show(int show_state) {
SetInitialFocus();
}
-void WindowWin::HideWindow() {
- // We can just call the function implemented by the widget.
- Hide();
-}
-
-void WindowWin::SetNativeWindowProperty(const char* name, void* value) {
- WidgetWin::SetNativeWindowProperty(name, value);
-}
-
-void* WindowWin::GetNativeWindowProperty(const char* name) {
- return WidgetWin::GetNativeWindowProperty(name);
-}
-
void WindowWin::PushForceHidden() {
if (force_hidden_count_++ == 0)
Hide();
@@ -295,196 +283,6 @@ void WindowWin::PopForceHidden() {
}
}
-namespace {
-static BOOL CALLBACK SendDwmCompositionChanged(HWND window, LPARAM param) {
- SendMessage(window, WM_DWMCOMPOSITIONCHANGED, 0, 0);
- return TRUE;
-}
-} // namespace
-
-////////////////////////////////////////////////////////////////////////////////
-// WindowWin, Window implementation:
-
-void WindowWin::Activate() {
- if (IsMinimized())
- ::ShowWindow(GetNativeView(), SW_RESTORE);
- ::SetWindowPos(GetNativeView(), HWND_TOP, 0, 0, 0, 0,
- SWP_NOSIZE | SWP_NOMOVE);
- SetForegroundWindow(GetNativeView());
-}
-
-void WindowWin::Deactivate() {
- HWND hwnd = ::GetNextWindow(GetNativeView(), GW_HWNDNEXT);
- if (hwnd)
- ::SetForegroundWindow(hwnd);
-}
-
-void WindowWin::Maximize() {
- ExecuteSystemMenuCommand(SC_MAXIMIZE);
-}
-
-void WindowWin::Minimize() {
- ExecuteSystemMenuCommand(SC_MINIMIZE);
-}
-
-void WindowWin::Restore() {
- ExecuteSystemMenuCommand(SC_RESTORE);
-}
-
-bool WindowWin::IsActive() const {
- return is_active_;
-}
-
-bool WindowWin::IsVisible() const {
- return !!::IsWindowVisible(GetNativeView());
-}
-
-bool WindowWin::IsMaximized() const {
- return !!::IsZoomed(GetNativeView());
-}
-
-bool WindowWin::IsMinimized() const {
- return !!::IsIconic(GetNativeView());
-}
-
-void WindowWin::SetFullscreen(bool fullscreen) {
- if (fullscreen_ == fullscreen)
- return; // Nothing to do.
-
- // Reduce jankiness during the following position changes by hiding the window
- // until it's in the final position.
- PushForceHidden();
-
- // Size/position/style window appropriately.
- if (!fullscreen_) {
- // Save current window information. We force the window into restored mode
- // before going fullscreen because Windows doesn't seem to hide the
- // taskbar if the window is in the maximized state.
- saved_window_info_.maximized = IsMaximized();
- if (saved_window_info_.maximized)
- Restore();
- saved_window_info_.style = GetWindowLong(GWL_STYLE);
- saved_window_info_.ex_style = GetWindowLong(GWL_EXSTYLE);
- GetWindowRect(&saved_window_info_.window_rect);
- }
-
- // Toggle fullscreen mode.
- fullscreen_ = fullscreen;
-
- if (fullscreen_) {
- // Set new window style and size.
- MONITORINFO monitor_info;
- monitor_info.cbSize = sizeof(monitor_info);
- GetMonitorInfo(MonitorFromWindow(GetNativeView(), MONITOR_DEFAULTTONEAREST),
- &monitor_info);
- gfx::Rect monitor_rect(monitor_info.rcMonitor);
- SetWindowLong(GWL_STYLE,
- saved_window_info_.style & ~(WS_CAPTION | WS_THICKFRAME));
- SetWindowLong(GWL_EXSTYLE,
- saved_window_info_.ex_style & ~(WS_EX_DLGMODALFRAME |
- WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE));
- SetWindowPos(NULL, monitor_rect.x(), monitor_rect.y(),
- monitor_rect.width(), monitor_rect.height(),
- SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
- } else {
- // Reset original window style and size. The multiple window size/moves
- // here are ugly, but if SetWindowPos() doesn't redraw, the taskbar won't be
- // repainted. Better-looking methods welcome.
- gfx::Rect new_rect(saved_window_info_.window_rect);
- SetWindowLong(GWL_STYLE, saved_window_info_.style);
- SetWindowLong(GWL_EXSTYLE, saved_window_info_.ex_style);
- SetWindowPos(NULL, new_rect.x(), new_rect.y(), new_rect.width(),
- new_rect.height(),
- SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
- if (saved_window_info_.maximized)
- Maximize();
- }
-
- // Undo our anti-jankiness hacks.
- PopForceHidden();
-}
-
-bool WindowWin::IsFullscreen() const {
- return fullscreen_;
-}
-
-void WindowWin::SetUseDragFrame(bool use_drag_frame) {
- if (use_drag_frame) {
- // Make the frame slightly transparent during the drag operation.
- drag_frame_saved_window_style_ = GetWindowLong(GWL_STYLE);
- drag_frame_saved_window_ex_style_ = GetWindowLong(GWL_EXSTYLE);
- SetWindowLong(GWL_EXSTYLE,
- drag_frame_saved_window_ex_style_ | WS_EX_LAYERED);
- // Remove the captions tyle so the window doesn't have window controls for a
- // more "transparent" look.
- SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_ & ~WS_CAPTION);
- SetLayeredWindowAttributes(GetNativeWindow(), RGB(0xFF, 0xFF, 0xFF),
- kDragFrameWindowAlpha, LWA_ALPHA);
- } else {
- SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_);
- SetWindowLong(GWL_EXSTYLE, drag_frame_saved_window_ex_style_);
- }
-}
-
-void WindowWin::SetIsAlwaysOnTop(bool always_on_top) {
- ::SetWindowPos(GetNativeView(),
- always_on_top ? HWND_TOPMOST : HWND_NOTOPMOST,
- 0, 0, 0, 0,
- SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
-}
-
-NonClientFrameView* WindowWin::CreateFrameViewForWindow() {
- if (ShouldUseNativeFrame())
- return new NativeFrameView(this);
- return new CustomFrameView(this);
-}
-
-void WindowWin::UpdateFrameAfterFrameChange() {
- // We've either gained or lost a custom window region, so reset it now.
- ResetWindowRegion(true);
-}
-
-gfx::NativeWindow WindowWin::GetNativeWindow() const {
- return GetNativeView();
-}
-
-bool WindowWin::ShouldUseNativeFrame() const {
- ui::ThemeProvider* tp = GetThemeProvider();
- if (!tp)
- return WidgetWin::IsAeroGlassEnabled();
- return tp->ShouldUseNativeFrame();
-}
-
-void WindowWin::FrameTypeChanged() {
- // Called when the frame type could possibly be changing (theme change or
- // DWM composition change).
- if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
- // We need to toggle the rendering policy of the DWM/glass frame as we
- // change from opaque to glass. "Non client rendering enabled" means that
- // the DWM's glass non-client rendering is enabled, which is why
- // DWMNCRP_ENABLED is used for the native frame case. _DISABLED means the
- // DWM doesn't render glass, and so is used in the custom frame case.
- DWMNCRENDERINGPOLICY policy =
- delegate_->IsUsingNativeFrame() ? DWMNCRP_ENABLED : DWMNCRP_DISABLED;
- DwmSetWindowAttribute(GetNativeView(), DWMWA_NCRENDERING_POLICY,
- &policy, sizeof(DWMNCRENDERINGPOLICY));
- }
-
- // Send a frame change notification, since the non-client metrics have
- // changed.
- SendFrameChanged(GetNativeView());
-
- // Update the non-client view with the correct frame view for the active frame
- // type.
- GetWindow()->non_client_view()->UpdateFrame();
-
- // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want
- // to notify our children too, since we can have MDI child windows who need to
- // update their appearance.
- EnumChildWindows(GetNativeView(), &SendDwmCompositionChanged, NULL);
-}
-
-
// static
gfx::Font WindowWin::GetWindowTitleFont() {
NONCLIENTMETRICS ncm;
@@ -594,6 +392,10 @@ LRESULT WindowWin::OnAppCommand(HWND window, short app_command, WORD device,
return 0;
}
+void WindowWin::OnClose() {
+ GetWindow()->CloseWindow();
+}
+
void WindowWin::OnCommand(UINT notification_code, int command_id, HWND window) {
// If the notification code is > 1 it means it is control specific and we
// should ignore it.
@@ -1211,6 +1013,198 @@ const NativeWidget* WindowWin::AsNativeWidget() const {
return this;
}
+void WindowWin::SetWindowBounds(const gfx::Rect& bounds,
+ gfx::NativeWindow other_window) {
+ SetChildBounds(GetNativeView(), GetParent(), other_window, bounds,
+ kMonitorEdgePadding, 0);
+}
+
+void WindowWin::HideWindow() {
+ // We can just call the function implemented by the widget.
+ Hide();
+}
+
+void WindowWin::Activate() {
+ if (IsMinimized())
+ ::ShowWindow(GetNativeView(), SW_RESTORE);
+ ::SetWindowPos(GetNativeView(), HWND_TOP, 0, 0, 0, 0,
+ SWP_NOSIZE | SWP_NOMOVE);
+ SetForegroundWindow(GetNativeView());
+}
+
+void WindowWin::Deactivate() {
+ HWND hwnd = ::GetNextWindow(GetNativeView(), GW_HWNDNEXT);
+ if (hwnd)
+ ::SetForegroundWindow(hwnd);
+}
+
+void WindowWin::Maximize() {
+ ExecuteSystemMenuCommand(SC_MAXIMIZE);
+}
+
+void WindowWin::Minimize() {
+ ExecuteSystemMenuCommand(SC_MINIMIZE);
+}
+
+void WindowWin::Restore() {
+ ExecuteSystemMenuCommand(SC_RESTORE);
+}
+
+bool WindowWin::IsActive() const {
+ return is_active_;
+}
+
+bool WindowWin::IsVisible() const {
+ return !!::IsWindowVisible(GetNativeView());
+}
+
+bool WindowWin::IsMaximized() const {
+ return !!::IsZoomed(GetNativeView());
+}
+
+bool WindowWin::IsMinimized() const {
+ return !!::IsIconic(GetNativeView());
+}
+
+void WindowWin::SetFullscreen(bool fullscreen) {
+ if (fullscreen_ == fullscreen)
+ return; // Nothing to do.
+
+ // Reduce jankiness during the following position changes by hiding the window
+ // until it's in the final position.
+ PushForceHidden();
+
+ // Size/position/style window appropriately.
+ if (!fullscreen_) {
+ // Save current window information. We force the window into restored mode
+ // before going fullscreen because Windows doesn't seem to hide the
+ // taskbar if the window is in the maximized state.
+ saved_window_info_.maximized = IsMaximized();
+ if (saved_window_info_.maximized)
+ Restore();
+ saved_window_info_.style = GetWindowLong(GWL_STYLE);
+ saved_window_info_.ex_style = GetWindowLong(GWL_EXSTYLE);
+ GetWindowRect(&saved_window_info_.window_rect);
+ }
+
+ // Toggle fullscreen mode.
+ fullscreen_ = fullscreen;
+
+ if (fullscreen_) {
+ // Set new window style and size.
+ MONITORINFO monitor_info;
+ monitor_info.cbSize = sizeof(monitor_info);
+ GetMonitorInfo(MonitorFromWindow(GetNativeView(), MONITOR_DEFAULTTONEAREST),
+ &monitor_info);
+ gfx::Rect monitor_rect(monitor_info.rcMonitor);
+ SetWindowLong(GWL_STYLE,
+ saved_window_info_.style & ~(WS_CAPTION | WS_THICKFRAME));
+ SetWindowLong(GWL_EXSTYLE,
+ saved_window_info_.ex_style & ~(WS_EX_DLGMODALFRAME |
+ WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE));
+ SetWindowPos(NULL, monitor_rect.x(), monitor_rect.y(),
+ monitor_rect.width(), monitor_rect.height(),
+ SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
+ } else {
+ // Reset original window style and size. The multiple window size/moves
+ // here are ugly, but if SetWindowPos() doesn't redraw, the taskbar won't be
+ // repainted. Better-looking methods welcome.
+ gfx::Rect new_rect(saved_window_info_.window_rect);
+ SetWindowLong(GWL_STYLE, saved_window_info_.style);
+ SetWindowLong(GWL_EXSTYLE, saved_window_info_.ex_style);
+ SetWindowPos(NULL, new_rect.x(), new_rect.y(), new_rect.width(),
+ new_rect.height(),
+ SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED);
+ if (saved_window_info_.maximized)
+ Maximize();
+ }
+
+ // Undo our anti-jankiness hacks.
+ PopForceHidden();
+}
+
+bool WindowWin::IsFullscreen() const {
+ return fullscreen_;
+}
+
+void WindowWin::SetAlwaysOnTop(bool always_on_top) {
+ ::SetWindowPos(GetNativeView(), always_on_top ? HWND_TOPMOST : HWND_NOTOPMOST,
+ 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+}
+
+bool WindowWin::IsAppWindow() const {
+ return false;
+}
+
+void WindowWin::SetUseDragFrame(bool use_drag_frame) {
+ if (use_drag_frame) {
+ // Make the frame slightly transparent during the drag operation.
+ drag_frame_saved_window_style_ = GetWindowLong(GWL_STYLE);
+ drag_frame_saved_window_ex_style_ = GetWindowLong(GWL_EXSTYLE);
+ SetWindowLong(GWL_EXSTYLE,
+ drag_frame_saved_window_ex_style_ | WS_EX_LAYERED);
+ // Remove the captions tyle so the window doesn't have window controls for a
+ // more "transparent" look.
+ SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_ & ~WS_CAPTION);
+ SetLayeredWindowAttributes(GetNativeWindow(), RGB(0xFF, 0xFF, 0xFF),
+ kDragFrameWindowAlpha, LWA_ALPHA);
+ } else {
+ SetWindowLong(GWL_STYLE, drag_frame_saved_window_style_);
+ SetWindowLong(GWL_EXSTYLE, drag_frame_saved_window_ex_style_);
+ }
+}
+
+NonClientFrameView* WindowWin::CreateFrameViewForWindow() {
+ if (ShouldUseNativeFrame())
+ return new NativeFrameView(this);
+ return new CustomFrameView(this);
+}
+
+void WindowWin::UpdateFrameAfterFrameChange() {
+ // We've either gained or lost a custom window region, so reset it now.
+ ResetWindowRegion(true);
+}
+
+gfx::NativeWindow WindowWin::GetNativeWindow() const {
+ return GetNativeView();
+}
+
+bool WindowWin::ShouldUseNativeFrame() const {
+ ui::ThemeProvider* tp = GetThemeProvider();
+ if (!tp)
+ return WidgetWin::IsAeroGlassEnabled();
+ return tp->ShouldUseNativeFrame();
+}
+
+void WindowWin::FrameTypeChanged() {
+ // Called when the frame type could possibly be changing (theme change or
+ // DWM composition change).
+ if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
+ // We need to toggle the rendering policy of the DWM/glass frame as we
+ // change from opaque to glass. "Non client rendering enabled" means that
+ // the DWM's glass non-client rendering is enabled, which is why
+ // DWMNCRP_ENABLED is used for the native frame case. _DISABLED means the
+ // DWM doesn't render glass, and so is used in the custom frame case.
+ DWMNCRENDERINGPOLICY policy =
+ delegate_->IsUsingNativeFrame() ? DWMNCRP_ENABLED : DWMNCRP_DISABLED;
+ DwmSetWindowAttribute(GetNativeView(), DWMWA_NCRENDERING_POLICY,
+ &policy, sizeof(DWMNCRENDERINGPOLICY));
+ }
+
+ // Send a frame change notification, since the non-client metrics have
+ // changed.
+ SendFrameChanged(GetNativeView());
+
+ // Update the non-client view with the correct frame view for the active frame
+ // type.
+ GetWindow()->non_client_view()->UpdateFrame();
+
+ // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want
+ // to notify our children too, since we can have MDI child windows who need to
+ // update their appearance.
+ EnumChildWindows(GetNativeView(), &SendDwmCompositionChanged, NULL);
+}
+
////////////////////////////////////////////////////////////////////////////////
// WindowWin, private:
diff --git a/views/window/window_win.h b/views/window/window_win.h
index 9c74f75..64310ba 100644
--- a/views/window/window_win.h
+++ b/views/window/window_win.h
@@ -54,32 +54,14 @@ class WindowWin : public WidgetWin,
focus_on_creation_ = focus_on_creation;
}
- // Overridden from Window:
- virtual void SetWindowBounds(const gfx::Rect& bounds,
- gfx::NativeWindow other_window) OVERRIDE;
- virtual void HideWindow() OVERRIDE;
- virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE;
- virtual void* GetNativeWindowProperty(const char* name) OVERRIDE;
- virtual void PushForceHidden() OVERRIDE;
- virtual void PopForceHidden() OVERRIDE;
- virtual void Activate() OVERRIDE;
- virtual void Deactivate() OVERRIDE;
- virtual void Maximize() OVERRIDE;
- virtual void Minimize() OVERRIDE;
- virtual void Restore() OVERRIDE;
- virtual bool IsActive() const OVERRIDE;
- virtual bool IsVisible() const OVERRIDE;
- virtual bool IsMaximized() const OVERRIDE;
- virtual bool IsMinimized() const OVERRIDE;
- virtual void SetFullscreen(bool fullscreen) OVERRIDE;
- virtual bool IsFullscreen() const OVERRIDE;
- virtual void SetUseDragFrame(bool use_drag_frame) OVERRIDE;
- virtual void SetIsAlwaysOnTop(bool always_on_top) OVERRIDE;
- virtual NonClientFrameView* CreateFrameViewForWindow() OVERRIDE;
- virtual void UpdateFrameAfterFrameChange() OVERRIDE;
- virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE;
- virtual bool ShouldUseNativeFrame() const OVERRIDE;
- virtual void FrameTypeChanged() OVERRIDE;
+ // Hides the window if it hasn't already been force-hidden. The force hidden
+ // count is tracked, so calling multiple times is allowed, you just have to
+ // be sure to call PopForceHidden the same number of times.
+ void PushForceHidden();
+
+ // Decrements the force hidden count, showing the window if we have reached
+ // the top of the stack. See PushForceHidden.
+ void PopForceHidden();
// Returns the system set window title font.
static gfx::Font GetWindowTitleFont();
@@ -115,6 +97,7 @@ class WindowWin : public WidgetWin,
short app_command,
WORD device,
int keystate) OVERRIDE;
+ virtual void OnClose() OVERRIDE;
virtual void OnCommand(UINT notification_code,
int command_id,
HWND window) OVERRIDE;
@@ -169,6 +152,28 @@ class WindowWin : public WidgetWin,
virtual void SetAccessibleState(AccessibilityTypes::State state) OVERRIDE;
virtual NativeWidget* AsNativeWidget() OVERRIDE;
virtual const NativeWidget* AsNativeWidget() const OVERRIDE;
+ virtual void SetWindowBounds(const gfx::Rect& bounds,
+ gfx::NativeWindow other_window) OVERRIDE;
+ virtual void HideWindow() OVERRIDE;
+ virtual void Activate() OVERRIDE;
+ virtual void Deactivate() OVERRIDE;
+ virtual void Maximize() OVERRIDE;
+ virtual void Minimize() OVERRIDE;
+ virtual void Restore() OVERRIDE;
+ virtual bool IsActive() const OVERRIDE;
+ virtual bool IsVisible() const OVERRIDE;
+ virtual bool IsMaximized() const OVERRIDE;
+ virtual bool IsMinimized() const OVERRIDE;
+ virtual void SetFullscreen(bool fullscreen) OVERRIDE;
+ virtual bool IsFullscreen() const OVERRIDE;
+ virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE;
+ virtual bool IsAppWindow() const OVERRIDE;
+ virtual void SetUseDragFrame(bool use_drag_frame) OVERRIDE;
+ virtual NonClientFrameView* CreateFrameViewForWindow() OVERRIDE;
+ virtual void UpdateFrameAfterFrameChange() OVERRIDE;
+ virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE;
+ virtual bool ShouldUseNativeFrame() const OVERRIDE;
+ virtual void FrameTypeChanged() OVERRIDE;
private:
// Information saved before going into fullscreen mode, used to restore the