mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
mouse pointer is visible when outside of window
This commit is contained in:
parent
515a6ba022
commit
278f5ca58d
@ -102,6 +102,9 @@ public: // do not call direct ..
|
|||||||
OSStatus buildGL(bool full_screen);
|
OSStatus buildGL(bool full_screen);
|
||||||
bool set_icon_filename(const Filename &icon_filename);
|
bool set_icon_filename(const Filename &icon_filename);
|
||||||
|
|
||||||
|
void set_pointer_in_window(int x, int y);
|
||||||
|
void set_pointer_out_of_window();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UInt32 _last_key_modifiers;
|
UInt32 _last_key_modifiers;
|
||||||
UInt32 _last_buttons;
|
UInt32 _last_buttons;
|
||||||
@ -118,6 +121,12 @@ private:
|
|||||||
AGLContext _holder_aglcontext;
|
AGLContext _holder_aglcontext;
|
||||||
#endif
|
#endif
|
||||||
CFDictionaryRef _originalMode;
|
CFDictionaryRef _originalMode;
|
||||||
|
|
||||||
|
// True if _properties.get_cursor_hidden() is true.
|
||||||
|
bool _cursor_hidden;
|
||||||
|
|
||||||
|
// True if the cursor is actually hidden right now via system calls.
|
||||||
|
bool _display_hide_cursor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TypeHandle get_class_type() {
|
static TypeHandle get_class_type() {
|
||||||
|
@ -538,6 +538,9 @@ osxGraphicsWindow::osxGraphicsWindow(GraphicsPipe *pipe,
|
|||||||
_input_devices[0].set_pointer_in_window(0, 0);
|
_input_devices[0].set_pointer_in_window(0, 0);
|
||||||
_last_key_modifiers = 0;
|
_last_key_modifiers = 0;
|
||||||
_last_buttons = 0;
|
_last_buttons = 0;
|
||||||
|
|
||||||
|
_cursor_hidden = false;
|
||||||
|
_display_hide_cursor = false;
|
||||||
|
|
||||||
if (osxdisplay_cat.is_debug())
|
if (osxdisplay_cat.is_debug())
|
||||||
osxdisplay_cat.debug() << "osxGraphicsWindow::osxGraphicsWindow() -" <<_ID << "\n";
|
osxdisplay_cat.debug() << "osxGraphicsWindow::osxGraphicsWindow() -" <<_ID << "\n";
|
||||||
@ -675,6 +678,44 @@ bool osxGraphicsWindow::set_icon_filename(const Filename &icon_filename)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: osxGraphicsWindow::set_pointer_in_window
|
||||||
|
// Access: Private
|
||||||
|
// Description: Indicates the mouse pointer is seen within the
|
||||||
|
// window.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void osxGraphicsWindow::
|
||||||
|
set_pointer_in_window(int x, int y) {
|
||||||
|
_input_devices[0].set_pointer_in_window(x, y);
|
||||||
|
|
||||||
|
if (_cursor_hidden != _display_hide_cursor) {
|
||||||
|
if (_cursor_hidden) {
|
||||||
|
CGDisplayHideCursor(kCGDirectMainDisplay);
|
||||||
|
_display_hide_cursor = true;
|
||||||
|
} else {
|
||||||
|
CGDisplayShowCursor(kCGDirectMainDisplay);
|
||||||
|
_display_hide_cursor = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: osxGraphicsWindow::set_pointer_out_of_window
|
||||||
|
// Access: Private
|
||||||
|
// Description: Indicates the mouse pointer is no longer within the
|
||||||
|
// window.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void osxGraphicsWindow::
|
||||||
|
set_pointer_out_of_window() {
|
||||||
|
_input_devices[0].set_pointer_out_of_window();
|
||||||
|
|
||||||
|
if (_display_hide_cursor) {
|
||||||
|
CGDisplayShowCursor(kCGDirectMainDisplay);
|
||||||
|
_display_hide_cursor = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: osxGraphicsWindow::begin_frame
|
// Function: osxGraphicsWindow::begin_frame
|
||||||
// Access: Public, Virtual
|
// Access: Public, Virtual
|
||||||
@ -1292,8 +1333,13 @@ void osxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint)
|
|||||||
// Mac OS X v10.1 and later
|
// Mac OS X v10.1 and later
|
||||||
// should this be front window???
|
// should this be front window???
|
||||||
GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window);
|
GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window);
|
||||||
if(!_is_fullscreen && (window == NULL || window != _osx_window ))
|
|
||||||
return eventNotHandledErr;
|
if(!_is_fullscreen && (window == NULL || window != _osx_window )) {
|
||||||
|
if (kind == kEventMouseMoved) {
|
||||||
|
set_pointer_out_of_window();
|
||||||
|
}
|
||||||
|
return eventNotHandledErr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GetWindowPortBounds (window, &rectPort);
|
GetWindowPortBounds (window, &rectPort);
|
||||||
@ -1323,7 +1369,7 @@ void osxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint)
|
|||||||
SystemPointToLocalPoint(qdGlobalPoint);
|
SystemPointToLocalPoint(qdGlobalPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
_input_devices[0].set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v);
|
set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v);
|
||||||
|
|
||||||
UInt32 new_buttons = GetCurrentEventButtonState();
|
UInt32 new_buttons = GetCurrentEventButtonState();
|
||||||
HandleButtonDelta(new_buttons);
|
HandleButtonDelta(new_buttons);
|
||||||
@ -1346,7 +1392,14 @@ void osxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint)
|
|||||||
GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint);
|
GetEventParameter(event, kEventParamMouseLocation,typeQDPoint, NULL, sizeof(Point),NULL , (void*) &qdGlobalPoint);
|
||||||
SystemPointToLocalPoint(qdGlobalPoint);
|
SystemPointToLocalPoint(qdGlobalPoint);
|
||||||
}
|
}
|
||||||
_input_devices[0].set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v);
|
if (kind == kEventMouseMoved &&
|
||||||
|
(qdGlobalPoint.h < 0 || qdGlobalPoint.v < 0)) {
|
||||||
|
// Moving into the titlebar region.
|
||||||
|
set_pointer_out_of_window();
|
||||||
|
} else {
|
||||||
|
// Moving within the window itself (or dragging anywhere).
|
||||||
|
set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v);
|
||||||
|
}
|
||||||
result = noErr;
|
result = noErr;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1359,7 +1412,7 @@ void osxGraphicsWindow::SystemPointToLocalPoint(Point &qdGlobalPoint)
|
|||||||
|
|
||||||
if (wheelAxis == kEventMouseWheelAxisY)
|
if (wheelAxis == kEventMouseWheelAxisY)
|
||||||
{
|
{
|
||||||
_input_devices[0].set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v);
|
set_pointer_in_window((int)qdGlobalPoint.h, (int)qdGlobalPoint.v);
|
||||||
if (wheelDelta > 0)
|
if (wheelDelta > 0)
|
||||||
{
|
{
|
||||||
_input_devices[0].button_down(MouseButton::wheel_up());
|
_input_devices[0].button_down(MouseButton::wheel_up());
|
||||||
@ -1600,7 +1653,7 @@ if (osxdisplay_cat.is_debug())
|
|||||||
Point pt = {0, 0};
|
Point pt = {0, 0};
|
||||||
pt.h = x;
|
pt.h = x;
|
||||||
pt.v = y;
|
pt.v = y;
|
||||||
_input_devices[0].set_pointer_in_window(x, y);
|
set_pointer_in_window(x, y);
|
||||||
|
|
||||||
if(_properties.get_mouse_mode()==WindowProperties::M_absolute)
|
if(_properties.get_mouse_mode()==WindowProperties::M_absolute)
|
||||||
{
|
{
|
||||||
@ -1758,10 +1811,17 @@ void osxGraphicsWindow::set_properties_now(WindowProperties &properties)
|
|||||||
|
|
||||||
if (properties.has_cursor_hidden()) {
|
if (properties.has_cursor_hidden()) {
|
||||||
_properties.set_cursor_hidden(properties.get_cursor_hidden());
|
_properties.set_cursor_hidden(properties.get_cursor_hidden());
|
||||||
if (properties.get_cursor_hidden()) {
|
_cursor_hidden = properties.get_cursor_hidden();
|
||||||
CGDisplayHideCursor(kCGDirectMainDisplay);
|
if (_cursor_hidden && _input_devices[0].has_pointer()) {
|
||||||
|
if (!_display_hide_cursor) {
|
||||||
|
CGDisplayHideCursor(kCGDirectMainDisplay);
|
||||||
|
_display_hide_cursor = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
CGDisplayShowCursor(kCGDirectMainDisplay);
|
if (_display_hide_cursor) {
|
||||||
|
CGDisplayShowCursor(kCGDirectMainDisplay);
|
||||||
|
_display_hide_cursor = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
properties.clear_cursor_hidden();
|
properties.clear_cursor_hidden();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user