summaryrefslogtreecommitdiffstats
path: root/chrome
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
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')
-rw-r--r--chrome/browser/views/download_started_animation.cc2
-rw-r--r--chrome/browser/views/status_bubble_views.cc2
-rw-r--r--chrome/browser/views/tabs/hwnd_photobooth.cc2
-rw-r--r--chrome/views/widget_win.cc36
-rw-r--r--chrome/views/widget_win.h3
5 files changed, 29 insertions, 16 deletions
diff --git a/chrome/browser/views/download_started_animation.cc b/chrome/browser/views/download_started_animation.cc
index c41cea8..42ce4b8 100644
--- a/chrome/browser/views/download_started_animation.cc
+++ b/chrome/browser/views/download_started_animation.cc
@@ -57,7 +57,7 @@ DownloadStartedAnimation::DownloadStartedAnimation(TabContents* tab_contents)
popup_->Init(tab_contents_->GetNativeView(), rc, false);
popup_->SetContentsView(this);
Reposition();
- popup_->ShowWindow(SW_SHOWNOACTIVATE);
+ popup_->Show();
Start();
}
diff --git a/chrome/browser/views/status_bubble_views.cc b/chrome/browser/views/status_bubble_views.cc
index 816677d..f3ec662 100644
--- a/chrome/browser/views/status_bubble_views.cc
+++ b/chrome/browser/views/status_bubble_views.cc
@@ -478,7 +478,7 @@ void StatusBubbleViews::Init() {
popup_->Init(frame_->GetHWND(), rc, false);
popup_->SetContentsView(view_);
Reposition();
- popup_->ShowWindow(SW_SHOWNOACTIVATE);
+ popup_->Show();
}
}
diff --git a/chrome/browser/views/tabs/hwnd_photobooth.cc b/chrome/browser/views/tabs/hwnd_photobooth.cc
index 3cf5908..88fb24c 100644
--- a/chrome/browser/views/tabs/hwnd_photobooth.cc
+++ b/chrome/browser/views/tabs/hwnd_photobooth.cc
@@ -151,7 +151,7 @@ void HWNDPhotobooth::CreateCaptureWindow(HWND initial_hwnd) {
capture_window_->Init(NULL, capture_bounds, false);
// If the capture window isn't visible, blitting from the TabContents'
// HWND's DC to the capture bitmap produces blankness.
- capture_window_->ShowWindow(SW_SHOWNOACTIVATE);
+ capture_window_->Show();
SetLayeredWindowAttributes(
capture_window_->GetHWND(), RGB(0xFF, 0xFF, 0xFF), 0xFF, LWA_ALPHA);
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.