cocoa: remove pre-10.6 code

This commit is contained in:
rdb 2019-12-11 17:05:51 +01:00
parent 48ff3aeb08
commit 0e56ddc438
6 changed files with 0 additions and 136 deletions

View File

@ -21,9 +21,7 @@
#import <Foundation/NSAutoreleasePool.h>
#import <AppKit/NSApplication.h>
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
#import <AppKit/NSRunningApplication.h>
#endif
#include <mach-o/arch.h>
@ -70,7 +68,6 @@ load_display_information() {
// Display modes
size_t num_modes = 0;
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
CFArrayRef modes = CGDisplayCopyAllDisplayModes(_display, NULL);
if (modes != NULL) {
num_modes = CFArrayGetCount(modes);
@ -117,33 +114,6 @@ load_display_information() {
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
const NXArchInfo *ainfo = NXGetLocalArchInfo();
_display_information->_cpu_brand_string = strdup(ainfo->description);

View File

@ -67,13 +67,8 @@ protected:
virtual void close_window();
virtual bool open_window();
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
CGDisplayModeRef find_display_mode(int width, int height);
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_relative();
@ -96,13 +91,8 @@ private:
bool _context_needs_update;
bool _vsync_enabled = false;
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
CGDisplayModeRef _fullscreen_mode;
CGDisplayModeRef _windowed_mode;
#else
CFDictionaryRef _fullscreen_mode;
CFDictionaryRef _windowed_mode;
#endif
typedef pmap<Filename, NSImage*> IconImages;
IconImages _images;

View File

@ -75,9 +75,7 @@ CocoaGraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
CocoaPandaAppDelegate *delegate = [[CocoaPandaAppDelegate alloc] init];
[NSApp setDelegate:delegate];
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
#endif
NSMenu *mainMenu = [[NSMenu alloc] init];
NSMenuItem *applicationMenuItem = [[NSMenuItem alloc] init];
@ -626,12 +624,7 @@ open_window() {
if (_properties.get_fullscreen()) {
// Change the display mode.
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
CGDisplayModeRef mode;
#else
CFDictionaryRef mode;
#endif
mode = find_display_mode(_properties.get_x_size(),
_properties.get_y_size());
@ -790,12 +783,7 @@ set_properties_now(WindowProperties &properties) {
height = _properties.get_y_size();
}
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
CGDisplayModeRef mode;
#else
CFDictionaryRef mode;
#endif
mode = find_display_mode(width, height);
if (mode == NULL) {
@ -872,11 +860,7 @@ set_properties_now(WindowProperties &properties) {
properties.clear_size();
} else {
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
CGDisplayModeRef mode = find_display_mode(width, height);
#else
CFDictionaryRef mode = find_display_mode(width, height);
#endif
if (mode == NULL) {
cocoadisplay_cat.error()
@ -1109,7 +1093,6 @@ set_properties_now(WindowProperties &properties) {
* Returns an appropriate CGDisplayModeRef for the given width and height, or
* NULL if none was found.
*/
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
CGDisplayModeRef CocoaGraphicsWindow::
find_display_mode(int width, int height) {
CFArrayRef modes = CGDisplayCopyAllDisplayModes(_display, NULL);
@ -1153,72 +1136,13 @@ find_display_mode(int width, int height) {
CFRelease(modes);
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, &current_width);
CFNumberGetValue((CFNumberRef) CFDictionaryGetValue(current_mode, kCGDisplayHeight),
kCFNumberIntType, &current_height);
CFNumberGetValue((CFNumberRef) CFDictionaryGetValue(current_mode, kCGDisplayBitsPerPixel),
kCFNumberIntType, &current_bpp);
CFNumberGetValue((CFNumberRef) CFDictionaryGetValue(current_mode, kCGDisplayRefreshRate),
kCFNumberIntType, &current_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
* given. Returns true on success, false on failure.
*/
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
bool CocoaGraphicsWindow::
do_switch_fullscreen(CGDisplayModeRef mode) {
#else
bool CocoaGraphicsWindow::
do_switch_fullscreen(CFDictionaryRef mode) {
#endif
if (mode == NULL) {
if (_windowed_mode == NULL) {
// Already windowed.
@ -1226,12 +1150,8 @@ do_switch_fullscreen(CFDictionaryRef mode) {
}
// 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);
CGDisplayModeRelease(_windowed_mode);
#else
CGDisplaySwitchToMode(_display, _windowed_mode);
#endif
CGDisplayRelease(_display);
_windowed_mode = NULL;
_context_needs_update = true;
@ -1243,20 +1163,12 @@ do_switch_fullscreen(CFDictionaryRef mode) {
}
// Store the existing mode under _windowed_mode.
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
_windowed_mode = CGDisplayCopyDisplayMode(_display);
#else
_windowed_mode = CGDisplayCurrentMode(_display);
#endif
_fullscreen_mode = mode;
_context_needs_update = true;
CGError err;
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
err = CGDisplaySetDisplayMode(_display, _fullscreen_mode, NULL);
#else
err = CGDisplaySwitchToMode(_display, _fullscreen_mode);
#endif
if (err != kCGErrorSuccess) {
return false;

View File

@ -22,9 +22,7 @@
self = [super initWithFrame: frameRect];
_context = context;
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
[self setCanDrawConcurrently:YES];
#endif
// 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.

View File

@ -28,9 +28,7 @@
[self setDelegate:delegate];
[self setOpaque:YES];
[self setReleasedWhenClosed:YES];
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
[self setAllowsConcurrentViewDrawing:YES];
#endif
// Necessary to be able to accept mouseMoved in the NSView
[self setAcceptsMouseMovedEvents:YES];

View File

@ -17,11 +17,7 @@
class CocoaGraphicsWindow;
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
@interface CocoaPandaWindowDelegate : NSObject<NSWindowDelegate> {
#else
@interface CocoaPandaWindowDelegate : NSObject {
#endif
@private
CocoaGraphicsWindow *_graphicsWindow;
}