macOS: remove code present only to support macOS versions 10.6 and earlier - cont'd.
This commit is contained in:
parent
3f56b8091d
commit
95e5b1b9c5
206
src/Fl_cocoa.mm
206
src/Fl_cocoa.mm
@ -186,9 +186,7 @@ const NSUInteger NSWindowStyleMaskBorderless = NSBorderlessWindowMask;
|
||||
const NSUInteger NSWindowStyleMaskMiniaturizable = NSMiniaturizableWindowMask;
|
||||
const NSUInteger NSWindowStyleMaskClosable = NSClosableWindowMask;
|
||||
const NSUInteger NSWindowStyleMaskTitled = NSTitledWindowMask;
|
||||
# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
const NSUInteger NSWindowStyleMaskFullScreen = NSFullScreenWindowMask;
|
||||
# endif
|
||||
|
||||
const NSUInteger NSEventMaskAny = NSAnyEventMask;
|
||||
const NSUInteger NSEventMaskSystemDefined = NSSystemDefinedMask;
|
||||
@ -557,19 +555,13 @@ void Fl_Cocoa_Screen_Driver::breakMacEventLoop()
|
||||
- (void)checkSubwindowFrame;
|
||||
- (void)waitForExpose;
|
||||
- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen;
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
- (NSPoint)convertBaseToScreen:(NSPoint)aPoint;
|
||||
#endif
|
||||
- (NSBitmapImageRep*)rect_to_NSBitmapImageRep:(Fl_Rect*)r;
|
||||
- (void)makeKeyWindow;
|
||||
@end
|
||||
|
||||
|
||||
@interface FLView : NSView <NSTextInput, NSTextInputClient
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
,NSDraggingSource
|
||||
#endif
|
||||
> {
|
||||
@interface FLView : NSView <NSTextInput, NSTextInputClient, NSDraggingSource> {
|
||||
BOOL in_key_event; // YES means keypress is being processed by handleEvent
|
||||
BOOL need_handle; // YES means Fl::handle(FL_KEYBOARD,) is needed after handleEvent processing
|
||||
NSInteger identifier;
|
||||
@ -611,11 +603,9 @@ void Fl_Cocoa_Screen_Driver::breakMacEventLoop()
|
||||
- (void)draggingExited:(id < NSDraggingInfo >)sender;
|
||||
- (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal;
|
||||
- (void)updateTrackingAreas;
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
- (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context;
|
||||
- (void)draggingSession:(NSDraggingSession *)session
|
||||
endedAtPoint:(NSPoint)screenPoint operation:(NSDragOperation)operation;
|
||||
#endif
|
||||
- (BOOL)did_view_resolution_change;
|
||||
#if defined(FLTK_HAVE_PEN_SUPPORT)
|
||||
- (void)tabletProximity:(NSEvent *)theEvent;
|
||||
@ -646,22 +636,11 @@ void Fl_Cocoa_Screen_Driver::breakMacEventLoop()
|
||||
// and before the FLWindow receives the final dealloc message
|
||||
w = NULL;
|
||||
}
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
- (NSPoint)convertBaseToScreen:(NSPoint)aPoint
|
||||
{
|
||||
if (fl_mac_os_version >= 100700) {
|
||||
NSRect r = [self convertRectToScreen:NSMakeRect(aPoint.x, aPoint.y, 0, 0)];
|
||||
return r.origin;
|
||||
}
|
||||
else {
|
||||
// replaces return [super convertBaseToScreen:aPoint] that may trigger a compiler warning
|
||||
typedef NSPoint (*convertIMP)(id, SEL, NSPoint);
|
||||
static convertIMP addr = (convertIMP)[NSWindow instanceMethodForSelector:@selector(convertBaseToScreen:)];
|
||||
return addr(self, @selector(convertBaseToScreen:), aPoint);
|
||||
}
|
||||
NSRect r = [self convertRectToScreen:NSMakeRect(aPoint.x, aPoint.y, 0, 0)];
|
||||
return r.origin;
|
||||
}
|
||||
#endif
|
||||
|
||||
- (FLWindow*)initWithFl_W:(Fl_Window *)flw
|
||||
contentRect:(NSRect)rect
|
||||
styleMask:(NSUInteger)windowStyle
|
||||
@ -669,12 +648,7 @@ void Fl_Cocoa_Screen_Driver::breakMacEventLoop()
|
||||
self = [super initWithContentRect:rect styleMask:windowStyle backing:NSBackingStoreBuffered defer:NO];
|
||||
if (self) {
|
||||
w = flw;
|
||||
if (fl_mac_os_version >= 100700) {
|
||||
// replaces [self setRestorable:NO] that may trigger a compiler warning
|
||||
typedef void (*setIMP)(id, SEL, BOOL);
|
||||
static setIMP addr = (setIMP)[NSWindow instanceMethodForSelector:@selector(setRestorable:)];
|
||||
addr(self, @selector(setRestorable:), NO);
|
||||
}
|
||||
[self setRestorable:NO];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@ -1431,11 +1405,7 @@ static FLWindowDelegate *flwindowdelegate_instance = nil;
|
||||
FLWindow *nsw = (FLWindow*)[notif object];
|
||||
Fl_Window *w = [nsw getFl_Window];
|
||||
/* Restore previous fullscreen level */
|
||||
if (w->fullscreen_active()
|
||||
# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
&& (fl_mac_os_version < 100700 || !(nsw.styleMask & NSWindowStyleMaskFullScreen))
|
||||
#endif
|
||||
) {
|
||||
if (w->fullscreen_active() && !(nsw.styleMask & NSWindowStyleMaskFullScreen)) {
|
||||
[nsw setLevel:NSStatusWindowLevel];
|
||||
fixup_window_levels();
|
||||
}
|
||||
@ -2334,31 +2304,27 @@ static FLTextInputContext* fltextinputcontext_instance = nil;
|
||||
|
||||
@implementation FLView
|
||||
- (BOOL)did_view_resolution_change {
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
if (fl_mac_os_version >= 100700) { // determine whether window is mapped to a retina display
|
||||
Fl_Window *window = [(FLWindow*)[self window] getFl_Window];
|
||||
Fl_Cocoa_Window_Driver *d = Fl_Cocoa_Window_Driver::driver(window);
|
||||
bool previous = d->mapped_to_retina();
|
||||
NSView *view = (!views_use_CA && window->parent() && !window->as_gl_window()) ?
|
||||
[fl_xid(window->top_window()) contentView] : self;
|
||||
if (view) {
|
||||
NSSize s = [view convertSizeToBacking:NSMakeSize(10, 10)]; // 10.7
|
||||
d->mapped_to_retina( int(s.width + 0.5) > 10 );
|
||||
}
|
||||
BOOL retval = (d->wait_for_expose_value == 0 && previous != d->mapped_to_retina());
|
||||
if (retval) {
|
||||
d->changed_resolution(true);
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14
|
||||
if (views_use_CA && !window->as_gl_window() ) {
|
||||
[self reset_aux_bitmap];
|
||||
window->redraw();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return retval;
|
||||
// determine whether window is mapped to a retina display
|
||||
Fl_Window *window = [(FLWindow*)[self window] getFl_Window];
|
||||
Fl_Cocoa_Window_Driver *d = Fl_Cocoa_Window_Driver::driver(window);
|
||||
bool previous = d->mapped_to_retina();
|
||||
NSView *view = (!views_use_CA && window->parent() && !window->as_gl_window()) ?
|
||||
[fl_xid(window->top_window()) contentView] : self;
|
||||
if (view) {
|
||||
NSSize s = [view convertSizeToBacking:NSMakeSize(10, 10)]; // 10.7
|
||||
d->mapped_to_retina( int(s.width + 0.5) > 10 );
|
||||
}
|
||||
BOOL retval = (d->wait_for_expose_value == 0 && previous != d->mapped_to_retina());
|
||||
if (retval) {
|
||||
d->changed_resolution(true);
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14
|
||||
if (views_use_CA && !window->as_gl_window() ) {
|
||||
[self reset_aux_bitmap];
|
||||
window->redraw();
|
||||
}
|
||||
#endif
|
||||
return NO;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_14
|
||||
- (void)create_aux_bitmap:(CGContextRef)gc retina:(BOOL)r {
|
||||
@ -2987,7 +2953,6 @@ static FLTextInputContext* fltextinputcontext_instance = nil;
|
||||
return identifier;
|
||||
}
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
- (NSDragOperation)draggingSession:(NSDraggingSession *)session sourceOperationMaskForDraggingContext:(NSDraggingContext)context
|
||||
{
|
||||
return NSDragOperationCopy;
|
||||
@ -3003,7 +2968,6 @@ static FLTextInputContext* fltextinputcontext_instance = nil;
|
||||
Fl::pushed( 0 );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
@ -3094,36 +3058,6 @@ void Fl_Cocoa_Window_Driver::makeWindow()
|
||||
changed_resolution(false);
|
||||
|
||||
NSRect crect;
|
||||
if (w->fullscreen_active() && fl_mac_os_version < 100700) {
|
||||
int top, bottom, left, right;
|
||||
int sx, sy, sw, sh, X, Y, W, H;
|
||||
|
||||
top = fullscreen_screen_top();
|
||||
bottom = fullscreen_screen_bottom();
|
||||
left = fullscreen_screen_left();
|
||||
right = fullscreen_screen_right();
|
||||
|
||||
if ((top < 0) || (bottom < 0) || (left < 0) || (right < 0)) {
|
||||
top = Fl::screen_num(w->x(), w->y(), w->w(), w->h());
|
||||
bottom = top;
|
||||
left = top;
|
||||
right = top;
|
||||
}
|
||||
|
||||
Fl::screen_xywh(sx, sy, sw, sh, top);
|
||||
Y = sy;
|
||||
Fl::screen_xywh(sx, sy, sw, sh, bottom);
|
||||
H = sy + sh - Y;
|
||||
Fl::screen_xywh(sx, sy, sw, sh, left);
|
||||
X = sx;
|
||||
Fl::screen_xywh(sx, sy, sw, sh, right);
|
||||
W = sx + sw - X;
|
||||
|
||||
w->resize(X, Y, W, H);
|
||||
|
||||
winstyle = NSWindowStyleMaskBorderless;
|
||||
winlevel = NSStatusWindowLevel;
|
||||
}
|
||||
float s = Fl::screen_driver()->scale(0);
|
||||
crect.origin.x = round(s * w->x()); // correct origin set later for subwindows
|
||||
crect.origin.y = main_screen_height - round(s * (w->y() + w->h()));
|
||||
@ -3239,7 +3173,7 @@ void Fl_Cocoa_Window_Driver::makeWindow()
|
||||
} else { // a top-level window
|
||||
if ([cw canBecomeKeyWindow]) [cw makeKeyAndOrderFront:nil];
|
||||
else [cw orderFront:nil];
|
||||
if (w->fullscreen_active() && fl_mac_os_version >= 100700) {
|
||||
if (w->fullscreen_active()) {
|
||||
if (fullscreen_screen_top() >= 0) {
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12
|
||||
if (fl_mac_os_version >= 101200)
|
||||
@ -3265,9 +3199,7 @@ void Fl_Cocoa_Window_Driver::makeWindow()
|
||||
}
|
||||
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
static BOOL fullscreen_screen_border = NO; // YES means the multi-screened window had a border before
|
||||
#endif
|
||||
|
||||
|
||||
static NSUInteger calc_win_style(Fl_Window *win);
|
||||
@ -3275,13 +3207,12 @@ static NSUInteger calc_win_style(Fl_Window *win);
|
||||
|
||||
void Fl_Cocoa_Window_Driver::fullscreen_on() {
|
||||
pWindow->_set_fullscreen();
|
||||
# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
bool has_border = pWindow->border();
|
||||
if (fl_mac_os_version >= 100700 && fullscreen_screen_top() >= 0 && has_border) {
|
||||
if (fullscreen_screen_top() >= 0 && has_border) {
|
||||
fullscreen_screen_border = YES;
|
||||
has_border = false;
|
||||
}
|
||||
if (fl_mac_os_version >= 100700 && has_border) {
|
||||
if (has_border) {
|
||||
NSWindow *nswin = fl_xid(pWindow);
|
||||
# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_13
|
||||
if (fl_mac_os_version >= 101300) {
|
||||
@ -3296,12 +3227,9 @@ void Fl_Cocoa_Window_Driver::fullscreen_on() {
|
||||
pWindow->_set_fullscreen();
|
||||
}
|
||||
[nswin toggleFullScreen:nil];
|
||||
} else
|
||||
# endif
|
||||
{
|
||||
} else {
|
||||
FLWindow *nswin = fl_xid(pWindow);
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
if (fl_mac_os_version >= 100700 && (nswin.styleMask & NSWindowStyleMaskFullScreen)) {
|
||||
if (nswin.styleMask & NSWindowStyleMaskFullScreen) {
|
||||
// from single-screen fullscreen to "All Screens" fullscreen, with border
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12
|
||||
if (fl_mac_os_version >= 101200) {
|
||||
@ -3320,7 +3248,6 @@ void Fl_Cocoa_Window_Driver::fullscreen_on() {
|
||||
}
|
||||
pWindow->_set_fullscreen();
|
||||
}
|
||||
#endif
|
||||
[nswin setStyleMask:NSWindowStyleMaskBorderless]; // 10.6
|
||||
if ([nswin isKeyWindow]) {
|
||||
if ([nswin level] != NSStatusWindowLevel) {
|
||||
@ -3396,8 +3323,7 @@ static void restore_window_title_and_icon(Fl_Window *pWindow, NSImage *icon) {
|
||||
void Fl_Cocoa_Window_Driver::fullscreen_off(int X, int Y, int W, int H) {
|
||||
NSWindow *nswin = fl_xid(pWindow);
|
||||
pWindow->_clear_fullscreen();
|
||||
# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
if (fl_mac_os_version >= 100700 && ([nswin styleMask] & NSWindowStyleMaskFullScreen)) {
|
||||
if ([nswin styleMask] & NSWindowStyleMaskFullScreen) {
|
||||
# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_13
|
||||
if (fl_mac_os_version >= 101300) {
|
||||
NSWindow *active_tab = [[nswin tabGroup] selectedWindow];
|
||||
@ -3406,9 +3332,7 @@ void Fl_Cocoa_Window_Driver::fullscreen_off(int X, int Y, int W, int H) {
|
||||
# endif
|
||||
[nswin toggleFullScreen:nil];
|
||||
pWindow->resize(*no_fullscreen_x(), *no_fullscreen_y(), *no_fullscreen_w(), *no_fullscreen_h());
|
||||
} else
|
||||
# endif
|
||||
{
|
||||
} else {
|
||||
// Transition from multi-screen fullscreen mode to normal mode
|
||||
NSInteger level = NSNormalWindowLevel;
|
||||
if (pWindow->modal()) level = modal_window_level();
|
||||
@ -3429,9 +3353,7 @@ void Fl_Cocoa_Window_Driver::fullscreen_off(int X, int Y, int W, int H) {
|
||||
else [nswin orderFront:nil];
|
||||
}
|
||||
Fl::handle(FL_FULLSCREEN, pWindow);
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
fullscreen_screen_border = NO;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -4272,31 +4194,15 @@ static NSImage *imageFromText(const char *text, int *pwidth, int *pheight)
|
||||
|
||||
static NSImage *defaultDragImage(int *pwidth, int *pheight)
|
||||
{
|
||||
const int version_threshold = 100700;
|
||||
int width, height;
|
||||
if (fl_mac_os_version >= version_threshold) {
|
||||
width = 50; height = 40;
|
||||
}
|
||||
else {
|
||||
width = 16; height = 16;
|
||||
}
|
||||
const int width = 50, height = 40;
|
||||
Fl_Image_Surface *off = new Fl_Image_Surface(width, height, 1);
|
||||
Fl_Surface_Device::push_current(off);
|
||||
if (fl_mac_os_version >= version_threshold) {
|
||||
fl_font(FL_HELVETICA, 20);
|
||||
fl_color(FL_BLACK);
|
||||
char str[4];
|
||||
// the "Delivery truck" Unicode character from "Apple Color Emoji" font
|
||||
int l = fl_utf8encode(0x1F69A, str);
|
||||
fl_draw(str, l, 1, 16);
|
||||
}
|
||||
else { // draw two squares
|
||||
CGContextSetRGBFillColor( (CGContextRef)off->offscreen(), 0,0,0,0);
|
||||
fl_rectf(0,0,width,height);
|
||||
CGContextSetRGBStrokeColor( (CGContextRef)off->offscreen(), 0,0,0,0.6);
|
||||
fl_rect(0,0,width,height);
|
||||
fl_rect(2,2,width-4,height-4);
|
||||
}
|
||||
fl_font(FL_HELVETICA, 20);
|
||||
fl_color(FL_BLACK);
|
||||
char str[4];
|
||||
// the "Delivery truck" Unicode character from "Apple Color Emoji" font
|
||||
int l = fl_utf8encode(0x1F69A, str);
|
||||
fl_draw(str, l, 1, 16);
|
||||
Fl_Surface_Device::pop_current();
|
||||
NSImage* image = CGBitmapContextToNSImage( (CGContextRef)off->offscreen() );
|
||||
delete off;
|
||||
@ -4329,36 +4235,12 @@ int Fl_Cocoa_Screen_Driver::dnd(int use_selection)
|
||||
NSPoint pt = [theEvent locationInWindow];
|
||||
pt.x -= width/2;
|
||||
pt.y -= height/2;
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
if (fl_mac_os_version >= 100700) {
|
||||
NSPasteboardItem *pbItem = [[[NSPasteboardItem alloc] init] autorelease];
|
||||
[pbItem setData:(NSData*)text forType:UTF8_pasteboard_type];
|
||||
NSDraggingItem *dragItem = [[[NSDraggingItem alloc] initWithPasteboardWriter:pbItem] autorelease];
|
||||
NSRect r = {pt, {CGFloat(width), CGFloat(height)}};
|
||||
[dragItem setDraggingFrame:r contents:image];
|
||||
[myview beginDraggingSessionWithItems:[NSArray arrayWithObject:dragItem] event:theEvent source:myview];
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
static NSSize offset={0,0};
|
||||
// the 2 deprecation warnings can be ignored because this runs only for macOS < 10.7
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
// deprecated in 10.13
|
||||
NSPasteboard *mypasteboard = [NSPasteboard pasteboardWithName:NSDragPboard];
|
||||
[mypasteboard declareTypes:[NSArray arrayWithObject:UTF8_pasteboard_type] owner:nil];
|
||||
[mypasteboard setData:(NSData*)text forType:UTF8_pasteboard_type];
|
||||
[myview dragImage:image at:pt offset:offset // deprecated in 10.7
|
||||
event:theEvent pasteboard:mypasteboard
|
||||
source:myview slideBack:YES];
|
||||
#pragma clang diagnostic pop
|
||||
if ( w ) {
|
||||
int old_event = Fl::e_number;
|
||||
w->handle(Fl::e_number = FL_RELEASE);
|
||||
Fl::e_number = old_event;
|
||||
Fl::pushed( 0 );
|
||||
}
|
||||
}
|
||||
NSPasteboardItem *pbItem = [[[NSPasteboardItem alloc] init] autorelease];
|
||||
[pbItem setData:(NSData*)text forType:UTF8_pasteboard_type];
|
||||
NSDraggingItem *dragItem = [[[NSDraggingItem alloc] initWithPasteboardWriter:pbItem] autorelease];
|
||||
NSRect r = {pt, {CGFloat(width), CGFloat(height)}};
|
||||
[dragItem setDraggingFrame:r contents:image];
|
||||
[myview beginDraggingSessionWithItems:[NSArray arrayWithObject:dragItem] event:theEvent source:myview];
|
||||
CFRelease(text);
|
||||
[localPool release];
|
||||
return true;
|
||||
|
||||
@ -117,26 +117,10 @@ static NSOpenGLPixelFormat* mode_to_NSOpenGLPixelFormat(int m, const int *alistp
|
||||
attribs[n++] = NSOpenGLPFASampleBuffers; attribs[n++] = (NSOpenGLPixelFormatAttribute)1;
|
||||
attribs[n++] = NSOpenGLPFASamples; attribs[n++] = (NSOpenGLPixelFormatAttribute)4;
|
||||
}
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
|
||||
#define NSOpenGLPFAOpenGLProfile (NSOpenGLPixelFormatAttribute)99
|
||||
#define kCGLPFAOpenGLProfile NSOpenGLPFAOpenGLProfile
|
||||
#define NSOpenGLProfileVersionLegacy (NSOpenGLPixelFormatAttribute)0x1000
|
||||
#define NSOpenGLProfileVersion3_2Core (NSOpenGLPixelFormatAttribute)0x3200
|
||||
#define kCGLOGLPVersion_Legacy NSOpenGLProfileVersionLegacy
|
||||
#endif
|
||||
if (fl_mac_os_version >= 100700) {
|
||||
attribs[n++] = NSOpenGLPFAOpenGLProfile;
|
||||
attribs[n++] = (m & FL_OPENGL3) ? NSOpenGLProfileVersion3_2Core : NSOpenGLProfileVersionLegacy;
|
||||
}
|
||||
attribs[n++] = NSOpenGLPFAOpenGLProfile;
|
||||
attribs[n++] = (m & FL_OPENGL3) ? NSOpenGLProfileVersion3_2Core : NSOpenGLProfileVersionLegacy;
|
||||
} else {
|
||||
while (alistp[n] && n < 30) {
|
||||
if (alistp[n] == kCGLPFAOpenGLProfile) {
|
||||
if (fl_mac_os_version < 100700) {
|
||||
if (alistp[n+1] != kCGLOGLPVersion_Legacy) return nil;
|
||||
n += 2;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
attribs[n] = (NSOpenGLPixelFormatAttribute)alistp[n];
|
||||
n++;
|
||||
}
|
||||
@ -189,12 +173,7 @@ static NSOpenGLContext *create_GLcontext_for_window(
|
||||
if (shared_ctx && !context) context = [[NSOpenGLContext alloc] initWithFormat:pixelformat shareContext:nil];
|
||||
if (context) {
|
||||
NSView *view = [fl_xid(window) contentView];
|
||||
if (view && fl_mac_os_version >= 100700) {
|
||||
//replaces [view setWantsBestResolutionOpenGLSurface:YES] without compiler warning
|
||||
typedef void (*bestResolutionIMP)(id, SEL, BOOL);
|
||||
static bestResolutionIMP addr = (bestResolutionIMP)[NSView instanceMethodForSelector:@selector(setWantsBestResolutionOpenGLSurface:)];
|
||||
addr(view, @selector(setWantsBestResolutionOpenGLSurface:), Fl::use_high_res_GL() != 0);
|
||||
}
|
||||
[view setWantsBestResolutionOpenGLSurface:(Fl::use_high_res_GL() != 0)];
|
||||
[context setView:view];
|
||||
if (Fl_Cocoa_Window_Driver::driver(window)->subRect()) {
|
||||
remove_gl_context_opacity(context);
|
||||
@ -272,11 +251,9 @@ void Fl_Cocoa_Gl_Window_Driver::after_show() {
|
||||
[shared_gl1_ctxt retain];
|
||||
}
|
||||
[view addSubview:gl1view];
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
||||
if (fl_mac_os_version >= 100700 && Fl::use_high_res_GL()) {
|
||||
if (Fl::use_high_res_GL()) {
|
||||
[gl1view setWantsBestResolutionOpenGLSurface:YES];
|
||||
}
|
||||
#endif
|
||||
[gl1ctxt setView:gl1view];
|
||||
remove_gl_context_opacity(gl1ctxt);
|
||||
}
|
||||
@ -284,7 +261,7 @@ void Fl_Cocoa_Gl_Window_Driver::after_show() {
|
||||
|
||||
float Fl_Cocoa_Gl_Window_Driver::pixels_per_unit()
|
||||
{
|
||||
int retina = (fl_mac_os_version >= 100700 && Fl::use_high_res_GL() && Fl_X::flx(pWindow) &&
|
||||
int retina = (Fl::use_high_res_GL() && Fl_X::flx(pWindow) &&
|
||||
Fl_Cocoa_Window_Driver::driver(pWindow)->mapped_to_retina()) ? 2 : 1;
|
||||
return retina * Fl_Graphics_Driver::default_driver().scale();
|
||||
}
|
||||
|
||||
@ -85,30 +85,6 @@ void Fl_Cocoa_Window_Driver::draw_begin()
|
||||
|
||||
void Fl_Cocoa_Window_Driver::draw_end()
|
||||
{
|
||||
// on OS X, windows have no frame. Before OS X 10.7, to resize a window, we drag the lower right
|
||||
// corner. This code draws a little ribbed triangle for dragging.
|
||||
if (fl_mac_os_version < 100700 && !parent() && is_resizable()) {
|
||||
int minw, minh, maxw, maxh, set;
|
||||
set = pWindow->get_size_range(&minw, &minh, &maxw, &maxh, NULL, NULL, NULL);
|
||||
if (!set || minh != maxh || minw != maxw) {
|
||||
int dx = Fl::box_dw(pWindow->box())-Fl::box_dx(pWindow->box());
|
||||
int dy = Fl::box_dh(pWindow->box())-Fl::box_dy(pWindow->box());
|
||||
if (dx<=0) dx = 1;
|
||||
if (dy<=0) dy = 1;
|
||||
int x1 = w()-dx-1, x2 = x1, y1 = h()-dx-1, y2 = y1;
|
||||
Fl_Color c[4] = {
|
||||
pWindow->color(),
|
||||
fl_color_average(pWindow->color(), FL_WHITE, 0.7f),
|
||||
fl_color_average(pWindow->color(), FL_BLACK, 0.6f),
|
||||
fl_color_average(pWindow->color(), FL_BLACK, 0.8f),
|
||||
};
|
||||
int i;
|
||||
for (i=dx; i<12; i++) {
|
||||
fl_color(c[i&3]);
|
||||
fl_line(x1--, y1, x2, y2--);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Fl_Surface_Device::surface()->driver()->has_feature(Fl_Graphics_Driver::NATIVE)) {
|
||||
CGContextRef my_gc = (CGContextRef)Fl_Surface_Device::surface()->driver()->gc();
|
||||
if (shape_data_) CGContextRestoreGState(my_gc);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user