annotate src/macselect.c @ 79314:2a7f5d50fe6f

*** empty log message ***
author Nick Roberts <nickrob@snap.net.nz>
date Fri, 02 Nov 2007 04:11:00 +0000
parents 922696f363b0
children fc2bcd2a8aad b98604865ea0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1 /* Selection processing for Emacs on Mac OS.
75348
3d45362f1d38 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 75240
diff changeset
2 Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
3
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
4 This file is part of GNU Emacs.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
5
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
6 GNU Emacs is free software; you can redistribute it and/or modify
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
78260
922696f363b0 Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 76745
diff changeset
8 the Free Software Foundation; either version 3, or (at your option)
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
9 any later version.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
10
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
11 GNU Emacs is distributed in the hope that it will be useful,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
14 GNU General Public License for more details.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
15
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
17 along with GNU Emacs; see the file COPYING. If not, write to
64084
a8fa7c632ee4 Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62271
diff changeset
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
a8fa7c632ee4 Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 62271
diff changeset
19 Boston, MA 02110-1301, USA. */
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
20
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
21 #include <config.h>
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
22
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
23 #include "lisp.h"
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
24 #include "macterm.h"
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
25 #include "blockinput.h"
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
26 #include "keymap.h"
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
27
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
28 #if !TARGET_API_MAC_CARBON
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
29 #include <Endian.h>
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
30 typedef int ScrapRef;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
31 typedef ResType ScrapFlavorType;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
32 #endif /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
33
72544
f8ade754466c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71985
diff changeset
34 static OSStatus get_scrap_from_symbol P_ ((Lisp_Object, int, ScrapRef *));
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
35 static ScrapFlavorType get_flavor_type_from_symbol P_ ((Lisp_Object));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
36 static int valid_scrap_target_type_p P_ ((Lisp_Object));
72544
f8ade754466c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71985
diff changeset
37 static OSStatus clear_scrap P_ ((ScrapRef *));
f8ade754466c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71985
diff changeset
38 static OSStatus put_scrap_string P_ ((ScrapRef, Lisp_Object, Lisp_Object));
f8ade754466c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71985
diff changeset
39 static OSStatus put_scrap_private_timestamp P_ ((ScrapRef, unsigned long));
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
40 static ScrapFlavorType scrap_has_target_type P_ ((ScrapRef, Lisp_Object));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
41 static Lisp_Object get_scrap_string P_ ((ScrapRef, Lisp_Object));
72544
f8ade754466c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71985
diff changeset
42 static OSStatus get_scrap_private_timestamp P_ ((ScrapRef, unsigned long *));
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
43 static Lisp_Object get_scrap_target_type_list P_ ((ScrapRef));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
44 static void x_own_selection P_ ((Lisp_Object, Lisp_Object));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
45 static Lisp_Object x_get_local_selection P_ ((Lisp_Object, Lisp_Object, int));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
46 static Lisp_Object x_get_foreign_selection P_ ((Lisp_Object,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
47 Lisp_Object,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
48 Lisp_Object));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
49 EXFUN (Fx_selection_owner_p, 1);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
50 #ifdef MAC_OSX
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
51 static OSStatus mac_handle_service_event P_ ((EventHandlerCallRef,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
52 EventRef, void *));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
53 void init_service_handler P_ ((void));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
54 #endif
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
55
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
56 Lisp_Object QPRIMARY, QSECONDARY, QTIMESTAMP, QTARGETS;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
57
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
58 static Lisp_Object Vx_lost_selection_functions;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
59 /* Coding system for communicating with other programs via scrap. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
60 static Lisp_Object Vselection_coding_system;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
61
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
62 /* Coding system for the next communicating with other programs. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
63 static Lisp_Object Vnext_selection_coding_system;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
64
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
65 static Lisp_Object Qforeign_selection;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
66
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
67 /* The timestamp of the last input event Emacs received from the
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
68 window server. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
69 /* Defined in keyboard.c. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
70 extern unsigned long last_event_timestamp;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
71
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
72 /* This is an association list whose elements are of the form
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
73 ( SELECTION-NAME SELECTION-VALUE SELECTION-TIMESTAMP FRAME)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
74 SELECTION-NAME is a lisp symbol.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
75 SELECTION-VALUE is the value that emacs owns for that selection.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
76 It may be any kind of Lisp object.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
77 SELECTION-TIMESTAMP is the time at which emacs began owning this selection,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
78 as a cons of two 16-bit numbers (making a 32 bit time.)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
79 FRAME is the frame for which we made the selection.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
80 If there is an entry in this alist, and the data for the flavor
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
81 type SCRAP_FLAVOR_TYPE_EMACS_TIMESTAMP in the corresponding scrap
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
82 (if exists) coincides with SELECTION-TIMESTAMP, then it can be
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
83 assumed that Emacs owns that selection.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
84 The only (eq) parts of this list that are visible from Lisp are the
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
85 selection-values. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
86 static Lisp_Object Vselection_alist;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
87
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
88 #define SCRAP_FLAVOR_TYPE_EMACS_TIMESTAMP 'Etsp'
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
89
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
90 /* This is an alist whose CARs are selection-types and whose CDRs are
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
91 the names of Lisp functions to call to convert the given Emacs
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
92 selection value to a string representing the given selection type.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
93 This is for Lisp-level extension of the emacs selection
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
94 handling. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
95 static Lisp_Object Vselection_converter_alist;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
96
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
97 /* A selection name (represented as a Lisp symbol) can be associated
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
98 with a named scrap via `mac-scrap-name' property. Likewise for a
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
99 selection type with a scrap flavor type via `mac-ostype'. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
100 static Lisp_Object Qmac_scrap_name, Qmac_ostype;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
101
62102
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
102 #ifdef MAC_OSX
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
103 /* Selection name for communication via Services menu. */
70562
e2bd086e6902 (Vmac_service_selection) [MAC_OSX]: Rename from
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70495
diff changeset
104 static Lisp_Object Vmac_service_selection;
62102
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
105 #endif
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
106
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
107 /* Get a reference to the scrap corresponding to the symbol SYM. The
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
108 reference is set to *SCRAP, and it becomes NULL if there's no
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
109 corresponding scrap. Clear the scrap if CLEAR_P is non-zero. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
110
72544
f8ade754466c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71985
diff changeset
111 static OSStatus
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
112 get_scrap_from_symbol (sym, clear_p, scrap)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
113 Lisp_Object sym;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
114 int clear_p;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
115 ScrapRef *scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
116 {
72544
f8ade754466c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71985
diff changeset
117 OSStatus err = noErr;
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
118 Lisp_Object str = Fget (sym, Qmac_scrap_name);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
119
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
120 if (!STRINGP (str))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
121 *scrap = NULL;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
122 else
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
123 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
124 #if TARGET_API_MAC_CARBON
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
125 #ifdef MAC_OSX
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
126 CFStringRef scrap_name = cfstring_create_with_string (str);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
127 OptionBits options = (clear_p ? kScrapClearNamedScrap
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
128 : kScrapGetNamedScrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
129
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
130 err = GetScrapByName (scrap_name, options, scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
131 CFRelease (scrap_name);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
132 #else /* !MAC_OSX */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
133 if (clear_p)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
134 err = ClearCurrentScrap ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
135 if (err == noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
136 err = GetCurrentScrap (scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
137 #endif /* !MAC_OSX */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
138 #else /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
139 if (clear_p)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
140 err = ZeroScrap ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
141 if (err == noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
142 *scrap = 1;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
143 #endif /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
144 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
145
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
146 return err;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
147 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
148
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
149 /* Get a scrap flavor type from the symbol SYM. Return 0 if no
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
150 corresponding flavor type. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
151
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
152 static ScrapFlavorType
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
153 get_flavor_type_from_symbol (sym)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
154 Lisp_Object sym;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
155 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
156 Lisp_Object str = Fget (sym, Qmac_ostype);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
157
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
158 if (STRINGP (str) && SBYTES (str) == 4)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
159 return EndianU32_BtoN (*((UInt32 *) SDATA (str)));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
160
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
161 return 0;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
162 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
163
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
164 /* Check if the symbol SYM has a corresponding scrap flavor type. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
165
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
166 static int
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
167 valid_scrap_target_type_p (sym)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
168 Lisp_Object sym;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
169 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
170 return get_flavor_type_from_symbol (sym) != 0;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
171 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
172
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
173 /* Clear the scrap whose reference is *SCRAP. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
174
72544
f8ade754466c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71985
diff changeset
175 static INLINE OSStatus
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
176 clear_scrap (scrap)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
177 ScrapRef *scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
178 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
179 #if TARGET_API_MAC_CARBON
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
180 #ifdef MAC_OSX
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
181 return ClearScrap (scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
182 #else
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
183 return ClearCurrentScrap ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
184 #endif
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
185 #else /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
186 return ZeroScrap ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
187 #endif /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
188 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
189
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
190 /* Put Lisp String STR to the scrap SCRAP. The target type is
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
191 specified by TYPE. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
192
72544
f8ade754466c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71985
diff changeset
193 static OSStatus
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
194 put_scrap_string (scrap, type, str)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
195 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
196 Lisp_Object type, str;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
197 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
198 ScrapFlavorType flavor_type = get_flavor_type_from_symbol (type);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
199
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
200 if (flavor_type == 0)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
201 return noTypeErr;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
202
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
203 #if TARGET_API_MAC_CARBON
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
204 return PutScrapFlavor (scrap, flavor_type, kScrapFlavorMaskNone,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
205 SBYTES (str), SDATA (str));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
206 #else /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
207 return PutScrap (SBYTES (str), flavor_type, SDATA (str));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
208 #endif /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
209 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
210
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
211 /* Put TIMESTAMP to the scrap SCRAP. The timestamp is used for
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
212 checking if the scrap is owned by the process. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
213
72544
f8ade754466c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71985
diff changeset
214 static INLINE OSStatus
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
215 put_scrap_private_timestamp (scrap, timestamp)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
216 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
217 unsigned long timestamp;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
218 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
219 #if TARGET_API_MAC_CARBON
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
220 return PutScrapFlavor (scrap, SCRAP_FLAVOR_TYPE_EMACS_TIMESTAMP,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
221 kScrapFlavorMaskSenderOnly,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
222 sizeof (timestamp), &timestamp);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
223 #else /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
224 return PutScrap (sizeof (timestamp), SCRAP_FLAVOR_TYPE_EMACS_TIMESTAMP,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
225 &timestamp);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
226 #endif /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
227 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
228
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
229 /* Check if data for the target type TYPE is available in SCRAP. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
230
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
231 static ScrapFlavorType
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
232 scrap_has_target_type (scrap, type)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
233 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
234 Lisp_Object type;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
235 {
72544
f8ade754466c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71985
diff changeset
236 OSStatus err;
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
237 ScrapFlavorType flavor_type = get_flavor_type_from_symbol (type);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
238
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
239 if (flavor_type)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
240 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
241 #if TARGET_API_MAC_CARBON
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
242 ScrapFlavorFlags flags;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
243
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
244 err = GetScrapFlavorFlags (scrap, flavor_type, &flags);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
245 if (err != noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
246 flavor_type = 0;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
247 #else /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
248 SInt32 size, offset;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
249
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
250 size = GetScrap (NULL, flavor_type, &offset);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
251 if (size < 0)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
252 flavor_type = 0;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
253 #endif /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
254 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
255
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
256 return flavor_type;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
257 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
258
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
259 /* Get data for the target type TYPE from SCRAP and create a Lisp
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
260 string. Return nil if failed to get data. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
261
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
262 static Lisp_Object
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
263 get_scrap_string (scrap, type)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
264 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
265 Lisp_Object type;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
266 {
72544
f8ade754466c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71985
diff changeset
267 OSStatus err;
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
268 Lisp_Object result = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
269 ScrapFlavorType flavor_type = get_flavor_type_from_symbol (type);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
270 #if TARGET_API_MAC_CARBON
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
271 Size size;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
272
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
273 if (flavor_type)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
274 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
275 err = GetScrapFlavorSize (scrap, flavor_type, &size);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
276 if (err == noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
277 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
278 do
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
279 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
280 result = make_uninit_string (size);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
281 err = GetScrapFlavorData (scrap, flavor_type,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
282 &size, SDATA (result));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
283 if (err != noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
284 result = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
285 else if (size < SBYTES (result))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
286 result = make_unibyte_string (SDATA (result), size);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
287 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
288 while (STRINGP (result) && size > SBYTES (result));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
289 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
290 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
291 #else
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
292 Handle handle;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
293 SInt32 size, offset;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
294
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
295 if (flavor_type)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
296 size = GetScrap (NULL, flavor_type, &offset);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
297 if (size >= 0)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
298 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
299 handle = NewHandle (size);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
300 HLock (handle);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
301 size = GetScrap (handle, flavor_type, &offset);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
302 if (size >= 0)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
303 result = make_unibyte_string (*handle, size);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
304 DisposeHandle (handle);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
305 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
306 #endif
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
307
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
308 return result;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
309 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
310
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
311 /* Get timestamp from the scrap SCRAP and set to *TIMPSTAMP. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
312
72544
f8ade754466c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71985
diff changeset
313 static OSStatus
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
314 get_scrap_private_timestamp (scrap, timestamp)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
315 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
316 unsigned long *timestamp;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
317 {
72544
f8ade754466c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71985
diff changeset
318 OSStatus err = noErr;
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
319 #if TARGET_API_MAC_CARBON
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
320 ScrapFlavorFlags flags;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
321
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
322 err = GetScrapFlavorFlags (scrap, SCRAP_FLAVOR_TYPE_EMACS_TIMESTAMP, &flags);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
323 if (err == noErr)
69963
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
324 {
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
325 if (!(flags & kScrapFlavorMaskSenderOnly))
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
326 err = noTypeErr;
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
327 else
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
328 {
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
329 Size size = sizeof (*timestamp);
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
330
69963
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
331 err = GetScrapFlavorData (scrap, SCRAP_FLAVOR_TYPE_EMACS_TIMESTAMP,
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
332 &size, timestamp);
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
333 if (err == noErr && size != sizeof (*timestamp))
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
334 err = noTypeErr;
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
335 }
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
336 }
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
337 #else /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
338 Handle handle;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
339 SInt32 size, offset;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
340
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
341 size = GetScrap (NULL, SCRAP_FLAVOR_TYPE_EMACS_TIMESTAMP, &offset);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
342 if (size == sizeof (*timestamp))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
343 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
344 handle = NewHandle (size);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
345 HLock (handle);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
346 size = GetScrap (handle, SCRAP_FLAVOR_TYPE_EMACS_TIMESTAMP, &offset);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
347 if (size == sizeof (*timestamp))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
348 *timestamp = *((unsigned long *) *handle);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
349 DisposeHandle (handle);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
350 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
351 if (size != sizeof (*timestamp))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
352 err = noTypeErr;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
353 #endif /* !TARGET_API_MAC_CARBON */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
354
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
355 return err;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
356 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
357
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
358 /* Get the list of target types in SCRAP. The return value is a list
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
359 of target type symbols possibly followed by scrap flavor type
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
360 strings. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
361
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
362 static Lisp_Object
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
363 get_scrap_target_type_list (scrap)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
364 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
365 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
366 Lisp_Object result = Qnil, rest, target_type;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
367 #if TARGET_API_MAC_CARBON
72544
f8ade754466c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71985
diff changeset
368 OSStatus err;
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
369 UInt32 count, i, type;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
370 ScrapFlavorInfo *flavor_info = NULL;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
371 Lisp_Object strings = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
372
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
373 err = GetScrapFlavorCount (scrap, &count);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
374 if (err == noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
375 flavor_info = xmalloc (sizeof (ScrapFlavorInfo) * count);
70070
9559d7f62131 (get_scrap_target_type_list, defer_apple_events)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69963
diff changeset
376 err = GetScrapFlavorInfoList (scrap, &count, flavor_info);
9559d7f62131 (get_scrap_target_type_list, defer_apple_events)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69963
diff changeset
377 if (err != noErr)
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
378 {
70070
9559d7f62131 (get_scrap_target_type_list, defer_apple_events)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69963
diff changeset
379 xfree (flavor_info);
9559d7f62131 (get_scrap_target_type_list, defer_apple_events)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69963
diff changeset
380 flavor_info = NULL;
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
381 }
64312
c528a5858404 (get_scrap_target_type_list): Avoid NULL pointer dereference.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
382 if (flavor_info == NULL)
c528a5858404 (get_scrap_target_type_list): Avoid NULL pointer dereference.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64084
diff changeset
383 count = 0;
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
384 #endif
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
385 for (rest = Vselection_converter_alist; CONSP (rest); rest = XCDR (rest))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
386 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
387 ScrapFlavorType flavor_type = 0;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
388
76745
f6a525134188 (get_scrap_target_type_list, x_own_selection): Move
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75376
diff changeset
389 if (CONSP (XCAR (rest))
f6a525134188 (get_scrap_target_type_list, x_own_selection): Move
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75376
diff changeset
390 && (target_type = XCAR (XCAR (rest)),
f6a525134188 (get_scrap_target_type_list, x_own_selection): Move
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75376
diff changeset
391 SYMBOLP (target_type))
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
392 && (flavor_type = scrap_has_target_type (scrap, target_type)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
393 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
394 result = Fcons (target_type, result);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
395 #if TARGET_API_MAC_CARBON
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
396 for (i = 0; i < count; i++)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
397 if (flavor_info[i].flavorType == flavor_type)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
398 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
399 flavor_info[i].flavorType = 0;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
400 break;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
401 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
402 #endif
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
403 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
404 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
405 #if TARGET_API_MAC_CARBON
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
406 if (flavor_info)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
407 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
408 for (i = 0; i < count; i++)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
409 if (flavor_info[i].flavorType)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
410 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
411 type = EndianU32_NtoB (flavor_info[i].flavorType);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
412 strings = Fcons (make_unibyte_string ((char *) &type, 4), strings);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
413 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
414 result = nconc2 (result, strings);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
415 xfree (flavor_info);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
416 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
417 #endif
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
418
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
419 return result;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
420 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
421
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
422 /* Do protocol to assert ourself as a selection owner.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
423 Update the Vselection_alist so that we can reply to later requests for
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
424 our selection. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
425
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
426 static void
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
427 x_own_selection (selection_name, selection_value)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
428 Lisp_Object selection_name, selection_value;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
429 {
72544
f8ade754466c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71985
diff changeset
430 OSStatus err;
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
431 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
432 struct gcpro gcpro1, gcpro2;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
433 Lisp_Object rest, handler_fn, value, type;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
434 int count;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
435
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
436 CHECK_SYMBOL (selection_name);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
437
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
438 GCPRO2 (selection_name, selection_value);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
439
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
440 BLOCK_INPUT;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
441
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
442 err = get_scrap_from_symbol (selection_name, 1, &scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
443 if (err == noErr && scrap)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
444 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
445 /* Don't allow a quit within the converter.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
446 When the user types C-g, he would be surprised
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
447 if by luck it came during a converter. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
448 count = SPECPDL_INDEX ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
449 specbind (Qinhibit_quit, Qt);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
450
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
451 for (rest = Vselection_converter_alist; CONSP (rest); rest = XCDR (rest))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
452 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
453 if (!(CONSP (XCAR (rest))
76745
f6a525134188 (get_scrap_target_type_list, x_own_selection): Move
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75376
diff changeset
454 && (type = XCAR (XCAR (rest)),
f6a525134188 (get_scrap_target_type_list, x_own_selection): Move
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75376
diff changeset
455 SYMBOLP (type))
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
456 && valid_scrap_target_type_p (type)
76745
f6a525134188 (get_scrap_target_type_list, x_own_selection): Move
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75376
diff changeset
457 && (handler_fn = XCDR (XCAR (rest)),
f6a525134188 (get_scrap_target_type_list, x_own_selection): Move
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75376
diff changeset
458 SYMBOLP (handler_fn))))
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
459 continue;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
460
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
461 if (!NILP (handler_fn))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
462 value = call3 (handler_fn, selection_name,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
463 type, selection_value);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
464
62102
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
465 if (STRINGP (value))
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
466 err = put_scrap_string (scrap, type, value);
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
467 else if (CONSP (value)
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
468 && EQ (XCAR (value), type)
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
469 && STRINGP (XCDR (value)))
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
470 err = put_scrap_string (scrap, type, XCDR (value));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
471 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
472
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
473 unbind_to (count, Qnil);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
474
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
475 if (err == noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
476 err = put_scrap_private_timestamp (scrap, last_event_timestamp);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
477 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
478
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
479 UNBLOCK_INPUT;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
480
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
481 UNGCPRO;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
482
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
483 if (scrap && err != noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
484 error ("Can't set selection");
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
485
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
486 /* Now update the local cache */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
487 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
488 Lisp_Object selection_time;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
489 Lisp_Object selection_data;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
490 Lisp_Object prev_value;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
491
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
492 selection_time = long_to_cons (last_event_timestamp);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
493 selection_data = Fcons (selection_name,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
494 Fcons (selection_value,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
495 Fcons (selection_time,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
496 Fcons (selected_frame, Qnil))));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
497 prev_value = assq_no_quit (selection_name, Vselection_alist);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
498
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
499 Vselection_alist = Fcons (selection_data, Vselection_alist);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
500
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
501 /* If we already owned the selection, remove the old selection data.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
502 Perhaps we should destructively modify it instead.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
503 Don't use Fdelq as that may QUIT. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
504 if (!NILP (prev_value))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
505 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
506 Lisp_Object rest; /* we know it's not the CAR, so it's easy. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
507 for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
508 if (EQ (prev_value, Fcar (XCDR (rest))))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
509 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
510 XSETCDR (rest, Fcdr (XCDR (rest)));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
511 break;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
512 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
513 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
514 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
515 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
516
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
517 /* Given a selection-name and desired type, look up our local copy of
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
518 the selection value and convert it to the type.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
519 The value is nil or a string.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
520 This function is used both for remote requests (LOCAL_REQUEST is zero)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
521 and for local x-get-selection-internal (LOCAL_REQUEST is nonzero).
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
522
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
523 This calls random Lisp code, and may signal or gc. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
524
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
525 static Lisp_Object
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
526 x_get_local_selection (selection_symbol, target_type, local_request)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
527 Lisp_Object selection_symbol, target_type;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
528 int local_request;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
529 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
530 Lisp_Object local_value;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
531 Lisp_Object handler_fn, value, type, check;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
532 int count;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
533
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
534 if (NILP (Fx_selection_owner_p (selection_symbol)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
535 return Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
536
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
537 local_value = assq_no_quit (selection_symbol, Vselection_alist);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
538
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
539 /* TIMESTAMP is a special case 'cause that's easiest. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
540 if (EQ (target_type, QTIMESTAMP))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
541 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
542 handler_fn = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
543 value = XCAR (XCDR (XCDR (local_value)));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
544 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
545 #if 0
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
546 else if (EQ (target_type, QDELETE))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
547 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
548 handler_fn = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
549 Fx_disown_selection_internal
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
550 (selection_symbol,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
551 XCAR (XCDR (XCDR (local_value))));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
552 value = QNULL;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
553 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
554 #endif
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
555 else
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
556 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
557 /* Don't allow a quit within the converter.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
558 When the user types C-g, he would be surprised
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
559 if by luck it came during a converter. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
560 count = SPECPDL_INDEX ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
561 specbind (Qinhibit_quit, Qt);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
562
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
563 CHECK_SYMBOL (target_type);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
564 handler_fn = Fcdr (Fassq (target_type, Vselection_converter_alist));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
565 /* gcpro is not needed here since nothing but HANDLER_FN
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
566 is live, and that ought to be a symbol. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
567
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
568 if (!NILP (handler_fn))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
569 value = call3 (handler_fn,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
570 selection_symbol, (local_request ? Qnil : target_type),
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
571 XCAR (XCDR (local_value)));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
572 else
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
573 value = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
574 unbind_to (count, Qnil);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
575 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
576
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
577 /* Make sure this value is of a type that we could transmit
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
578 to another X client. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
579
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
580 check = value;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
581 if (CONSP (value)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
582 && SYMBOLP (XCAR (value)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
583 type = XCAR (value),
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
584 check = XCDR (value);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
585
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
586 if (STRINGP (check)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
587 || VECTORP (check)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
588 || SYMBOLP (check)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
589 || INTEGERP (check)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
590 || NILP (value))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
591 return value;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
592 /* Check for a value that cons_to_long could handle. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
593 else if (CONSP (check)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
594 && INTEGERP (XCAR (check))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
595 && (INTEGERP (XCDR (check))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
596 ||
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
597 (CONSP (XCDR (check))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
598 && INTEGERP (XCAR (XCDR (check)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
599 && NILP (XCDR (XCDR (check))))))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
600 return value;
71985
ae7908422c59 (x_get_local_selection): Use signal_error.
Kim F. Storm <storm@cua.dk>
parents: 70988
diff changeset
601
ae7908422c59 (x_get_local_selection): Use signal_error.
Kim F. Storm <storm@cua.dk>
parents: 70988
diff changeset
602 signal_error ("Invalid data returned by selection-conversion function",
ae7908422c59 (x_get_local_selection): Use signal_error.
Kim F. Storm <storm@cua.dk>
parents: 70988
diff changeset
603 list2 (handler_fn, value));
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
604 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
605
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
606
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
607 /* Clear all selections that were made from frame F.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
608 We do this when about to delete a frame. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
609
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
610 void
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
611 x_clear_frame_selections (f)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
612 FRAME_PTR f;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
613 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
614 Lisp_Object frame;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
615 Lisp_Object rest;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
616
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
617 XSETFRAME (frame, f);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
618
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
619 /* Otherwise, we're really honest and truly being told to drop it.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
620 Don't use Fdelq as that may QUIT;. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
621
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
622 /* Delete elements from the beginning of Vselection_alist. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
623 while (!NILP (Vselection_alist)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
624 && EQ (frame, Fcar (Fcdr (Fcdr (Fcdr (Fcar (Vselection_alist)))))))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
625 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
626 /* Let random Lisp code notice that the selection has been stolen. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
627 Lisp_Object hooks, selection_symbol;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
628
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
629 hooks = Vx_lost_selection_functions;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
630 selection_symbol = Fcar (Fcar (Vselection_alist));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
631
62102
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
632 if (!EQ (hooks, Qunbound)
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
633 && !NILP (Fx_selection_owner_p (selection_symbol)))
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
634 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
635 for (; CONSP (hooks); hooks = Fcdr (hooks))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
636 call1 (Fcar (hooks), selection_symbol);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
637 #if 0 /* This can crash when deleting a frame
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
638 from x_connection_closed. Anyway, it seems unnecessary;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
639 something else should cause a redisplay. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
640 redisplay_preserve_echo_area (21);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
641 #endif
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
642 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
643
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
644 Vselection_alist = Fcdr (Vselection_alist);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
645 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
646
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
647 /* Delete elements after the beginning of Vselection_alist. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
648 for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
649 if (EQ (frame, Fcar (Fcdr (Fcdr (Fcdr (Fcar (XCDR (rest))))))))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
650 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
651 /* Let random Lisp code notice that the selection has been stolen. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
652 Lisp_Object hooks, selection_symbol;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
653
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
654 hooks = Vx_lost_selection_functions;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
655 selection_symbol = Fcar (Fcar (XCDR (rest)));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
656
62102
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
657 if (!EQ (hooks, Qunbound)
b710f3bc2da3 (x_own_selection): Accept Lisp string as result of
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 61819
diff changeset
658 && !NILP (Fx_selection_owner_p (selection_symbol)))
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
659 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
660 for (; CONSP (hooks); hooks = Fcdr (hooks))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
661 call1 (Fcar (hooks), selection_symbol);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
662 #if 0 /* See above */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
663 redisplay_preserve_echo_area (22);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
664 #endif
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
665 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
666 XSETCDR (rest, Fcdr (XCDR (rest)));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
667 break;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
668 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
669 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
670
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
671 /* Do protocol to read selection-data from the server.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
672 Converts this to Lisp data and returns it. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
673
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
674 static Lisp_Object
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
675 x_get_foreign_selection (selection_symbol, target_type, time_stamp)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
676 Lisp_Object selection_symbol, target_type, time_stamp;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
677 {
72544
f8ade754466c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71985
diff changeset
678 OSStatus err;
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
679 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
680 Lisp_Object result = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
681
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
682 BLOCK_INPUT;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
683
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
684 err = get_scrap_from_symbol (selection_symbol, 0, &scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
685 if (err == noErr && scrap)
69963
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
686 {
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
687 if (EQ (target_type, QTARGETS))
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
688 {
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
689 result = get_scrap_target_type_list (scrap);
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
690 result = Fvconcat (1, &result);
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
691 }
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
692 else
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
693 {
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
694 result = get_scrap_string (scrap, target_type);
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
695 if (STRINGP (result))
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
696 Fput_text_property (make_number (0), make_number (SBYTES (result)),
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
697 Qforeign_selection, target_type, result);
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
698 }
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
699 }
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
700
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
701 UNBLOCK_INPUT;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
702
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
703 return result;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
704 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
705
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
706
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
707 DEFUN ("x-own-selection-internal", Fx_own_selection_internal,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
708 Sx_own_selection_internal, 2, 2, 0,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
709 doc: /* Assert a selection of the given TYPE with the given VALUE.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
710 TYPE is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
711 VALUE is typically a string, or a cons of two markers, but may be
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
712 anything that the functions on `selection-converter-alist' know about. */)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
713 (selection_name, selection_value)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
714 Lisp_Object selection_name, selection_value;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
715 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
716 check_mac ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
717 CHECK_SYMBOL (selection_name);
64607
fefea1491def (Fx_own_selection_internal): Follow error conventions.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64312
diff changeset
718 if (NILP (selection_value)) error ("SELECTION-VALUE may not be nil");
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
719 x_own_selection (selection_name, selection_value);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
720 return selection_value;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
721 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
722
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
723
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
724 /* Request the selection value from the owner. If we are the owner,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
725 simply return our selection value. If we are not the owner, this
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
726 will block until all of the data has arrived. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
727
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
728 DEFUN ("x-get-selection-internal", Fx_get_selection_internal,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
729 Sx_get_selection_internal, 2, 3, 0,
64607
fefea1491def (Fx_own_selection_internal): Follow error conventions.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64312
diff changeset
730 doc: /* Return text selected from some Mac application.
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
731 SELECTION is a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
732 TYPE is the type of data desired, typically `STRING'.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
733 TIME_STAMP is ignored on Mac. */)
64607
fefea1491def (Fx_own_selection_internal): Follow error conventions.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64312
diff changeset
734 (selection_symbol, target_type, time_stamp)
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
735 Lisp_Object selection_symbol, target_type, time_stamp;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
736 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
737 Lisp_Object val = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
738 struct gcpro gcpro1, gcpro2;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
739 GCPRO2 (target_type, val); /* we store newly consed data into these */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
740 check_mac ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
741 CHECK_SYMBOL (selection_symbol);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
742 CHECK_SYMBOL (target_type);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
743
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
744 val = x_get_local_selection (selection_symbol, target_type, 1);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
745
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
746 if (NILP (val))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
747 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
748 val = x_get_foreign_selection (selection_symbol, target_type, time_stamp);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
749 goto DONE;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
750 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
751
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
752 if (CONSP (val)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
753 && SYMBOLP (XCAR (val)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
754 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
755 val = XCDR (val);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
756 if (CONSP (val) && NILP (XCDR (val)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
757 val = XCAR (val);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
758 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
759 DONE:
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
760 UNGCPRO;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
761 return val;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
762 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
763
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
764 DEFUN ("x-disown-selection-internal", Fx_disown_selection_internal,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
765 Sx_disown_selection_internal, 1, 2, 0,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
766 doc: /* If we own the selection SELECTION, disown it.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
767 Disowning it means there is no such selection. */)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
768 (selection, time)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
769 Lisp_Object selection;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
770 Lisp_Object time;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
771 {
72544
f8ade754466c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71985
diff changeset
772 OSStatus err;
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
773 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
774 Lisp_Object local_selection_data;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
775
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
776 check_mac ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
777 CHECK_SYMBOL (selection);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
778
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
779 if (NILP (Fx_selection_owner_p (selection)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
780 return Qnil; /* Don't disown the selection when we're not the owner. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
781
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
782 local_selection_data = assq_no_quit (selection, Vselection_alist);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
783
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
784 /* Don't use Fdelq as that may QUIT;. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
785
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
786 if (EQ (local_selection_data, Fcar (Vselection_alist)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
787 Vselection_alist = Fcdr (Vselection_alist);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
788 else
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
789 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
790 Lisp_Object rest;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
791 for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
792 if (EQ (local_selection_data, Fcar (XCDR (rest))))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
793 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
794 XSETCDR (rest, Fcdr (XCDR (rest)));
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
795 break;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
796 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
797 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
798
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
799 /* Let random lisp code notice that the selection has been stolen. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
800
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
801 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
802 Lisp_Object rest;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
803 rest = Vx_lost_selection_functions;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
804 if (!EQ (rest, Qunbound))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
805 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
806 for (; CONSP (rest); rest = Fcdr (rest))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
807 call1 (Fcar (rest), selection);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
808 prepare_menu_bars ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
809 redisplay_preserve_echo_area (20);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
810 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
811 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
812
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
813 BLOCK_INPUT;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
814
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
815 err = get_scrap_from_symbol (selection, 0, &scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
816 if (err == noErr && scrap)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
817 clear_scrap (&scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
818
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
819 UNBLOCK_INPUT;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
820
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
821 return Qt;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
822 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
823
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
824
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
825 DEFUN ("x-selection-owner-p", Fx_selection_owner_p, Sx_selection_owner_p,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
826 0, 1, 0,
64607
fefea1491def (Fx_own_selection_internal): Follow error conventions.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64312
diff changeset
827 doc: /* Whether the current Emacs process owns the given SELECTION.
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
828 The arg should be the name of the selection in question, typically one of
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
829 the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
830 For convenience, the symbol nil is the same as `PRIMARY',
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
831 and t is the same as `SECONDARY'. */)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
832 (selection)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
833 Lisp_Object selection;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
834 {
72544
f8ade754466c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71985
diff changeset
835 OSStatus err;
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
836 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
837 Lisp_Object result = Qnil, local_selection_data;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
838
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
839 check_mac ();
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
840 CHECK_SYMBOL (selection);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
841 if (EQ (selection, Qnil)) selection = QPRIMARY;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
842 if (EQ (selection, Qt)) selection = QSECONDARY;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
843
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
844 local_selection_data = assq_no_quit (selection, Vselection_alist);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
845
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
846 if (NILP (local_selection_data))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
847 return Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
848
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
849 BLOCK_INPUT;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
850
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
851 err = get_scrap_from_symbol (selection, 0, &scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
852 if (err == noErr && scrap)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
853 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
854 unsigned long timestamp;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
855
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
856 err = get_scrap_private_timestamp (scrap, &timestamp);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
857 if (err == noErr
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
858 && (timestamp
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
859 == cons_to_long (XCAR (XCDR (XCDR (local_selection_data))))))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
860 result = Qt;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
861 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
862 else
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
863 result = Qt;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
864
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
865 UNBLOCK_INPUT;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
866
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
867 return result;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
868 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
869
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
870 DEFUN ("x-selection-exists-p", Fx_selection_exists_p, Sx_selection_exists_p,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
871 0, 1, 0,
64607
fefea1491def (Fx_own_selection_internal): Follow error conventions.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64312
diff changeset
872 doc: /* Whether there is an owner for the given SELECTION.
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
873 The arg should be the name of the selection in question, typically one of
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
874 the symbols `PRIMARY', `SECONDARY', or `CLIPBOARD'.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
875 For convenience, the symbol nil is the same as `PRIMARY',
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
876 and t is the same as `SECONDARY'. */)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
877 (selection)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
878 Lisp_Object selection;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
879 {
72544
f8ade754466c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71985
diff changeset
880 OSStatus err;
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
881 ScrapRef scrap;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
882 Lisp_Object result = Qnil, rest;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
883
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
884 /* It should be safe to call this before we have an Mac frame. */
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
885 if (! FRAME_MAC_P (SELECTED_FRAME ()))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
886 return Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
887
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
888 CHECK_SYMBOL (selection);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
889 if (!NILP (Fx_selection_owner_p (selection)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
890 return Qt;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
891 if (EQ (selection, Qnil)) selection = QPRIMARY;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
892 if (EQ (selection, Qt)) selection = QSECONDARY;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
893
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
894 BLOCK_INPUT;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
895
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
896 err = get_scrap_from_symbol (selection, 0, &scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
897 if (err == noErr && scrap)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
898 for (rest = Vselection_converter_alist; CONSP (rest); rest = XCDR (rest))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
899 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
900 if (CONSP (XCAR (rest)) && SYMBOLP (XCAR (XCAR (rest)))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
901 && scrap_has_target_type (scrap, XCAR (XCAR (rest))))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
902 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
903 result = Qt;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
904 break;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
905 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
906 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
907
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
908 UNBLOCK_INPUT;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
909
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
910 return result;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
911 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
912
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
913
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
914 /***********************************************************************
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
915 Apple event support
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
916 ***********************************************************************/
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
917 int mac_ready_for_apple_events = 0;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
918 static Lisp_Object Vmac_apple_event_map;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
919 static Lisp_Object Qmac_apple_event_class, Qmac_apple_event_id;
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
920 static Lisp_Object Qemacs_suspension_id;
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
921 extern Lisp_Object Qundefined;
70383
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
922 extern void mac_store_apple_event P_ ((Lisp_Object, Lisp_Object,
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
923 const AEDesc *));
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
924
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
925 struct apple_event_binding
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
926 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
927 UInt32 code; /* Apple event class or ID. */
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
928 Lisp_Object key, binding;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
929 };
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
930
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
931 struct suspended_ae_info
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
932 {
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
933 UInt32 expiration_tick, suspension_id;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
934 AppleEvent apple_event, reply;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
935 struct suspended_ae_info *next;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
936 };
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
937
72544
f8ade754466c (get_scrap_from_symbol, clear_scrap, put_scrap_string)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 71985
diff changeset
938 /* List of apple events deferred at the startup time. */
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
939 static struct suspended_ae_info *deferred_apple_events = NULL;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
940
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
941 /* List of suspended apple events, in order of expiration_tick. */
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
942 static struct suspended_ae_info *suspended_apple_events = NULL;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
943
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
944 static void
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
945 find_event_binding_fun (key, binding, args, data)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
946 Lisp_Object key, binding, args;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
947 void *data;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
948 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
949 struct apple_event_binding *event_binding =
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
950 (struct apple_event_binding *)data;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
951 Lisp_Object code_string;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
952
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
953 if (!SYMBOLP (key))
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
954 return;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
955 code_string = Fget (key, args);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
956 if (STRINGP (code_string) && SBYTES (code_string) == 4
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
957 && (EndianU32_BtoN (*((UInt32 *) SDATA (code_string)))
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
958 == event_binding->code))
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
959 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
960 event_binding->key = key;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
961 event_binding->binding = binding;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
962 }
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
963 }
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
964
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
965 static void
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
966 find_event_binding (keymap, event_binding, class_p)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
967 Lisp_Object keymap;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
968 struct apple_event_binding *event_binding;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
969 int class_p;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
970 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
971 if (event_binding->code == 0)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
972 event_binding->binding =
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
973 access_keymap (keymap, event_binding->key, 0, 1, 0);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
974 else
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
975 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
976 event_binding->binding = Qnil;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
977 map_keymap (keymap, find_event_binding_fun,
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
978 class_p ? Qmac_apple_event_class : Qmac_apple_event_id,
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
979 event_binding, 0);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
980 }
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
981 }
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
982
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
983 void
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
984 mac_find_apple_event_spec (class, id, class_key, id_key, binding)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
985 AEEventClass class;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
986 AEEventID id;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
987 Lisp_Object *class_key, *id_key, *binding;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
988 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
989 struct apple_event_binding event_binding;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
990 Lisp_Object keymap;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
991
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
992 *binding = Qnil;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
993
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
994 keymap = get_keymap (Vmac_apple_event_map, 0, 0);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
995 if (NILP (keymap))
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
996 return;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
997
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
998 event_binding.code = class;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
999 event_binding.key = *class_key;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1000 event_binding.binding = Qnil;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1001 find_event_binding (keymap, &event_binding, 1);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1002 *class_key = event_binding.key;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1003 keymap = get_keymap (event_binding.binding, 0, 0);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1004 if (NILP (keymap))
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1005 return;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1006
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1007 event_binding.code = id;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1008 event_binding.key = *id_key;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1009 event_binding.binding = Qnil;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1010 find_event_binding (keymap, &event_binding, 0);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1011 *id_key = event_binding.key;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1012 *binding = event_binding.binding;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1013 }
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1014
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1015 static OSErr
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1016 defer_apple_events (apple_event, reply)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1017 const AppleEvent *apple_event, *reply;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1018 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1019 OSErr err;
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1020 struct suspended_ae_info *new;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1021
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1022 new = xmalloc (sizeof (struct suspended_ae_info));
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1023 bzero (new, sizeof (struct suspended_ae_info));
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1024 new->apple_event.descriptorType = typeNull;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1025 new->reply.descriptorType = typeNull;
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1026
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1027 err = AESuspendTheCurrentEvent (apple_event);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1028
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1029 /* Mac OS 10.3 Xcode manual says AESuspendTheCurrentEvent makes
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1030 copies of the Apple event and the reply, but Mac OS 10.4 Xcode
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1031 manual says it doesn't. Anyway we create copies of them and save
69963
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
1032 them in `deferred_apple_events'. */
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1033 if (err == noErr)
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1034 err = AEDuplicateDesc (apple_event, &new->apple_event);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1035 if (err == noErr)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1036 err = AEDuplicateDesc (reply, &new->reply);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1037 if (err == noErr)
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1038 {
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1039 new->next = deferred_apple_events;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1040 deferred_apple_events = new;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1041 }
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1042 else
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1043 {
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1044 AEDisposeDesc (&new->apple_event);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1045 AEDisposeDesc (&new->reply);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1046 xfree (new);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1047 }
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1048
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1049 return err;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1050 }
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1051
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1052 static OSErr
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1053 mac_handle_apple_event_1 (class, id, apple_event, reply)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1054 Lisp_Object class, id;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1055 const AppleEvent *apple_event;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1056 AppleEvent *reply;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1057 {
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1058 OSErr err;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1059 static UInt32 suspension_id = 0;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1060 struct suspended_ae_info *new;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1061
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1062 new = xmalloc (sizeof (struct suspended_ae_info));
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1063 bzero (new, sizeof (struct suspended_ae_info));
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1064 new->apple_event.descriptorType = typeNull;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1065 new->reply.descriptorType = typeNull;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1066
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1067 err = AESuspendTheCurrentEvent (apple_event);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1068 if (err == noErr)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1069 err = AEDuplicateDesc (apple_event, &new->apple_event);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1070 if (err == noErr)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1071 err = AEDuplicateDesc (reply, &new->reply);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1072 if (err == noErr)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1073 err = AEPutAttributePtr (&new->apple_event, KEY_EMACS_SUSPENSION_ID_ATTR,
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1074 typeUInt32, &suspension_id, sizeof (UInt32));
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1075 if (err == noErr)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1076 {
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1077 OSErr err1;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1078 SInt32 reply_requested;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1079
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1080 err1 = AEGetAttributePtr (&new->apple_event, keyReplyRequestedAttr,
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1081 typeSInt32, NULL, &reply_requested,
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1082 sizeof (SInt32), NULL);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1083 if (err1 != noErr)
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1084 {
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1085 /* Emulate keyReplyRequestedAttr in older versions. */
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1086 reply_requested = reply->descriptorType != typeNull;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1087 err = AEPutAttributePtr (&new->apple_event, keyReplyRequestedAttr,
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1088 typeSInt32, &reply_requested,
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1089 sizeof (SInt32));
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1090 }
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1091 }
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1092 if (err == noErr)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1093 {
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1094 SInt32 timeout = 0;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1095 struct suspended_ae_info **p;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1096
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1097 new->suspension_id = suspension_id;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1098 suspension_id++;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1099 err = AEGetAttributePtr (apple_event, keyTimeoutAttr, typeSInt32,
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1100 NULL, &timeout, sizeof (SInt32), NULL);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1101 new->expiration_tick = TickCount () + timeout;
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1102
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1103 for (p = &suspended_apple_events; *p; p = &(*p)->next)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1104 if ((*p)->expiration_tick >= new->expiration_tick)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1105 break;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1106 new->next = *p;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1107 *p = new;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1108
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1109 mac_store_apple_event (class, id, &new->apple_event);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1110 }
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1111 else
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1112 {
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1113 AEDisposeDesc (&new->reply);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1114 AEDisposeDesc (&new->apple_event);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1115 xfree (new);
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1116 }
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1117
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1118 return err;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1119 }
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1120
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1121 static pascal OSErr
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1122 mac_handle_apple_event (apple_event, reply, refcon)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1123 const AppleEvent *apple_event;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1124 AppleEvent *reply;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1125 SInt32 refcon;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1126 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1127 OSErr err;
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1128 UInt32 suspension_id;
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1129 AEEventClass event_class;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1130 AEEventID event_id;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1131 Lisp_Object class_key, id_key, binding;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1132
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1133 if (!mac_ready_for_apple_events)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1134 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1135 err = defer_apple_events (apple_event, reply);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1136 if (err != noErr)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1137 return errAEEventNotHandled;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1138 return noErr;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1139 }
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1140
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1141 err = AEGetAttributePtr (apple_event, KEY_EMACS_SUSPENSION_ID_ATTR,
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1142 typeUInt32, NULL,
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1143 &suspension_id, sizeof (UInt32), NULL);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1144 if (err == noErr)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1145 /* Previously suspended event. Pass it to the next handler. */
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1146 return errAEEventNotHandled;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1147
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1148 err = AEGetAttributePtr (apple_event, keyEventClassAttr, typeType, NULL,
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1149 &event_class, sizeof (AEEventClass), NULL);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1150 if (err == noErr)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1151 err = AEGetAttributePtr (apple_event, keyEventIDAttr, typeType, NULL,
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1152 &event_id, sizeof (AEEventID), NULL);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1153 if (err == noErr)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1154 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1155 mac_find_apple_event_spec (event_class, event_id,
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1156 &class_key, &id_key, &binding);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1157 if (!NILP (binding) && !EQ (binding, Qundefined))
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1158 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1159 if (INTEGERP (binding))
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1160 return XINT (binding);
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1161 err = mac_handle_apple_event_1 (class_key, id_key,
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1162 apple_event, reply);
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1163 }
70988
5605e49b641f (mac_handle_apple_event): Return
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70873
diff changeset
1164 else
5605e49b641f (mac_handle_apple_event): Return
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70873
diff changeset
1165 err = errAEEventNotHandled;
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1166 }
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1167 if (err == noErr)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1168 return noErr;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1169 else
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1170 return errAEEventNotHandled;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1171 }
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1172
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1173 static int
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1174 cleanup_suspended_apple_events (head, all_p)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1175 struct suspended_ae_info **head;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1176 int all_p;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1177 {
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1178 UInt32 current_tick = TickCount (), nresumed = 0;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1179 struct suspended_ae_info *p, *next;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1180
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1181 for (p = *head; p; p = next)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1182 {
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1183 if (!all_p && p->expiration_tick > current_tick)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1184 break;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1185 AESetTheCurrentEvent (&p->apple_event);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1186 AEResumeTheCurrentEvent (&p->apple_event, &p->reply,
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1187 (AEEventHandlerUPP) kAENoDispatch, 0);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1188 AEDisposeDesc (&p->reply);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1189 AEDisposeDesc (&p->apple_event);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1190 nresumed++;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1191 next = p->next;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1192 xfree (p);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1193 }
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1194 *head = p;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1195
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1196 return nresumed;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1197 }
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1198
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1199 static void
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1200 cleanup_all_suspended_apple_events ()
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1201 {
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1202 cleanup_suspended_apple_events (&deferred_apple_events, 1);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1203 cleanup_suspended_apple_events (&suspended_apple_events, 1);
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1204 }
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1205
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1206 void
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1207 init_apple_event_handler ()
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1208 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1209 OSErr err;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1210 long result;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1211
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1212 /* Make sure we have Apple events before starting. */
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1213 err = Gestalt (gestaltAppleEventsAttr, &result);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1214 if (err != noErr)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1215 abort ();
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1216
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1217 if (!(result & (1 << gestaltAppleEventsPresent)))
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1218 abort ();
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1219
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1220 err = AEInstallEventHandler (typeWildCard, typeWildCard,
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1221 #if TARGET_API_MAC_CARBON
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1222 NewAEEventHandlerUPP (mac_handle_apple_event),
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1223 #else
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1224 NewAEEventHandlerProc (mac_handle_apple_event),
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1225 #endif
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1226 0L, false);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1227 if (err != noErr)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1228 abort ();
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1229
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1230 atexit (cleanup_all_suspended_apple_events);
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1231 }
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1232
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1233 static UInt32
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1234 get_suspension_id (apple_event)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1235 Lisp_Object apple_event;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1236 {
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1237 Lisp_Object tem;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1238
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1239 CHECK_CONS (apple_event);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1240 CHECK_STRING_CAR (apple_event);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1241 if (SBYTES (XCAR (apple_event)) != 4
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1242 || strcmp (SDATA (XCAR (apple_event)), "aevt") != 0)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1243 error ("Not an apple event");
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1244
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1245 tem = assq_no_quit (Qemacs_suspension_id, XCDR (apple_event));
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1246 if (NILP (tem))
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1247 error ("Suspension ID not available");
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1248
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1249 tem = XCDR (tem);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1250 if (!(CONSP (tem)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1251 && STRINGP (XCAR (tem)) && SBYTES (XCAR (tem)) == 4
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1252 && strcmp (SDATA (XCAR (tem)), "magn") == 0
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1253 && STRINGP (XCDR (tem)) && SBYTES (XCDR (tem)) == 4))
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1254 error ("Bad suspension ID format");
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1255
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1256 return *((UInt32 *) SDATA (XCDR (tem)));
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1257 }
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1258
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1259
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1260 DEFUN ("mac-process-deferred-apple-events", Fmac_process_deferred_apple_events, Smac_process_deferred_apple_events, 0, 0, 0,
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1261 doc: /* Process Apple events that are deferred at the startup time. */)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1262 ()
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1263 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1264 if (mac_ready_for_apple_events)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1265 return Qnil;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1266
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1267 BLOCK_INPUT;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1268 mac_ready_for_apple_events = 1;
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1269 if (deferred_apple_events)
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1270 {
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1271 struct suspended_ae_info *prev, *tail, *next;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1272
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1273 /* `nreverse' deferred_apple_events. */
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1274 prev = NULL;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1275 for (tail = deferred_apple_events; tail; tail = next)
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1276 {
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1277 next = tail->next;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1278 tail->next = prev;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1279 prev = tail;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1280 }
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1281
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1282 /* Now `prev' points to the first cell. */
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1283 for (tail = prev; tail; tail = next)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1284 {
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1285 next = tail->next;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1286 AEResumeTheCurrentEvent (&tail->apple_event, &tail->reply,
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1287 ((AEEventHandlerUPP)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1288 kAEUseStandardDispatch), 0);
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1289 AEDisposeDesc (&tail->reply);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1290 AEDisposeDesc (&tail->apple_event);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1291 xfree (tail);
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1292 }
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1293
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1294 deferred_apple_events = NULL;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1295 }
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1296 UNBLOCK_INPUT;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1297
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1298 return Qt;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1299 }
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1300
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1301 DEFUN ("mac-cleanup-expired-apple-events", Fmac_cleanup_expired_apple_events, Smac_cleanup_expired_apple_events, 0, 0, 0,
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1302 doc: /* Clean up expired Apple events.
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1303 Return the number of expired events. */)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1304 ()
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1305 {
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1306 int nexpired;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1307
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1308 BLOCK_INPUT;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1309 nexpired = cleanup_suspended_apple_events (&suspended_apple_events, 0);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1310 UNBLOCK_INPUT;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1311
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1312 return make_number (nexpired);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1313 }
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1314
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1315 DEFUN ("mac-ae-set-reply-parameter", Fmac_ae_set_reply_parameter, Smac_ae_set_reply_parameter, 3, 3, 0,
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1316 doc: /* Set parameter KEYWORD to DESCRIPTOR on reply of APPLE-EVENT.
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1317 KEYWORD is a 4-byte string. DESCRIPTOR is a Lisp representation of an
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1318 Apple event descriptor. It has the form of (TYPE . DATA), where TYPE
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1319 is a 4-byte string. Valid format of DATA is as follows:
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1320
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1321 * If TYPE is "null", then DATA is nil.
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1322 * If TYPE is "list", then DATA is a list (DESCRIPTOR1 ... DESCRIPTORn).
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1323 * If TYPE is "reco", then DATA is a list ((KEYWORD1 . DESCRIPTOR1)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1324 ... (KEYWORDn . DESCRIPTORn)).
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1325 * If TYPE is "aevt", then DATA is ignored and the descriptor is
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1326 treated as null.
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1327 * Otherwise, DATA is a string.
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1328
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1329 If a (sub-)descriptor is in an invalid format, it is silently treated
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1330 as null.
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1331
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1332 Return t if the parameter is successfully set. Otherwise return nil. */)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1333 (apple_event, keyword, descriptor)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1334 Lisp_Object apple_event, keyword, descriptor;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1335 {
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1336 Lisp_Object result = Qnil;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1337 UInt32 suspension_id;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1338 struct suspended_ae_info *p;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1339
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1340 suspension_id = get_suspension_id (apple_event);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1341
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1342 CHECK_STRING (keyword);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1343 if (SBYTES (keyword) != 4)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1344 error ("Apple event keyword must be a 4-byte string: %s",
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1345 SDATA (keyword));
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1346
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1347 BLOCK_INPUT;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1348 for (p = suspended_apple_events; p; p = p->next)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1349 if (p->suspension_id == suspension_id)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1350 break;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1351 if (p && p->reply.descriptorType != typeNull)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1352 {
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1353 OSErr err;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1354
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1355 err = mac_ae_put_lisp (&p->reply,
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1356 EndianU32_BtoN (*((UInt32 *) SDATA (keyword))),
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1357 descriptor);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1358 if (err == noErr)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1359 result = Qt;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1360 }
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1361 UNBLOCK_INPUT;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1362
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1363 return result;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1364 }
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1365
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1366 DEFUN ("mac-resume-apple-event", Fmac_resume_apple_event, Smac_resume_apple_event, 1, 2, 0,
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1367 doc: /* Resume handling of APPLE-EVENT.
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1368 Every Apple event handled by the Lisp interpreter is suspended first.
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1369 This function resumes such a suspended event either to complete Apple
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1370 event handling to give a reply, or to redispatch it to other handlers.
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1371
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1372 If optional ERROR-CODE is an integer, it specifies the error number
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1373 that is set in the reply. If ERROR-CODE is t, the resumed event is
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1374 handled with the standard dispatching mechanism, but it is not handled
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1375 by Emacs again, thus it is redispatched to other handlers.
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1376
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1377 Return t if APPLE-EVENT is successfully resumed. Otherwise return
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1378 nil, which means the event is already resumed or expired. */)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1379 (apple_event, error_code)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1380 Lisp_Object apple_event, error_code;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1381 {
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1382 Lisp_Object result = Qnil;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1383 UInt32 suspension_id;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1384 struct suspended_ae_info **p, *ae;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1385
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1386 suspension_id = get_suspension_id (apple_event);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1387
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1388 BLOCK_INPUT;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1389 for (p = &suspended_apple_events; *p; p = &(*p)->next)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1390 if ((*p)->suspension_id == suspension_id)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1391 break;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1392 if (*p)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1393 {
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1394 ae = *p;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1395 *p = (*p)->next;
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1396 if (INTEGERP (error_code)
75240
ffa0f75caa03 (Fmac_resume_apple_event): Set error number when
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 74628
diff changeset
1397 && ae->reply.descriptorType != typeNull)
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1398 {
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1399 SInt32 errn = XINT (error_code);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1400
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1401 AEPutParamPtr (&ae->reply, keyErrorNumber, typeSInt32,
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1402 &errn, sizeof (SInt32));
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1403 }
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1404 AESetTheCurrentEvent (&ae->apple_event);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1405 AEResumeTheCurrentEvent (&ae->apple_event, &ae->reply,
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1406 ((AEEventHandlerUPP)
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1407 (EQ (error_code, Qt) ?
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1408 kAEUseStandardDispatch : kAENoDispatch)),
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1409 0);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1410 AEDisposeDesc (&ae->reply);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1411 AEDisposeDesc (&ae->apple_event);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1412 xfree (ae);
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1413 result = Qt;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1414 }
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1415 UNBLOCK_INPUT;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1416
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1417 return result;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1418 }
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1419
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1420
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1421 /***********************************************************************
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1422 Drag and drop support
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1423 ***********************************************************************/
70383
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1424 #if TARGET_API_MAC_CARBON
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1425 static Lisp_Object Vmac_dnd_known_types;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1426 static pascal OSErr mac_do_track_drag P_ ((DragTrackingMessage, WindowRef,
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1427 void *, DragRef));
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1428 static pascal OSErr mac_do_receive_drag P_ ((WindowRef, void *, DragRef));
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1429 static DragTrackingHandlerUPP mac_do_track_dragUPP = NULL;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1430 static DragReceiveHandlerUPP mac_do_receive_dragUPP = NULL;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1431
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1432 extern void mac_store_drag_event P_ ((WindowRef, Point, SInt16,
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1433 const AEDesc *));
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1434
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1435 static pascal OSErr
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1436 mac_do_track_drag (message, window, refcon, drag)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1437 DragTrackingMessage message;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1438 WindowRef window;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1439 void *refcon;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1440 DragRef drag;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1441 {
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1442 OSErr err = noErr;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1443 static int can_accept;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1444 UInt16 num_items, index;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1445
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1446 if (GetFrontWindowOfClass (kMovableModalWindowClass, false))
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1447 return dragNotAcceptedErr;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1448
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1449 switch (message)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1450 {
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1451 case kDragTrackingEnterHandler:
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1452 err = CountDragItems (drag, &num_items);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1453 if (err != noErr)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1454 break;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1455 can_accept = 0;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1456 for (index = 1; index <= num_items; index++)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1457 {
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1458 ItemReference item;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1459 FlavorFlags flags;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1460 Lisp_Object rest;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1461
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1462 err = GetDragItemReferenceNumber (drag, index, &item);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1463 if (err != noErr)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1464 continue;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1465 for (rest = Vmac_dnd_known_types; CONSP (rest); rest = XCDR (rest))
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1466 {
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1467 Lisp_Object str;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1468 FlavorType type;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1469
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1470 str = XCAR (rest);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1471 if (!(STRINGP (str) && SBYTES (str) == 4))
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1472 continue;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1473 type = EndianU32_BtoN (*((UInt32 *) SDATA (str)));
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1474
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1475 err = GetFlavorFlags (drag, item, type, &flags);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1476 if (err == noErr)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1477 {
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1478 can_accept = 1;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1479 break;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1480 }
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1481 }
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1482 }
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1483 break;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1484
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1485 case kDragTrackingEnterWindow:
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1486 if (can_accept)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1487 {
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1488 RgnHandle hilite_rgn = NewRgn ();
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1489
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1490 if (hilite_rgn)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1491 {
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1492 Rect r;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1493
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1494 GetWindowPortBounds (window, &r);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1495 OffsetRect (&r, -r.left, -r.top);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1496 RectRgn (hilite_rgn, &r);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1497 ShowDragHilite (drag, hilite_rgn, true);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1498 DisposeRgn (hilite_rgn);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1499 }
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1500 SetThemeCursor (kThemeCopyArrowCursor);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1501 }
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1502 break;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1503
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1504 case kDragTrackingInWindow:
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1505 break;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1506
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1507 case kDragTrackingLeaveWindow:
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1508 if (can_accept)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1509 {
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1510 HideDragHilite (drag);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1511 SetThemeCursor (kThemeArrowCursor);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1512 }
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1513 break;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1514
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1515 case kDragTrackingLeaveHandler:
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1516 break;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1517 }
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1518
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1519 if (err != noErr)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1520 return dragNotAcceptedErr;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1521 return noErr;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1522 }
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1523
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1524 static pascal OSErr
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1525 mac_do_receive_drag (window, refcon, drag)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1526 WindowRef window;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1527 void *refcon;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1528 DragRef drag;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1529 {
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1530 OSErr err;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1531 int num_types, i;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1532 Lisp_Object rest, str;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1533 FlavorType *types;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1534 AppleEvent apple_event;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1535 Point mouse_pos;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1536 SInt16 modifiers;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1537
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1538 if (GetFrontWindowOfClass (kMovableModalWindowClass, false))
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1539 return dragNotAcceptedErr;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1540
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1541 num_types = 0;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1542 for (rest = Vmac_dnd_known_types; CONSP (rest); rest = XCDR (rest))
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1543 {
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1544 str = XCAR (rest);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1545 if (STRINGP (str) && SBYTES (str) == 4)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1546 num_types++;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1547 }
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1548
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1549 types = xmalloc (sizeof (FlavorType) * num_types);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1550 i = 0;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1551 for (rest = Vmac_dnd_known_types; CONSP (rest); rest = XCDR (rest))
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1552 {
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1553 str = XCAR (rest);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1554 if (STRINGP (str) && SBYTES (str) == 4)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1555 types[i++] = EndianU32_BtoN (*((UInt32 *) SDATA (str)));
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1556 }
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1557
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1558 err = create_apple_event_from_drag_ref (drag, num_types, types,
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1559 &apple_event);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1560 xfree (types);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1561
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1562 if (err == noErr)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1563 err = GetDragMouse (drag, &mouse_pos, NULL);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1564 if (err == noErr)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1565 {
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1566 GlobalToLocal (&mouse_pos);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1567 err = GetDragModifiers (drag, NULL, NULL, &modifiers);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1568 }
75376
7b70538ea11c [TARGET_API_MAC_CARBON] (mac_do_receive_drag): Don't
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75348
diff changeset
1569 if (err == noErr)
7b70538ea11c [TARGET_API_MAC_CARBON] (mac_do_receive_drag): Don't
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75348
diff changeset
1570 {
7b70538ea11c [TARGET_API_MAC_CARBON] (mac_do_receive_drag): Don't
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75348
diff changeset
1571 UInt32 key_modifiers = modifiers;
7b70538ea11c [TARGET_API_MAC_CARBON] (mac_do_receive_drag): Don't
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75348
diff changeset
1572
7b70538ea11c [TARGET_API_MAC_CARBON] (mac_do_receive_drag): Don't
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75348
diff changeset
1573 err = AEPutParamPtr (&apple_event, kEventParamKeyModifiers,
7b70538ea11c [TARGET_API_MAC_CARBON] (mac_do_receive_drag): Don't
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75348
diff changeset
1574 typeUInt32, &key_modifiers, sizeof (UInt32));
7b70538ea11c [TARGET_API_MAC_CARBON] (mac_do_receive_drag): Don't
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75348
diff changeset
1575 }
70383
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1576
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1577 if (err == noErr)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1578 {
75376
7b70538ea11c [TARGET_API_MAC_CARBON] (mac_do_receive_drag): Don't
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75348
diff changeset
1579 mac_store_drag_event (window, mouse_pos, 0, &apple_event);
70383
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1580 AEDisposeDesc (&apple_event);
74628
6f17f4d8d9d6 [TARGET_API_MAC_CARBON] (mac_do_receive_drag): Use
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 73574
diff changeset
1581 mac_wakeup_from_rne ();
70383
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1582 return noErr;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1583 }
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1584 else
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1585 return dragNotAcceptedErr;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1586 }
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1587 #endif /* TARGET_API_MAC_CARBON */
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1588
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1589 OSErr
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1590 install_drag_handler (window)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1591 WindowRef window;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1592 {
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1593 OSErr err = noErr;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1594
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1595 #if TARGET_API_MAC_CARBON
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1596 if (mac_do_track_dragUPP == NULL)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1597 mac_do_track_dragUPP = NewDragTrackingHandlerUPP (mac_do_track_drag);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1598 if (mac_do_receive_dragUPP == NULL)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1599 mac_do_receive_dragUPP = NewDragReceiveHandlerUPP (mac_do_receive_drag);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1600
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1601 err = InstallTrackingHandler (mac_do_track_dragUPP, window, NULL);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1602 if (err == noErr)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1603 err = InstallReceiveHandler (mac_do_receive_dragUPP, window, NULL);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1604 #endif
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1605
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1606 return err;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1607 }
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1608
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1609 void
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1610 remove_drag_handler (window)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1611 WindowRef window;
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1612 {
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1613 #if TARGET_API_MAC_CARBON
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1614 if (mac_do_track_dragUPP)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1615 RemoveTrackingHandler (mac_do_track_dragUPP, window);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1616 if (mac_do_receive_dragUPP)
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1617 RemoveReceiveHandler (mac_do_receive_dragUPP, window);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1618 #endif
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1619 }
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1620
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1621
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1622 /***********************************************************************
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1623 Services menu support
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1624 ***********************************************************************/
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1625 #ifdef MAC_OSX
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1626 void
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1627 init_service_handler ()
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1628 {
73574
848513456fe7 (init_service_handler): Make variable `specs' static
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72544
diff changeset
1629 static const EventTypeSpec specs[] =
848513456fe7 (init_service_handler): Make variable `specs' static
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72544
diff changeset
1630 {{kEventClassService, kEventServiceGetTypes},
848513456fe7 (init_service_handler): Make variable `specs' static
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72544
diff changeset
1631 {kEventClassService, kEventServiceCopy},
848513456fe7 (init_service_handler): Make variable `specs' static
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72544
diff changeset
1632 {kEventClassService, kEventServicePaste},
848513456fe7 (init_service_handler): Make variable `specs' static
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 72544
diff changeset
1633 {kEventClassService, kEventServicePerform}};
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1634 InstallApplicationEventHandler (NewEventHandlerUPP (mac_handle_service_event),
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1635 GetEventTypeCount (specs), specs, NULL, NULL);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1636 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1637
70562
e2bd086e6902 (Vmac_service_selection) [MAC_OSX]: Rename from
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70495
diff changeset
1638 extern OSStatus mac_store_service_event P_ ((EventRef));
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1639
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1640 static OSStatus
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1641 copy_scrap_flavor_data (from_scrap, to_scrap, flavor_type)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1642 ScrapRef from_scrap, to_scrap;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1643 ScrapFlavorType flavor_type;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1644 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1645 OSStatus err;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1646 Size size, size_allocated;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1647 char *buf = NULL;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1648
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1649 err = GetScrapFlavorSize (from_scrap, flavor_type, &size);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1650 if (err == noErr)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1651 buf = xmalloc (size);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1652 while (buf)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1653 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1654 size_allocated = size;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1655 err = GetScrapFlavorData (from_scrap, flavor_type, &size, buf);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1656 if (err != noErr)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1657 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1658 xfree (buf);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1659 buf = NULL;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1660 }
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1661 else if (size_allocated < size)
70070
9559d7f62131 (get_scrap_target_type_list, defer_apple_events)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69963
diff changeset
1662 buf = xrealloc (buf, size);
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1663 else
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1664 break;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1665 }
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1666 if (err == noErr)
69963
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
1667 {
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
1668 if (buf == NULL)
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
1669 err = memFullErr;
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
1670 else
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
1671 {
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
1672 err = PutScrapFlavor (to_scrap, flavor_type, kScrapFlavorMaskNone,
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
1673 size, buf);
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
1674 xfree (buf);
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
1675 }
b25e279aa874 (get_flavor_type_from_symbol): Remove unused variable `val'.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67489
diff changeset
1676 }
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1677
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1678 return err;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1679 }
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1680
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1681 static OSStatus
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1682 mac_handle_service_event (call_ref, event, data)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1683 EventHandlerCallRef call_ref;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1684 EventRef event;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1685 void *data;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1686 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1687 OSStatus err = noErr;
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1688 ScrapRef cur_scrap, specific_scrap;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1689 UInt32 event_kind = GetEventKind (event);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1690 CFMutableArrayRef copy_types, paste_types;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1691 CFStringRef type;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1692 Lisp_Object rest;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1693 ScrapFlavorType flavor_type;
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1694
70562
e2bd086e6902 (Vmac_service_selection) [MAC_OSX]: Rename from
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70495
diff changeset
1695 /* Check if Vmac_service_selection is a valid selection that has a
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1696 corresponding scrap. */
70562
e2bd086e6902 (Vmac_service_selection) [MAC_OSX]: Rename from
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70495
diff changeset
1697 if (!SYMBOLP (Vmac_service_selection))
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1698 err = eventNotHandledErr;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1699 else
70562
e2bd086e6902 (Vmac_service_selection) [MAC_OSX]: Rename from
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70495
diff changeset
1700 err = get_scrap_from_symbol (Vmac_service_selection, 0, &cur_scrap);
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1701 if (!(err == noErr && cur_scrap))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1702 return eventNotHandledErr;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1703
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1704 switch (event_kind)
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1705 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1706 case kEventServiceGetTypes:
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1707 /* Set paste types. */
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1708 err = GetEventParameter (event, kEventParamServicePasteTypes,
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1709 typeCFMutableArrayRef, NULL,
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1710 sizeof (CFMutableArrayRef), NULL,
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1711 &paste_types);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1712 if (err != noErr)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1713 break;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1714
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1715 for (rest = Vselection_converter_alist; CONSP (rest);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1716 rest = XCDR (rest))
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1717 if (CONSP (XCAR (rest)) && SYMBOLP (XCAR (XCAR (rest)))
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1718 && (flavor_type =
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1719 get_flavor_type_from_symbol (XCAR (XCAR (rest)))))
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1720 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1721 type = CreateTypeStringWithOSType (flavor_type);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1722 if (type)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1723 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1724 CFArrayAppendValue (paste_types, type);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1725 CFRelease (type);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1726 }
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1727 }
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1728
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1729 /* Set copy types. */
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1730 err = GetEventParameter (event, kEventParamServiceCopyTypes,
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1731 typeCFMutableArrayRef, NULL,
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1732 sizeof (CFMutableArrayRef), NULL,
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1733 &copy_types);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1734 if (err != noErr)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1735 break;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1736
70562
e2bd086e6902 (Vmac_service_selection) [MAC_OSX]: Rename from
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70495
diff changeset
1737 if (NILP (Fx_selection_owner_p (Vmac_service_selection)))
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1738 break;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1739 else
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1740 goto copy_all_flavors;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1741
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1742 case kEventServiceCopy:
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1743 err = GetEventParameter (event, kEventParamScrapRef,
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1744 typeScrapRef, NULL,
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1745 sizeof (ScrapRef), NULL, &specific_scrap);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1746 if (err != noErr
70562
e2bd086e6902 (Vmac_service_selection) [MAC_OSX]: Rename from
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70495
diff changeset
1747 || NILP (Fx_selection_owner_p (Vmac_service_selection)))
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1748 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1749 err = eventNotHandledErr;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1750 break;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1751 }
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1752
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1753 copy_all_flavors:
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1754 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1755 UInt32 count, i;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1756 ScrapFlavorInfo *flavor_info = NULL;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1757 ScrapFlavorFlags flags;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1758
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1759 err = GetScrapFlavorCount (cur_scrap, &count);
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1760 if (err == noErr)
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1761 flavor_info = xmalloc (sizeof (ScrapFlavorInfo) * count);
70070
9559d7f62131 (get_scrap_target_type_list, defer_apple_events)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69963
diff changeset
1762 err = GetScrapFlavorInfoList (cur_scrap, &count, flavor_info);
9559d7f62131 (get_scrap_target_type_list, defer_apple_events)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69963
diff changeset
1763 if (err != noErr)
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1764 {
70070
9559d7f62131 (get_scrap_target_type_list, defer_apple_events)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69963
diff changeset
1765 xfree (flavor_info);
9559d7f62131 (get_scrap_target_type_list, defer_apple_events)
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 69963
diff changeset
1766 flavor_info = NULL;
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1767 }
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1768 if (flavor_info == NULL)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1769 break;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1770
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1771 for (i = 0; i < count; i++)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1772 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1773 flavor_type = flavor_info[i].flavorType;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1774 err = GetScrapFlavorFlags (cur_scrap, flavor_type, &flags);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1775 if (err == noErr && !(flags & kScrapFlavorMaskSenderOnly))
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1776 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1777 if (event_kind == kEventServiceCopy)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1778 err = copy_scrap_flavor_data (cur_scrap, specific_scrap,
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1779 flavor_type);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1780 else /* event_kind == kEventServiceGetTypes */
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1781 {
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1782 type = CreateTypeStringWithOSType (flavor_type);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1783 if (type)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1784 {
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1785 CFArrayAppendValue (copy_types, type);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1786 CFRelease (type);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1787 }
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1788 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1789 }
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1790 }
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1791 xfree (flavor_info);
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1792 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1793 break;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1794
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1795 case kEventServicePaste:
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1796 case kEventServicePerform:
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1797 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1798 int data_exists_p = 0;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1799
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1800 err = GetEventParameter (event, kEventParamScrapRef, typeScrapRef,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1801 NULL, sizeof (ScrapRef), NULL,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1802 &specific_scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1803 if (err == noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1804 err = clear_scrap (&cur_scrap);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1805 if (err == noErr)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1806 for (rest = Vselection_converter_alist; CONSP (rest);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1807 rest = XCDR (rest))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1808 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1809 if (! (CONSP (XCAR (rest)) && SYMBOLP (XCAR (XCAR (rest)))))
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1810 continue;
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1811 flavor_type = get_flavor_type_from_symbol (XCAR (XCAR (rest)));
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1812 if (flavor_type == 0)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1813 continue;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1814 err = copy_scrap_flavor_data (specific_scrap, cur_scrap,
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1815 flavor_type);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1816 if (err == noErr)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1817 data_exists_p = 1;
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1818 }
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1819 if (!data_exists_p)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1820 err = eventNotHandledErr;
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1821 else
70562
e2bd086e6902 (Vmac_service_selection) [MAC_OSX]: Rename from
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70495
diff changeset
1822 err = mac_store_service_event (event);
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1823 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1824 break;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1825 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1826
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1827 if (err != noErr)
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1828 err = eventNotHandledErr;
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1829 return err;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1830 }
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1831 #endif
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1832
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1833
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1834 void
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1835 syms_of_macselect ()
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1836 {
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1837 defsubr (&Sx_get_selection_internal);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1838 defsubr (&Sx_own_selection_internal);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1839 defsubr (&Sx_disown_selection_internal);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1840 defsubr (&Sx_selection_owner_p);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1841 defsubr (&Sx_selection_exists_p);
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1842 defsubr (&Smac_process_deferred_apple_events);
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1843 defsubr (&Smac_cleanup_expired_apple_events);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1844 defsubr (&Smac_resume_apple_event);
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1845 defsubr (&Smac_ae_set_reply_parameter);
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1846
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1847 Vselection_alist = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1848 staticpro (&Vselection_alist);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1849
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1850 DEFVAR_LISP ("selection-converter-alist", &Vselection_converter_alist,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1851 doc: /* An alist associating selection-types with functions.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1852 These functions are called to convert the selection, with three args:
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1853 the name of the selection (typically `PRIMARY', `SECONDARY', or `CLIPBOARD');
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1854 a desired type to which the selection should be converted;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1855 and the local selection value (whatever was given to `x-own-selection').
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1856
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1857 The function should return the value to send to the Scrap Manager
64607
fefea1491def (Fx_own_selection_internal): Follow error conventions.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64312
diff changeset
1858 \(must be a string). A return value of nil
76745
f6a525134188 (get_scrap_target_type_list, x_own_selection): Move
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 75376
diff changeset
1859 means that the conversion could not be done. */);
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1860 Vselection_converter_alist = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1861
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1862 DEFVAR_LISP ("x-lost-selection-functions", &Vx_lost_selection_functions,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1863 doc: /* A list of functions to be called when Emacs loses a selection.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1864 \(This happens when a Lisp program explicitly clears the selection.)
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1865 The functions are called with one argument, the selection type
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1866 \(a symbol, typically `PRIMARY', `SECONDARY', or `CLIPBOARD'). */);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1867 Vx_lost_selection_functions = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1868
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1869 DEFVAR_LISP ("selection-coding-system", &Vselection_coding_system,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1870 doc: /* Coding system for communicating with other programs.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1871 When sending or receiving text via cut_buffer, selection, and clipboard,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1872 the text is encoded or decoded by this coding system.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1873 The default value is determined by the system script code. */);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1874 Vselection_coding_system = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1875
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1876 DEFVAR_LISP ("next-selection-coding-system", &Vnext_selection_coding_system,
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1877 doc: /* Coding system for the next communication with other programs.
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1878 Usually, `selection-coding-system' is used for communicating with
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1879 other programs. But, if this variable is set, it is used for the
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1880 next communication only. After the communication, this variable is
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1881 set to nil. */);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1882 Vnext_selection_coding_system = Qnil;
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1883
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1884 DEFVAR_LISP ("mac-apple-event-map", &Vmac_apple_event_map,
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1885 doc: /* Keymap for Apple events handled by Emacs. */);
67489
e9ee2ee1d26e (syms_of_macselect) <mac-apple-event-map>:
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 67457
diff changeset
1886 Vmac_apple_event_map = Qnil;
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1887
70383
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1888 #if TARGET_API_MAC_CARBON
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1889 DEFVAR_LISP ("mac-dnd-known-types", &Vmac_dnd_known_types,
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1890 doc: /* The types accepted by default for dropped data.
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1891 The types are chosen in the order they appear in the list. */);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1892 Vmac_dnd_known_types = list4 (build_string ("hfs "), build_string ("utxt"),
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1893 build_string ("TEXT"), build_string ("TIFF"));
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1894 #ifdef MAC_OSX
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1895 Vmac_dnd_known_types = Fcons (build_string ("furl"), Vmac_dnd_known_types);
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1896 #endif
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1897 #endif
84a220b0dd72 Update copyright year.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70070
diff changeset
1898
62271
6cae229f309b (syms_of_macselect) [MAC_OSX]: Apply a change that was previously
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62102
diff changeset
1899 #ifdef MAC_OSX
70562
e2bd086e6902 (Vmac_service_selection) [MAC_OSX]: Rename from
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70495
diff changeset
1900 DEFVAR_LISP ("mac-service-selection", &Vmac_service_selection,
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1901 doc: /* Selection name for communication via Services menu. */);
70562
e2bd086e6902 (Vmac_service_selection) [MAC_OSX]: Rename from
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70495
diff changeset
1902 Vmac_service_selection = intern ("PRIMARY");
62271
6cae229f309b (syms_of_macselect) [MAC_OSX]: Apply a change that was previously
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 62102
diff changeset
1903 #endif
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1904
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1905 QPRIMARY = intern ("PRIMARY"); staticpro (&QPRIMARY);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1906 QSECONDARY = intern ("SECONDARY"); staticpro (&QSECONDARY);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1907 QTIMESTAMP = intern ("TIMESTAMP"); staticpro (&QTIMESTAMP);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1908 QTARGETS = intern ("TARGETS"); staticpro (&QTARGETS);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1909
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1910 Qforeign_selection = intern ("foreign-selection");
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1911 staticpro (&Qforeign_selection);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1912
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1913 Qmac_scrap_name = intern ("mac-scrap-name");
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1914 staticpro (&Qmac_scrap_name);
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1915
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1916 Qmac_ostype = intern ("mac-ostype");
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1917 staticpro (&Qmac_ostype);
67457
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1918
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1919 Qmac_apple_event_class = intern ("mac-apple-event-class");
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1920 staticpro (&Qmac_apple_event_class);
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1921
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1922 Qmac_apple_event_id = intern ("mac-apple-event-id");
819dc1a5c256 Include keymap.h.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 64607
diff changeset
1923 staticpro (&Qmac_apple_event_id);
70873
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1924
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1925 Qemacs_suspension_id = intern ("emacs-suspension-id");
523dd2f40cc1 (Qemacs_suspension_id): New variable.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents: 70562
diff changeset
1926 staticpro (&Qemacs_suspension_id);
61777
c323711ae68f New file for selection processing on Mac OS.
YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
parents:
diff changeset
1927 }
61819
df86749111d6 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 61777
diff changeset
1928
df86749111d6 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 61777
diff changeset
1929 /* arch-tag: f3c91ad8-99e0-4bd6-9eef-251b2f848732
df86749111d6 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 61777
diff changeset
1930 (do not change this comment) */