mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
fix osx win-fixed-size
This commit is contained in:
parent
5a635059b6
commit
a49e684dbe
@ -229,7 +229,11 @@ event_handler(EventHandlerCallRef myHandler, EventRef event) {
|
|||||||
|
|
||||||
WindowRef window = NULL;
|
WindowRef window = NULL;
|
||||||
GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL,
|
GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL,
|
||||||
sizeof(WindowRef), NULL, &window);
|
sizeof(window), NULL, &window);
|
||||||
|
|
||||||
|
UInt32 attributes = 0;
|
||||||
|
GetEventParameter(event, kEventParamAttributes, typeUInt32, NULL,
|
||||||
|
sizeof(attributes), NULL, &attributes);
|
||||||
|
|
||||||
if (osxdisplay_cat.is_spam()) {
|
if (osxdisplay_cat.is_spam()) {
|
||||||
osxdisplay_cat.spam()
|
osxdisplay_cat.spam()
|
||||||
@ -276,6 +280,23 @@ event_handler(EventHandlerCallRef myHandler, EventRef event) {
|
|||||||
SetUserFocusWindow (window);
|
SetUserFocusWindow (window);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case kEventWindowBoundsChanging:
|
||||||
|
// Gives us a chance to intercept resize attempts
|
||||||
|
if (attributes & kWindowBoundsChangeSizeChanged) {
|
||||||
|
// If the window is supposed to be fixed-size, enforce this.
|
||||||
|
if (_properties.get_fixed_size()) {
|
||||||
|
Rect bounds;
|
||||||
|
GetEventParameter(event, kEventParamCurrentBounds,
|
||||||
|
typeQDRectangle, NULL, sizeof(bounds), NULL, &bounds);
|
||||||
|
bounds.right = bounds.left + _properties.get_x_size();
|
||||||
|
bounds.bottom = bounds.top + _properties.get_y_size();
|
||||||
|
SetEventParameter(event, kEventParamCurrentBounds,
|
||||||
|
typeQDRectangle, sizeof(bounds), &bounds);
|
||||||
|
result = noErr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case kEventWindowBoundsChanged: // called for resize and moves (drag)
|
case kEventWindowBoundsChanged: // called for resize and moves (drag)
|
||||||
do_resize();
|
do_resize();
|
||||||
break;
|
break;
|
||||||
@ -1199,6 +1220,11 @@ os_open_window(WindowProperties &req_properties) {
|
|||||||
}
|
}
|
||||||
} else */
|
} else */
|
||||||
{
|
{
|
||||||
|
int attributes = kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute;
|
||||||
|
if (req_properties.has_fixed_size() && req_properties.get_fixed_size()) {
|
||||||
|
attributes &= ~kWindowResizableAttribute;
|
||||||
|
}
|
||||||
|
|
||||||
if (req_properties.has_undecorated() && req_properties.get_undecorated()) {
|
if (req_properties.has_undecorated() && req_properties.get_undecorated()) {
|
||||||
// create a unmovable .. no edge window..
|
// create a unmovable .. no edge window..
|
||||||
|
|
||||||
@ -1207,7 +1233,10 @@ os_open_window(WindowProperties &req_properties) {
|
|||||||
<< "Creating undecorated window\n";
|
<< "Creating undecorated window\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateNewWindow(kDocumentWindowClass, kWindowStandardDocumentAttributes | kWindowNoTitleBarAttribute, &r, &_osx_window);
|
// We don't want a resize box either.
|
||||||
|
attributes &= ~kWindowResizableAttribute;
|
||||||
|
attributes |= kWindowNoTitleBarAttribute;
|
||||||
|
CreateNewWindow(kDocumentWindowClass, attributes, &r, &_osx_window);
|
||||||
} else {
|
} else {
|
||||||
// create a window with crome and sizing and sucj
|
// create a window with crome and sizing and sucj
|
||||||
// In this case, we want to constrain the window to the
|
// In this case, we want to constrain the window to the
|
||||||
@ -1225,7 +1254,7 @@ os_open_window(WindowProperties &req_properties) {
|
|||||||
osxdisplay_cat.debug()
|
osxdisplay_cat.debug()
|
||||||
<< "Creating standard window\n";
|
<< "Creating standard window\n";
|
||||||
}
|
}
|
||||||
CreateNewWindow(kDocumentWindowClass, kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute, &r, &_osx_window);
|
CreateNewWindow(kDocumentWindowClass, attributes, &r, &_osx_window);
|
||||||
add_a_window(_osx_window);
|
add_a_window(_osx_window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1238,6 +1267,7 @@ os_open_window(WindowProperties &req_properties) {
|
|||||||
{ kEventClassWindow, kEventWindowActivated },
|
{ kEventClassWindow, kEventWindowActivated },
|
||||||
{ kEventClassWindow, kEventWindowDeactivated },
|
{ kEventClassWindow, kEventWindowDeactivated },
|
||||||
{ kEventClassWindow, kEventWindowClose },
|
{ kEventClassWindow, kEventWindowClose },
|
||||||
|
{ kEventClassWindow, kEventWindowBoundsChanging },
|
||||||
{ kEventClassWindow, kEventWindowBoundsChanged },
|
{ kEventClassWindow, kEventWindowBoundsChanged },
|
||||||
|
|
||||||
{ kEventClassWindow, kEventWindowCollapsed },
|
{ kEventClassWindow, kEventWindowCollapsed },
|
||||||
|
@ -133,14 +133,20 @@ TinyOsxGraphicsWindow* TinyOsxGraphicsWindow::GetCurrentOSxWindow(WindowRef wind
|
|||||||
// Description: The standard window event handler for non-fullscreen
|
// Description: The standard window event handler for non-fullscreen
|
||||||
// windows.
|
// windows.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
OSStatus TinyOsxGraphicsWindow::event_handler(EventHandlerCallRef myHandler, EventRef event) {
|
OSStatus TinyOsxGraphicsWindow::
|
||||||
|
event_handler(EventHandlerCallRef myHandler, EventRef event) {
|
||||||
|
|
||||||
OSStatus result = eventNotHandledErr;
|
OSStatus result = eventNotHandledErr;
|
||||||
UInt32 the_class = GetEventClass(event);
|
UInt32 the_class = GetEventClass(event);
|
||||||
UInt32 kind = GetEventKind(event);
|
UInt32 kind = GetEventKind(event);
|
||||||
|
|
||||||
WindowRef window = NULL;
|
WindowRef window = NULL;
|
||||||
GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window);
|
GetEventParameter(event, kEventParamDirectObject, typeWindowRef, NULL,
|
||||||
|
sizeof(window), NULL, &window);
|
||||||
|
|
||||||
|
UInt32 attributes = 0;
|
||||||
|
GetEventParameter(event, kEventParamAttributes, typeUInt32, NULL,
|
||||||
|
sizeof(attributes), NULL, &attributes);
|
||||||
|
|
||||||
if (tinydisplay_cat.is_spam()) {
|
if (tinydisplay_cat.is_spam()) {
|
||||||
tinydisplay_cat.spam() << ClockObject::get_global_clock()->get_real_time() << " event_handler: " << (void *)this << ", " << window << ", " << the_class << ", " << kind << "\n";
|
tinydisplay_cat.spam() << ClockObject::get_global_clock()->get_real_time() << " event_handler: " << (void *)this << ", " << window << ", " << the_class << ", " << kind << "\n";
|
||||||
@ -179,6 +185,23 @@ OSStatus TinyOsxGraphicsWindow::event_handler(EventHandlerCallRef myHandler, Eve
|
|||||||
if (window == FrontNonFloatingWindow ())
|
if (window == FrontNonFloatingWindow ())
|
||||||
SetUserFocusWindow (window);
|
SetUserFocusWindow (window);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case kEventWindowBoundsChanging:
|
||||||
|
// Gives us a chance to intercept resize attempts
|
||||||
|
if (attributes & kWindowBoundsChangeSizeChanged) {
|
||||||
|
// If the window is supposed to be fixed-size, enforce this.
|
||||||
|
if (_properties.get_fixed_size()) {
|
||||||
|
Rect bounds;
|
||||||
|
GetEventParameter(event, kEventParamCurrentBounds,
|
||||||
|
typeQDRectangle, NULL, sizeof(bounds), NULL, &bounds);
|
||||||
|
bounds.right = bounds.left + _properties.get_x_size();
|
||||||
|
bounds.bottom = bounds.top + _properties.get_y_size();
|
||||||
|
SetEventParameter(event, kEventParamCurrentBounds,
|
||||||
|
typeQDRectangle, sizeof(bounds), &bounds); result = noErr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case kEventWindowBoundsChanged: // called for resize and moves (drag)
|
case kEventWindowBoundsChanged: // called for resize and moves (drag)
|
||||||
DoResize();
|
DoResize();
|
||||||
break;
|
break;
|
||||||
@ -433,7 +456,6 @@ void TinyOsxGraphicsWindow::ReleaseSystemResources() {
|
|||||||
_pending_icon = NULL;
|
_pending_icon = NULL;
|
||||||
}
|
}
|
||||||
if (_current_icon != NULL) {
|
if (_current_icon != NULL) {
|
||||||
cerr << "release current icon\n";
|
|
||||||
CGImageRelease(_current_icon);
|
CGImageRelease(_current_icon);
|
||||||
_current_icon = NULL;
|
_current_icon = NULL;
|
||||||
}
|
}
|
||||||
@ -951,16 +973,23 @@ bool TinyOsxGraphicsWindow::OSOpenWindow(WindowProperties &req_properties) {
|
|||||||
}
|
}
|
||||||
else */
|
else */
|
||||||
{
|
{
|
||||||
|
int attributes = kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute;
|
||||||
|
if (req_properties.has_fixed_size() && req_properties.get_fixed_size()) {
|
||||||
|
attributes &= ~kWindowResizableAttribute;
|
||||||
|
}
|
||||||
|
|
||||||
if (req_properties.has_undecorated() && req_properties.get_undecorated()) { // create a unmovable .. no edge window..
|
if (req_properties.has_undecorated() && req_properties.get_undecorated()) { // create a unmovable .. no edge window..
|
||||||
tinydisplay_cat.info() << "Creating undecorated window\n";
|
tinydisplay_cat.info() << "Creating undecorated window\n";
|
||||||
|
|
||||||
CreateNewWindow(kDocumentWindowClass, kWindowStandardDocumentAttributes | kWindowNoTitleBarAttribute, &r, &_osx_window);
|
// We don't want a resize box either.
|
||||||
|
attributes &= ~kWindowResizableAttribute;
|
||||||
|
attributes |= kWindowNoTitleBarAttribute;
|
||||||
|
CreateNewWindow(kDocumentWindowClass, attributes, &r, &_osx_window);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // create a window with crome and sizing and sucj
|
{ // create a window with crome and sizing and sucj
|
||||||
// In this case, we want to constrain the window to the
|
// In this case, we want to constrain the window to the
|
||||||
// available size.
|
// available size.
|
||||||
|
|
||||||
Rect bounds;
|
Rect bounds;
|
||||||
GetAvailableWindowPositioningBounds(GetMainDevice(), &bounds);
|
GetAvailableWindowPositioningBounds(GetMainDevice(), &bounds);
|
||||||
|
|
||||||
@ -970,7 +999,7 @@ bool TinyOsxGraphicsWindow::OSOpenWindow(WindowProperties &req_properties) {
|
|||||||
r.bottom = min(r.bottom, bounds.bottom);
|
r.bottom = min(r.bottom, bounds.bottom);
|
||||||
|
|
||||||
tinydisplay_cat.info() << "Creating standard window\n";
|
tinydisplay_cat.info() << "Creating standard window\n";
|
||||||
CreateNewWindow(kDocumentWindowClass, kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute, &r, &_osx_window);
|
CreateNewWindow(kDocumentWindowClass, attributes, &r, &_osx_window);
|
||||||
AddAWindow(_osx_window);
|
AddAWindow(_osx_window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -986,6 +1015,7 @@ bool TinyOsxGraphicsWindow::OSOpenWindow(WindowProperties &req_properties) {
|
|||||||
{ kEventClassWindow, kEventWindowActivated },
|
{ kEventClassWindow, kEventWindowActivated },
|
||||||
{ kEventClassWindow, kEventWindowDeactivated },
|
{ kEventClassWindow, kEventWindowDeactivated },
|
||||||
{ kEventClassWindow, kEventWindowClose },
|
{ kEventClassWindow, kEventWindowClose },
|
||||||
|
{ kEventClassWindow, kEventWindowBoundsChanging },
|
||||||
{ kEventClassWindow, kEventWindowBoundsChanged },
|
{ kEventClassWindow, kEventWindowBoundsChanged },
|
||||||
|
|
||||||
{ kEventClassWindow, kEventWindowCollapsed },
|
{ kEventClassWindow, kEventWindowCollapsed },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user