+2011-07-08 Jan Djärv <jan.h.d@swipnet.se>
+
+ * nsselect.m (ns_get_local_selection): Change to extern (Bug#8842).
+
+ * nsmenu.m (ns_update_menubar): Remove useless setDelegate call
+ on svcsMenu (Bug#8842).
+
+ * nsfns.m (Fx_open_connection): Remove NSStringPboardType from
+ ns_return_types.
+ (Fns_list_services): Just return Qnil on 10.6, code not working there.
+
+ * nsterm.m (QUTF8_STRING): Declare.
+ (initFrameFromEmacs): Call registerServicesMenuSendTypes.
+ (validRequestorForSendType): Return type is (id).
+ Change indexOfObjectIdenticalTo to indexOfObject.
+ Check if we have local selection before returning self (Bug#8842).
+ (writeSelectionToPasteboard): Put local selection into paste board
+ if we have a local selection (Bug#8842).
+ (syms_of_nsterm): DEFSYM QUTF8_STRING.
+
+ * nsterm.h (MAC_OS_X_VERSION_10_6): Define here instead of nsterm.m.
+ (ns_get_local_selection): Declare.
+
2011-07-07 Lars Magne Ingebrigtsen <larsi@gnus.org>
* keymap.c (describe_map_tree): Don't insert a double newline at
/* Register our external input/output types, used for determining
applicable services and also drag/drop eligibility. */
- ns_send_types = [[NSArray arrayWithObject: NSStringPboardType] retain];
- ns_return_types = [[NSArray arrayWithObject: NSStringPboardType] retain];
+ ns_send_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] retain];
+ ns_return_types = [[NSArray arrayWithObjects: nil] retain];
ns_drag_types = [[NSArray arrayWithObjects:
NSStringPboardType,
NSTabularTextPboardType,
doc: /* List available Nextstep services by querying NSApp. */)
(void)
{
+#if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+ /* You can't get services like this in 10.6+. */
+ return Qnil;
+#else
Lisp_Object ret = Qnil;
NSMenu *svcs;
id delegate;
ret = interpret_services_menu (svcs, Qnil, ret);
return ret;
+#endif
}
#ifdef HAVE_NS
+#ifdef NS_IMPL_COCOA
+#ifndef MAC_OS_X_VERSION_10_6
+#define MAC_OS_X_VERSION_10_6 1060
+#endif
+#endif
+
#ifdef __OBJC__
/* ==========================================================================
extern Lisp_Object ns_map_event_to_object ();
extern Lisp_Object ns_string_from_pasteboard ();
extern void ns_string_to_pasteboard ();
+extern Lisp_Object ns_get_local_selection (Lisp_Object selection_name,
+ Lisp_Object target_type);
extern void nxatoms_of_nsselect ();
extern int ns_lisp_to_cursor_type ();
extern Lisp_Object ns_cursor_type_to_lisp (int arg);
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. */
[self allocateGState];
+ [NSApp registerServicesMenuSendTypes: ns_send_types
+ returnTypes: ns_return_types];
+
ns_window_num++;
return self;
}
}
-- 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];
- (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;
}
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));