diff options
| author | Jan Djärv | 2015-05-15 16:21:59 +0200 |
|---|---|---|
| committer | Jan Djärv | 2015-05-15 16:23:44 +0200 |
| commit | e0e0753505cc2efefcee16bbed99ec6b9e5bcb39 (patch) | |
| tree | c34a9973a17919fe937ae5591c3d99c4e4a58ecb | |
| parent | 2abfe21de9241aea36f7221184886b6b39f7648b (diff) | |
| download | emacs-e0e0753505cc2efefcee16bbed99ec6b9e5bcb39.tar.gz emacs-e0e0753505cc2efefcee16bbed99ec6b9e5bcb39.zip | |
Fix warnings on OSX 10.10.
* nsfns.m (MODAL_OK_RESPONSE): New define for different OSX versions.
(Fns_read_file_name): Check against MODAL_OK_RESPONSE.
(compute_tip_xy): Use convertRectToScreen for OSX >= 10.7
* nsmenu.m (initWithContentRect:styleMask:backing:defer:)
* nsimage.m (allocInitFromFile, setPixmapData): Only call
setScalesWhenResized for OSX < 10.6.
* nsterm.h (EmacsScroller): Declare scrollerWidth.
* nsterm.m (ns_copy_bits): New function that does not use deprecated
NSCopyBits.
(ns_scroll_run, ns_shift_glyphs_for_insert): Call ns_copy_bits.
(runAlertPanel): New function.
(applicationShouldTerminate:): Call runAlertPanel.
(initFrameFromEmacs, toggleFullScreen:): Only call useOptimizedDrawing
for OSX < 10.10.
(initFrameFromEmacs:): Only call allocateGState for OSX < 10.10.
(windowWillUseStandardFrame:defaultFrame:): Cast arg to abs to int.
(draggingEntered:): Returns NSDragOperation.
(scrollerWidth): Use scrollerWidthForControlSize for OSX >= 10.7.
| -rw-r--r-- | src/nsfns.m | 20 | ||||
| -rw-r--r-- | src/nsimage.m | 8 | ||||
| -rw-r--r-- | src/nsmenu.m | 4 | ||||
| -rw-r--r-- | src/nsterm.h | 1 | ||||
| -rw-r--r-- | src/nsterm.m | 83 |
5 files changed, 95 insertions, 21 deletions
diff --git a/src/nsfns.m b/src/nsfns.m index f8863e6d400..5f584e1c1bb 100644 --- a/src/nsfns.m +++ b/src/nsfns.m | |||
| @@ -1455,6 +1455,15 @@ ns_run_file_dialog (void) | |||
| 1455 | ns_fd_data.panel = nil; | 1455 | ns_fd_data.panel = nil; |
| 1456 | } | 1456 | } |
| 1457 | 1457 | ||
| 1458 | #ifdef NS_IMPL_COCOA | ||
| 1459 | #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_9 | ||
| 1460 | #define MODAL_OK_RESPONSE NSModalResponseOK | ||
| 1461 | #endif | ||
| 1462 | #endif | ||
| 1463 | #ifndef MODAL_OK_RESPONSE | ||
| 1464 | #define MODAL_OK_RESPONSE NSOKButton | ||
| 1465 | #endif | ||
| 1466 | |||
| 1458 | DEFUN ("ns-read-file-name", Fns_read_file_name, Sns_read_file_name, 1, 5, 0, | 1467 | DEFUN ("ns-read-file-name", Fns_read_file_name, Sns_read_file_name, 1, 5, 0, |
| 1459 | doc: /* Use a graphical panel to read a file name, using prompt PROMPT. | 1468 | doc: /* Use a graphical panel to read a file name, using prompt PROMPT. |
| 1460 | Optional arg DIR, if non-nil, supplies a default directory. | 1469 | Optional arg DIR, if non-nil, supplies a default directory. |
| @@ -1549,7 +1558,7 @@ Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */) | |||
| 1549 | while (ns_fd_data.panel != nil) | 1558 | while (ns_fd_data.panel != nil) |
| 1550 | [NSApp run]; | 1559 | [NSApp run]; |
| 1551 | 1560 | ||
| 1552 | ret = (ns_fd_data.ret == NSOKButton); | 1561 | ret = (ns_fd_data.ret == MODAL_OK_RESPONSE); |
| 1553 | 1562 | ||
| 1554 | if (ret) | 1563 | if (ret) |
| 1555 | { | 1564 | { |
| @@ -2677,7 +2686,16 @@ compute_tip_xy (struct frame *f, | |||
| 2677 | pt.y = dpyinfo->last_mouse_motion_y; | 2686 | pt.y = dpyinfo->last_mouse_motion_y; |
| 2678 | /* Convert to screen coordinates */ | 2687 | /* Convert to screen coordinates */ |
| 2679 | pt = [view convertPoint: pt toView: nil]; | 2688 | pt = [view convertPoint: pt toView: nil]; |
| 2689 | #if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 | ||
| 2680 | pt = [[view window] convertBaseToScreen: pt]; | 2690 | pt = [[view window] convertBaseToScreen: pt]; |
| 2691 | #else | ||
| 2692 | { | ||
| 2693 | NSRect r = NSMakeRect (pt.x, pt.y, 0, 0); | ||
| 2694 | r = [[view window] convertRectToScreen: r]; | ||
| 2695 | pt.x = r.origin.x; | ||
| 2696 | pt.y = r.origin.y; | ||
| 2697 | } | ||
| 2698 | #endif | ||
| 2681 | } | 2699 | } |
| 2682 | else | 2700 | else |
| 2683 | { | 2701 | { |
diff --git a/src/nsimage.m b/src/nsimage.m index 3e90226cbf6..4d01419edf9 100644 --- a/src/nsimage.m +++ b/src/nsimage.m | |||
| @@ -187,7 +187,11 @@ ns_set_alpha (void *img, int x, int y, unsigned char a) | |||
| 187 | 187 | ||
| 188 | /* The next two lines cause the DPI of the image to be ignored. | 188 | /* The next two lines cause the DPI of the image to be ignored. |
| 189 | This seems to be the behavior users expect. */ | 189 | This seems to be the behavior users expect. */ |
| 190 | #ifdef NS_IMPL_COCOA | ||
| 191 | #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 | ||
| 190 | [image setScalesWhenResized: YES]; | 192 | [image setScalesWhenResized: YES]; |
| 193 | #endif | ||
| 194 | #endif | ||
| 191 | [image setSize: NSMakeSize([imgRep pixelsWide], [imgRep pixelsHigh])]; | 195 | [image setSize: NSMakeSize([imgRep pixelsWide], [imgRep pixelsHigh])]; |
| 192 | 196 | ||
| 193 | [image setName: [NSString stringWithUTF8String: SSDATA (file)]]; | 197 | [image setName: [NSString stringWithUTF8String: SSDATA (file)]]; |
| @@ -353,7 +357,11 @@ ns_set_alpha (void *img, int x, int y, unsigned char a) | |||
| 353 | 357 | ||
| 354 | /* The next two lines cause the DPI of the image to be ignored. | 358 | /* The next two lines cause the DPI of the image to be ignored. |
| 355 | This seems to be the behavior users expect. */ | 359 | This seems to be the behavior users expect. */ |
| 360 | #ifdef NS_IMPL_COCOA | ||
| 361 | #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 | ||
| 356 | [self setScalesWhenResized: YES]; | 362 | [self setScalesWhenResized: YES]; |
| 363 | #endif | ||
| 364 | #endif | ||
| 357 | [self setSize: NSMakeSize([bmr pixelsWide], [bmr pixelsHigh])]; | 365 | [self setSize: NSMakeSize([bmr pixelsWide], [bmr pixelsHigh])]; |
| 358 | 366 | ||
| 359 | break; | 367 | break; |
diff --git a/src/nsmenu.m b/src/nsmenu.m index 26fe26e5e0d..a4c26fe82ba 100644 --- a/src/nsmenu.m +++ b/src/nsmenu.m | |||
| @@ -1506,7 +1506,11 @@ ns_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents) | |||
| 1506 | area.size.width = ICONSIZE; | 1506 | area.size.width = ICONSIZE; |
| 1507 | area.size.height= ICONSIZE; | 1507 | area.size.height= ICONSIZE; |
| 1508 | img = [[NSImage imageNamed: @"NSApplicationIcon"] copy]; | 1508 | img = [[NSImage imageNamed: @"NSApplicationIcon"] copy]; |
| 1509 | #ifdef NS_IMPL_COCOA | ||
| 1510 | #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6 | ||
| 1509 | [img setScalesWhenResized: YES]; | 1511 | [img setScalesWhenResized: YES]; |
| 1512 | #endif | ||
| 1513 | #endif | ||
| 1510 | [img setSize: NSMakeSize (ICONSIZE, ICONSIZE)]; | 1514 | [img setSize: NSMakeSize (ICONSIZE, ICONSIZE)]; |
| 1511 | imgView = [[NSImageView alloc] initWithFrame: area]; | 1515 | imgView = [[NSImageView alloc] initWithFrame: area]; |
| 1512 | [imgView setImage: img]; | 1516 | [imgView setImage: img]; |
diff --git a/src/nsterm.h b/src/nsterm.h index d8ffd93a71b..c06b7c49a6d 100644 --- a/src/nsterm.h +++ b/src/nsterm.h | |||
| @@ -396,6 +396,7 @@ typedef float EmacsCGFloat; | |||
| 396 | - condemn; | 396 | - condemn; |
| 397 | - reprieve; | 397 | - reprieve; |
| 398 | - (bool)judge; | 398 | - (bool)judge; |
| 399 | + (CGFloat)scrollerWidth; | ||
| 399 | @end | 400 | @end |
| 400 | 401 | ||
| 401 | 402 | ||
diff --git a/src/nsterm.m b/src/nsterm.m index 6a4d0a6ad23..11656a780ce 100644 --- a/src/nsterm.m +++ b/src/nsterm.m | |||
| @@ -2093,6 +2093,18 @@ ns_clear_frame_area (struct frame *f, int x, int y, int width, int height) | |||
| 2093 | return; | 2093 | return; |
| 2094 | } | 2094 | } |
| 2095 | 2095 | ||
| 2096 | static void | ||
| 2097 | ns_copy_bits (struct frame *f, NSRect src, NSRect dest) | ||
| 2098 | { | ||
| 2099 | if (FRAME_NS_VIEW (f)) | ||
| 2100 | { | ||
| 2101 | ns_focus (f, &dest, 1); | ||
| 2102 | [FRAME_NS_VIEW (f) scrollRect: src | ||
| 2103 | by: NSMakeSize (dest.origin.x - src.origin.x, | ||
| 2104 | dest.origin.y - src.origin.y)]; | ||
| 2105 | ns_unfocus (f); | ||
| 2106 | } | ||
| 2107 | } | ||
| 2096 | 2108 | ||
| 2097 | static void | 2109 | static void |
| 2098 | ns_scroll_run (struct window *w, struct run *run) | 2110 | ns_scroll_run (struct window *w, struct run *run) |
| @@ -2145,11 +2157,8 @@ ns_scroll_run (struct window *w, struct run *run) | |||
| 2145 | { | 2157 | { |
| 2146 | NSRect srcRect = NSMakeRect (x, from_y, width, height); | 2158 | NSRect srcRect = NSMakeRect (x, from_y, width, height); |
| 2147 | NSRect dstRect = NSMakeRect (x, to_y, width, height); | 2159 | NSRect dstRect = NSMakeRect (x, to_y, width, height); |
| 2148 | NSPoint dstOrigin = NSMakePoint (x, to_y); | ||
| 2149 | 2160 | ||
| 2150 | ns_focus (f, &dstRect, 1); | 2161 | ns_copy_bits (f, srcRect , dstRect); |
| 2151 | NSCopyBits (0, srcRect , dstOrigin); | ||
| 2152 | ns_unfocus (f); | ||
| 2153 | } | 2162 | } |
| 2154 | 2163 | ||
| 2155 | unblock_input (); | 2164 | unblock_input (); |
| @@ -2205,13 +2214,10 @@ ns_shift_glyphs_for_insert (struct frame *f, | |||
| 2205 | { | 2214 | { |
| 2206 | NSRect srcRect = NSMakeRect (x, y, width, height); | 2215 | NSRect srcRect = NSMakeRect (x, y, width, height); |
| 2207 | NSRect dstRect = NSMakeRect (x+shift_by, y, width, height); | 2216 | NSRect dstRect = NSMakeRect (x+shift_by, y, width, height); |
| 2208 | NSPoint dstOrigin = dstRect.origin; | ||
| 2209 | 2217 | ||
| 2210 | NSTRACE (ns_shift_glyphs_for_insert); | 2218 | NSTRACE (ns_shift_glyphs_for_insert); |
| 2211 | 2219 | ||
| 2212 | ns_focus (f, &dstRect, 1); | 2220 | ns_copy_bits (f, srcRect, dstRect); |
| 2213 | NSCopyBits (0, srcRect, dstOrigin); | ||
| 2214 | ns_unfocus (f); | ||
| 2215 | } | 2221 | } |
| 2216 | 2222 | ||
| 2217 | 2223 | ||
| @@ -4886,21 +4892,43 @@ ns_term_shutdown (int sig) | |||
| 4886 | EV_TRAILER ((id)nil); | 4892 | EV_TRAILER ((id)nil); |
| 4887 | } | 4893 | } |
| 4888 | 4894 | ||
| 4895 | static bool | ||
| 4896 | runAlertPanel(NSString *title, | ||
| 4897 | NSString *msgFormat, | ||
| 4898 | NSString *defaultButton, | ||
| 4899 | NSString *alternateButton) | ||
| 4900 | { | ||
| 4901 | #if !defined (NS_IMPL_COCOA) || \ | ||
| 4902 | MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_9 | ||
| 4903 | return NSRunAlertPanel(title, msgFormat, defaultButton, alternateButton, nil) | ||
| 4904 | == NSAlertDefaultReturn; | ||
| 4905 | #else | ||
| 4906 | NSAlert *alert = [[NSAlert alloc] init]; | ||
| 4907 | [alert setAlertStyle: NSCriticalAlertStyle]; | ||
| 4908 | [alert setMessageText: msgFormat]; | ||
| 4909 | [alert addButtonWithTitle: defaultButton]; | ||
| 4910 | [alert addButtonWithTitle: alternateButton]; | ||
| 4911 | NSInteger ret = [alert runModal]; | ||
| 4912 | [alert release]; | ||
| 4913 | return ret == NSAlertFirstButtonReturn; | ||
| 4914 | #endif | ||
| 4915 | } | ||
| 4916 | |||
| 4889 | 4917 | ||
| 4890 | - (NSApplicationTerminateReply)applicationShouldTerminate: (id)sender | 4918 | - (NSApplicationTerminateReply)applicationShouldTerminate: (id)sender |
| 4891 | { | 4919 | { |
| 4892 | int ret; | 4920 | bool ret; |
| 4893 | 4921 | ||
| 4894 | if (NILP (ns_confirm_quit)) // || ns_shutdown_properly --> TO DO | 4922 | if (NILP (ns_confirm_quit)) // || ns_shutdown_properly --> TO DO |
| 4895 | return NSTerminateNow; | 4923 | return NSTerminateNow; |
| 4896 | 4924 | ||
| 4897 | ret = NSRunAlertPanel(ns_app_name, | 4925 | ret = runAlertPanel(ns_app_name, |
| 4898 | @"Exit requested. Would you like to Save Buffers and Exit, or Cancel the request?", | 4926 | @"Exit requested. Would you like to Save Buffers and Exit, or Cancel the request?", |
| 4899 | @"Save Buffers and Exit", @"Cancel", nil); | 4927 | @"Save Buffers and Exit", @"Cancel"); |
| 4900 | 4928 | ||
| 4901 | if (ret == NSAlertDefaultReturn) | 4929 | if (ret) |
| 4902 | return NSTerminateNow; | 4930 | return NSTerminateNow; |
| 4903 | else if (ret == NSAlertAlternateReturn) | 4931 | else |
| 4904 | return NSTerminateCancel; | 4932 | return NSTerminateCancel; |
| 4905 | return NSTerminateNow; /* just in case */ | 4933 | return NSTerminateNow; /* just in case */ |
| 4906 | } | 4934 | } |
| @@ -6251,8 +6279,10 @@ if (cols > 0 && rows > 0) | |||
| 6251 | 6279 | ||
| 6252 | [win setAcceptsMouseMovedEvents: YES]; | 6280 | [win setAcceptsMouseMovedEvents: YES]; |
| 6253 | [win setDelegate: self]; | 6281 | [win setDelegate: self]; |
| 6282 | #if !defined (NS_IMPL_COCOA) || \ | ||
| 6283 | MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_9 | ||
| 6254 | [win useOptimizedDrawing: YES]; | 6284 | [win useOptimizedDrawing: YES]; |
| 6255 | 6285 | #endif | |
| 6256 | sz.width = frame_resize_pixelwise ? 1 : FRAME_COLUMN_WIDTH (f); | 6286 | sz.width = frame_resize_pixelwise ? 1 : FRAME_COLUMN_WIDTH (f); |
| 6257 | sz.height = frame_resize_pixelwise ? 1 : FRAME_LINE_HEIGHT (f); | 6287 | sz.height = frame_resize_pixelwise ? 1 : FRAME_LINE_HEIGHT (f); |
| 6258 | [win setResizeIncrements: sz]; | 6288 | [win setResizeIncrements: sz]; |
| @@ -6313,8 +6343,10 @@ if (cols > 0 && rows > 0) | |||
| 6313 | if ([col alphaComponent] != (EmacsCGFloat) 1.0) | 6343 | if ([col alphaComponent] != (EmacsCGFloat) 1.0) |
| 6314 | [win setOpaque: NO]; | 6344 | [win setOpaque: NO]; |
| 6315 | 6345 | ||
| 6346 | #if !defined (NS_IMPL_COCOA) || \ | ||
| 6347 | MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_9 | ||
| 6316 | [self allocateGState]; | 6348 | [self allocateGState]; |
| 6317 | 6349 | #endif | |
| 6318 | [NSApp registerServicesMenuSendTypes: ns_send_types | 6350 | [NSApp registerServicesMenuSendTypes: ns_send_types |
| 6319 | returnTypes: nil]; | 6351 | returnTypes: nil]; |
| 6320 | 6352 | ||
| @@ -6369,7 +6401,7 @@ if (cols > 0 && rows > 0) | |||
| 6369 | } | 6401 | } |
| 6370 | else if (next_maximized == FULLSCREEN_HEIGHT | 6402 | else if (next_maximized == FULLSCREEN_HEIGHT |
| 6371 | || (next_maximized == -1 | 6403 | || (next_maximized == -1 |
| 6372 | && abs (defaultFrame.size.height - result.size.height) | 6404 | && abs ((int)(defaultFrame.size.height - result.size.height)) |
| 6373 | > FRAME_LINE_HEIGHT (emacsframe))) | 6405 | > FRAME_LINE_HEIGHT (emacsframe))) |
| 6374 | { | 6406 | { |
| 6375 | /* first click */ | 6407 | /* first click */ |
| @@ -6392,7 +6424,7 @@ if (cols > 0 && rows > 0) | |||
| 6392 | } | 6424 | } |
| 6393 | else if (next_maximized == FULLSCREEN_MAXIMIZED | 6425 | else if (next_maximized == FULLSCREEN_MAXIMIZED |
| 6394 | || (next_maximized == -1 | 6426 | || (next_maximized == -1 |
| 6395 | && abs (defaultFrame.size.width - result.size.width) | 6427 | && abs ((int)(defaultFrame.size.width - result.size.width)) |
| 6396 | > FRAME_COLUMN_WIDTH (emacsframe))) | 6428 | > FRAME_COLUMN_WIDTH (emacsframe))) |
| 6397 | { | 6429 | { |
| 6398 | result = defaultFrame; /* second click */ | 6430 | result = defaultFrame; /* second click */ |
| @@ -6639,7 +6671,10 @@ if (cols > 0 && rows > 0) | |||
| 6639 | [fw setTitle:[w title]]; | 6671 | [fw setTitle:[w title]]; |
| 6640 | [fw setDelegate:self]; | 6672 | [fw setDelegate:self]; |
| 6641 | [fw setAcceptsMouseMovedEvents: YES]; | 6673 | [fw setAcceptsMouseMovedEvents: YES]; |
| 6674 | #if !defined (NS_IMPL_COCOA) || \ | ||
| 6675 | MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_9 | ||
| 6642 | [fw useOptimizedDrawing: YES]; | 6676 | [fw useOptimizedDrawing: YES]; |
| 6677 | #endif | ||
| 6643 | [fw setResizeIncrements: sz]; | 6678 | [fw setResizeIncrements: sz]; |
| 6644 | [fw setBackgroundColor: col]; | 6679 | [fw setBackgroundColor: col]; |
| 6645 | if ([col alphaComponent] != (EmacsCGFloat) 1.0) | 6680 | if ([col alphaComponent] != (EmacsCGFloat) 1.0) |
| @@ -6882,7 +6917,7 @@ if (cols > 0 && rows > 0) | |||
| 6882 | /* NSDraggingDestination protocol methods. Actually this is not really a | 6917 | /* NSDraggingDestination protocol methods. Actually this is not really a |
| 6883 | protocol, but a category of Object. O well... */ | 6918 | protocol, but a category of Object. O well... */ |
| 6884 | 6919 | ||
| 6885 | -(NSUInteger) draggingEntered: (id <NSDraggingInfo>) sender | 6920 | -(NSDragOperation) draggingEntered: (id <NSDraggingInfo>) sender |
| 6886 | { | 6921 | { |
| 6887 | NSTRACE (draggingEntered); | 6922 | NSTRACE (draggingEntered); |
| 6888 | return NSDragOperationGeneric; | 6923 | return NSDragOperationGeneric; |
| @@ -7263,7 +7298,15 @@ if (cols > 0 && rows > 0) | |||
| 7263 | { | 7298 | { |
| 7264 | /* TODO: if we want to allow variable widths, this is the place to do it, | 7299 | /* TODO: if we want to allow variable widths, this is the place to do it, |
| 7265 | however neither GNUstep nor Cocoa support it very well */ | 7300 | however neither GNUstep nor Cocoa support it very well */ |
| 7266 | return [NSScroller scrollerWidth]; | 7301 | CGFloat r; |
| 7302 | #if !defined (NS_IMPL_COCOA) || \ | ||
| 7303 | MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 | ||
| 7304 | r = [NSScroller scrollerWidth]; | ||
| 7305 | #else | ||
| 7306 | r = [NSScroller scrollerWidthForControlSize: NSRegularControlSize | ||
| 7307 | scrollerStyle: NSScrollerStyleLegacy]; | ||
| 7308 | #endif | ||
| 7309 | return r; | ||
| 7267 | } | 7310 | } |
| 7268 | 7311 | ||
| 7269 | 7312 | ||