Commit 9624f609 authored by Alan Third's avatar Alan Third

Fix some deprecation notices on macOS 10.14

* src/nsimage.m ([EmacsImage setXBMColor:]): Replace colorSpaceName
code.
* src/nsmenu.m ([EmacsDialogPanel initWithContentRect:styleMask:]):
Remove reference to oneShot.
* src/nsterm.h (ns_enable_screen_updates): Remove function prototype.
(NSPasteboardTypeString):
(NSPasteboardTypeTabularText):
(NSControlStateValueOn):
(NSControlStateValueOff):
(NSBezelStyleRounded):
(NSPasteboardTypeURL): Define new names and replace all callers.
* src/nsterm.m ([EmacsColor colorUsingDefaultColorSpace]): Replace
calls to colorUsingColorSpaceName on macOS > 10.7.
([EmacsView performDragOperation:]): Add FIXME about deprecation.
(ns_disable_screen_updates):
(ns_enable_screen_updates): Remove functions and all callers.
(disable_screen_updates_count): Remove variable.
* src/macfont.m (macfont_draw): Use CGContext instead of graphicsPort
on macOS >= 10.10
parent cb367c8e
Pipeline #1769 failed with stage
in 51 minutes and 4 seconds
......@@ -2818,7 +2818,18 @@ So we use CTFontDescriptorCreateMatchingFontDescriptor (no
}
}
context = [[NSGraphicsContext currentContext] graphicsPort];
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
if ([[NSGraphicsContext currentContext] respondsToSelector:@selector(CGContext)])
#endif
context = [[NSGraphicsContext currentContext] CGContext];
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
else
#endif
#endif
#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
context = [[NSGraphicsContext currentContext] graphicsPort];
#endif
CGContextSaveGState (context);
if (!CGRectIsNull (background_rect))
......
......@@ -313,8 +313,8 @@ - (instancetype)setXBMColor: (NSColor *)color
if (bmRep == nil || color == nil)
return self;
if ([color colorSpaceName] != NSCalibratedRGBColorSpace)
rgbColor = [color colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
if ([color colorSpace] != [NSColorSpace deviceRGBColorSpace])
rgbColor = [color colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]];
else
rgbColor = color;
......
......@@ -668,9 +668,9 @@ - (NSMenuItem *)addItemWithWidgetValue: (void *)wvptr
/* Draw radio buttons and tickboxes. */
if (wv->selected && (wv->button_type == BUTTON_TYPE_TOGGLE ||
wv->button_type == BUTTON_TYPE_RADIO))
[item setState: NSOnState];
[item setState: NSControlStateValueOn];
else
[item setState: NSOffState];
[item setState: NSControlStateValueOff];
[item setTag: (NSInteger)wv->call_data];
}
......@@ -1594,7 +1594,7 @@ - (instancetype)initWithContentRect: (NSRect)contentRect styleMask: (NSWindowSty
[cell setBordered: NO];
[cell setEnabled: NO];
[cell setCellAttribute: NSCellIsInsetButton to: 8];
[cell setBezelStyle: NSRoundedBezelStyle];
[cell setBezelStyle: NSBezelStyleRounded];
matrix = [[NSMatrix alloc] initWithFrame: contentRect
mode: NSHighlightModeMatrix
......@@ -1607,7 +1607,6 @@ - (instancetype)initWithContentRect: (NSRect)contentRect styleMask: (NSWindowSty
[matrix autorelease];
[[self contentView] addSubview: matrix];
[self setOneShot: YES];
[self setReleasedWhenClosed: YES];
[self setHidesOnDeactivate: YES];
return self;
......
......@@ -57,7 +57,7 @@ Updated by Christian Limpach (chris@nice.ch)
if (EQ (sym, QCLIPBOARD)) return NSPasteboardNameGeneral;
if (EQ (sym, QPRIMARY)) return NXPrimaryPboard;
if (EQ (sym, QSECONDARY)) return NXSecondaryPboard;
if (EQ (sym, QTEXT)) return NSStringPboardType;
if (EQ (sym, QTEXT)) return NSPasteboardTypeString;
return [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (sym))];
}
......@@ -76,11 +76,11 @@ Updated by Christian Limpach (chris@nice.ch)
return QPRIMARY;
if ([t isEqualToString: NXSecondaryPboard])
return QSECONDARY;
if ([t isEqualToString: NSStringPboardType])
if ([t isEqualToString: NSPasteboardTypeString])
return QTEXT;
if ([t isEqualToString: NSFilenamesPboardType])
return QFILE_NAME;
if ([t isEqualToString: NSTabularTextPboardType])
if ([t isEqualToString: NSPasteboardTypeTabularText])
return QTEXT;
return intern ([t UTF8String]);
}
......@@ -193,7 +193,7 @@ Updated by Christian Limpach (chris@nice.ch)
else
{
// Used for ns-own-selection-internal.
eassert (gtype == NSStringPboardType);
eassert (gtype == NSPasteboardTypeString);
[pb setString: nsStr forType: gtype];
}
[nsStr release];
......@@ -345,7 +345,7 @@ Updated by Christian Limpach (chris@nice.ch)
}
/* We only support copy of text. */
type = NSStringPboardType;
type = NSPasteboardTypeString;
target_symbol = ns_string_to_symbol (type);
if (STRINGP (value))
{
......@@ -472,9 +472,9 @@ Updated by Christian Limpach (chris@nice.ch)
[NSNumber numberWithLong:0], NSPasteboardNameGeneral,
[NSNumber numberWithLong:0], NXPrimaryPboard,
[NSNumber numberWithLong:0], NXSecondaryPboard,
[NSNumber numberWithLong:0], NSStringPboardType,
[NSNumber numberWithLong:0], NSPasteboardTypeString,
[NSNumber numberWithLong:0], NSFilenamesPboardType,
[NSNumber numberWithLong:0], NSTabularTextPboardType,
[NSNumber numberWithLong:0], NSPasteboardTypeTabularText,
nil] retain];
}
......
......@@ -1165,10 +1165,6 @@ extern void ns_release_autorelease_pool (void *);
extern const char *ns_get_defaults_value (const char *key);
extern void ns_init_locale (void);
#ifdef NS_IMPL_COCOA
extern void ns_enable_screen_updates (void);
#endif
/* in nsmenu */
extern void update_frame_tool_bar (struct frame *f);
extern void free_frame_tool_bar (struct frame *f);
......@@ -1336,4 +1332,14 @@ enum NSWindowTabbingMode
/* Deprecated in macOS 10.13. */
#define NSPasteboardNameGeneral NSGeneralPboard
#endif
#if !defined (NS_IMPL_COCOA) || !defined (MAC_OS_X_VERSION_10_14)
/* Deprecated in macOS 10.14. */
#define NSPasteboardTypeString NSStringPboardType
#define NSPasteboardTypeTabularText NSTabularTextPboardType
#define NSPasteboardTypeURL NSURLPboardType
#define NSControlStateValueOn NSOnState
#define NSControlStateValueOff NSOffState
#define NSBezelStyleRounded NSRoundedBezelStyle
#endif
#endif /* HAVE_NS */
......@@ -160,20 +160,28 @@ + (NSColor *)colorForEmacsRed:(CGFloat)red green:(CGFloat)green
- (NSColor *)colorUsingDefaultColorSpace
{
/* FIXMES: We're checking for colorWithSRGBRed here so this will
only work in the same place as in the method above. It should
really be a check whether we're on macOS 10.7 or above. */
/* FIXME: We're checking for colorWithSRGBRed here so this will only
work in the same place as in the method above. It should really
be a check whether we're on macOS 10.7 or above. */
#if defined (NS_IMPL_COCOA) \
&& MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
if (ns_use_srgb_colorspace
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
&& [NSColor respondsToSelector:
@selector(colorWithSRGBRed:green:blue:alpha:)]
if ([NSColor respondsToSelector:
@selector(colorWithSRGBRed:green:blue:alpha:)])
#endif
)
return [self colorUsingColorSpace: [NSColorSpace sRGBColorSpace]];
{
if (ns_use_srgb_colorspace)
return [self colorUsingColorSpace: [NSColorSpace sRGBColorSpace]];
else
return [self colorUsingColorSpace: [NSColorSpace deviceRGBColorSpace]];
}
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
else
#endif
#endif /* NS_IMPL_COCOA && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 */
#if defined (NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MIN_REQUIRED < 1070
return [self colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
#endif
}
@end
......@@ -283,9 +291,6 @@ - (NSColor *)colorUsingDefaultColorSpace
static BOOL ns_fake_keydown = NO;
#ifdef NS_IMPL_COCOA
static BOOL ns_menu_bar_is_hidden = NO;
/* The number of times NSDisableScreenUpdates has been called. */
static int disable_screen_updates_count = 0;
#endif
/* static int debug_lock = 0; */
......@@ -688,40 +693,6 @@ Free a pool and temporary objects it refers to (callable from C)
}
#ifdef NS_IMPL_COCOA
/* Disabling screen updates can be used to make several actions appear
"atomic" to the end user. It seems some actions can still update
the display, though.
When we re-enable screen updates the number of calls to
NSEnableScreenUpdates should match the number to
NSDisableScreenUpdates.
We use these functions to prevent the user seeing a blank frame
after it has been resized. ns_set_window_size disables updates and
when redisplay completes unwind_redisplay enables them again
(bug#30699). */
static void
ns_disable_screen_updates (void)
{
NSDisableScreenUpdates ();
disable_screen_updates_count++;
}
void
ns_enable_screen_updates (void)
/* Re-enable screen updates. Called from unwind_redisplay. */
{
while (disable_screen_updates_count > 0)
{
NSEnableScreenUpdates ();
disable_screen_updates_count--;
}
}
#endif
static BOOL
ns_menu_bar_should_be_hidden (void)
/* True, if the menu bar should be hidden. */
......@@ -1779,15 +1750,6 @@ Hide the window (X11 semantics)
block_input ();
#ifdef NS_IMPL_COCOA
/* To prevent showing the user a blank frame, stop updates being
flushed to the screen until after redisplay has completed. This
breaks live resize (resizing with a mouse), so don't do it if
we're in a live resize loop. */
if (![view inLiveResize])
ns_disable_screen_updates ();
#endif
if (pixelwise)
{
pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width);
......@@ -5459,14 +5421,14 @@ Needs to be here because ns_initialize_display_info () uses AppKit classes.
NSTRACE_MSG ("Input/output types");
ns_send_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] retain];
ns_return_types = [[NSArray arrayWithObjects: NSStringPboardType, nil]
ns_send_types = [[NSArray arrayWithObjects: NSPasteboardTypeString, nil] retain];
ns_return_types = [[NSArray arrayWithObjects: NSPasteboardTypeString, nil]
retain];
ns_drag_types = [[NSArray arrayWithObjects:
NSStringPboardType,
NSTabularTextPboardType,
NSPasteboardTypeString,
NSPasteboardTypeTabularText,
NSFilenamesPboardType,
NSURLPboardType, nil] retain];
NSPasteboardTypeURL, nil] retain];
/* If fullscreen is in init/default-frame-alist, focus isn't set
right for fullscreen windows, so set this. */
......@@ -8276,6 +8238,9 @@ -(BOOL)performDragOperation: (id <NSDraggingInfo>) sender
{
return NO;
}
/* FIXME: NSFilenamesPboardType is deprecated in 10.14, but the
NSURL method can only handle one file at a time. Stick with the
existing code at the moment. */
else if ([type isEqualToString: NSFilenamesPboardType])
{
NSArray *files;
......@@ -8370,8 +8335,8 @@ - (BOOL) writeSelectionToPasteboard: (NSPasteboard *)pb types: (NSArray *)types
NSTRACE ("[EmacsView writeSelectionToPasteboard:types:]");
/* We only support NSStringPboardType. */
if ([types containsObject:NSStringPboardType] == NO) {
/* We only support NSPasteboardTypeString. */
if ([types containsObject:NSPasteboardTypeString] == NO) {
return NO;
}
......@@ -8385,7 +8350,7 @@ - (BOOL) writeSelectionToPasteboard: (NSPasteboard *)pb types: (NSArray *)types
if (! STRINGP (val))
return NO;
typesDeclared = [NSArray arrayWithObject:NSStringPboardType];
typesDeclared = [NSArray arrayWithObject:NSPasteboardTypeString];
[pb declareTypes:typesDeclared owner:nil];
ns_string_to_pasteboard (pb, val);
return YES;
......@@ -9047,10 +9012,12 @@ - (void)mouseDown: (NSEvent *)e
last_hit_part = horizontal ? scroll_bar_before_handle : scroll_bar_above_handle; break;
case NSScrollerIncrementPage:
last_hit_part = horizontal ? scroll_bar_after_handle : scroll_bar_below_handle; break;
#if defined (NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MIN_REQUIRED < 1070
case NSScrollerDecrementLine:
last_hit_part = horizontal ? scroll_bar_left_arrow : scroll_bar_up_arrow; break;
case NSScrollerIncrementLine:
last_hit_part = horizontal ? scroll_bar_right_arrow : scroll_bar_down_arrow; break;
#endif
case NSScrollerKnob:
last_hit_part = horizontal ? scroll_bar_horizontal_handle : scroll_bar_handle; break;
case NSScrollerKnobSlot: /* GNUstep-only */
......
......@@ -13986,12 +13986,6 @@ redisplay_internal (void)
#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS)
if (popup_activated ())
{
#ifdef NS_IMPL_COCOA
/* On macOS we may have disabled screen updates due to window
resizing. We should re-enable them so the popup can be
displayed. */
ns_enable_screen_updates ();
#endif
return;
}
#endif
......@@ -14794,12 +14788,6 @@ unwind_redisplay (void)
{
redisplaying_p = false;
unblock_buffer_flips ();
#ifdef NS_IMPL_COCOA
/* On macOS we may have disabled screen updates due to window
resizing. When redisplay completes we want to re-enable
them. */
ns_enable_screen_updates ();
#endif
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment