1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-02-04 14:40:54 -08:00

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.
This commit is contained in:
Jan Djärv 2015-05-15 16:21:59 +02:00
parent 2abfe21de9
commit e0e0753505
5 changed files with 95 additions and 21 deletions

View file

@ -1455,6 +1455,15 @@ ns_run_file_dialog (void)
ns_fd_data.panel = nil;
}
#ifdef NS_IMPL_COCOA
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_9
#define MODAL_OK_RESPONSE NSModalResponseOK
#endif
#endif
#ifndef MODAL_OK_RESPONSE
#define MODAL_OK_RESPONSE NSOKButton
#endif
DEFUN ("ns-read-file-name", Fns_read_file_name, Sns_read_file_name, 1, 5, 0,
doc: /* Use a graphical panel to read a file name, using prompt PROMPT.
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. */)
while (ns_fd_data.panel != nil)
[NSApp run];
ret = (ns_fd_data.ret == NSOKButton);
ret = (ns_fd_data.ret == MODAL_OK_RESPONSE);
if (ret)
{
@ -2677,7 +2686,16 @@ compute_tip_xy (struct frame *f,
pt.y = dpyinfo->last_mouse_motion_y;
/* Convert to screen coordinates */
pt = [view convertPoint: pt toView: nil];
#if !defined (NS_IMPL_COCOA) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
pt = [[view window] convertBaseToScreen: pt];
#else
{
NSRect r = NSMakeRect (pt.x, pt.y, 0, 0);
r = [[view window] convertRectToScreen: r];
pt.x = r.origin.x;
pt.y = r.origin.y;
}
#endif
}
else
{

View file

@ -187,7 +187,11 @@ ns_set_alpha (void *img, int x, int y, unsigned char a)
/* The next two lines cause the DPI of the image to be ignored.
This seems to be the behavior users expect. */
#ifdef NS_IMPL_COCOA
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6
[image setScalesWhenResized: YES];
#endif
#endif
[image setSize: NSMakeSize([imgRep pixelsWide], [imgRep pixelsHigh])];
[image setName: [NSString stringWithUTF8String: SSDATA (file)]];
@ -353,7 +357,11 @@ ns_set_alpha (void *img, int x, int y, unsigned char a)
/* The next two lines cause the DPI of the image to be ignored.
This seems to be the behavior users expect. */
#ifdef NS_IMPL_COCOA
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6
[self setScalesWhenResized: YES];
#endif
#endif
[self setSize: NSMakeSize([bmr pixelsWide], [bmr pixelsHigh])];
break;

View file

@ -1506,7 +1506,11 @@ ns_popup_dialog (struct frame *f, Lisp_Object header, Lisp_Object contents)
area.size.width = ICONSIZE;
area.size.height= ICONSIZE;
img = [[NSImage imageNamed: @"NSApplicationIcon"] copy];
#ifdef NS_IMPL_COCOA
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6
[img setScalesWhenResized: YES];
#endif
#endif
[img setSize: NSMakeSize (ICONSIZE, ICONSIZE)];
imgView = [[NSImageView alloc] initWithFrame: area];
[imgView setImage: img];

View file

@ -396,6 +396,7 @@ typedef float EmacsCGFloat;
- condemn;
- reprieve;
- (bool)judge;
+ (CGFloat)scrollerWidth;
@end

View file

@ -2093,6 +2093,18 @@ ns_clear_frame_area (struct frame *f, int x, int y, int width, int height)
return;
}
static void
ns_copy_bits (struct frame *f, NSRect src, NSRect dest)
{
if (FRAME_NS_VIEW (f))
{
ns_focus (f, &dest, 1);
[FRAME_NS_VIEW (f) scrollRect: src
by: NSMakeSize (dest.origin.x - src.origin.x,
dest.origin.y - src.origin.y)];
ns_unfocus (f);
}
}
static void
ns_scroll_run (struct window *w, struct run *run)
@ -2145,11 +2157,8 @@ ns_scroll_run (struct window *w, struct run *run)
{
NSRect srcRect = NSMakeRect (x, from_y, width, height);
NSRect dstRect = NSMakeRect (x, to_y, width, height);
NSPoint dstOrigin = NSMakePoint (x, to_y);
ns_focus (f, &dstRect, 1);
NSCopyBits (0, srcRect , dstOrigin);
ns_unfocus (f);
ns_copy_bits (f, srcRect , dstRect);
}
unblock_input ();
@ -2205,13 +2214,10 @@ ns_shift_glyphs_for_insert (struct frame *f,
{
NSRect srcRect = NSMakeRect (x, y, width, height);
NSRect dstRect = NSMakeRect (x+shift_by, y, width, height);
NSPoint dstOrigin = dstRect.origin;
NSTRACE (ns_shift_glyphs_for_insert);
ns_focus (f, &dstRect, 1);
NSCopyBits (0, srcRect, dstOrigin);
ns_unfocus (f);
ns_copy_bits (f, srcRect, dstRect);
}
@ -4886,21 +4892,43 @@ ns_term_shutdown (int sig)
EV_TRAILER ((id)nil);
}
static bool
runAlertPanel(NSString *title,
NSString *msgFormat,
NSString *defaultButton,
NSString *alternateButton)
{
#if !defined (NS_IMPL_COCOA) || \
MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_9
return NSRunAlertPanel(title, msgFormat, defaultButton, alternateButton, nil)
== NSAlertDefaultReturn;
#else
NSAlert *alert = [[NSAlert alloc] init];
[alert setAlertStyle: NSCriticalAlertStyle];
[alert setMessageText: msgFormat];
[alert addButtonWithTitle: defaultButton];
[alert addButtonWithTitle: alternateButton];
NSInteger ret = [alert runModal];
[alert release];
return ret == NSAlertFirstButtonReturn;
#endif
}
- (NSApplicationTerminateReply)applicationShouldTerminate: (id)sender
{
int ret;
bool ret;
if (NILP (ns_confirm_quit)) // || ns_shutdown_properly --> TO DO
return NSTerminateNow;
ret = NSRunAlertPanel(ns_app_name,
@"Exit requested. Would you like to Save Buffers and Exit, or Cancel the request?",
@"Save Buffers and Exit", @"Cancel", nil);
ret = runAlertPanel(ns_app_name,
@"Exit requested. Would you like to Save Buffers and Exit, or Cancel the request?",
@"Save Buffers and Exit", @"Cancel");
if (ret == NSAlertDefaultReturn)
if (ret)
return NSTerminateNow;
else if (ret == NSAlertAlternateReturn)
else
return NSTerminateCancel;
return NSTerminateNow; /* just in case */
}
@ -6251,8 +6279,10 @@ if (cols > 0 && rows > 0)
[win setAcceptsMouseMovedEvents: YES];
[win setDelegate: self];
#if !defined (NS_IMPL_COCOA) || \
MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_9
[win useOptimizedDrawing: YES];
#endif
sz.width = frame_resize_pixelwise ? 1 : FRAME_COLUMN_WIDTH (f);
sz.height = frame_resize_pixelwise ? 1 : FRAME_LINE_HEIGHT (f);
[win setResizeIncrements: sz];
@ -6313,8 +6343,10 @@ if (cols > 0 && rows > 0)
if ([col alphaComponent] != (EmacsCGFloat) 1.0)
[win setOpaque: NO];
#if !defined (NS_IMPL_COCOA) || \
MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_9
[self allocateGState];
#endif
[NSApp registerServicesMenuSendTypes: ns_send_types
returnTypes: nil];
@ -6369,7 +6401,7 @@ if (cols > 0 && rows > 0)
}
else if (next_maximized == FULLSCREEN_HEIGHT
|| (next_maximized == -1
&& abs (defaultFrame.size.height - result.size.height)
&& abs ((int)(defaultFrame.size.height - result.size.height))
> FRAME_LINE_HEIGHT (emacsframe)))
{
/* first click */
@ -6392,7 +6424,7 @@ if (cols > 0 && rows > 0)
}
else if (next_maximized == FULLSCREEN_MAXIMIZED
|| (next_maximized == -1
&& abs (defaultFrame.size.width - result.size.width)
&& abs ((int)(defaultFrame.size.width - result.size.width))
> FRAME_COLUMN_WIDTH (emacsframe)))
{
result = defaultFrame; /* second click */
@ -6639,7 +6671,10 @@ if (cols > 0 && rows > 0)
[fw setTitle:[w title]];
[fw setDelegate:self];
[fw setAcceptsMouseMovedEvents: YES];
#if !defined (NS_IMPL_COCOA) || \
MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_9
[fw useOptimizedDrawing: YES];
#endif
[fw setResizeIncrements: sz];
[fw setBackgroundColor: col];
if ([col alphaComponent] != (EmacsCGFloat) 1.0)
@ -6882,7 +6917,7 @@ if (cols > 0 && rows > 0)
/* NSDraggingDestination protocol methods. Actually this is not really a
protocol, but a category of Object. O well... */
-(NSUInteger) draggingEntered: (id <NSDraggingInfo>) sender
-(NSDragOperation) draggingEntered: (id <NSDraggingInfo>) sender
{
NSTRACE (draggingEntered);
return NSDragOperationGeneric;
@ -7263,7 +7298,15 @@ if (cols > 0 && rows > 0)
{
/* TODO: if we want to allow variable widths, this is the place to do it,
however neither GNUstep nor Cocoa support it very well */
return [NSScroller scrollerWidth];
CGFloat r;
#if !defined (NS_IMPL_COCOA) || \
MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
r = [NSScroller scrollerWidth];
#else
r = [NSScroller scrollerWidthForControlSize: NSRegularControlSize
scrollerStyle: NSScrollerStyleLegacy];
#endif
return r;
}