summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ChangeLog23
-rw-r--r--src/nsfns.m9
-rw-r--r--src/nsmenu.m1
-rw-r--r--src/nsselect.m2
-rw-r--r--src/nsterm.h8
-rw-r--r--src/nsterm.m46
6 files changed, 77 insertions, 12 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 4cacc677c23..c925b323499 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,26 @@
+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
diff --git a/src/nsfns.m b/src/nsfns.m
index cdf350066be..d124f61a4f2 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -1728,8 +1728,8 @@ terminate Emacs if we can't open the connection.
/* 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,
@@ -1876,6 +1876,10 @@ DEFUN ("ns-list-services", Fns_list_services, Sns_list_services, 0, 0, 0,
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;
@@ -1919,6 +1923,7 @@ DEFUN ("ns-list-services", Fns_list_services, Sns_list_services, 0, 0, 0,
ret = interpret_services_menu (svcs, Qnil, ret);
return ret;
+#endif
}
diff --git a/src/nsmenu.m b/src/nsmenu.m
index 2a2f952e751..0d25b82d5b5 100644
--- a/src/nsmenu.m
+++ b/src/nsmenu.m
@@ -457,7 +457,6 @@ ns_update_menubar (struct frame *f, int deep_p, EmacsMenu *submenu)
{
/* but we need to make sure it will update on demand */
[svcsMenu setFrame: f];
- [svcsMenu setDelegate: svcsMenu];
}
else
#endif
diff --git a/src/nsselect.m b/src/nsselect.m
index 950fb1f1f14..aeb2a3e3a99 100644
--- a/src/nsselect.m
+++ b/src/nsselect.m
@@ -175,7 +175,7 @@ ns_string_to_pasteboard_internal (id pb, Lisp_Object str, NSString *gtype)
}
-static Lisp_Object
+Lisp_Object
ns_get_local_selection (Lisp_Object selection_name,
Lisp_Object target_type)
{
diff --git a/src/nsterm.h b/src/nsterm.h
index 7459087c988..b442973f0d9 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -25,6 +25,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#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__
/* ==========================================================================
@@ -700,6 +706,8 @@ extern void check_ns (void);
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);
diff --git a/src/nsterm.m b/src/nsterm.m
index 52e0dc6c2a8..ac95409ee7e 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. */
@@ -5364,6 +5365,9 @@ ns_term_shutdown (int sig)
[self allocateGState];
+ [NSApp registerServicesMenuSendTypes: ns_send_types
+ returnTypes: ns_return_types];
+
ns_window_num++;
return self;
}
@@ -5735,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];
@@ -5765,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;
}
@@ -6390,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));