aboutsummaryrefslogtreecommitdiffstats
path: root/src/nsterm.m
diff options
context:
space:
mode:
authorJan Djärv2015-05-15 16:21:59 +0200
committerJan Djärv2015-05-15 16:23:44 +0200
commite0e0753505cc2efefcee16bbed99ec6b9e5bcb39 (patch)
treec34a9973a17919fe937ae5591c3d99c4e4a58ecb /src/nsterm.m
parent2abfe21de9241aea36f7221184886b6b39f7648b (diff)
downloademacs-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.
Diffstat (limited to 'src/nsterm.m')
-rw-r--r--src/nsterm.m83
1 files changed, 63 insertions, 20 deletions
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
2096static void
2097ns_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
2097static void 2109static void
2098ns_scroll_run (struct window *w, struct run *run) 2110ns_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
4895static bool
4896runAlertPanel(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