summaryrefslogtreecommitdiffstats
path: root/chrome/views
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-23 17:45:50 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-23 17:45:50 +0000
commit175d82b7675c9ca4e45efda7393fc636bc722299 (patch)
tree711078621f4d09349717ded9c91039d1651b7ecb /chrome/views
parentc8b152d7db2db01cf545e0c5483d24ba95da7a21 (diff)
downloadchromium_src-175d82b7675c9ca4e45efda7393fc636bc722299.zip
chromium_src-175d82b7675c9ca4e45efda7393fc636bc722299.tar.gz
chromium_src-175d82b7675c9ca4e45efda7393fc636bc722299.tar.bz2
A few minor changes to WidgetWin:
* Add a Show() method to match Hide(), and use it in existing code. This abstracts the specifics of this a bit and will be convenient for fullscreen UI. * Safe Hide() (and, for speed, Close()) behind IsWindow() checks just like CloseNow(), which I'll need for some tricky window-closing code in the fullscreen UI. (Right now, Hide() will eventually fail an assertion if you call it when the widget is no longer a window, which seems unnecessarily harsh.) Review URL: http://codereview.chromium.org/27017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10190 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views')
-rw-r--r--chrome/views/widget_win.cc36
-rw-r--r--chrome/views/widget_win.h3
2 files changed, 26 insertions, 13 deletions
diff --git a/chrome/views/widget_win.cc b/chrome/views/widget_win.cc
index 209184c..0c8b6b7 100644
--- a/chrome/views/widget_win.cc
+++ b/chrome/views/widget_win.cc
@@ -347,6 +347,9 @@ RootView* WidgetWin::FindRootView(HWND hwnd) {
}
void WidgetWin::Close() {
+ if (!IsWindow())
+ return; // No need to do anything.
+
// Let's hide ourselves right away.
Hide();
if (close_widget_factory_.empty()) {
@@ -361,13 +364,20 @@ void WidgetWin::Close() {
}
void WidgetWin::Hide() {
- // NOTE: Be careful not to activate any windows here (for example, calling
- // ShowWindow(SW_HIDE) will automatically activate another window). This
- // code can be called while a window is being deactivated, and activating
- // another window will screw up the activation that is already in progress.
- SetWindowPos(NULL, 0, 0, 0, 0,
- SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE |
- SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER);
+ if (IsWindow()) {
+ // NOTE: Be careful not to activate any windows here (for example, calling
+ // ShowWindow(SW_HIDE) will automatically activate another window). This
+ // code can be called while a window is being deactivated, and activating
+ // another window will screw up the activation that is already in progress.
+ SetWindowPos(NULL, 0, 0, 0, 0,
+ SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE |
+ SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER);
+ }
+}
+
+void WidgetWin::Show() {
+ if (IsWindow())
+ ShowWindow(SW_SHOWNOACTIVATE);
}
void WidgetWin::CloseNow() {
@@ -572,11 +582,11 @@ LRESULT WidgetWin::OnMouseRange(UINT msg, WPARAM w_param, LPARAM l_param) {
}
void WidgetWin::OnNCLButtonDblClk(UINT flags, const CPoint& point) {
- SetMsgHandled(ProcessMousePressed(point, MK_LBUTTON, true, true));
+ SetMsgHandled(ProcessMousePressed(point, flags | MK_LBUTTON, true, true));
}
void WidgetWin::OnNCLButtonDown(UINT flags, const CPoint& point) {
- SetMsgHandled(ProcessMousePressed(point, MK_LBUTTON, false, true));
+ SetMsgHandled(ProcessMousePressed(point, flags | MK_LBUTTON, false, true));
}
void WidgetWin::OnNCLButtonUp(UINT flags, const CPoint& point) {
@@ -584,11 +594,11 @@ void WidgetWin::OnNCLButtonUp(UINT flags, const CPoint& point) {
}
void WidgetWin::OnNCMButtonDblClk(UINT flags, const CPoint& point) {
- SetMsgHandled(ProcessMousePressed(point, MK_MBUTTON, true, true));
+ SetMsgHandled(ProcessMousePressed(point, flags | MK_MBUTTON, true, true));
}
void WidgetWin::OnNCMButtonDown(UINT flags, const CPoint& point) {
- SetMsgHandled(ProcessMousePressed(point, MK_MBUTTON, false, true));
+ SetMsgHandled(ProcessMousePressed(point, flags | MK_MBUTTON, false, true));
}
void WidgetWin::OnNCMButtonUp(UINT flags, const CPoint& point) {
@@ -613,11 +623,11 @@ LRESULT WidgetWin::OnNCMouseMove(UINT flags, const CPoint& point) {
}
void WidgetWin::OnNCRButtonDblClk(UINT flags, const CPoint& point) {
- SetMsgHandled(ProcessMousePressed(point, MK_RBUTTON, true, true));
+ SetMsgHandled(ProcessMousePressed(point, flags | MK_RBUTTON, true, true));
}
void WidgetWin::OnNCRButtonDown(UINT flags, const CPoint& point) {
- SetMsgHandled(ProcessMousePressed(point, MK_RBUTTON, false, true));
+ SetMsgHandled(ProcessMousePressed(point, flags | MK_RBUTTON, false, true));
}
void WidgetWin::OnNCRButtonUp(UINT flags, const CPoint& point) {
diff --git a/chrome/views/widget_win.h b/chrome/views/widget_win.h
index 6710aee..d135e27 100644
--- a/chrome/views/widget_win.h
+++ b/chrome/views/widget_win.h
@@ -152,6 +152,9 @@ class WidgetWin : public Widget,
// Hides the window. This does NOT delete the window, it just hides it.
virtual void Hide();
+ // Shows the window without changing size/position/activation state.
+ virtual void Show();
+
// Closes the window synchronously. Note that this should not be called from
// an ATL message callback as it deletes the WidgetWin and ATL will
// dereference it after the callback is processed.