diff options
author | Michael Lutz <michi@icosahedron.de> | 2021-02-06 02:49:09 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2021-02-13 22:21:17 +0100 |
commit | f4bd54fedd40806ff34d884c0fa17e0b7403ede1 (patch) | |
tree | 18bf9b2c89bef9a84888935060aa7739fc2c9658 /src/video/cocoa/cocoa_v.mm | |
parent | bd42fc94cc1dc064d0c20cfa4fad108dc64931c6 (diff) | |
download | openttd-f4bd54fedd40806ff34d884c0fa17e0b7403ede1.tar.xz |
Codechange: [OSX] Move mouse event handling to our NSView.
Diffstat (limited to 'src/video/cocoa/cocoa_v.mm')
-rw-r--r-- | src/video/cocoa/cocoa_v.mm | 52 |
1 files changed, 1 insertions, 51 deletions
diff --git a/src/video/cocoa/cocoa_v.mm b/src/video/cocoa/cocoa_v.mm index 88f461234..07640a0f8 100644 --- a/src/video/cocoa/cocoa_v.mm +++ b/src/video/cocoa/cocoa_v.mm @@ -397,6 +397,7 @@ bool VideoDriver_Cocoa::MakeWindow(int width, int height) [ this->window setContentView:this->cocoaview ]; [ this->cocoaview addSubview:draw_view ]; + [ this->window makeFirstResponder:this->cocoaview ]; [ draw_view release ]; [ this->window setColorSpace:[ NSColorSpace sRGBColorSpace ] ]; @@ -497,57 +498,6 @@ void VideoDriver_Cocoa::UpdatePalette(uint first_color, uint num_colors) this->num_dirty_rects = lengthof(this->dirty_rects); } -/** - * Convert local coordinate to window server (CoreGraphics) coordinate - * @param p local coordinates - * @return window driver coordinates - */ -CGPoint VideoDriver_Cocoa::PrivateLocalToCG(NSPoint *p) -{ - - p->y = this->window_height - p->y; - *p = [ this->cocoaview convertPoint:*p toView:nil ]; - *p = [ this->window convertRectToScreen:NSMakeRect(p->x, p->y, 0, 0) ].origin; - - p->y = NSScreen.screens[0].frame.size.height - p->y; - - CGPoint cgp; - cgp.x = p->x; - cgp.y = p->y; - - return cgp; -} - -/** - * Return the mouse location - * @param event UI event - * @return mouse location as NSPoint - */ -NSPoint VideoDriver_Cocoa::GetMouseLocation(NSEvent *event) -{ - NSPoint pt; - - if ( [ event window ] == nil) { - pt = [ this->cocoaview convertPoint:[ [ this->cocoaview window ] convertRectFromScreen:NSMakeRect([ event locationInWindow ].x, [ event locationInWindow ].y, 0, 0) ].origin fromView:nil ]; - } else { - pt = [ event locationInWindow ]; - } - - pt.y = this->window_height - pt.y; - - return pt; -} - -/** - * Return whether the mouse is within our view - * @param pt Mouse coordinates - * @return Whether mouse coordinates are within view - */ -bool VideoDriver_Cocoa::MouseIsInsideView(NSPoint *pt) -{ - return [ cocoaview mouse:*pt inRect:[ this->cocoaview bounds ] ]; -} - /** Clear buffer to opaque black. */ static void ClearWindowBuffer(uint32 *buffer, uint32 pitch, uint32 height) { |