X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/40d83b412f584cc02e68d4eac8fd5e6eb769e2fe..1692ae2dd5ff8f6f1fc6f6f62b9a44ab7e615615:/src/nsterm.m diff --git a/src/nsterm.m b/src/nsterm.m index 91f0cbba58..ac95409ee7 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -134,11 +134,12 @@ static unsigned convert_ns_to_X_keysym[] = 0x1B, 0x1B /* escape */ }; - static Lisp_Object Qmodifier_value; Lisp_Object Qalt, Qcontrol, Qhyper, Qmeta, Qsuper, Qnone; extern Lisp_Object Qcursor_color, Qcursor_type, Qns, Qleft; +static Lisp_Object QUTF8_STRING; + /* On OS X picks up the default NSGlobalDomain AppleAntiAliasingThreshold, the maximum font size to NOT antialias. On GNUstep there is currently no way to control this behavior. */ @@ -158,7 +159,7 @@ long context_menu_value = 0; /* display update */ NSPoint last_mouse_motion_position; static NSRect last_mouse_glyph; -static unsigned long last_mouse_movement_time = 0; +static Time last_mouse_movement_time = 0; static Lisp_Object last_mouse_motion_frame; static EmacsScroller *last_mouse_scroll_bar = nil; static struct frame *ns_updating_frame; @@ -583,6 +584,11 @@ ns_menu_bar_should_be_hidden (void) static void ns_update_auto_hide_menu_bar (void) { +#ifndef MAC_OS_X_VERSION_10_6 +#define MAC_OS_X_VERSION_10_6 1060 +#endif +#ifdef NS_IMPL_COCOA +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 BLOCK_INPUT; NSTRACE (ns_update_auto_hide_menu_bar); @@ -615,6 +621,8 @@ ns_update_auto_hide_menu_bar (void) } UNBLOCK_INPUT; +#endif +#endif } @@ -1782,7 +1790,7 @@ note_mouse_movement (struct frame *frame, float x, float y) static void ns_mouse_position (struct frame **fp, int insist, Lisp_Object *bar_window, enum scroll_bar_part *part, Lisp_Object *x, Lisp_Object *y, - unsigned long *time) + Time *time) /* -------------------------------------------------------------------------- External (hook): inform emacs about mouse position and hit parts. If a scrollbar is being dragged, set bar_window, part, x, y, time. @@ -4051,6 +4059,8 @@ ns_term_init (Lisp_Object display_name) void ns_term_shutdown (int sig) { + [[NSUserDefaults standardUserDefaults] synchronize]; + /* code not reached in emacs.c after this is called by shut_down_emacs: */ if (STRINGP (Vauto_save_list_file_name)) unlink (SDATA (Vauto_save_list_file_name)); @@ -5355,6 +5365,9 @@ ns_term_shutdown (int sig) [self allocateGState]; + [NSApp registerServicesMenuSendTypes: ns_send_types + returnTypes: ns_return_types]; + ns_window_num++; return self; } @@ -5726,13 +5739,17 @@ ns_term_shutdown (int sig) } -- validRequestorForSendType: (NSString *)typeSent - returnType: (NSString *)typeReturned +- (id) validRequestorForSendType: (NSString *)typeSent + returnType: (NSString *)typeReturned { NSTRACE (validRequestorForSendType); - if ([ns_send_types indexOfObjectIdenticalTo: typeSent] != NSNotFound && - [ns_return_types indexOfObjectIdenticalTo: typeSent] != NSNotFound) - return self; + if (typeSent != nil && [ns_send_types indexOfObject: typeSent] != NSNotFound + && (typeReturned == nil + || [ns_return_types indexOfObject: typeSent] != NSNotFound)) + { + if (! NILP (ns_get_local_selection (QPRIMARY, QUTF8_STRING))) + return self; + } return [super validRequestorForSendType: typeSent returnType: typeReturned]; @@ -5756,8 +5773,28 @@ ns_term_shutdown (int sig) - (BOOL) writeSelectionToPasteboard: (NSPasteboard *)pb types: (NSArray *)types { - /* supposed to write for as many of types as we are able */ - return NO; + NSArray *typesDeclared; + Lisp_Object val; + + /* We only support NSStringPboardType */ + if ([types containsObject:NSStringPboardType] == NO) { + return NO; + } + + val = ns_get_local_selection (QPRIMARY, QUTF8_STRING); + if (CONSP (val) && SYMBOLP (XCAR (val))) + { + val = XCDR (val); + if (CONSP (val) && NILP (XCDR (val))) + val = XCAR (val); + } + if (! STRINGP (val)) + return NO; + + typesDeclared = [NSArray arrayWithObject:NSStringPboardType]; + [pb declareTypes:typesDeclared owner:nil]; + ns_string_to_pasteboard (pb, val); + return YES; } @@ -6381,6 +6418,8 @@ syms_of_nsterm (void) DEFSYM (Qsuper, "super"); DEFSYM (Qcontrol, "control"); DEFSYM (Qnone, "none"); + DEFSYM (QUTF8_STRING, "UTF8_STRING"); + Fput (Qalt, Qmodifier_value, make_number (alt_modifier)); Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier)); Fput (Qmeta, Qmodifier_value, make_number (meta_modifier)); @@ -6524,5 +6563,3 @@ baseline level. The default value is nil. */); /* Tell emacs about this window system. */ Fprovide (intern ("ns"), Qnil); } - -