aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Third2019-04-02 21:49:36 +0100
committerAlan Third2019-05-21 20:57:33 +0100
commit9624f609493da7c08016ba00d6895bad0fe26a0e (patch)
tree766d6c8f60ad8e4d3053502de12634f960717e39 /src
parentcb367c8e0d4a881acf8255e1ff6bdd6442efb538 (diff)
downloademacs-9624f609493da7c08016ba00d6895bad0fe26a0e.tar.gz
emacs-9624f609493da7c08016ba00d6895bad0fe26a0e.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/macfont.m13
-rw-r--r--src/nsimage.m4
-rw-r--r--src/nsmenu.m7
-rw-r--r--src/nsselect.m14
-rw-r--r--src/nsterm.h14
-rw-r--r--src/nsterm.m91
-rw-r--r--src/xdisp.c12
7 files changed, 63 insertions, 92 deletions
diff --git a/src/macfont.m b/src/macfont.m
index d69af679813..f825e6291d3 100644
--- a/src/macfont.m
+++ b/src/macfont.m
@@ -2818,7 +2818,18 @@ macfont_draw (struct glyph_string *s, int from, int to, int x, int y,
2818 } 2818 }
2819 } 2819 }
2820 2820
2821 context = [[NSGraphicsContext currentContext] graphicsPort]; 2821#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000
2822#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
2823 if ([[NSGraphicsContext currentContext] respondsToSelector:@selector(CGContext)])
2824#endif
2825 context = [[NSGraphicsContext currentContext] CGContext];
2826#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
2827 else
2828#endif
2829#endif
2830#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000
2831 context = [[NSGraphicsContext currentContext] graphicsPort];
2832#endif
2822 CGContextSaveGState (context); 2833 CGContextSaveGState (context);
2823 2834
2824 if (!CGRectIsNull (background_rect)) 2835 if (!CGRectIsNull (background_rect))
diff --git a/src/nsimage.m b/src/nsimage.m
index 33236c48d42..0249d22acae 100644
--- a/src/nsimage.m
+++ b/src/nsimage.m
@@ -313,8 +313,8 @@ ns_set_alpha (void *img, int x, int y, unsigned char a)
313 if (bmRep == nil || color == nil) 313 if (bmRep == nil || color == nil)
314 return self; 314 return self;
315 315
316 if ([color colorSpaceName] != NSCalibratedRGBColorSpace) 316 if ([color colorSpace] != [NSColorSpace deviceRGBColorSpace])
317 rgbColor = [color colorUsingColorSpaceName: NSCalibratedRGBColorSpace]; 317 rgbColor = [color colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]];
318 else 318 else
319 rgbColor = color; 319 rgbColor = color;
320 320
diff --git a/src/nsmenu.m b/src/nsmenu.m
index fd1323344b3..3fe06cda02a 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -668,9 +668,9 @@ ns_activate_menubar (struct frame *f)
668 /* Draw radio buttons and tickboxes. */ 668 /* Draw radio buttons and tickboxes. */
669 if (wv->selected && (wv->button_type == BUTTON_TYPE_TOGGLE || 669 if (wv->selected && (wv->button_type == BUTTON_TYPE_TOGGLE ||
670 wv->button_type == BUTTON_TYPE_RADIO)) 670 wv->button_type == BUTTON_TYPE_RADIO))
671 [item setState: NSOnState]; 671 [item setState: NSControlStateValueOn];
672 else 672 else
673 [item setState: NSOffState]; 673 [item setState: NSControlStateValueOff];
674 674
675 [item setTag: (NSInteger)wv->call_data]; 675 [item setTag: (NSInteger)wv->call_data];
676 } 676 }
@@ -1594,7 +1594,7 @@ ns_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents)
1594 [cell setBordered: NO]; 1594 [cell setBordered: NO];
1595 [cell setEnabled: NO]; 1595 [cell setEnabled: NO];
1596 [cell setCellAttribute: NSCellIsInsetButton to: 8]; 1596 [cell setCellAttribute: NSCellIsInsetButton to: 8];
1597 [cell setBezelStyle: NSRoundedBezelStyle]; 1597 [cell setBezelStyle: NSBezelStyleRounded];
1598 1598
1599 matrix = [[NSMatrix alloc] initWithFrame: contentRect 1599 matrix = [[NSMatrix alloc] initWithFrame: contentRect
1600 mode: NSHighlightModeMatrix 1600 mode: NSHighlightModeMatrix
@@ -1607,7 +1607,6 @@ ns_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents)
1607 [matrix autorelease]; 1607 [matrix autorelease];
1608 1608
1609 [[self contentView] addSubview: matrix]; 1609 [[self contentView] addSubview: matrix];
1610 [self setOneShot: YES];
1611 [self setReleasedWhenClosed: YES]; 1610 [self setReleasedWhenClosed: YES];
1612 [self setHidesOnDeactivate: YES]; 1611 [self setHidesOnDeactivate: YES];
1613 return self; 1612 return self;
diff --git a/src/nsselect.m b/src/nsselect.m
index cf36c869eb1..b044fe6f32d 100644
--- a/src/nsselect.m
+++ b/src/nsselect.m
@@ -57,7 +57,7 @@ symbol_to_nsstring (Lisp_Object sym)
57 if (EQ (sym, QCLIPBOARD)) return NSPasteboardNameGeneral; 57 if (EQ (sym, QCLIPBOARD)) return NSPasteboardNameGeneral;
58 if (EQ (sym, QPRIMARY)) return NXPrimaryPboard; 58 if (EQ (sym, QPRIMARY)) return NXPrimaryPboard;
59 if (EQ (sym, QSECONDARY)) return NXSecondaryPboard; 59 if (EQ (sym, QSECONDARY)) return NXSecondaryPboard;
60 if (EQ (sym, QTEXT)) return NSStringPboardType; 60 if (EQ (sym, QTEXT)) return NSPasteboardTypeString;
61 return [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (sym))]; 61 return [NSString stringWithUTF8String: SSDATA (SYMBOL_NAME (sym))];
62} 62}
63 63
@@ -76,11 +76,11 @@ ns_string_to_symbol (NSString *t)
76 return QPRIMARY; 76 return QPRIMARY;
77 if ([t isEqualToString: NXSecondaryPboard]) 77 if ([t isEqualToString: NXSecondaryPboard])
78 return QSECONDARY; 78 return QSECONDARY;
79 if ([t isEqualToString: NSStringPboardType]) 79 if ([t isEqualToString: NSPasteboardTypeString])
80 return QTEXT; 80 return QTEXT;
81 if ([t isEqualToString: NSFilenamesPboardType]) 81 if ([t isEqualToString: NSFilenamesPboardType])
82 return QFILE_NAME; 82 return QFILE_NAME;
83 if ([t isEqualToString: NSTabularTextPboardType]) 83 if ([t isEqualToString: NSPasteboardTypeTabularText])
84 return QTEXT; 84 return QTEXT;
85 return intern ([t UTF8String]); 85 return intern ([t UTF8String]);
86} 86}
@@ -193,7 +193,7 @@ ns_string_to_pasteboard_internal (id pb, Lisp_Object str, NSString *gtype)
193 else 193 else
194 { 194 {
195 // Used for ns-own-selection-internal. 195 // Used for ns-own-selection-internal.
196 eassert (gtype == NSStringPboardType); 196 eassert (gtype == NSPasteboardTypeString);
197 [pb setString: nsStr forType: gtype]; 197 [pb setString: nsStr forType: gtype];
198 } 198 }
199 [nsStr release]; 199 [nsStr release];
@@ -345,7 +345,7 @@ anything that the functions on `selection-converter-alist' know about. */)
345 } 345 }
346 346
347 /* We only support copy of text. */ 347 /* We only support copy of text. */
348 type = NSStringPboardType; 348 type = NSPasteboardTypeString;
349 target_symbol = ns_string_to_symbol (type); 349 target_symbol = ns_string_to_symbol (type);
350 if (STRINGP (value)) 350 if (STRINGP (value))
351 { 351 {
@@ -472,9 +472,9 @@ nxatoms_of_nsselect (void)
472 [NSNumber numberWithLong:0], NSPasteboardNameGeneral, 472 [NSNumber numberWithLong:0], NSPasteboardNameGeneral,
473 [NSNumber numberWithLong:0], NXPrimaryPboard, 473 [NSNumber numberWithLong:0], NXPrimaryPboard,
474 [NSNumber numberWithLong:0], NXSecondaryPboard, 474 [NSNumber numberWithLong:0], NXSecondaryPboard,
475 [NSNumber numberWithLong:0], NSStringPboardType, 475 [NSNumber numberWithLong:0], NSPasteboardTypeString,
476 [NSNumber numberWithLong:0], NSFilenamesPboardType, 476 [NSNumber numberWithLong:0], NSFilenamesPboardType,
477 [NSNumber numberWithLong:0], NSTabularTextPboardType, 477 [NSNumber numberWithLong:0], NSPasteboardTypeTabularText,
478 nil] retain]; 478 nil] retain];
479} 479}
480 480
diff --git a/src/nsterm.h b/src/nsterm.h
index 66e12720401..1e56276ca3c 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -1165,10 +1165,6 @@ extern void ns_release_autorelease_pool (void *);
1165extern const char *ns_get_defaults_value (const char *key); 1165extern const char *ns_get_defaults_value (const char *key);
1166extern void ns_init_locale (void); 1166extern void ns_init_locale (void);
1167 1167
1168#ifdef NS_IMPL_COCOA
1169extern void ns_enable_screen_updates (void);
1170#endif
1171
1172/* in nsmenu */ 1168/* in nsmenu */
1173extern void update_frame_tool_bar (struct frame *f); 1169extern void update_frame_tool_bar (struct frame *f);
1174extern void free_frame_tool_bar (struct frame *f); 1170extern void free_frame_tool_bar (struct frame *f);
@@ -1336,4 +1332,14 @@ enum NSWindowTabbingMode
1336/* Deprecated in macOS 10.13. */ 1332/* Deprecated in macOS 10.13. */
1337#define NSPasteboardNameGeneral NSGeneralPboard 1333#define NSPasteboardNameGeneral NSGeneralPboard
1338#endif 1334#endif
1335
1336#if !defined (NS_IMPL_COCOA) || !defined (MAC_OS_X_VERSION_10_14)
1337/* Deprecated in macOS 10.14. */
1338#define NSPasteboardTypeString NSStringPboardType
1339#define NSPasteboardTypeTabularText NSTabularTextPboardType
1340#define NSPasteboardTypeURL NSURLPboardType
1341#define NSControlStateValueOn NSOnState
1342#define NSControlStateValueOff NSOffState
1343#define NSBezelStyleRounded NSRoundedBezelStyle
1344#endif
1339#endif /* HAVE_NS */ 1345#endif /* HAVE_NS */
diff --git a/src/nsterm.m b/src/nsterm.m
index a927c5f6463..0cae5e9d448 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -160,20 +160,28 @@ char const * nstrace_fullscreen_type_name (int fs_type)
160 160
161- (NSColor *)colorUsingDefaultColorSpace 161- (NSColor *)colorUsingDefaultColorSpace
162{ 162{
163 /* FIXMES: We're checking for colorWithSRGBRed here so this will 163 /* FIXME: We're checking for colorWithSRGBRed here so this will only
164 only work in the same place as in the method above. It should 164 work in the same place as in the method above. It should really
165 really be a check whether we're on macOS 10.7 or above. */ 165 be a check whether we're on macOS 10.7 or above. */
166#if defined (NS_IMPL_COCOA) \ 166#if defined (NS_IMPL_COCOA) \
167 && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 167 && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070
168 if (ns_use_srgb_colorspace
169#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070 168#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
170 && [NSColor respondsToSelector: 169 if ([NSColor respondsToSelector:
171 @selector(colorWithSRGBRed:green:blue:alpha:)] 170 @selector(colorWithSRGBRed:green:blue:alpha:)])
172#endif 171#endif
173 ) 172 {
174 return [self colorUsingColorSpace: [NSColorSpace sRGBColorSpace]]; 173 if (ns_use_srgb_colorspace)
174 return [self colorUsingColorSpace: [NSColorSpace sRGBColorSpace]];
175 else
176 return [self colorUsingColorSpace: [NSColorSpace deviceRGBColorSpace]];
177 }
178#if MAC_OS_X_VERSION_MIN_REQUIRED < 1070
179 else
175#endif 180#endif
181#endif /* NS_IMPL_COCOA && MAC_OS_X_VERSION_MAX_ALLOWED >= 1070 */
182#if defined (NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MIN_REQUIRED < 1070
176 return [self colorUsingColorSpaceName: NSCalibratedRGBColorSpace]; 183 return [self colorUsingColorSpaceName: NSCalibratedRGBColorSpace];
184#endif
177} 185}
178 186
179@end 187@end
@@ -283,9 +291,6 @@ static int ns_window_num = 0;
283static BOOL ns_fake_keydown = NO; 291static BOOL ns_fake_keydown = NO;
284#ifdef NS_IMPL_COCOA 292#ifdef NS_IMPL_COCOA
285static BOOL ns_menu_bar_is_hidden = NO; 293static BOOL ns_menu_bar_is_hidden = NO;
286
287/* The number of times NSDisableScreenUpdates has been called. */
288static int disable_screen_updates_count = 0;
289#endif 294#endif
290/* static int debug_lock = 0; */ 295/* static int debug_lock = 0; */
291 296
@@ -688,40 +693,6 @@ ns_release_autorelease_pool (void *pool)
688} 693}
689 694
690 695
691#ifdef NS_IMPL_COCOA
692/* Disabling screen updates can be used to make several actions appear
693 "atomic" to the end user. It seems some actions can still update
694 the display, though.
695
696 When we re-enable screen updates the number of calls to
697 NSEnableScreenUpdates should match the number to
698 NSDisableScreenUpdates.
699
700 We use these functions to prevent the user seeing a blank frame
701 after it has been resized. ns_set_window_size disables updates and
702 when redisplay completes unwind_redisplay enables them again
703 (bug#30699). */
704
705static void
706ns_disable_screen_updates (void)
707{
708 NSDisableScreenUpdates ();
709 disable_screen_updates_count++;
710}
711
712void
713ns_enable_screen_updates (void)
714/* Re-enable screen updates. Called from unwind_redisplay. */
715{
716 while (disable_screen_updates_count > 0)
717 {
718 NSEnableScreenUpdates ();
719 disable_screen_updates_count--;
720 }
721}
722#endif
723
724
725static BOOL 696static BOOL
726ns_menu_bar_should_be_hidden (void) 697ns_menu_bar_should_be_hidden (void)
727/* True, if the menu bar should be hidden. */ 698/* True, if the menu bar should be hidden. */
@@ -1779,15 +1750,6 @@ ns_set_window_size (struct frame *f,
1779 1750
1780 block_input (); 1751 block_input ();
1781 1752
1782#ifdef NS_IMPL_COCOA
1783 /* To prevent showing the user a blank frame, stop updates being
1784 flushed to the screen until after redisplay has completed. This
1785 breaks live resize (resizing with a mouse), so don't do it if
1786 we're in a live resize loop. */
1787 if (![view inLiveResize])
1788 ns_disable_screen_updates ();
1789#endif
1790
1791 if (pixelwise) 1753 if (pixelwise)
1792 { 1754 {
1793 pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width); 1755 pixelwidth = FRAME_TEXT_TO_PIXEL_WIDTH (f, width);
@@ -5459,14 +5421,14 @@ ns_term_init (Lisp_Object display_name)
5459 5421
5460 NSTRACE_MSG ("Input/output types"); 5422 NSTRACE_MSG ("Input/output types");
5461 5423
5462 ns_send_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] retain]; 5424 ns_send_types = [[NSArray arrayWithObjects: NSPasteboardTypeString, nil] retain];
5463 ns_return_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] 5425 ns_return_types = [[NSArray arrayWithObjects: NSPasteboardTypeString, nil]
5464 retain]; 5426 retain];
5465 ns_drag_types = [[NSArray arrayWithObjects: 5427 ns_drag_types = [[NSArray arrayWithObjects:
5466 NSStringPboardType, 5428 NSPasteboardTypeString,
5467 NSTabularTextPboardType, 5429 NSPasteboardTypeTabularText,
5468 NSFilenamesPboardType, 5430 NSFilenamesPboardType,
5469 NSURLPboardType, nil] retain]; 5431 NSPasteboardTypeURL, nil] retain];
5470 5432
5471 /* If fullscreen is in init/default-frame-alist, focus isn't set 5433 /* If fullscreen is in init/default-frame-alist, focus isn't set
5472 right for fullscreen windows, so set this. */ 5434 right for fullscreen windows, so set this. */
@@ -8276,6 +8238,9 @@ not_in_argv (NSString *arg)
8276 { 8238 {
8277 return NO; 8239 return NO;
8278 } 8240 }
8241 /* FIXME: NSFilenamesPboardType is deprecated in 10.14, but the
8242 NSURL method can only handle one file at a time. Stick with the
8243 existing code at the moment. */
8279 else if ([type isEqualToString: NSFilenamesPboardType]) 8244 else if ([type isEqualToString: NSFilenamesPboardType])
8280 { 8245 {
8281 NSArray *files; 8246 NSArray *files;
@@ -8370,8 +8335,8 @@ not_in_argv (NSString *arg)
8370 8335
8371 NSTRACE ("[EmacsView writeSelectionToPasteboard:types:]"); 8336 NSTRACE ("[EmacsView writeSelectionToPasteboard:types:]");
8372 8337
8373 /* We only support NSStringPboardType. */ 8338 /* We only support NSPasteboardTypeString. */
8374 if ([types containsObject:NSStringPboardType] == NO) { 8339 if ([types containsObject:NSPasteboardTypeString] == NO) {
8375 return NO; 8340 return NO;
8376 } 8341 }
8377 8342
@@ -8385,7 +8350,7 @@ not_in_argv (NSString *arg)
8385 if (! STRINGP (val)) 8350 if (! STRINGP (val))
8386 return NO; 8351 return NO;
8387 8352
8388 typesDeclared = [NSArray arrayWithObject:NSStringPboardType]; 8353 typesDeclared = [NSArray arrayWithObject:NSPasteboardTypeString];
8389 [pb declareTypes:typesDeclared owner:nil]; 8354 [pb declareTypes:typesDeclared owner:nil];
8390 ns_string_to_pasteboard (pb, val); 8355 ns_string_to_pasteboard (pb, val);
8391 return YES; 8356 return YES;
@@ -9047,10 +9012,12 @@ not_in_argv (NSString *arg)
9047 last_hit_part = horizontal ? scroll_bar_before_handle : scroll_bar_above_handle; break; 9012 last_hit_part = horizontal ? scroll_bar_before_handle : scroll_bar_above_handle; break;
9048 case NSScrollerIncrementPage: 9013 case NSScrollerIncrementPage:
9049 last_hit_part = horizontal ? scroll_bar_after_handle : scroll_bar_below_handle; break; 9014 last_hit_part = horizontal ? scroll_bar_after_handle : scroll_bar_below_handle; break;
9015#if defined (NS_IMPL_GNUSTEP) || MAC_OS_X_VERSION_MIN_REQUIRED < 1070
9050 case NSScrollerDecrementLine: 9016 case NSScrollerDecrementLine:
9051 last_hit_part = horizontal ? scroll_bar_left_arrow : scroll_bar_up_arrow; break; 9017 last_hit_part = horizontal ? scroll_bar_left_arrow : scroll_bar_up_arrow; break;
9052 case NSScrollerIncrementLine: 9018 case NSScrollerIncrementLine:
9053 last_hit_part = horizontal ? scroll_bar_right_arrow : scroll_bar_down_arrow; break; 9019 last_hit_part = horizontal ? scroll_bar_right_arrow : scroll_bar_down_arrow; break;
9020#endif
9054 case NSScrollerKnob: 9021 case NSScrollerKnob:
9055 last_hit_part = horizontal ? scroll_bar_horizontal_handle : scroll_bar_handle; break; 9022 last_hit_part = horizontal ? scroll_bar_horizontal_handle : scroll_bar_handle; break;
9056 case NSScrollerKnobSlot: /* GNUstep-only */ 9023 case NSScrollerKnobSlot: /* GNUstep-only */
diff --git a/src/xdisp.c b/src/xdisp.c
index c561ea9e36c..9eed74cb98a 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -13986,12 +13986,6 @@ redisplay_internal (void)
13986#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS) 13986#if defined (USE_X_TOOLKIT) || defined (USE_GTK) || defined (HAVE_NS)
13987 if (popup_activated ()) 13987 if (popup_activated ())
13988 { 13988 {
13989#ifdef NS_IMPL_COCOA
13990 /* On macOS we may have disabled screen updates due to window
13991 resizing. We should re-enable them so the popup can be
13992 displayed. */
13993 ns_enable_screen_updates ();
13994#endif
13995 return; 13989 return;
13996 } 13990 }
13997#endif 13991#endif
@@ -14794,12 +14788,6 @@ unwind_redisplay (void)
14794{ 14788{
14795 redisplaying_p = false; 14789 redisplaying_p = false;
14796 unblock_buffer_flips (); 14790 unblock_buffer_flips ();
14797#ifdef NS_IMPL_COCOA
14798 /* On macOS we may have disabled screen updates due to window
14799 resizing. When redisplay completes we want to re-enable
14800 them. */
14801 ns_enable_screen_updates ();
14802#endif
14803} 14791}
14804 14792
14805 14793