mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-29 08:15:18 -04:00
cocoa: remove pre-10.6 code
This commit is contained in:
parent
48ff3aeb08
commit
0e56ddc438
@ -21,9 +21,7 @@
|
|||||||
|
|
||||||
#import <Foundation/NSAutoreleasePool.h>
|
#import <Foundation/NSAutoreleasePool.h>
|
||||||
#import <AppKit/NSApplication.h>
|
#import <AppKit/NSApplication.h>
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
|
||||||
#import <AppKit/NSRunningApplication.h>
|
#import <AppKit/NSRunningApplication.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <mach-o/arch.h>
|
#include <mach-o/arch.h>
|
||||||
|
|
||||||
@ -70,7 +68,6 @@ load_display_information() {
|
|||||||
|
|
||||||
// Display modes
|
// Display modes
|
||||||
size_t num_modes = 0;
|
size_t num_modes = 0;
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
|
||||||
CFArrayRef modes = CGDisplayCopyAllDisplayModes(_display, NULL);
|
CFArrayRef modes = CGDisplayCopyAllDisplayModes(_display, NULL);
|
||||||
if (modes != NULL) {
|
if (modes != NULL) {
|
||||||
num_modes = CFArrayGetCount(modes);
|
num_modes = CFArrayGetCount(modes);
|
||||||
@ -117,33 +114,6 @@ load_display_information() {
|
|||||||
CFRelease(modes);
|
CFRelease(modes);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
CFArrayRef modes = CGDisplayAvailableModes(_display);
|
|
||||||
if (modes != NULL) {
|
|
||||||
num_modes = CFArrayGetCount(modes);
|
|
||||||
_display_information->_total_display_modes = num_modes;
|
|
||||||
_display_information->_display_mode_array = new DisplayMode[num_modes];
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < num_modes; ++i) {
|
|
||||||
CFDictionaryRef mode = (CFDictionaryRef) CFArrayGetValueAtIndex(modes, i);
|
|
||||||
|
|
||||||
CFNumberGetValue((CFNumberRef) CFDictionaryGetValue(mode, kCGDisplayWidth),
|
|
||||||
kCFNumberIntType, &_display_information->_display_mode_array[i].width);
|
|
||||||
|
|
||||||
CFNumberGetValue((CFNumberRef) CFDictionaryGetValue(mode, kCGDisplayHeight),
|
|
||||||
kCFNumberIntType, &_display_information->_display_mode_array[i].height);
|
|
||||||
|
|
||||||
CFNumberGetValue((CFNumberRef) CFDictionaryGetValue(mode, kCGDisplayBitsPerPixel),
|
|
||||||
kCFNumberIntType, &_display_information->_display_mode_array[i].bits_per_pixel);
|
|
||||||
|
|
||||||
CFNumberGetValue((CFNumberRef) CFDictionaryGetValue(mode, kCGDisplayRefreshRate),
|
|
||||||
kCFNumberIntType, &_display_information->_display_mode_array[i].refresh_rate);
|
|
||||||
|
|
||||||
_display_information->_display_mode_array[i].fullscreen_only = false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Get processor information
|
// Get processor information
|
||||||
const NXArchInfo *ainfo = NXGetLocalArchInfo();
|
const NXArchInfo *ainfo = NXGetLocalArchInfo();
|
||||||
_display_information->_cpu_brand_string = strdup(ainfo->description);
|
_display_information->_cpu_brand_string = strdup(ainfo->description);
|
||||||
|
@ -67,13 +67,8 @@ protected:
|
|||||||
virtual void close_window();
|
virtual void close_window();
|
||||||
virtual bool open_window();
|
virtual bool open_window();
|
||||||
|
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
|
||||||
CGDisplayModeRef find_display_mode(int width, int height);
|
CGDisplayModeRef find_display_mode(int width, int height);
|
||||||
bool do_switch_fullscreen(CGDisplayModeRef mode);
|
bool do_switch_fullscreen(CGDisplayModeRef mode);
|
||||||
#else
|
|
||||||
CFDictionaryRef find_display_mode(int width, int height);
|
|
||||||
bool do_switch_fullscreen(CFDictionaryRef mode);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
virtual void mouse_mode_absolute();
|
virtual void mouse_mode_absolute();
|
||||||
virtual void mouse_mode_relative();
|
virtual void mouse_mode_relative();
|
||||||
@ -96,13 +91,8 @@ private:
|
|||||||
bool _context_needs_update;
|
bool _context_needs_update;
|
||||||
bool _vsync_enabled = false;
|
bool _vsync_enabled = false;
|
||||||
|
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
|
||||||
CGDisplayModeRef _fullscreen_mode;
|
CGDisplayModeRef _fullscreen_mode;
|
||||||
CGDisplayModeRef _windowed_mode;
|
CGDisplayModeRef _windowed_mode;
|
||||||
#else
|
|
||||||
CFDictionaryRef _fullscreen_mode;
|
|
||||||
CFDictionaryRef _windowed_mode;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef pmap<Filename, NSImage*> IconImages;
|
typedef pmap<Filename, NSImage*> IconImages;
|
||||||
IconImages _images;
|
IconImages _images;
|
||||||
|
@ -75,9 +75,7 @@ CocoaGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
|
|||||||
CocoaPandaAppDelegate *delegate = [[CocoaPandaAppDelegate alloc] init];
|
CocoaPandaAppDelegate *delegate = [[CocoaPandaAppDelegate alloc] init];
|
||||||
[NSApp setDelegate:delegate];
|
[NSApp setDelegate:delegate];
|
||||||
|
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
|
||||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||||
#endif
|
|
||||||
NSMenu *mainMenu = [[NSMenu alloc] init];
|
NSMenu *mainMenu = [[NSMenu alloc] init];
|
||||||
|
|
||||||
NSMenuItem *applicationMenuItem = [[NSMenuItem alloc] init];
|
NSMenuItem *applicationMenuItem = [[NSMenuItem alloc] init];
|
||||||
@ -626,12 +624,7 @@ open_window() {
|
|||||||
|
|
||||||
if (_properties.get_fullscreen()) {
|
if (_properties.get_fullscreen()) {
|
||||||
// Change the display mode.
|
// Change the display mode.
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
|
||||||
CGDisplayModeRef mode;
|
CGDisplayModeRef mode;
|
||||||
#else
|
|
||||||
CFDictionaryRef mode;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mode = find_display_mode(_properties.get_x_size(),
|
mode = find_display_mode(_properties.get_x_size(),
|
||||||
_properties.get_y_size());
|
_properties.get_y_size());
|
||||||
|
|
||||||
@ -790,12 +783,7 @@ set_properties_now(WindowProperties &properties) {
|
|||||||
height = _properties.get_y_size();
|
height = _properties.get_y_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
|
||||||
CGDisplayModeRef mode;
|
CGDisplayModeRef mode;
|
||||||
#else
|
|
||||||
CFDictionaryRef mode;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mode = find_display_mode(width, height);
|
mode = find_display_mode(width, height);
|
||||||
|
|
||||||
if (mode == NULL) {
|
if (mode == NULL) {
|
||||||
@ -872,11 +860,7 @@ set_properties_now(WindowProperties &properties) {
|
|||||||
properties.clear_size();
|
properties.clear_size();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
|
||||||
CGDisplayModeRef mode = find_display_mode(width, height);
|
CGDisplayModeRef mode = find_display_mode(width, height);
|
||||||
#else
|
|
||||||
CFDictionaryRef mode = find_display_mode(width, height);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (mode == NULL) {
|
if (mode == NULL) {
|
||||||
cocoadisplay_cat.error()
|
cocoadisplay_cat.error()
|
||||||
@ -1109,7 +1093,6 @@ set_properties_now(WindowProperties &properties) {
|
|||||||
* Returns an appropriate CGDisplayModeRef for the given width and height, or
|
* Returns an appropriate CGDisplayModeRef for the given width and height, or
|
||||||
* NULL if none was found.
|
* NULL if none was found.
|
||||||
*/
|
*/
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
|
||||||
CGDisplayModeRef CocoaGraphicsWindow::
|
CGDisplayModeRef CocoaGraphicsWindow::
|
||||||
find_display_mode(int width, int height) {
|
find_display_mode(int width, int height) {
|
||||||
CFArrayRef modes = CGDisplayCopyAllDisplayModes(_display, NULL);
|
CFArrayRef modes = CGDisplayCopyAllDisplayModes(_display, NULL);
|
||||||
@ -1153,72 +1136,13 @@ find_display_mode(int width, int height) {
|
|||||||
CFRelease(modes);
|
CFRelease(modes);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#else // Version for pre-10.6.
|
|
||||||
CFDictionaryRef CocoaGraphicsWindow::
|
|
||||||
find_display_mode(int width, int height) {
|
|
||||||
// Get the current mode and extract its properties.
|
|
||||||
CFDictionaryRef current_mode = CGDisplayCurrentMode(_display);
|
|
||||||
int current_width, current_height, current_bpp, current_refresh_rate;
|
|
||||||
|
|
||||||
CFNumberGetValue((CFNumberRef) CFDictionaryGetValue(current_mode, kCGDisplayWidth),
|
|
||||||
kCFNumberIntType, ¤t_width);
|
|
||||||
|
|
||||||
CFNumberGetValue((CFNumberRef) CFDictionaryGetValue(current_mode, kCGDisplayHeight),
|
|
||||||
kCFNumberIntType, ¤t_height);
|
|
||||||
|
|
||||||
CFNumberGetValue((CFNumberRef) CFDictionaryGetValue(current_mode, kCGDisplayBitsPerPixel),
|
|
||||||
kCFNumberIntType, ¤t_bpp);
|
|
||||||
|
|
||||||
CFNumberGetValue((CFNumberRef) CFDictionaryGetValue(current_mode, kCGDisplayRefreshRate),
|
|
||||||
kCFNumberIntType, ¤t_refresh_rate);
|
|
||||||
|
|
||||||
// Check if it is suitable and if so, return it.
|
|
||||||
if (current_width == width && current_height == height) {
|
|
||||||
return current_mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Iterate over the modes to find a suitable one.
|
|
||||||
CFArrayRef modes = CGDisplayAvailableModes(_display);
|
|
||||||
size_t num_modes = CFArrayGetCount(modes);
|
|
||||||
int mode_width, mode_height, mode_bpp, mode_refresh_rate;
|
|
||||||
|
|
||||||
for (size_t i = 0; i < num_modes; ++i) {
|
|
||||||
CFDictionaryRef mode = (CFDictionaryRef) CFArrayGetValueAtIndex(modes, i);
|
|
||||||
|
|
||||||
CFNumberGetValue((CFNumberRef) CFDictionaryGetValue(mode, kCGDisplayWidth),
|
|
||||||
kCFNumberIntType, &mode_width);
|
|
||||||
|
|
||||||
CFNumberGetValue((CFNumberRef) CFDictionaryGetValue(mode, kCGDisplayHeight),
|
|
||||||
kCFNumberIntType, &mode_height);
|
|
||||||
|
|
||||||
CFNumberGetValue((CFNumberRef) CFDictionaryGetValue(mode, kCGDisplayBitsPerPixel),
|
|
||||||
kCFNumberIntType, &mode_bpp);
|
|
||||||
|
|
||||||
CFNumberGetValue((CFNumberRef) CFDictionaryGetValue(mode, kCGDisplayRefreshRate),
|
|
||||||
kCFNumberIntType, &mode_refresh_rate);
|
|
||||||
|
|
||||||
if (mode_width == width && mode_height == height &&
|
|
||||||
mode_refresh_rate == current_refresh_rate &&
|
|
||||||
mode_bpp == current_bpp) {
|
|
||||||
return mode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switches to the indicated fullscreen mode, or back to windowed if NULL was
|
* Switches to the indicated fullscreen mode, or back to windowed if NULL was
|
||||||
* given. Returns true on success, false on failure.
|
* given. Returns true on success, false on failure.
|
||||||
*/
|
*/
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
|
||||||
bool CocoaGraphicsWindow::
|
bool CocoaGraphicsWindow::
|
||||||
do_switch_fullscreen(CGDisplayModeRef mode) {
|
do_switch_fullscreen(CGDisplayModeRef mode) {
|
||||||
#else
|
|
||||||
bool CocoaGraphicsWindow::
|
|
||||||
do_switch_fullscreen(CFDictionaryRef mode) {
|
|
||||||
#endif
|
|
||||||
if (mode == NULL) {
|
if (mode == NULL) {
|
||||||
if (_windowed_mode == NULL) {
|
if (_windowed_mode == NULL) {
|
||||||
// Already windowed.
|
// Already windowed.
|
||||||
@ -1226,12 +1150,8 @@ do_switch_fullscreen(CFDictionaryRef mode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Switch back to the mode we were in when we were still windowed.
|
// Switch back to the mode we were in when we were still windowed.
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
|
||||||
CGDisplaySetDisplayMode(_display, _windowed_mode, NULL);
|
CGDisplaySetDisplayMode(_display, _windowed_mode, NULL);
|
||||||
CGDisplayModeRelease(_windowed_mode);
|
CGDisplayModeRelease(_windowed_mode);
|
||||||
#else
|
|
||||||
CGDisplaySwitchToMode(_display, _windowed_mode);
|
|
||||||
#endif
|
|
||||||
CGDisplayRelease(_display);
|
CGDisplayRelease(_display);
|
||||||
_windowed_mode = NULL;
|
_windowed_mode = NULL;
|
||||||
_context_needs_update = true;
|
_context_needs_update = true;
|
||||||
@ -1243,20 +1163,12 @@ do_switch_fullscreen(CFDictionaryRef mode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Store the existing mode under _windowed_mode.
|
// Store the existing mode under _windowed_mode.
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
|
||||||
_windowed_mode = CGDisplayCopyDisplayMode(_display);
|
_windowed_mode = CGDisplayCopyDisplayMode(_display);
|
||||||
#else
|
|
||||||
_windowed_mode = CGDisplayCurrentMode(_display);
|
|
||||||
#endif
|
|
||||||
_fullscreen_mode = mode;
|
_fullscreen_mode = mode;
|
||||||
_context_needs_update = true;
|
_context_needs_update = true;
|
||||||
|
|
||||||
CGError err;
|
CGError err;
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
|
||||||
err = CGDisplaySetDisplayMode(_display, _fullscreen_mode, NULL);
|
err = CGDisplaySetDisplayMode(_display, _fullscreen_mode, NULL);
|
||||||
#else
|
|
||||||
err = CGDisplaySwitchToMode(_display, _fullscreen_mode);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (err != kCGErrorSuccess) {
|
if (err != kCGErrorSuccess) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -22,9 +22,7 @@
|
|||||||
self = [super initWithFrame: frameRect];
|
self = [super initWithFrame: frameRect];
|
||||||
|
|
||||||
_context = context;
|
_context = context;
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
|
||||||
[self setCanDrawConcurrently:YES];
|
[self setCanDrawConcurrently:YES];
|
||||||
#endif
|
|
||||||
|
|
||||||
// If a layer ends up becoming attached to the view, tell AppKit we'll manage
|
// If a layer ends up becoming attached to the view, tell AppKit we'll manage
|
||||||
// the redrawing since we're doing things our own way.
|
// the redrawing since we're doing things our own way.
|
||||||
|
@ -28,9 +28,7 @@
|
|||||||
[self setDelegate:delegate];
|
[self setDelegate:delegate];
|
||||||
[self setOpaque:YES];
|
[self setOpaque:YES];
|
||||||
[self setReleasedWhenClosed:YES];
|
[self setReleasedWhenClosed:YES];
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
|
||||||
[self setAllowsConcurrentViewDrawing:YES];
|
[self setAllowsConcurrentViewDrawing:YES];
|
||||||
#endif
|
|
||||||
|
|
||||||
// Necessary to be able to accept mouseMoved in the NSView
|
// Necessary to be able to accept mouseMoved in the NSView
|
||||||
[self setAcceptsMouseMovedEvents:YES];
|
[self setAcceptsMouseMovedEvents:YES];
|
||||||
|
@ -17,11 +17,7 @@
|
|||||||
|
|
||||||
class CocoaGraphicsWindow;
|
class CocoaGraphicsWindow;
|
||||||
|
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
|
||||||
@interface CocoaPandaWindowDelegate : NSObject<NSWindowDelegate> {
|
@interface CocoaPandaWindowDelegate : NSObject<NSWindowDelegate> {
|
||||||
#else
|
|
||||||
@interface CocoaPandaWindowDelegate : NSObject {
|
|
||||||
#endif
|
|
||||||
@private
|
@private
|
||||||
CocoaGraphicsWindow *_graphicsWindow;
|
CocoaGraphicsWindow *_graphicsWindow;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user