Chromium Code Reviews| Index: chrome/browser/ui/panels/panel_window_controller_cocoa.mm |
| diff --git a/chrome/browser/ui/panels/panel_window_controller_cocoa.mm b/chrome/browser/ui/panels/panel_window_controller_cocoa.mm |
| index 5ce263b6cdcc58c6439651ae6f79399caba4bc23..2d883bc3b97e68610c06647eee17093d634aef8e 100644 |
| --- a/chrome/browser/ui/panels/panel_window_controller_cocoa.mm |
| +++ b/chrome/browser/ui/panels/panel_window_controller_cocoa.mm |
| @@ -58,6 +58,20 @@ enum { |
| #endif // MAC_OS_X_VERSION_10_6 |
| +namespace { |
| + |
| +// Converts a point from the Cocoa screen coordinates (with (0,0) in the |
| +// low-left corner of the primary screen) to the platfrom-independent screen |
| +// coordinates (with the (0,0) in the top-left corner). |
| +gfx::Point ConvertPointFromCocoaCoordinates(NSPoint point) { |
|
jennb
2012/03/03 02:19:33
ConvertCoordinatesFromCocoa ? matches better with
jianli
2012/03/07 19:14:31
Renamed the other one to ConvertRectToCocoaCoordin
|
| + // Flip coordinates based on the primary screen. |
| + NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; |
| + |
| + return gfx::Point(point.x, NSHeight([screen frame]) - point.y); |
| +} |
| + |
| +} // namespace |
| + |
| @implementation PanelWindowCocoaImpl |
| - (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen { |
| return frameRect; |
| @@ -402,9 +416,10 @@ enum { |
| return windowShim_->panel()->draggable(); |
| } |
| -- (void)startDrag { |
| +- (void)startDrag:(NSPoint)mouseLocation { |
| animateOnBoundsChange_ = NO; |
| - windowShim_->panel()->manager()->StartDragging(windowShim_->panel()); |
| + windowShim_->panel()->manager()->StartDragging( |
| + windowShim_->panel(), ConvertPointFromCocoaCoordinates(mouseLocation)); |
| } |
| - (void)endDrag:(BOOL)cancelled { |
| @@ -412,9 +427,9 @@ enum { |
| windowShim_->panel()->manager()->EndDragging(cancelled); |
| } |
| -- (void)dragWithDeltaX:(int)deltaX |
| - deltaY:(int)deltaY { |
| - windowShim_->panel()->manager()->Drag(deltaX, deltaY); |
| +- (void)drag:(NSPoint)mouseLocation { |
| + windowShim_->panel()->manager()->Drag( |
| + ConvertPointFromCocoaCoordinates(mouseLocation)); |
| } |
| - (void)setPanelFrame:(NSRect)frame |
| @@ -624,4 +639,9 @@ enum { |
| // cases when minimized Panel is getting keyboard input, invisibly. |
| return windowShim_->panel()->expansion_state() == Panel::EXPANDED; |
| } |
| + |
| +- (void)setAlwaysOnTop:(bool)onTop { |
| + NSWindow* window = [self window]; |
| + [window setLevel:(onTop ? NSStatusWindowLevel : NSNormalWindowLevel)]; |
| +} |
| @end |