mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 19:20:09 +00:00
Impl OSXWindow::setMousePosition on Skia/OSX port
This commit is contained in:
parent
2fe612fd00
commit
66c5e04a58
@ -10,6 +10,7 @@
|
||||
|
||||
#include <Cocoa/Cocoa.h>
|
||||
|
||||
#include "gfx/point.h"
|
||||
#include "gfx/rect.h"
|
||||
#include "gfx/size.h"
|
||||
#include "she/keys.h"
|
||||
@ -41,6 +42,7 @@ public:
|
||||
- (void)setScale:(int)scale;
|
||||
- (gfx::Size)clientSize;
|
||||
- (gfx::Size)restoredSize;
|
||||
- (void)setMousePosition:(const gfx::Point&)position;
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
@ -74,4 +74,23 @@
|
||||
return [self clientSize];
|
||||
}
|
||||
|
||||
- (void)setMousePosition:(const gfx::Point&)position
|
||||
{
|
||||
NSView* view = self.contentView;
|
||||
NSPoint pt = NSMakePoint(
|
||||
position.x*m_scale,
|
||||
view.frame.size.height - position.y*m_scale);
|
||||
|
||||
pt = [view convertPoint:pt toView:view];
|
||||
pt = [view convertPoint:pt toView:nil];
|
||||
pt = [self convertBaseToScreen:pt];
|
||||
pt.y = [[self screen] frame].size.height - pt.y;
|
||||
|
||||
CGPoint pos = CGPointMake(pt.x, pt.y);
|
||||
CGEventRef event = CGEventCreateMouseEvent(
|
||||
NULL, kCGEventMouseMoved, pos, kCGMouseButtonLeft);
|
||||
CGEventPost(kCGHIDEventTap, event);
|
||||
CFRelease(event);
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -83,6 +83,10 @@ public:
|
||||
[m_window setTitle:[NSString stringWithUTF8String:title.c_str()]];
|
||||
}
|
||||
|
||||
void setMousePosition(const gfx::Point& position) {
|
||||
[m_window setMousePosition:position];
|
||||
}
|
||||
|
||||
void updateWindow(const gfx::Rect& bounds) {
|
||||
[[m_window contentView] setNeedsDisplay:YES];
|
||||
}
|
||||
@ -338,6 +342,8 @@ void SkiaWindow::releaseMouse()
|
||||
|
||||
void SkiaWindow::setMousePosition(const gfx::Point& position)
|
||||
{
|
||||
if (m_impl)
|
||||
m_impl->setMousePosition(position);
|
||||
}
|
||||
|
||||
void SkiaWindow::setNativeMouseCursor(NativeCursor cursor)
|
||||
|
Loading…
x
Reference in New Issue
Block a user