Merge pull request #548 from Felbo/master

mouse_mode implementation on OS X.
This commit is contained in:
reduz 2014-06-26 09:43:12 -03:00
commit 1cc96a4d74
2 changed files with 29 additions and 1 deletions

View File

@ -98,7 +98,7 @@ public:
id context;
CursorShape cursor_shape;
MouseMode mouse_mode;
protected:
virtual int get_video_driver_count() const;
@ -159,6 +159,8 @@ public:
void run();
void set_mouse_mode(MouseMode p_mode);
MouseMode get_mouse_mode() const;
OS_OSX();
};

View File

@ -1280,6 +1280,32 @@ void OS_OSX::run() {
main_loop->finish();
}
void OS_OSX::set_mouse_mode(MouseMode p_mode) {
if (p_mode==mouse_mode)
return;
if (p_mode==MOUSE_MODE_CAPTURED) {
// Apple Docs state that the display parameter is not used.
// "This parameter is not used. By default, you may pass kCGDirectMainDisplay."
// https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/Quartz_Services_Ref/Reference/reference.html
CGDisplayHideCursor(kCGDirectMainDisplay);
CGAssociateMouseAndMouseCursorPosition(false);
} else if (p_mode==MOUSE_MODE_HIDDEN) {
CGDisplayHideCursor(kCGDirectMainDisplay);
CGAssociateMouseAndMouseCursorPosition(true);
} else {
CGDisplayShowCursor(kCGDirectMainDisplay);
CGAssociateMouseAndMouseCursorPosition(true);
}
mouse_mode=p_mode;
}
OS::MouseMode OS_OSX::get_mouse_mode() const {
return mouse_mode;
}
OS_OSX* OS_OSX::singleton=NULL;