diff options
-rw-r--r-- | chrome/browser/task_manager_win.cc | 107 | ||||
-rw-r--r-- | chrome/browser/views/chrome_views_delegate.cc | 16 | ||||
-rw-r--r-- | chrome/browser/views/chrome_views_delegate.h | 5 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 5 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.h | 3 | ||||
-rw-r--r-- | chrome/browser/views/page_info_window.cc | 2 | ||||
-rw-r--r-- | views/DEPS | 6 | ||||
-rw-r--r-- | views/views_delegate.h | 12 | ||||
-rw-r--r-- | views/window/window.h | 3 | ||||
-rw-r--r-- | views/window/window_delegate.cc | 15 | ||||
-rw-r--r-- | views/window/window_delegate.h | 34 | ||||
-rw-r--r-- | views/window/window_gtk.cc | 4 | ||||
-rw-r--r-- | views/window/window_gtk.h | 1 | ||||
-rw-r--r-- | views/window/window_win.cc | 84 | ||||
-rw-r--r-- | views/window/window_win.h | 17 |
15 files changed, 134 insertions, 180 deletions
diff --git a/chrome/browser/task_manager_win.cc b/chrome/browser/task_manager_win.cc index d20d5a2..9b0db00 100644 --- a/chrome/browser/task_manager_win.cc +++ b/chrome/browser/task_manager_win.cc @@ -5,6 +5,7 @@ #include "chrome/browser/task_manager.h" #include "base/stats_table.h" +#include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_process.h" #include "chrome/common/pref_names.h" @@ -190,8 +191,7 @@ class TaskManagerViewImpl : public TaskManagerView, // views::DialogDelegate virtual bool CanResize() const; virtual bool CanMaximize() const; - virtual bool IsAlwaysOnTop() const; - virtual bool HasAlwaysOnTopMenu() const; + virtual bool ExecuteWindowsCommand(int command_id); virtual std::wstring GetWindowTitle() const; virtual std::wstring GetWindowName() const; virtual int GetDialogButtons() const; @@ -220,6 +220,15 @@ class TaskManagerViewImpl : public TaskManagerView, virtual void ExecuteCommand(int id); private: + // Initializes the state of the always-on-top setting as the window is shown. + void InitAlwaysOnTopState(); + + // Adds an always on top item to the window's system menu. + void AddAlwaysOnTopSystemMenuItem(); + + // Restores saved always on top state from a previous session. + bool GetSavedAlwaysOnTopState(bool* always_on_top) const; + scoped_ptr<views::NativeButton> kill_button_; scoped_ptr<views::Link> about_memory_link_; views::GroupTableView* tab_table_; @@ -233,13 +242,20 @@ class TaskManagerViewImpl : public TaskManagerView, scoped_ptr<TaskManagerTableModel> table_model_; + // True when the Task Manager window should be shown on top of other windows. + bool is_always_on_top_; + + // We need to own the text of the menu, the Windows API does not copy it. + std::wstring always_on_top_menu_text_; + DISALLOW_COPY_AND_ASSIGN(TaskManagerViewImpl); }; TaskManagerViewImpl::TaskManagerViewImpl(TaskManager* task_manager, TaskManagerModel* model) : task_manager_(task_manager), - model_(model) { + model_(model), + is_always_on_top_(false) { Init(); } @@ -410,6 +426,7 @@ void TaskManagerViewImpl::OpenWindow() { window()->Activate(); } else { views::Window::CreateChromeWindow(NULL, gfx::Rect(), this); + InitAlwaysOnTopState(); model_->StartUpdating(); window()->Show(); } @@ -430,14 +447,38 @@ bool TaskManagerViewImpl::CanMaximize() const { return true; } -bool TaskManagerViewImpl::IsAlwaysOnTop() const { - return true; +bool TaskManagerViewImpl::ExecuteWindowsCommand(int command_id) { + if (command_id == IDC_ALWAYS_ON_TOP) { + is_always_on_top_ = !is_always_on_top_; + + // Change the menu check state. + HMENU system_menu = GetSystemMenu(GetWindow()->GetNativeWindow(), FALSE); + MENUITEMINFO menu_info; + memset(&menu_info, 0, sizeof(MENUITEMINFO)); + menu_info.cbSize = sizeof(MENUITEMINFO); + BOOL r = GetMenuItemInfo(system_menu, IDC_ALWAYS_ON_TOP, + FALSE, &menu_info); + DCHECK(r); + menu_info.fMask = MIIM_STATE; + if (is_always_on_top_) + menu_info.fState = MFS_CHECKED; + r = SetMenuItemInfo(system_menu, IDC_ALWAYS_ON_TOP, FALSE, &menu_info); + + // Now change the actual window's behavior. + window()->SetIsAlwaysOnTop(is_always_on_top_); + + // Save the state. + if (g_browser_process->local_state()) { + DictionaryValue* window_preferences = + g_browser_process->local_state()->GetMutableDictionary( + GetWindowName().c_str()); + window_preferences->SetBoolean(L"always_on_top", is_always_on_top_); + } + return true; + } + return false; } -bool TaskManagerViewImpl::HasAlwaysOnTopMenu() const { - return true; -}; - std::wstring TaskManagerViewImpl::GetWindowTitle() const { return l10n_util::GetString(IDS_TASK_MANAGER_TITLE); } @@ -515,6 +556,54 @@ void TaskManagerViewImpl::ExecuteCommand(int id) { tab_table_->SetColumnVisibility(id, !tab_table_->IsColumnVisible(id)); } +void TaskManagerViewImpl::InitAlwaysOnTopState() { + is_always_on_top_ = false; + if (GetSavedAlwaysOnTopState(&is_always_on_top_)) + window()->SetIsAlwaysOnTop(is_always_on_top_); + AddAlwaysOnTopSystemMenuItem(); +} + +void TaskManagerViewImpl::AddAlwaysOnTopSystemMenuItem() { + // The Win32 API requires that we own the text. + always_on_top_menu_text_ = l10n_util::GetString(IDS_ALWAYS_ON_TOP); + + // Let's insert a menu to the window. + HMENU system_menu = ::GetSystemMenu(GetWindow()->GetNativeWindow(), FALSE); + int index = ::GetMenuItemCount(system_menu) - 1; + if (index < 0) { + // Paranoia check. + NOTREACHED(); + index = 0; + } + // First we add the separator. + MENUITEMINFO menu_info; + memset(&menu_info, 0, sizeof(MENUITEMINFO)); + menu_info.cbSize = sizeof(MENUITEMINFO); + menu_info.fMask = MIIM_FTYPE; + menu_info.fType = MFT_SEPARATOR; + ::InsertMenuItem(system_menu, index, TRUE, &menu_info); + + // Then the actual menu. + menu_info.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING | MIIM_STATE; + menu_info.fType = MFT_STRING; + menu_info.fState = MFS_ENABLED; + if (is_always_on_top_) + menu_info.fState |= MFS_CHECKED; + menu_info.wID = IDC_ALWAYS_ON_TOP; + menu_info.dwTypeData = const_cast<wchar_t*>(always_on_top_menu_text_.c_str()); + ::InsertMenuItem(system_menu, index, TRUE, &menu_info); +} + +bool TaskManagerViewImpl::GetSavedAlwaysOnTopState(bool* always_on_top) const { + if (!g_browser_process->local_state()) + return false; + + const DictionaryValue* dictionary = + g_browser_process->local_state()->GetDictionary(GetWindowName().c_str()); + return dictionary && + dictionary->GetBoolean(L"always_on_top", always_on_top) && always_on_top; +} + } // namespace void TaskManager::Init() { diff --git a/chrome/browser/views/chrome_views_delegate.cc b/chrome/browser/views/chrome_views_delegate.cc index 1c04bc6..c793a54 100644 --- a/chrome/browser/views/chrome_views_delegate.cc +++ b/chrome/browser/views/chrome_views_delegate.cc @@ -19,8 +19,7 @@ Clipboard* ChromeViewsDelegate::GetClipboard() const { void ChromeViewsDelegate::SaveWindowPlacement(const std::wstring& window_name, const gfx::Rect& bounds, - bool maximized, - bool always_on_top) { + bool maximized) { if (!g_browser_process->local_state()) return; @@ -32,7 +31,6 @@ void ChromeViewsDelegate::SaveWindowPlacement(const std::wstring& window_name, window_preferences->SetInteger(L"right", bounds.right()); window_preferences->SetInteger(L"bottom", bounds.bottom()); window_preferences->SetBoolean(L"maximized", maximized); - window_preferences->SetBoolean(L"always_on_top", always_on_top); } bool ChromeViewsDelegate::GetSavedWindowBounds(const std::wstring& window_name, @@ -65,18 +63,6 @@ bool ChromeViewsDelegate::GetSavedMaximizedState( maximized; } -bool ChromeViewsDelegate::GetSavedAlwaysOnTopState( - const std::wstring& window_name, - bool* always_on_top) const { - if (!g_browser_process->local_state()) - return false; - - const DictionaryValue* dictionary = - g_browser_process->local_state()->GetDictionary(window_name.c_str()); - return dictionary && dictionary->GetBoolean(L"always_on_top", always_on_top) && - always_on_top; -} - #if defined(OS_WIN) HICON ChromeViewsDelegate::GetDefaultWindowIcon() const { return LoadIcon(GetModuleHandle(L"chrome.dll"), diff --git a/chrome/browser/views/chrome_views_delegate.h b/chrome/browser/views/chrome_views_delegate.h index 007e7b0..346fd73 100644 --- a/chrome/browser/views/chrome_views_delegate.h +++ b/chrome/browser/views/chrome_views_delegate.h @@ -17,14 +17,11 @@ class ChromeViewsDelegate : public views::ViewsDelegate { virtual Clipboard* GetClipboard() const; virtual void SaveWindowPlacement(const std::wstring& window_name, const gfx::Rect& bounds, - bool maximized, - bool always_on_top); + bool maximized); virtual bool GetSavedWindowBounds(const std::wstring& window_name, gfx::Rect* bounds) const; virtual bool GetSavedMaximizedState(const std::wstring& window_name, bool* maximized) const; - virtual bool GetSavedAlwaysOnTopState(const std::wstring& window_name, - bool* always_on_top) const; #if defined(OS_WIN) virtual HICON GetDefaultWindowIcon() const; #endif diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index a438cdf..1af097f 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -1008,13 +1008,12 @@ std::wstring BrowserView::GetWindowName() const { } void BrowserView::SaveWindowPlacement(const gfx::Rect& bounds, - bool maximized, - bool always_on_top) { + bool maximized) { // If IsFullscreen() is true, we've just changed into fullscreen mode, and // we're catching the going-into-fullscreen sizing and positioning calls, // which we want to ignore. if (!IsFullscreen() && browser_->ShouldSaveWindowPlacement()) { - WindowDelegate::SaveWindowPlacement(bounds, maximized, always_on_top); + WindowDelegate::SaveWindowPlacement(bounds, maximized); browser_->SaveWindowPlacement(bounds, maximized); } } diff --git a/chrome/browser/views/frame/browser_view.h b/chrome/browser/views/frame/browser_view.h index c3e0734..af5b011 100644 --- a/chrome/browser/views/frame/browser_view.h +++ b/chrome/browser/views/frame/browser_view.h @@ -235,8 +235,7 @@ class BrowserView : public BrowserWindow, virtual bool ExecuteWindowsCommand(int command_id); virtual std::wstring GetWindowName() const; virtual void SaveWindowPlacement(const gfx::Rect& bounds, - bool maximized, - bool always_on_top); + bool maximized); virtual bool GetSavedWindowBounds(gfx::Rect* bounds) const; virtual bool GetSavedMaximizedState(bool* maximized) const; virtual views::View* GetContentsView(); diff --git a/chrome/browser/views/page_info_window.cc b/chrome/browser/views/page_info_window.cc index 8c9e6ad..1e72a6e 100644 --- a/chrome/browser/views/page_info_window.cc +++ b/chrome/browser/views/page_info_window.cc @@ -562,7 +562,7 @@ void PageInfoWindow::Init(Profile* profile, if (GetSavedWindowBounds(&bounds) && GetSavedMaximizedState(&maximized)) { CRect bounds_crect(bounds.ToRECT()); CalculateWindowBounds(&bounds_crect); - SaveWindowPlacement(gfx::Rect(bounds_crect), maximized, false); + SaveWindowPlacement(gfx::Rect(bounds_crect), maximized); } } @@ -3,12 +3,6 @@ include_rules = [ "+skia/ext", "+skia/include", - # TODO(beng): sever these dependencies into chrome by either refactoring or - # moving code into app/ - - # widget_win.cc - "+chrome/app/chrome_dll_resource.h", - # TODO(beng): swap these with app/views specific generated resources. "+grit/generated_resources.h", "+grit/theme_resources.h", diff --git a/views/views_delegate.h b/views/views_delegate.h index 082689c..6fe7f74 100644 --- a/views/views_delegate.h +++ b/views/views_delegate.h @@ -28,12 +28,11 @@ class ViewsDelegate { // Gets the clipboard. virtual Clipboard* GetClipboard() const = 0; - // Saves the position, size, maximized and always-on-top state for the - // window with the specified name. + // Saves the position, size and maximized state for the window with the + // specified name. virtual void SaveWindowPlacement(const std::wstring& window_name, const gfx::Rect& bounds, - bool maximized, - bool always_on_top) = 0; + bool maximized) = 0; // Retrieves the saved position and size for the window with the specified // name. @@ -45,11 +44,6 @@ class ViewsDelegate { virtual bool GetSavedMaximizedState(const std::wstring& window_name, bool* maximized) const = 0; - // Retrieves the saved always-on-top state for the window with the specified - // name. - virtual bool GetSavedAlwaysOnTopState(const std::wstring& window_name, - bool* always_on_top) const = 0; - #if defined(OS_WIN) // Retrieves the default window icon to use for windows if none is specified. virtual HICON GetDefaultWindowIcon() const = 0; diff --git a/views/window/window.h b/views/window/window.h index 17a2ff5..9d29a81 100644 --- a/views/window/window.h +++ b/views/window/window.h @@ -111,6 +111,9 @@ class Window { // Tell the window to update its icon from the delegate. virtual void UpdateWindowIcon() = 0; + // Sets whether or not the window is always-on-top. + virtual void SetIsAlwaysOnTop(bool always_on_top) = 0; + // Creates an appropriate NonClientFrameView for this window. virtual NonClientFrameView* CreateFrameViewForWindow() = 0; diff --git a/views/window/window_delegate.cc b/views/window/window_delegate.cc index ac5816f..4ac4d80 100644 --- a/views/window/window_delegate.cc +++ b/views/window/window_delegate.cc @@ -23,14 +23,13 @@ SkBitmap WindowDelegate::GetWindowIcon() { } void WindowDelegate::SaveWindowPlacement(const gfx::Rect& bounds, - bool maximized, - bool always_on_top) { + bool maximized) { std::wstring window_name = GetWindowName(); if (!ViewsDelegate::views_delegate || window_name.empty()) return; ViewsDelegate::views_delegate->SaveWindowPlacement( - window_name, bounds, maximized, always_on_top); + window_name, bounds, maximized); } bool WindowDelegate::GetSavedWindowBounds(gfx::Rect* bounds) const { @@ -51,16 +50,6 @@ bool WindowDelegate::GetSavedMaximizedState(bool* maximized) const { window_name, maximized); } -bool WindowDelegate::GetSavedAlwaysOnTopState(bool* always_on_top) const { - std::wstring window_name = GetWindowName(); - if (!ViewsDelegate::views_delegate || window_name.empty()) - return false; - - return ViewsDelegate::views_delegate->GetSavedAlwaysOnTopState( - window_name, always_on_top); -} - - ClientView* WindowDelegate::CreateClientView(Window* window) { return new ClientView(window, GetContentsView()); } diff --git a/views/window/window_delegate.h b/views/window/window_delegate.h index 992e94a..e790ff6 100644 --- a/views/window/window_delegate.h +++ b/views/window/window_delegate.h @@ -53,20 +53,6 @@ class WindowDelegate { return false; } - // Returns true if the window should be placed on top of all other windows on - // the system, even when it is not active. If HasAlwaysOnTopMenu() returns - // true, then this method is only used the first time the window is opened, it - // is stored in the preferences for next runs. - virtual bool IsAlwaysOnTop() const { - return false; - } - - // Returns whether an "always on top" menu should be added to the system menu - // of the window. - virtual bool HasAlwaysOnTopMenu() const { - return false; - } - // Returns true if the dialog should be displayed modally to the window that // opened it. Only windows with WindowType == DIALOG can be modal. virtual bool IsModal() const { @@ -105,21 +91,15 @@ class WindowDelegate { return std::wstring(); } - // Saves the window's bounds, maximized and always-on-top states. By default - // this uses the process' local state keyed by window name (See GetWindowName - // above). This behavior can be overridden to provide additional - // functionality. - virtual void SaveWindowPlacement(const gfx::Rect& bounds, - bool maximized, - bool always_on_top); - - // Retrieves the window's bounds, maximized and always-on-top states. By - // default, this uses the process' local state keyed by window name (See - // GetWindowName above). This behavior can be overridden to provide - // additional functionality. + // Saves the window's bounds and maximized states. By default this uses the + // process' local state keyed by window name (See GetWindowName above). This + // behavior can be overridden to provide additional functionality. + virtual void SaveWindowPlacement(const gfx::Rect& bounds, bool maximized); + + // Retrieves the window's bounds and maximized states. + // This behavior can be overridden to provide additional functionality. virtual bool GetSavedWindowBounds(gfx::Rect* bounds) const; virtual bool GetSavedMaximizedState(bool* maximized) const; - virtual bool GetSavedAlwaysOnTopState(bool* always_on_top) const; // Called when the window closes. virtual void WindowClosing() { } diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc index a8c710c..37ff816 100644 --- a/views/window/window_gtk.cc +++ b/views/window/window_gtk.cc @@ -129,6 +129,10 @@ void WindowGtk::UpdateWindowIcon() { NOTIMPLEMENTED(); } +void WindowGtk::SetIsAlwaysOnTop(bool always_on_top) { + NOTIMPLEMENTED(); +} + 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? diff --git a/views/window/window_gtk.h b/views/window/window_gtk.h index 224c85a5..ac33495 100644 --- a/views/window/window_gtk.h +++ b/views/window/window_gtk.h @@ -46,6 +46,7 @@ class WindowGtk : public WidgetGtk, public Window { virtual void DisableInactiveRendering(); virtual void UpdateWindowTitle(); virtual void UpdateWindowIcon(); + virtual void SetIsAlwaysOnTop(bool always_on_top); virtual NonClientFrameView* CreateFrameViewForWindow(); virtual void UpdateFrameAfterFrameChange(); virtual WindowDelegate* GetDelegate() const; diff --git a/views/window/window_win.cc b/views/window/window_win.cc index 40ec924..c5c92c7 100644 --- a/views/window/window_win.cc +++ b/views/window/window_win.cc @@ -14,7 +14,6 @@ #include "app/resource_bundle.h" #include "app/win_util.h" #include "base/win_util.h" -#include "chrome/app/chrome_dll_resource.h" #include "grit/generated_resources.h" #include "views/widget/root_view.h" #include "views/window/client_view.h" @@ -401,6 +400,13 @@ void WindowWin::UpdateWindowIcon() { } } +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 (non_client_view_->UseNativeFrame()) return new NativeFrameView(this); @@ -440,7 +446,6 @@ WindowWin::WindowWin(WindowDelegate* window_delegate) minimum_size_(100, 100), is_modal_(false), restored_enabled_(false), - is_always_on_top_(false), fullscreen_(false), window_closed_(false), disable_inactive_rendering_(false), @@ -471,7 +476,6 @@ void WindowWin::Init(HWND parent, const gfx::Rect& bounds) { is_modal_ = window_delegate_->IsModal(); if (is_modal_) BecomeModal(); - is_always_on_top_ = window_delegate_->IsAlwaysOnTop(); if (window_style() == 0) set_window_style(CalculateWindowStyle()); @@ -489,7 +493,6 @@ void WindowWin::Init(HWND parent, const gfx::Rect& bounds) { UpdateWindowTitle(); SetInitialBounds(bounds); - InitAlwaysOnTopState(); GetMonitorAndRects(bounds.ToRECT(), &last_monitor_, &last_monitor_rect_, &last_work_area_); @@ -1056,25 +1059,7 @@ void WindowWin::OnSysCommand(UINT notification_code, CPoint click) { if (window_delegate_->ExecuteWindowsCommand(notification_code)) return; - if (notification_code == IDC_ALWAYS_ON_TOP) { - is_always_on_top_ = !is_always_on_top_; - - // Change the menu check state. - HMENU system_menu = GetSystemMenu(GetNativeView(), FALSE); - MENUITEMINFO menu_info; - memset(&menu_info, 0, sizeof(MENUITEMINFO)); - menu_info.cbSize = sizeof(MENUITEMINFO); - BOOL r = GetMenuItemInfo(system_menu, IDC_ALWAYS_ON_TOP, - FALSE, &menu_info); - DCHECK(r); - menu_info.fMask = MIIM_STATE; - if (is_always_on_top_) - menu_info.fState = MFS_CHECKED; - r = SetMenuItemInfo(system_menu, IDC_ALWAYS_ON_TOP, FALSE, &menu_info); - - // Now change the actual window's behavior. - AlwaysOnTopChanged(); - } else if ((notification_code == SC_KEYMENU) && (click.x == VK_SPACE)) { + if ((notification_code == SC_KEYMENU) && (click.x == VK_SPACE)) { // Run the system menu at the NonClientView's desired location. RunSystemMenu(non_client_view_->GetSystemMenuPoint()); } else { @@ -1229,48 +1214,6 @@ void WindowWin::SetInitialBounds(const gfx::Rect& create_bounds) { } } -void WindowWin::InitAlwaysOnTopState() { - is_always_on_top_ = false; - if (window_delegate_->GetSavedAlwaysOnTopState(&is_always_on_top_) && - is_always_on_top_ != window_delegate_->IsAlwaysOnTop()) { - AlwaysOnTopChanged(); - } - - if (window_delegate_->HasAlwaysOnTopMenu()) - AddAlwaysOnTopSystemMenuItem(); -} - -void WindowWin::AddAlwaysOnTopSystemMenuItem() { - // The Win32 API requires that we own the text. - always_on_top_menu_text_ = l10n_util::GetString(IDS_ALWAYS_ON_TOP); - - // Let's insert a menu to the window. - HMENU system_menu = ::GetSystemMenu(GetNativeView(), FALSE); - int index = ::GetMenuItemCount(system_menu) - 1; - if (index < 0) { - // Paranoia check. - NOTREACHED(); - index = 0; - } - // First we add the separator. - MENUITEMINFO menu_info; - memset(&menu_info, 0, sizeof(MENUITEMINFO)); - menu_info.cbSize = sizeof(MENUITEMINFO); - menu_info.fMask = MIIM_FTYPE; - menu_info.fType = MFT_SEPARATOR; - ::InsertMenuItem(system_menu, index, TRUE, &menu_info); - - // Then the actual menu. - menu_info.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING | MIIM_STATE; - menu_info.fType = MFT_STRING; - menu_info.fState = MFS_ENABLED; - if (is_always_on_top_) - menu_info.fState |= MFS_CHECKED; - menu_info.wID = IDC_ALWAYS_ON_TOP; - menu_info.dwTypeData = const_cast<wchar_t*>(always_on_top_menu_text_.c_str()); - ::InsertMenuItem(system_menu, index, TRUE, &menu_info); -} - void WindowWin::RestoreEnabledIfNecessary() { if (is_modal_ && !restored_enabled_) { restored_enabled_ = true; @@ -1284,13 +1227,6 @@ void WindowWin::RestoreEnabledIfNecessary() { } } -void WindowWin::AlwaysOnTopChanged() { - ::SetWindowPos(GetNativeView(), - is_always_on_top_ ? HWND_TOPMOST : HWND_NOTOPMOST, - 0, 0, 0, 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED); -} - DWORD WindowWin::CalculateWindowStyle() { DWORD window_styles = WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_SYSMENU | WS_CAPTION; @@ -1316,8 +1252,6 @@ DWORD WindowWin::CalculateWindowExStyle() { DWORD window_ex_styles = 0; if (window_delegate_->AsDialogDelegate()) window_ex_styles |= WS_EX_DLGMODALFRAME; - if (window_delegate_->IsAlwaysOnTop()) - window_ex_styles |= WS_EX_TOPMOST; return window_ex_styles; } @@ -1338,7 +1272,7 @@ void WindowWin::SaveWindowPosition() { bool maximized = (win_placement.showCmd == SW_SHOWMAXIMIZED); CRect window_bounds(win_placement.rcNormalPosition); window_delegate_->SaveWindowPlacement( - gfx::Rect(win_placement.rcNormalPosition), maximized, is_always_on_top_); + gfx::Rect(win_placement.rcNormalPosition), maximized); } void WindowWin::LockUpdates() { diff --git a/views/window/window_win.h b/views/window/window_win.h index 5a90835..1760caa 100644 --- a/views/window/window_win.h +++ b/views/window/window_win.h @@ -80,6 +80,7 @@ class WindowWin : public WidgetWin, virtual void DisableInactiveRendering(); virtual void UpdateWindowTitle(); virtual void UpdateWindowIcon(); + virtual void SetIsAlwaysOnTop(bool always_on_top); virtual NonClientFrameView* CreateFrameViewForWindow(); virtual void UpdateFrameAfterFrameChange(); virtual WindowDelegate* GetDelegate() const; @@ -163,19 +164,9 @@ class WindowWin : public WidgetWin, // bounds used when the window was created. void SetInitialBounds(const gfx::Rect& create_bounds); - // Restore saved always on stop state and add the always on top system menu - // if needed. - void InitAlwaysOnTopState(); - - // Add an item for "Always on Top" to the System Menu. - void AddAlwaysOnTopSystemMenuItem(); - // If necessary, enables all ancestors. void RestoreEnabledIfNecessary(); - // Update the window style to reflect the always on top state. - void AlwaysOnTopChanged(); - // Calculate the appropriate window styles for this window. DWORD CalculateWindowStyle(); DWORD CalculateWindowExStyle(); @@ -245,12 +236,6 @@ class WindowWin : public WidgetWin, // true. bool restored_enabled_; - // Whether the window is currently always on top. - bool is_always_on_top_; - - // We need to own the text of the menu, the Windows API does not copy it. - std::wstring always_on_top_menu_text_; - // True if we're in fullscreen mode. bool fullscreen_; |