Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3845)

Unified Diff: chrome/browser/ui/panels/panel_mouse_watcher_win.cc

Issue 7966026: Reverting this change to see if this fixes the MinimizeRestore browser tests on Vista and XP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/panels/panel_mouse_watcher_win.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/panels/panel_mouse_watcher_win.cc
===================================================================
--- chrome/browser/ui/panels/panel_mouse_watcher_win.cc (revision 102405)
+++ chrome/browser/ui/panels/panel_mouse_watcher_win.cc (working copy)
@@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/browser/ui/panels/panel_mouse_watcher_win.h"
+
#include <windows.h>
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/ui/panels/panel.h"
#include "chrome/browser/ui/panels/panel_manager.h"
-#include "chrome/browser/ui/panels/panel_mouse_watcher.h"
namespace {
@@ -24,53 +25,34 @@
return ::GetModuleHandleFromAddress(GetCurrentModuleHandle);
}
-} // namespace
-
-class PanelMouseWatcherWin : public PanelMouseWatcher {
+class PanelMouseWatcherWin {
public:
PanelMouseWatcherWin();
- virtual ~PanelMouseWatcherWin();
+ ~PanelMouseWatcherWin();
- virtual void Start() OVERRIDE;
- virtual void Stop() OVERRIDE;
-
private:
static LRESULT CALLBACK MouseHookProc(int code, WPARAM wparam, LPARAM lparam);
+ void OnMouseAction(int mouse_x, int mouse_y);
+
HHOOK mouse_hook_;
+ bool bring_up_titlebars_;
DISALLOW_COPY_AND_ASSIGN(PanelMouseWatcherWin);
};
scoped_ptr<PanelMouseWatcherWin> mouse_watcher;
-// static
-PanelMouseWatcher* PanelMouseWatcher::GetInstance() {
- if (!mouse_watcher.get())
- mouse_watcher.reset(new PanelMouseWatcherWin());
-
- return mouse_watcher.get();
-}
-
PanelMouseWatcherWin::PanelMouseWatcherWin()
- : mouse_hook_(NULL) {
-}
-
-PanelMouseWatcherWin::~PanelMouseWatcherWin() {
- DCHECK(!mouse_hook_);
-}
-
-void PanelMouseWatcherWin::Start() {
- DCHECK(!mouse_hook_);
+ : mouse_hook_(NULL),
+ bring_up_titlebars_(false) {
mouse_hook_ = ::SetWindowsHookEx(
WH_MOUSE_LL, MouseHookProc, GetCurrentModuleHandle(), 0);
DCHECK(mouse_hook_);
}
-void PanelMouseWatcherWin::Stop() {
- DCHECK(mouse_hook_);
+PanelMouseWatcherWin::~PanelMouseWatcherWin() {
::UnhookWindowsHookEx(mouse_hook_);
- mouse_hook_ = NULL;
}
LRESULT CALLBACK PanelMouseWatcherWin::MouseHookProc(int code,
@@ -78,10 +60,35 @@
LPARAM lparam) {
if (code == HC_ACTION) {
MOUSEHOOKSTRUCT* hook_struct = reinterpret_cast<MOUSEHOOKSTRUCT*>(lparam);
- if (hook_struct) {
- mouse_watcher->HandleMouseMovement(
- gfx::Point(hook_struct->pt.x, hook_struct->pt.y));
- }
+ if (hook_struct)
+ mouse_watcher->OnMouseAction(hook_struct->pt.x, hook_struct->pt.y);
}
return ::CallNextHookEx(NULL, code, wparam, lparam);
}
+
+void PanelMouseWatcherWin::OnMouseAction(int mouse_x, int mouse_y) {
+ PanelManager* panel_manager = PanelManager::GetInstance();
+
+ bool bring_up_titlebars = panel_manager->ShouldBringUpTitlebars(
+ mouse_x, mouse_y);
+ if (bring_up_titlebars == bring_up_titlebars_)
+ return;
+ bring_up_titlebars_ = bring_up_titlebars;
+
+ panel_manager->BringUpOrDownTitlebars(bring_up_titlebars);
+}
+
+} // namespace
+
+void EnsureMouseWatcherStarted() {
+ if (!mouse_watcher.get())
+ mouse_watcher.reset(new PanelMouseWatcherWin());
+}
+
+void StopMouseWatcher() {
+ mouse_watcher.reset(NULL);
+}
+
+bool IsMouseWatcherStarted() {
+ return mouse_watcher.get() != NULL;
+}
« no previous file with comments | « chrome/browser/ui/panels/panel_mouse_watcher_win.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698