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

Side by Side Diff: chrome/browser/ui/panels/panel_mouse_watcher_win.cc

Issue 7242017: Support minimizing the panel into 3-pixel line on Windows. Also support bringing up/down the titl... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/panels/panel_mouse_watcher_win.h"
6
7 #include "base/logging.h"
8 #include "base/scoped_ptr.h"
9 #include "chrome/browser/ui/panels/panel.h"
10 #include "chrome/browser/ui/panels/panel_manager.h"
11
12 #include <windows.h>
13
14 namespace {
15
16 HMODULE GetModuleHandleFromAddress(void *address) {
17 MEMORY_BASIC_INFORMATION mbi;
18 SIZE_T result = ::VirtualQuery(address, &mbi, sizeof(mbi));
19 return static_cast<HMODULE>(mbi.AllocationBase);
20 }
21
22
23 // Gets the handle to the currently executing module.
24 HMODULE GetCurrentModuleHandle() {
25 return ::GetModuleHandleFromAddress(GetCurrentModuleHandle);
26 }
27
28 class PanelMouseWatcherWin {
29 public:
30 PanelMouseWatcherWin();
31 ~PanelMouseWatcherWin();
32
33 private:
34 static LRESULT CALLBACK MouseHookProc(int code, WPARAM wparam, LPARAM lparam);
35
36 void OnMouseAction(int mouse_x, int mouse_y);
37
38 HHOOK mouse_hook_;
39 bool bring_up_titlebar_;
40
41 DISALLOW_COPY_AND_ASSIGN(PanelMouseWatcherWin);
42 };
43
44 scoped_ptr<PanelMouseWatcherWin> mouse_watcher;
45
46 PanelMouseWatcherWin::PanelMouseWatcherWin()
47 : mouse_hook_(NULL),
48 bring_up_titlebar_(false) {
49 mouse_hook_ = ::SetWindowsHookEx(
50 WH_MOUSE_LL, MouseHookProc, GetCurrentModuleHandle(), 0);
51 DCHECK(mouse_hook_);
52 }
53
54 PanelMouseWatcherWin::~PanelMouseWatcherWin() {
55 ::UnhookWindowsHookEx(mouse_hook_);
56 }
57
58 LRESULT CALLBACK PanelMouseWatcherWin::MouseHookProc(int code,
59 WPARAM wparam,
60 LPARAM lparam) {
61 if (code == HC_ACTION) {
62 MOUSEHOOKSTRUCT* hook_struct = reinterpret_cast<MOUSEHOOKSTRUCT*>(lparam);
63 if (hook_struct)
64 mouse_watcher->OnMouseAction(hook_struct->pt.x, hook_struct->pt.y);
65 }
66 return ::CallNextHookEx(NULL, code, wparam, lparam);
67 }
68
69 void PanelMouseWatcherWin::OnMouseAction(int mouse_x, int mouse_y) {
70 PanelManager* panel_manager = PanelManager::GetInstance();
71
72 bool bring_up_titlebar =
73 panel_manager->ShouldBringUpTitleBarForAllMinimizedPanels(
74 mouse_x, mouse_y);
75 if (bring_up_titlebar == bring_up_titlebar_)
76 return;
77 bring_up_titlebar_ = bring_up_titlebar;
78
79 panel_manager->BringUpOrDownTitleBarForAllMinimizedPanels(bring_up_titlebar);
80 }
81
82 }
83
84 void EnsureMouseWatcherStarted() {
85 if (!mouse_watcher.get())
86 mouse_watcher.reset(new PanelMouseWatcherWin());
87 }
88
89 void StopMouseWatcher() {
90 mouse_watcher.reset(NULL);
91 }
92
93 bool IsMouseWatcherStarted() {
94 return mouse_watcher.get() != NULL;
95 }
OLDNEW
« 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