Index: chrome/browser/ui/panels/panel_browser_window_cocoa.mm |
diff --git a/chrome/browser/ui/panels/panel_browser_window_cocoa.mm b/chrome/browser/ui/panels/panel_browser_window_cocoa.mm |
index c4fe97e2b4146eb575fda9abc2a4389b6a6f1656..4a3bda24669469dcefff85921a42cd4398f5961c 100644 |
--- a/chrome/browser/ui/panels/panel_browser_window_cocoa.mm |
+++ b/chrome/browser/ui/panels/panel_browser_window_cocoa.mm |
@@ -10,6 +10,7 @@ |
#import "chrome/browser/ui/cocoa/browser_window_utils.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" |
#import "chrome/browser/ui/panels/panel_titlebar_view_cocoa.h" |
#import "chrome/browser/ui/panels/panel_window_controller_cocoa.h" |
#include "content/common/native_web_keyboard_event.h" |
@@ -58,6 +59,9 @@ PanelBrowserWindowCocoa::PanelBrowserWindowCocoa(Browser* browser, |
} |
PanelBrowserWindowCocoa::~PanelBrowserWindowCocoa() { |
+ PanelMouseWatcher* watcher = PanelMouseWatcher::GetInstance(); |
+ if (watcher->IsSubscribed(this)) |
+ watcher->RemoveSubscriber(this); |
} |
bool PanelBrowserWindowCocoa::isClosed() { |
@@ -109,12 +113,14 @@ void PanelBrowserWindowCocoa::OnPanelExpansionStateChanged( |
int height; // New height of the Panel in screen coordinates. |
switch (expansion_state) { |
case Panel::EXPANDED: |
+ PanelMouseWatcher::GetInstance()->RemoveSubscriber(this); |
height = restored_height_; |
break; |
case Panel::TITLE_ONLY: |
height = [controller_ titlebarHeightInScreeenCoordinates]; |
break; |
case Panel::MINIMIZED: |
+ PanelMouseWatcher::GetInstance()->AddSubscriber(this); |
height = 3; // TODO(dimich) merge with GTK patch which defines it better. |
prasadt
2011/09/21 16:54:15
You should be able to just use PanelManager::minim
Dmitry Titov
2011/09/21 20:38:51
Thanks, done.
|
break; |
default: |
@@ -133,10 +139,14 @@ void PanelBrowserWindowCocoa::OnPanelExpansionStateChanged( |
SetPanelBounds(bounds); |
} |
+// Coordinates are in gfx coordinate system (screen, with 0,0 at the top left). |
bool PanelBrowserWindowCocoa::ShouldBringUpPanelTitlebar(int mouse_x, |
int mouse_y) const { |
- NOTIMPLEMENTED(); |
- return false; |
+ // Trigger TITLE_ONLY expansion state to show the titlebar if the mouse is |
+ // under the minimized panel or somewhat above it. |
jennb
2011/09/21 17:48:19
Comment should also explain 'why'.
Dmitry Titov
2011/09/21 20:38:51
Removed the comment since the 'space above' is gon
|
+ int spaceAbovePanel = 3 * [controller_ titlebarHeightInScreeenCoordinates]; |
prasadt
2011/09/21 16:54:15
Any reason for different behavior on Mac?
I see c
jennb
2011/09/21 17:48:19
#1 is a good point. I know the reason for this ext
Dmitry Titov
2011/09/21 20:38:51
I think Prasad has a good point indeed, mostly abo
|
+ return bounds_.x() <= mouse_x && mouse_x <= bounds_.right() && |
+ mouse_y >= bounds_.y() - spaceAbovePanel; |
} |
void PanelBrowserWindowCocoa::ClosePanel() { |
@@ -300,7 +310,7 @@ NativePanelTesting* NativePanelTesting::Create(NativePanel* native_panel) { |
// static |
PanelMouseWatcher* NativePanelTesting::GetPanelMouseWatcherInstance() { |
- return NULL; |
+ return PanelMouseWatcher::GetInstance(); |
} |
NativePanelTestingCocoa::NativePanelTestingCocoa(NativePanel* native_panel) |
@@ -332,12 +342,13 @@ void NativePanelTestingCocoa::FinishDragTitlebar() { |
[titlebar() finishDragTitlebar]; |
} |
+// TODO(dimich) this method is platform-independent. Reuse it. |
void NativePanelTestingCocoa::SetMousePositionForMinimizeRestore( |
const gfx::Point& hover_point) { |
- NOTIMPLEMENTED(); |
+ PanelMouseWatcher::GetInstance()->HandleMouseMovement(hover_point); |
+ MessageLoopForUI::current()->RunAllPending(); |
} |
int NativePanelTestingCocoa::TitleOnlyHeight() const { |
- NOTIMPLEMENTED(); |
- return -1; |
+ return [native_panel_window_->controller_ titlebarHeightInScreeenCoordinates]; |
} |