diff options
| author | Jan Djärv | 2011-07-08 10:11:35 +0200 |
|---|---|---|
| committer | Jan Djärv | 2011-07-08 10:11:35 +0200 |
| commit | 699c10bd69f9395a5705b86259b957b7ed75f8ef (patch) | |
| tree | 0f2a8f9fbe20f446f5a94bad6f6296909c5f87d2 /src | |
| parent | d760b73104d0533a222adb058f48da3e4ca61f3f (diff) | |
| download | emacs-699c10bd69f9395a5705b86259b957b7ed75f8ef.tar.gz emacs-699c10bd69f9395a5705b86259b957b7ed75f8ef.zip | |
Fix services menu empty on OSX 1.6+.
* nsfns.m (Fx_open_connection): Remove NSStringPboardType from
ns_return_types.
(Fns_list_services): Just return Qnil on 10.6, code not working there.
* nsmenu.m (ns_update_menubar): Remove useless setDelegate call
on svcsMenu.
* nsselect.m (ns_get_local_selection): Change to extern (Bug#8842).
* nsterm.h (MAC_OS_X_VERSION_10_6): Define here instead of nsterm.m.
(ns_get_local_selection): Declare.
* 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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 23 | ||||
| -rw-r--r-- | src/nsfns.m | 9 | ||||
| -rw-r--r-- | src/nsmenu.m | 1 | ||||
| -rw-r--r-- | src/nsselect.m | 2 | ||||
| -rw-r--r-- | src/nsterm.h | 8 | ||||
| -rw-r--r-- | src/nsterm.m | 46 |
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 @@ | |||
| 1 | 2011-07-08 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * nsselect.m (ns_get_local_selection): Change to extern (Bug#8842). | ||
| 4 | |||
| 5 | * nsmenu.m (ns_update_menubar): Remove useless setDelegate call | ||
| 6 | on svcsMenu (Bug#8842). | ||
| 7 | |||
| 8 | * nsfns.m (Fx_open_connection): Remove NSStringPboardType from | ||
| 9 | ns_return_types. | ||
| 10 | (Fns_list_services): Just return Qnil on 10.6, code not working there. | ||
| 11 | |||
| 12 | * nsterm.m (QUTF8_STRING): Declare. | ||
| 13 | (initFrameFromEmacs): Call registerServicesMenuSendTypes. | ||
| 14 | (validRequestorForSendType): Return type is (id). | ||
| 15 | Change indexOfObjectIdenticalTo to indexOfObject. | ||
| 16 | Check if we have local selection before returning self (Bug#8842). | ||
| 17 | (writeSelectionToPasteboard): Put local selection into paste board | ||
| 18 | if we have a local selection (Bug#8842). | ||
| 19 | (syms_of_nsterm): DEFSYM QUTF8_STRING. | ||
| 20 | |||
| 21 | * nsterm.h (MAC_OS_X_VERSION_10_6): Define here instead of nsterm.m. | ||
| 22 | (ns_get_local_selection): Declare. | ||
| 23 | |||
| 1 | 2011-07-07 Lars Magne Ingebrigtsen <larsi@gnus.org> | 24 | 2011-07-07 Lars Magne Ingebrigtsen <larsi@gnus.org> |
| 2 | 25 | ||
| 3 | * keymap.c (describe_map_tree): Don't insert a double newline at | 26 | * 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. | |||
| 1728 | 1728 | ||
| 1729 | /* Register our external input/output types, used for determining | 1729 | /* Register our external input/output types, used for determining |
| 1730 | applicable services and also drag/drop eligibility. */ | 1730 | applicable services and also drag/drop eligibility. */ |
| 1731 | ns_send_types = [[NSArray arrayWithObject: NSStringPboardType] retain]; | 1731 | ns_send_types = [[NSArray arrayWithObjects: NSStringPboardType, nil] retain]; |
| 1732 | ns_return_types = [[NSArray arrayWithObject: NSStringPboardType] retain]; | 1732 | ns_return_types = [[NSArray arrayWithObjects: nil] retain]; |
| 1733 | ns_drag_types = [[NSArray arrayWithObjects: | 1733 | ns_drag_types = [[NSArray arrayWithObjects: |
| 1734 | NSStringPboardType, | 1734 | NSStringPboardType, |
| 1735 | NSTabularTextPboardType, | 1735 | NSTabularTextPboardType, |
| @@ -1876,6 +1876,10 @@ DEFUN ("ns-list-services", Fns_list_services, Sns_list_services, 0, 0, 0, | |||
| 1876 | doc: /* List available Nextstep services by querying NSApp. */) | 1876 | doc: /* List available Nextstep services by querying NSApp. */) |
| 1877 | (void) | 1877 | (void) |
| 1878 | { | 1878 | { |
| 1879 | #if defined (NS_IMPL_COCOA) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 | ||
| 1880 | /* You can't get services like this in 10.6+. */ | ||
| 1881 | return Qnil; | ||
| 1882 | #else | ||
| 1879 | Lisp_Object ret = Qnil; | 1883 | Lisp_Object ret = Qnil; |
| 1880 | NSMenu *svcs; | 1884 | NSMenu *svcs; |
| 1881 | id delegate; | 1885 | id delegate; |
| @@ -1919,6 +1923,7 @@ DEFUN ("ns-list-services", Fns_list_services, Sns_list_services, 0, 0, 0, | |||
| 1919 | 1923 | ||
| 1920 | ret = interpret_services_menu (svcs, Qnil, ret); | 1924 | ret = interpret_services_menu (svcs, Qnil, ret); |
| 1921 | return ret; | 1925 | return ret; |
| 1926 | #endif | ||
| 1922 | } | 1927 | } |
| 1923 | 1928 | ||
| 1924 | 1929 | ||
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) | |||
| 457 | { | 457 | { |
| 458 | /* but we need to make sure it will update on demand */ | 458 | /* but we need to make sure it will update on demand */ |
| 459 | [svcsMenu setFrame: f]; | 459 | [svcsMenu setFrame: f]; |
| 460 | [svcsMenu setDelegate: svcsMenu]; | ||
| 461 | } | 460 | } |
| 462 | else | 461 | else |
| 463 | #endif | 462 | #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) | |||
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | 177 | ||
| 178 | static Lisp_Object | 178 | Lisp_Object |
| 179 | ns_get_local_selection (Lisp_Object selection_name, | 179 | ns_get_local_selection (Lisp_Object selection_name, |
| 180 | Lisp_Object target_type) | 180 | Lisp_Object target_type) |
| 181 | { | 181 | { |
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/>. */ | |||
| 25 | 25 | ||
| 26 | #ifdef HAVE_NS | 26 | #ifdef HAVE_NS |
| 27 | 27 | ||
| 28 | #ifdef NS_IMPL_COCOA | ||
| 29 | #ifndef MAC_OS_X_VERSION_10_6 | ||
| 30 | #define MAC_OS_X_VERSION_10_6 1060 | ||
| 31 | #endif | ||
| 32 | #endif | ||
| 33 | |||
| 28 | #ifdef __OBJC__ | 34 | #ifdef __OBJC__ |
| 29 | 35 | ||
| 30 | /* ========================================================================== | 36 | /* ========================================================================== |
| @@ -700,6 +706,8 @@ extern void check_ns (void); | |||
| 700 | extern Lisp_Object ns_map_event_to_object (); | 706 | extern Lisp_Object ns_map_event_to_object (); |
| 701 | extern Lisp_Object ns_string_from_pasteboard (); | 707 | extern Lisp_Object ns_string_from_pasteboard (); |
| 702 | extern void ns_string_to_pasteboard (); | 708 | extern void ns_string_to_pasteboard (); |
| 709 | extern Lisp_Object ns_get_local_selection (Lisp_Object selection_name, | ||
| 710 | Lisp_Object target_type); | ||
| 703 | extern void nxatoms_of_nsselect (); | 711 | extern void nxatoms_of_nsselect (); |
| 704 | extern int ns_lisp_to_cursor_type (); | 712 | extern int ns_lisp_to_cursor_type (); |
| 705 | extern Lisp_Object ns_cursor_type_to_lisp (int arg); | 713 | 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[] = | |||
| 134 | 0x1B, 0x1B /* escape */ | 134 | 0x1B, 0x1B /* escape */ |
| 135 | }; | 135 | }; |
| 136 | 136 | ||
| 137 | |||
| 138 | static Lisp_Object Qmodifier_value; | 137 | static Lisp_Object Qmodifier_value; |
| 139 | Lisp_Object Qalt, Qcontrol, Qhyper, Qmeta, Qsuper, Qnone; | 138 | Lisp_Object Qalt, Qcontrol, Qhyper, Qmeta, Qsuper, Qnone; |
| 140 | extern Lisp_Object Qcursor_color, Qcursor_type, Qns, Qleft; | 139 | extern Lisp_Object Qcursor_color, Qcursor_type, Qns, Qleft; |
| 141 | 140 | ||
| 141 | static Lisp_Object QUTF8_STRING; | ||
| 142 | |||
| 142 | /* On OS X picks up the default NSGlobalDomain AppleAntiAliasingThreshold, | 143 | /* On OS X picks up the default NSGlobalDomain AppleAntiAliasingThreshold, |
| 143 | the maximum font size to NOT antialias. On GNUstep there is currently | 144 | the maximum font size to NOT antialias. On GNUstep there is currently |
| 144 | no way to control this behavior. */ | 145 | no way to control this behavior. */ |
| @@ -5364,6 +5365,9 @@ ns_term_shutdown (int sig) | |||
| 5364 | 5365 | ||
| 5365 | [self allocateGState]; | 5366 | [self allocateGState]; |
| 5366 | 5367 | ||
| 5368 | [NSApp registerServicesMenuSendTypes: ns_send_types | ||
| 5369 | returnTypes: ns_return_types]; | ||
| 5370 | |||
| 5367 | ns_window_num++; | 5371 | ns_window_num++; |
| 5368 | return self; | 5372 | return self; |
| 5369 | } | 5373 | } |
| @@ -5735,13 +5739,17 @@ ns_term_shutdown (int sig) | |||
| 5735 | } | 5739 | } |
| 5736 | 5740 | ||
| 5737 | 5741 | ||
| 5738 | - validRequestorForSendType: (NSString *)typeSent | 5742 | - (id) validRequestorForSendType: (NSString *)typeSent |
| 5739 | returnType: (NSString *)typeReturned | 5743 | returnType: (NSString *)typeReturned |
| 5740 | { | 5744 | { |
| 5741 | NSTRACE (validRequestorForSendType); | 5745 | NSTRACE (validRequestorForSendType); |
| 5742 | if ([ns_send_types indexOfObjectIdenticalTo: typeSent] != NSNotFound && | 5746 | if (typeSent != nil && [ns_send_types indexOfObject: typeSent] != NSNotFound |
| 5743 | [ns_return_types indexOfObjectIdenticalTo: typeSent] != NSNotFound) | 5747 | && (typeReturned == nil |
| 5744 | return self; | 5748 | || [ns_return_types indexOfObject: typeSent] != NSNotFound)) |
| 5749 | { | ||
| 5750 | if (! NILP (ns_get_local_selection (QPRIMARY, QUTF8_STRING))) | ||
| 5751 | return self; | ||
| 5752 | } | ||
| 5745 | 5753 | ||
| 5746 | return [super validRequestorForSendType: typeSent | 5754 | return [super validRequestorForSendType: typeSent |
| 5747 | returnType: typeReturned]; | 5755 | returnType: typeReturned]; |
| @@ -5765,8 +5773,28 @@ ns_term_shutdown (int sig) | |||
| 5765 | 5773 | ||
| 5766 | - (BOOL) writeSelectionToPasteboard: (NSPasteboard *)pb types: (NSArray *)types | 5774 | - (BOOL) writeSelectionToPasteboard: (NSPasteboard *)pb types: (NSArray *)types |
| 5767 | { | 5775 | { |
| 5768 | /* supposed to write for as many of types as we are able */ | 5776 | NSArray *typesDeclared; |
| 5769 | return NO; | 5777 | Lisp_Object val; |
| 5778 | |||
| 5779 | /* We only support NSStringPboardType */ | ||
| 5780 | if ([types containsObject:NSStringPboardType] == NO) { | ||
| 5781 | return NO; | ||
| 5782 | } | ||
| 5783 | |||
| 5784 | val = ns_get_local_selection (QPRIMARY, QUTF8_STRING); | ||
| 5785 | if (CONSP (val) && SYMBOLP (XCAR (val))) | ||
| 5786 | { | ||
| 5787 | val = XCDR (val); | ||
| 5788 | if (CONSP (val) && NILP (XCDR (val))) | ||
| 5789 | val = XCAR (val); | ||
| 5790 | } | ||
| 5791 | if (! STRINGP (val)) | ||
| 5792 | return NO; | ||
| 5793 | |||
| 5794 | typesDeclared = [NSArray arrayWithObject:NSStringPboardType]; | ||
| 5795 | [pb declareTypes:typesDeclared owner:nil]; | ||
| 5796 | ns_string_to_pasteboard (pb, val); | ||
| 5797 | return YES; | ||
| 5770 | } | 5798 | } |
| 5771 | 5799 | ||
| 5772 | 5800 | ||
| @@ -6390,6 +6418,8 @@ syms_of_nsterm (void) | |||
| 6390 | DEFSYM (Qsuper, "super"); | 6418 | DEFSYM (Qsuper, "super"); |
| 6391 | DEFSYM (Qcontrol, "control"); | 6419 | DEFSYM (Qcontrol, "control"); |
| 6392 | DEFSYM (Qnone, "none"); | 6420 | DEFSYM (Qnone, "none"); |
| 6421 | DEFSYM (QUTF8_STRING, "UTF8_STRING"); | ||
| 6422 | |||
| 6393 | Fput (Qalt, Qmodifier_value, make_number (alt_modifier)); | 6423 | Fput (Qalt, Qmodifier_value, make_number (alt_modifier)); |
| 6394 | Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier)); | 6424 | Fput (Qhyper, Qmodifier_value, make_number (hyper_modifier)); |
| 6395 | Fput (Qmeta, Qmodifier_value, make_number (meta_modifier)); | 6425 | Fput (Qmeta, Qmodifier_value, make_number (meta_modifier)); |