diff options
author | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-25 22:11:49 +0000 |
---|---|---|
committer | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-25 22:11:49 +0000 |
commit | 65bd67d12cbbf73a0c7842750bd30639ddad2306 (patch) | |
tree | c498514b6a1a3d3e50b62498a09fd642cb9aa139 /chrome/views | |
parent | c62b56cde3acdd5d16896795739d7ce894c6e1a7 (diff) | |
download | chromium_src-65bd67d12cbbf73a0c7842750bd30639ddad2306.zip chromium_src-65bd67d12cbbf73a0c7842750bd30639ddad2306.tar.gz chromium_src-65bd67d12cbbf73a0c7842750bd30639ddad2306.tar.bz2 |
Make the AeroGlassFrame better:
- client edge rendering is now pixel-perfect for all BrowserTypes.
- fix NCCALCSIZE handling that was making our top-right corner less than perfectly round
- make system menu work
- remove some unnecessary functions
B=1031854
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1340 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views')
-rw-r--r-- | chrome/views/custom_frame_window.cc | 31 | ||||
-rw-r--r-- | chrome/views/custom_frame_window.h | 9 | ||||
-rw-r--r-- | chrome/views/hwnd_view_container.h | 2 | ||||
-rw-r--r-- | chrome/views/window.cc | 40 | ||||
-rw-r--r-- | chrome/views/window.h | 8 | ||||
-rw-r--r-- | chrome/views/window_delegate.h | 5 |
6 files changed, 54 insertions, 41 deletions
diff --git a/chrome/views/custom_frame_window.cc b/chrome/views/custom_frame_window.cc index 24e6200..1842953 100644 --- a/chrome/views/custom_frame_window.cc +++ b/chrome/views/custom_frame_window.cc @@ -826,11 +826,6 @@ CustomFrameWindow::CustomFrameWindow(WindowDelegate* window_delegate, CustomFrameWindow::~CustomFrameWindow() { } -void CustomFrameWindow::ExecuteSystemMenuCommand(int command) { - if (command) - SendMessage(GetHWND(), WM_SYSCOMMAND, command, 0); -} - /////////////////////////////////////////////////////////////////////////////// // CustomFrameWindow, Window overrides: @@ -1083,14 +1078,6 @@ void CustomFrameWindow::OnNCPaint(HRGN rgn) { ReleaseDC(GetHWND(), dc); } -void CustomFrameWindow::OnNCRButtonDown(UINT flags, const CPoint& point) { - if (flags == HTCAPTION || flags == HTSYSMENU) { - RunSystemMenu(point); - } else { - SetMsgHandled(FALSE); - } -} - void CustomFrameWindow::OnNCLButtonDown(UINT ht_component, const CPoint& point) { switch (ht_component) { @@ -1121,11 +1108,10 @@ void CustomFrameWindow::OnNCLButtonDown(UINT ht_component, SetMsgHandled(TRUE); return; } - case HTSYSMENU: - RunSystemMenu(non_client_view_->GetSystemMenuPoint()); + default: + Window::OnNCLButtonDown(ht_component, point); break; } - SetMsgHandled(FALSE); } LRESULT CustomFrameWindow::OnSetCursor(HWND window, UINT hittest_code, @@ -1168,19 +1154,6 @@ void CustomFrameWindow::OnSize(UINT param, const CSize& size) { /////////////////////////////////////////////////////////////////////////////// // CustomFrameWindow, private: -void CustomFrameWindow::RunSystemMenu(const CPoint& point) { - // We need to reset and clean up any currently created system menu objects. - // We need to call this otherwise there's a small chance that we aren't going - // to get a system menu. We also can't take the return value of this - // function. We need to call it *again* to get a valid HMENU. - ::GetSystemMenu(GetHWND(), TRUE); - HMENU system_menu = ::GetSystemMenu(GetHWND(), FALSE); - int id = ::TrackPopupMenu(system_menu, - TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD, - point.x, point.y, 0, GetHWND(), NULL); - ExecuteSystemMenuCommand(id); -} - // static void CustomFrameWindow::InitClass() { static bool initialized = false; diff --git a/chrome/views/custom_frame_window.h b/chrome/views/custom_frame_window.h index e6356e9..d014c91 100644 --- a/chrome/views/custom_frame_window.h +++ b/chrome/views/custom_frame_window.h @@ -30,9 +30,6 @@ class CustomFrameWindow : public Window { NonClientView* non_client_view); virtual ~CustomFrameWindow(); - // Executes the specified SC_command. - void ExecuteSystemMenuCommand(int command); - // Returns whether or not the frame is active. bool is_active() const { return is_active_; } @@ -58,15 +55,11 @@ class CustomFrameWindow : public Window { virtual LRESULT OnNCHitTest(const CPoint& point); virtual LRESULT OnNCMouseMove(UINT flags, const CPoint& point); virtual void OnNCPaint(HRGN rgn); - virtual void OnNCRButtonDown(UINT flags, const CPoint& point); - virtual void OnNCLButtonDown(UINT flags, const CPoint& point); + virtual void OnNCLButtonDown(UINT ht_component, const CPoint& point); virtual LRESULT OnSetCursor(HWND window, UINT hittest_code, UINT message); virtual void OnSize(UINT param, const CSize& size); private: - // Shows the system menu at the specified screen point. - void RunSystemMenu(const CPoint& point); - // Resets the window region. void ResetWindowRegion(); diff --git a/chrome/views/hwnd_view_container.h b/chrome/views/hwnd_view_container.h index c281a66..6073b2d 100644 --- a/chrome/views/hwnd_view_container.h +++ b/chrome/views/hwnd_view_container.h @@ -328,7 +328,7 @@ class HWNDViewContainer : public ViewContainer, virtual void OnCaptureChanged(HWND hwnd); virtual void OnClose(); virtual void OnCommand( - UINT notification_code, int command_id, HWND window) { } + UINT notification_code, int command_id, HWND window) { SetMsgHandled(FALSE); } virtual LRESULT OnCreate(LPCREATESTRUCT create_struct) { return 0; } // WARNING: If you override this be sure and invoke super, otherwise we'll // leak a few things. diff --git a/chrome/views/window.cc b/chrome/views/window.cc index db6174c..6d8327f 100644 --- a/chrome/views/window.cc +++ b/chrome/views/window.cc @@ -172,6 +172,11 @@ void Window::UpdateWindowIcon() { } } +void Window::ExecuteSystemMenuCommand(int command) { + if (command) + SendMessage(GetHWND(), WM_SYSCOMMAND, command, 0); +} + // static bool Window::SaveWindowPositionToPrefService(PrefService* pref_service, const std::wstring& entry, @@ -321,6 +326,19 @@ void Window::SizeWindowToDefault() { win_util::CenterAndSizeWindow(owning_window(), GetHWND(), pref, true); } +void Window::RunSystemMenu(const CPoint& point) { + // We need to reset and clean up any currently created system menu objects. + // We need to call this otherwise there's a small chance that we aren't going + // to get a system menu. We also can't take the return value of this + // function. We need to call it *again* to get a valid HMENU. + ::GetSystemMenu(GetHWND(), TRUE); + HMENU system_menu = ::GetSystemMenu(GetHWND(), FALSE); + int id = ::TrackPopupMenu(system_menu, + TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD, + point.x, point.y, 0, GetHWND(), NULL); + ExecuteSystemMenuCommand(id); +} + /////////////////////////////////////////////////////////////////////////////// // Window, HWNDViewContainer overrides: @@ -330,7 +348,8 @@ void Window::OnActivate(UINT action, BOOL minimized, HWND window) { } void Window::OnCommand(UINT notification_code, int command_id, HWND window) { - window_delegate_->ExecuteWindowsCommand(command_id); + if (!window_delegate_->ExecuteWindowsCommand(command_id)) + HWNDViewContainer::OnCommand(notification_code, command_id, window); } void Window::OnDestroy() { @@ -376,6 +395,21 @@ LRESULT Window::OnNCHitTest(const CPoint& point) { return 0; } +void Window::OnNCLButtonDown(UINT ht_component, const CPoint& point) { + if (non_client_view_ && ht_component == HTSYSMENU) + RunSystemMenu(non_client_view_->GetSystemMenuPoint()); + HWNDViewContainer::OnNCLButtonDown(ht_component, point); +} + +void Window::OnNCRButtonDown(UINT ht_component, const CPoint& point) { + if (ht_component == HTCAPTION || ht_component == HTSYSMENU) { + RunSystemMenu(point); + } else { + HWNDViewContainer::OnNCRButtonDown(ht_component, point); + } +} + + LRESULT Window::OnSetCursor(HWND window, UINT hittest_code, UINT message) { if (hittest_code == HTBOTTOMRIGHT) { // If the mouse was over the resize gripper, make sure the right cursor is @@ -399,6 +433,10 @@ void Window::OnSize(UINT size_param, const CSize& new_size) { } void Window::OnSysCommand(UINT notification_code, CPoint click) { + // First see if the delegate can handle it. + if (window_delegate_->ExecuteWindowsCommand(notification_code)) + return; + if (notification_code == IDC_ALWAYS_ON_TOP) { is_always_on_top_ = !is_always_on_top_; diff --git a/chrome/views/window.h b/chrome/views/window.h index ab3e7a5..ac496bb 100644 --- a/chrome/views/window.h +++ b/chrome/views/window.h @@ -97,6 +97,9 @@ class Window : public HWNDViewContainer { // Tell the window to update its icon from the delegate. virtual void UpdateWindowIcon(); + // Executes the specified SC_command. + void ExecuteSystemMenuCommand(int command); + // The parent of this window. HWND owning_window() const { return owning_hwnd_; } @@ -150,6 +153,9 @@ class Window : public HWNDViewContainer { void set_client_view(ClientView* client_view) { client_view_ = client_view; } + // Shows the system menu at the specified screen point. + void RunSystemMenu(const CPoint& point); + // Overridden from HWNDViewContainer: virtual void OnActivate(UINT action, BOOL minimized, HWND window); virtual void OnCommand(UINT notification_code, int command_id, HWND window); @@ -157,6 +163,8 @@ class Window : public HWNDViewContainer { virtual LRESULT OnEraseBkgnd(HDC dc); virtual LRESULT OnNCActivate(BOOL active); virtual LRESULT OnNCHitTest(const CPoint& point); + virtual void OnNCLButtonDown(UINT ht_component, const CPoint& point); + virtual void OnNCRButtonDown(UINT ht_component, const CPoint& point); virtual LRESULT OnSetCursor(HWND window, UINT hittest_code, UINT message); virtual void OnSize(UINT size_param, const CSize& new_size); virtual void OnSysCommand(UINT notification_code, CPoint click); diff --git a/chrome/views/window_delegate.h b/chrome/views/window_delegate.h index 1ab7add..8abda7c 100644 --- a/chrome/views/window_delegate.h +++ b/chrome/views/window_delegate.h @@ -92,8 +92,9 @@ class WindowDelegate { return false; } - // Execute a command in the window's controller. - virtual void ExecuteWindowsCommand(int command_id) { } + // Execute a command in the window's controller. Returns true if the command + // was handled, false if it was not. + virtual bool ExecuteWindowsCommand(int command_id) { return false; } // Saves the specified bounds, maximized and always on top state as the // window's position to/ be restored the next time it is shown. |