aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2005-07-13 09:12:59 +0000
committerYAMAMOTO Mitsuharu2005-07-13 09:12:59 +0000
commit95dfb192752c48823cabe86399ed29d1d9edd04d (patch)
treea6b42d82e4fb78e52ff3278626280ebe5e5e2fd2 /src
parent852f7e6b6a3ed198c36aa3c8ff0bacba0179d68e (diff)
downloademacs-95dfb192752c48823cabe86399ed29d1d9edd04d.tar.gz
emacs-95dfb192752c48823cabe86399ed29d1d9edd04d.zip
Don't include stdlib.h or composite.h.
(x_use_underline_position_properties, last_mouse_press_frame) (x_noop_count, Qvendor_specific_keysyms): Remove unused variables. (syms_of_macterm, mac_initialize): Don't initialize them. (waiting_for_input, initial_argv, initial_argc) (Vcommand_line_args, Vx_no_window_manager, errno, window_scroll) (set_frame_menubar, path_from_vol_dir_name): Remove externs. (extra_keyboard_modifiers): Fix type in extern. (x_window_to_frame, x_window_to_scroll_bar): Remove declarations. (x_scroll_bar_report_motion): Add argument types to declaration. (mac_compute_glyph_string_overhangs): Add declaration. (disable_mouse_highlight): Remove unused variable. [USE_TOOLKIT_SCROLL_BARS] (construct_scroll_bar_click) (x_scroll_bar_handle_press, x_scroll_bar_handle_release) (x_scroll_bar_handle_drag): Remove argument `timestamp'. All callers changed. [USE_TOOLKIT_SCROLL_BARS] (construct_scroll_bar_click): Don't set timestamp. [USE_CARBON_EVENTS] (mac_handle_mouse_event): Likewise. (x_scroll_bar_create, XTset_vertical_scroll_bar): Show scroll bar only when its width is less than the height. (XTredeem_scroll_bar): Sync with xterm.c. (font_name_table, font_name_table_size, font_name_count): Make static. (drag_and_drop_file_list): Remove variable. Previous use is now local to function. (do_ae_open_documents): Move DRAG_N_DROP event construction part from XTread_socket. (XTread_socket): Consolidate setting of event timestamp. Move DRAG_N_DROP event construction part to do_ae_open_documents. Support extra_keyboard_modifiers.
Diffstat (limited to 'src')
-rw-r--r--src/macterm.c467
1 files changed, 151 insertions, 316 deletions
diff --git a/src/macterm.c b/src/macterm.c
index 59aafc3cd76..533464390c5 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -22,10 +22,10 @@ Boston, MA 02110-1301, USA. */
22 22
23#include <config.h> 23#include <config.h>
24#include <signal.h> 24#include <signal.h>
25
25#include <stdio.h> 26#include <stdio.h>
26#include <stdlib.h> 27
27#include "lisp.h" 28#include "lisp.h"
28#include "charset.h"
29#include "blockinput.h" 29#include "blockinput.h"
30 30
31#include "macterm.h" 31#include "macterm.h"
@@ -62,8 +62,6 @@ Boston, MA 02110-1301, USA. */
62 62
63#include "systty.h" 63#include "systty.h"
64#include "systime.h" 64#include "systime.h"
65#include "atimer.h"
66#include "keymap.h"
67 65
68#include <ctype.h> 66#include <ctype.h>
69#include <errno.h> 67#include <errno.h>
@@ -71,7 +69,8 @@ Boston, MA 02110-1301, USA. */
71#include <sys/stat.h> 69#include <sys/stat.h>
72#include <sys/param.h> 70#include <sys/param.h>
73 71
74#include "keyboard.h" 72#include "charset.h"
73#include "coding.h"
75#include "frame.h" 74#include "frame.h"
76#include "dispextern.h" 75#include "dispextern.h"
77#include "fontset.h" 76#include "fontset.h"
@@ -82,9 +81,10 @@ Boston, MA 02110-1301, USA. */
82#include "disptab.h" 81#include "disptab.h"
83#include "buffer.h" 82#include "buffer.h"
84#include "window.h" 83#include "window.h"
84#include "keyboard.h"
85#include "intervals.h" 85#include "intervals.h"
86#include "composite.h" 86#include "atimer.h"
87#include "coding.h" 87#include "keymap.h"
88 88
89/* Set of macros that handle mapping of Mac modifier keys to emacs. */ 89/* Set of macros that handle mapping of Mac modifier keys to emacs. */
90#define macCtrlKey (NILP (Vmac_reverse_ctrl_meta) ? controlKey : \ 90#define macCtrlKey (NILP (Vmac_reverse_ctrl_meta) ? controlKey : \
@@ -114,15 +114,6 @@ static int any_help_event_p;
114/* Last window where we saw the mouse. Used by mouse-autoselect-window. */ 114/* Last window where we saw the mouse. Used by mouse-autoselect-window. */
115static Lisp_Object last_window; 115static Lisp_Object last_window;
116 116
117/* Non-zero means make use of UNDERLINE_POSITION font properties. */
118
119int x_use_underline_position_properties;
120
121/* Non-zero means draw block and hollow cursor as wide as the glyph
122 under it. For example, if a block cursor is over a tab, it will be
123 drawn as wide as that tab on the display. */
124
125
126/* This is a chain of structures for all the X displays currently in 117/* This is a chain of structures for all the X displays currently in
127 use. */ 118 use. */
128 119
@@ -148,8 +139,6 @@ struct mac_display_info one_mac_display_info;
148 139
149extern struct frame *updating_frame; 140extern struct frame *updating_frame;
150 141
151extern int waiting_for_input;
152
153/* This is a frame waiting to be auto-raised, within XTread_socket. */ 142/* This is a frame waiting to be auto-raised, within XTread_socket. */
154 143
155struct frame *pending_autoraise_frame; 144struct frame *pending_autoraise_frame;
@@ -177,7 +166,6 @@ struct frame *pending_autoraise_frame;
177/* Where the mouse was last time we reported a mouse event. */ 166/* Where the mouse was last time we reported a mouse event. */
178 167
179static Rect last_mouse_glyph; 168static Rect last_mouse_glyph;
180static Lisp_Object last_mouse_press_frame;
181 169
182/* The scroll bar in which the last X motion event occurred. 170/* The scroll bar in which the last X motion event occurred.
183 171
@@ -211,45 +199,24 @@ static int volatile input_signal_count;
211static int input_signal_count; 199static int input_signal_count;
212#endif 200#endif
213 201
214/* Used locally within XTread_socket. */ 202extern Lisp_Object Vsystem_name;
215
216static int x_noop_count;
217
218/* Initial values of argv and argc. */
219
220extern char **initial_argv;
221extern int initial_argc;
222
223extern Lisp_Object Vcommand_line_args, Vsystem_name;
224
225/* Tells if a window manager is present or not. */
226
227extern Lisp_Object Vx_no_window_manager;
228
229extern int errno;
230 203
231/* A mask of extra modifier bits to put into every keyboard char. */ 204/* A mask of extra modifier bits to put into every keyboard char. */
232 205
233extern int extra_keyboard_modifiers; 206extern EMACS_INT extra_keyboard_modifiers;
234 207
235/* The keysyms to use for the various modifiers. */ 208/* The keysyms to use for the various modifiers. */
236 209
237static Lisp_Object Qalt, Qhyper, Qsuper, Qmodifier_value; 210static Lisp_Object Qalt, Qhyper, Qsuper, Qmodifier_value;
238 211
239static Lisp_Object Qvendor_specific_keysyms;
240
241#if 0
242extern XrmDatabase x_load_resources P_ ((Display *, char *, char *, char *));
243#endif
244
245extern int inhibit_window_system; 212extern int inhibit_window_system;
246 213
247#if __MRC__ && !TARGET_API_MAC_CARBON 214#if __MRC__ && !TARGET_API_MAC_CARBON
248QDGlobals qd; /* QuickDraw global information structure. */ 215QDGlobals qd; /* QuickDraw global information structure. */
249#endif 216#endif
250 217
218#define mac_window_to_frame(wp) (((mac_output *) GetWRefCon (wp))->mFP)
251 219
252struct frame * x_window_to_frame (struct mac_display_info *, WindowPtr);
253struct mac_display_info *mac_display_info_for_display (Display *); 220struct mac_display_info *mac_display_info_for_display (Display *);
254static void x_update_window_end P_ ((struct window *, int, int)); 221static void x_update_window_end P_ ((struct window *, int, int));
255static int x_io_error_quitter P_ ((Display *)); 222static int x_io_error_quitter P_ ((Display *));
@@ -289,17 +256,18 @@ static void x_flush P_ ((struct frame *f));
289static void x_update_begin P_ ((struct frame *)); 256static void x_update_begin P_ ((struct frame *));
290static void x_update_window_begin P_ ((struct window *)); 257static void x_update_window_begin P_ ((struct window *));
291static void x_after_update_window_line P_ ((struct glyph_row *)); 258static void x_after_update_window_line P_ ((struct glyph_row *));
259static void x_scroll_bar_report_motion P_ ((struct frame **, Lisp_Object *,
260 enum scroll_bar_part *,
261 Lisp_Object *, Lisp_Object *,
262 unsigned long *));
292 263
293static int is_emacs_window (WindowPtr); 264static int is_emacs_window (WindowPtr);
294 265
295int x_bitmap_icon (struct frame *, Lisp_Object); 266int x_bitmap_icon (struct frame *, Lisp_Object);
296void x_make_frame_visible (struct frame *); 267void x_make_frame_visible (struct frame *);
297 268
298extern void window_scroll (Lisp_Object, int, int, int);
299
300/* Defined in macmenu.h. */ 269/* Defined in macmenu.h. */
301extern void menubar_selection_callback (FRAME_PTR, int); 270extern void menubar_selection_callback (FRAME_PTR, int);
302extern void set_frame_menubar (FRAME_PTR, int, int);
303 271
304/* X display function emulation */ 272/* X display function emulation */
305 273
@@ -912,24 +880,6 @@ mac_copy_area_with_mask (display, src, mask, dest, gc, src_x, src_y,
912} 880}
913 881
914 882
915#if 0
916/* Convert a pair of local coordinates to global (screen) coordinates.
917 Assume graphic port has been properly set. */
918static void
919local_to_global_coord (short *h, short *v)
920{
921 Point p;
922
923 p.h = *h;
924 p.v = *v;
925
926 LocalToGlobal (&p);
927
928 *h = p.h;
929 *v = p.v;
930}
931#endif
932
933/* Mac replacement for XCopyArea: used only for scrolling. */ 883/* Mac replacement for XCopyArea: used only for scrolling. */
934 884
935static void 885static void
@@ -953,23 +903,10 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
953 Rect src_r, dest_r; 903 Rect src_r, dest_r;
954 904
955 SetPort (w); 905 SetPort (w);
956#if 0
957 mac_set_colors (gc, NULL);
958#endif
959 906
960 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height); 907 SetRect (&src_r, src_x, src_y, src_x + width, src_y + height);
961 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height); 908 SetRect (&dest_r, dest_x, dest_y, dest_x + width, dest_y + height);
962 909
963#if 0
964 /* Need to use global coordinates and screenBits since src and dest
965 areas overlap in general. */
966 local_to_global_coord (&src_r.left, &src_r.top);
967 local_to_global_coord (&src_r.right, &src_r.bottom);
968 local_to_global_coord (&dest_r.left, &dest_r.top);
969 local_to_global_coord (&dest_r.right, &dest_r.bottom);
970
971 CopyBits (&qd.screenBits, &qd.screenBits, &src_r, &dest_r, srcCopy, 0);
972#else
973 /* In Color QuickDraw, set ForeColor and BackColor as follows to avoid 910 /* In Color QuickDraw, set ForeColor and BackColor as follows to avoid
974 color mapping in CopyBits. Otherwise, it will be slow. */ 911 color mapping in CopyBits. Otherwise, it will be slow. */
975 ForeColor (blackColor); 912 ForeColor (blackColor);
@@ -977,7 +914,6 @@ mac_scroll_area (display, w, gc, src_x, src_y, width, height, dest_x, dest_y)
977 CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0); 914 CopyBits (&(w->portBits), &(w->portBits), &src_r, &dest_r, srcCopy, 0);
978 915
979 mac_set_colors (gc, NULL); 916 mac_set_colors (gc, NULL);
980#endif
981#endif /* not TARGET_API_MAC_CARBON */ 917#endif /* not TARGET_API_MAC_CARBON */
982} 918}
983 919
@@ -1345,7 +1281,6 @@ mac_draw_vertical_window_border (w, x, y0, y1)
1345 f->output_data.mac->normal_gc, x, y0, x, y1); 1281 f->output_data.mac->normal_gc, x, y0, x, y1);
1346} 1282}
1347 1283
1348
1349/* End update of window W (which is equal to updated_window). 1284/* End update of window W (which is equal to updated_window).
1350 1285
1351 Draw vertical borders between horizontally adjacent windows, and 1286 Draw vertical borders between horizontally adjacent windows, and
@@ -1357,7 +1292,7 @@ mac_draw_vertical_window_border (w, x, y0, y1)
1357 1292
1358 W may be a menu bar pseudo-window in case we don't have X toolkit 1293 W may be a menu bar pseudo-window in case we don't have X toolkit
1359 support. Such windows don't have a cursor, so don't display it 1294 support. Such windows don't have a cursor, so don't display it
1360 here. */ 1295 here. */
1361 1296
1362static void 1297static void
1363x_update_window_end (w, cursor_on_p, mouse_face_overwritten_p) 1298x_update_window_end (w, cursor_on_p, mouse_face_overwritten_p)
@@ -1390,14 +1325,6 @@ x_update_window_end (w, cursor_on_p, mouse_face_overwritten_p)
1390 dpyinfo->mouse_face_window = Qnil; 1325 dpyinfo->mouse_face_window = Qnil;
1391 } 1326 }
1392 1327
1393#if 0
1394 /* Unhide the caret. This won't actually show the cursor, unless it
1395 was visible before the corresponding call to HideCaret in
1396 x_update_window_begin. */
1397 if (w32_use_visible_system_caret)
1398 SendMessage (w32_system_caret_hwnd, WM_EMACS_SHOW_CARET, 0, 0);
1399#endif
1400
1401 updated_window = NULL; 1328 updated_window = NULL;
1402} 1329}
1403 1330
@@ -1483,19 +1410,18 @@ x_after_update_window_line (desired_row)
1483 height > 0)) 1410 height > 0))
1484 { 1411 {
1485 int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y)); 1412 int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y));
1413
1486 /* Internal border is drawn below the tool bar. */ 1414 /* Internal border is drawn below the tool bar. */
1487 if (WINDOWP (f->tool_bar_window) 1415 if (WINDOWP (f->tool_bar_window)
1488 && w == XWINDOW (f->tool_bar_window)) 1416 && w == XWINDOW (f->tool_bar_window))
1489 y -= width; 1417 y -= width;
1490 1418
1491 BLOCK_INPUT; 1419 BLOCK_INPUT;
1492
1493 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 1420 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
1494 0, y, width, height, 0); 1421 0, y, width, height, 0);
1495 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f), 1422 XClearArea (FRAME_MAC_DISPLAY (f), FRAME_MAC_WINDOW (f),
1496 FRAME_PIXEL_WIDTH (f) - width, y, 1423 FRAME_PIXEL_WIDTH (f) - width, y,
1497 width, height, 0); 1424 width, height, 0);
1498
1499 UNBLOCK_INPUT; 1425 UNBLOCK_INPUT;
1500 } 1426 }
1501} 1427}
@@ -1581,6 +1507,7 @@ x_draw_fringe_bitmap (w, row, p)
1581} 1507}
1582 1508
1583 1509
1510
1584/* This is called when starting Emacs and when restarting after 1511/* This is called when starting Emacs and when restarting after
1585 suspend. When starting Emacs, no window is mapped. And nothing 1512 suspend. When starting Emacs, no window is mapped. And nothing
1586 must be done to Emacs's own window if it is suspended (though that 1513 must be done to Emacs's own window if it is suspended (though that
@@ -1599,6 +1526,7 @@ XTreset_terminal_modes ()
1599{ 1526{
1600} 1527}
1601 1528
1529
1602 1530
1603/*********************************************************************** 1531/***********************************************************************
1604 Display Iterator 1532 Display Iterator
@@ -1786,6 +1714,7 @@ mac_encode_char (c, char2b, font_info, two_byte_p)
1786 ***********************************************************************/ 1714 ***********************************************************************/
1787 1715
1788 1716
1717
1789static void x_set_glyph_string_clipping P_ ((struct glyph_string *)); 1718static void x_set_glyph_string_clipping P_ ((struct glyph_string *));
1790static void x_set_glyph_string_gc P_ ((struct glyph_string *)); 1719static void x_set_glyph_string_gc P_ ((struct glyph_string *));
1791static void x_draw_glyph_string_background P_ ((struct glyph_string *, 1720static void x_draw_glyph_string_background P_ ((struct glyph_string *,
@@ -1794,6 +1723,7 @@ static void x_draw_glyph_string_foreground P_ ((struct glyph_string *));
1794static void x_draw_composite_glyph_string_foreground P_ ((struct glyph_string *)); 1723static void x_draw_composite_glyph_string_foreground P_ ((struct glyph_string *));
1795static void x_draw_glyph_string_box P_ ((struct glyph_string *)); 1724static void x_draw_glyph_string_box P_ ((struct glyph_string *));
1796static void x_draw_glyph_string P_ ((struct glyph_string *)); 1725static void x_draw_glyph_string P_ ((struct glyph_string *));
1726static void mac_compute_glyph_string_overhangs P_ ((struct glyph_string *));
1797static void x_set_cursor_gc P_ ((struct glyph_string *)); 1727static void x_set_cursor_gc P_ ((struct glyph_string *));
1798static void x_set_mode_line_face_gc P_ ((struct glyph_string *)); 1728static void x_set_mode_line_face_gc P_ ((struct glyph_string *));
1799static void x_set_mouse_face_gc P_ ((struct glyph_string *)); 1729static void x_set_mouse_face_gc P_ ((struct glyph_string *));
@@ -3397,7 +3327,6 @@ XTring_bell ()
3397 } 3327 }
3398} 3328}
3399 3329
3400
3401 3330
3402/* Specify how many text lines, from the top of the window, 3331/* Specify how many text lines, from the top of the window,
3403 should be affected by insert-lines and delete-lines operations. 3332 should be affected by insert-lines and delete-lines operations.
@@ -3832,43 +3761,6 @@ x_get_keysym_name (keysym)
3832 3761
3833 3762
3834 3763
3835#if 0
3836/* Mouse clicks and mouse movement. Rah. */
3837
3838/* Prepare a mouse-event in *RESULT for placement in the input queue.
3839
3840 If the event is a button press, then note that we have grabbed
3841 the mouse. */
3842
3843static Lisp_Object
3844construct_mouse_click (result, event, f)
3845 struct input_event *result;
3846 EventRecord *event;
3847 struct frame *f;
3848{
3849 Point mouseLoc;
3850
3851 result->kind = MOUSE_CLICK_EVENT;
3852 result->code = 0; /* only one mouse button */
3853 result->timestamp = event->when;
3854 result->modifiers = event->what == mouseDown ? down_modifier : up_modifier;
3855
3856 mouseLoc = event->where;
3857
3858 SetPortWindowPort (FRAME_MAC_WINDOW (f));
3859
3860 GlobalToLocal (&mouseLoc);
3861 XSETINT (result->x, mouseLoc.h);
3862 XSETINT (result->y, mouseLoc.v);
3863
3864 XSETFRAME (result->frame_or_window, f);
3865
3866 result->arg = Qnil;
3867 return Qnil;
3868}
3869#endif
3870
3871
3872/* Function to report a mouse movement to the mainstream Emacs code. 3764/* Function to report a mouse movement to the mainstream Emacs code.
3873 The input handler calls this. 3765 The input handler calls this.
3874 3766
@@ -3924,18 +3816,11 @@ note_mouse_movement (frame, pos)
3924 } 3816 }
3925} 3817}
3926 3818
3927/* This is used for debugging, to turn off note_mouse_highlight. */
3928
3929int disable_mouse_highlight;
3930
3931
3932 3819
3933/************************************************************************ 3820/************************************************************************
3934 Mouse Face 3821 Mouse Face
3935 ************************************************************************/ 3822 ************************************************************************/
3936 3823
3937static struct scroll_bar *x_window_to_scroll_bar ();
3938static void x_scroll_bar_report_motion ();
3939static int glyph_rect P_ ((struct frame *f, int, int, Rect *)); 3824static int glyph_rect P_ ((struct frame *f, int, int, Rect *));
3940 3825
3941 3826
@@ -4147,20 +4032,16 @@ static OSStatus install_scroll_bar_timer P_ ((void));
4147static OSStatus set_scroll_bar_timer P_ ((EventTimerInterval)); 4032static OSStatus set_scroll_bar_timer P_ ((EventTimerInterval));
4148static int control_part_code_to_scroll_bar_part P_ ((ControlPartCode)); 4033static int control_part_code_to_scroll_bar_part P_ ((ControlPartCode));
4149static void construct_scroll_bar_click P_ ((struct scroll_bar *, int, 4034static void construct_scroll_bar_click P_ ((struct scroll_bar *, int,
4150 unsigned long,
4151 struct input_event *)); 4035 struct input_event *));
4152static OSErr get_control_part_bounds P_ ((ControlHandle, ControlPartCode, 4036static OSErr get_control_part_bounds P_ ((ControlHandle, ControlPartCode,
4153 Rect *)); 4037 Rect *));
4154static void x_scroll_bar_handle_press P_ ((struct scroll_bar *, 4038static void x_scroll_bar_handle_press P_ ((struct scroll_bar *,
4155 ControlPartCode, 4039 ControlPartCode,
4156 unsigned long,
4157 struct input_event *)); 4040 struct input_event *));
4158static void x_scroll_bar_handle_release P_ ((struct scroll_bar *, 4041static void x_scroll_bar_handle_release P_ ((struct scroll_bar *,
4159 unsigned long,
4160 struct input_event *)); 4042 struct input_event *));
4161static void x_scroll_bar_handle_drag P_ ((WindowPtr, struct scroll_bar *, 4043static void x_scroll_bar_handle_drag P_ ((WindowPtr, struct scroll_bar *,
4162 Point, unsigned long, 4044 Point, struct input_event *));
4163 struct input_event *));
4164static void x_set_toolkit_scroll_bar_thumb P_ ((struct scroll_bar *, 4045static void x_set_toolkit_scroll_bar_thumb P_ ((struct scroll_bar *,
4165 int, int, int)); 4046 int, int, int));
4166 4047
@@ -4259,10 +4140,9 @@ control_part_code_to_scroll_bar_part (part_code)
4259} 4140}
4260 4141
4261static void 4142static void
4262construct_scroll_bar_click (bar, part, timestamp, bufp) 4143construct_scroll_bar_click (bar, part, bufp)
4263 struct scroll_bar *bar; 4144 struct scroll_bar *bar;
4264 int part; 4145 int part;
4265 unsigned long timestamp;
4266 struct input_event *bufp; 4146 struct input_event *bufp;
4267{ 4147{
4268 bufp->kind = SCROLL_BAR_CLICK_EVENT; 4148 bufp->kind = SCROLL_BAR_CLICK_EVENT;
@@ -4270,7 +4150,6 @@ construct_scroll_bar_click (bar, part, timestamp, bufp)
4270 bufp->arg = Qnil; 4150 bufp->arg = Qnil;
4271 bufp->part = part; 4151 bufp->part = part;
4272 bufp->code = 0; 4152 bufp->code = 0;
4273 bufp->timestamp = timestamp;
4274 XSETINT (bufp->x, 0); 4153 XSETINT (bufp->x, 0);
4275 XSETINT (bufp->y, 0); 4154 XSETINT (bufp->y, 0);
4276 bufp->modifiers = 0; 4155 bufp->modifiers = 0;
@@ -4294,10 +4173,9 @@ get_control_part_bounds (ch, part_code, rect)
4294} 4173}
4295 4174
4296static void 4175static void
4297x_scroll_bar_handle_press (bar, part_code, timestamp, bufp) 4176x_scroll_bar_handle_press (bar, part_code, bufp)
4298 struct scroll_bar *bar; 4177 struct scroll_bar *bar;
4299 ControlPartCode part_code; 4178 ControlPartCode part_code;
4300 unsigned long timestamp;
4301 struct input_event *bufp; 4179 struct input_event *bufp;
4302{ 4180{
4303 int part = control_part_code_to_scroll_bar_part (part_code); 4181 int part = control_part_code_to_scroll_bar_part (part_code);
@@ -4307,7 +4185,7 @@ x_scroll_bar_handle_press (bar, part_code, timestamp, bufp)
4307 4185
4308 if (part != scroll_bar_handle) 4186 if (part != scroll_bar_handle)
4309 { 4187 {
4310 construct_scroll_bar_click (bar, part, timestamp, bufp); 4188 construct_scroll_bar_click (bar, part, bufp);
4311 HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), part_code); 4189 HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), part_code);
4312 set_scroll_bar_timer (SCROLL_BAR_FIRST_DELAY); 4190 set_scroll_bar_timer (SCROLL_BAR_FIRST_DELAY);
4313 } 4191 }
@@ -4318,14 +4196,13 @@ x_scroll_bar_handle_press (bar, part_code, timestamp, bufp)
4318} 4196}
4319 4197
4320static void 4198static void
4321x_scroll_bar_handle_release (bar, timestamp, bufp) 4199x_scroll_bar_handle_release (bar, bufp)
4322 struct scroll_bar *bar; 4200 struct scroll_bar *bar;
4323 unsigned long timestamp;
4324 struct input_event *bufp; 4201 struct input_event *bufp;
4325{ 4202{
4326 if (last_scroll_bar_part != scroll_bar_handle 4203 if (last_scroll_bar_part != scroll_bar_handle
4327 || !GC_NILP (bar->dragging)) 4204 || !GC_NILP (bar->dragging))
4328 construct_scroll_bar_click (bar, scroll_bar_end_scroll, timestamp, bufp); 4205 construct_scroll_bar_click (bar, scroll_bar_end_scroll, bufp);
4329 4206
4330 HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), 0); 4207 HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), 0);
4331 set_scroll_bar_timer (kEventDurationForever); 4208 set_scroll_bar_timer (kEventDurationForever);
@@ -4336,11 +4213,10 @@ x_scroll_bar_handle_release (bar, timestamp, bufp)
4336} 4213}
4337 4214
4338static void 4215static void
4339x_scroll_bar_handle_drag (win, bar, mouse_pos, timestamp, bufp) 4216x_scroll_bar_handle_drag (win, bar, mouse_pos, bufp)
4340 WindowPtr win; 4217 WindowPtr win;
4341 struct scroll_bar *bar; 4218 struct scroll_bar *bar;
4342 Point mouse_pos; 4219 Point mouse_pos;
4343 unsigned long timestamp;
4344 struct input_event *bufp; 4220 struct input_event *bufp;
4345{ 4221{
4346 ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar); 4222 ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar);
@@ -4360,13 +4236,13 @@ x_scroll_bar_handle_drag (win, bar, mouse_pos, timestamp, bufp)
4360 top_range = (XINT (bar->track_height) - (r.bottom - r.top)) * 4236 top_range = (XINT (bar->track_height) - (r.bottom - r.top)) *
4361 (1.0 + (float) GetControlViewSize (ch) / GetControl32BitMaximum (ch)) 4237 (1.0 + (float) GetControlViewSize (ch) / GetControl32BitMaximum (ch))
4362 + .5; 4238 + .5;
4363 4239
4364 if (top < 0) 4240 if (top < 0)
4365 top = 0; 4241 top = 0;
4366 if (top > top_range) 4242 if (top > top_range)
4367 top = top_range; 4243 top = top_range;
4368 4244
4369 construct_scroll_bar_click (bar, scroll_bar_handle, timestamp, bufp); 4245 construct_scroll_bar_click (bar, scroll_bar_handle, bufp);
4370 XSETINT (bufp->x, top); 4246 XSETINT (bufp->x, top);
4371 XSETINT (bufp->y, top_range); 4247 XSETINT (bufp->y, top_range);
4372 } 4248 }
@@ -4404,7 +4280,7 @@ x_scroll_bar_handle_drag (win, bar, mouse_pos, timestamp, bufp)
4404 else if (part != last_scroll_bar_part 4280 else if (part != last_scroll_bar_part
4405 || scroll_bar_timer_event_posted_p) 4281 || scroll_bar_timer_event_posted_p)
4406 { 4282 {
4407 construct_scroll_bar_click (bar, part, timestamp, bufp); 4283 construct_scroll_bar_click (bar, part, bufp);
4408 last_scroll_bar_part = part; 4284 last_scroll_bar_part = part;
4409 HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), part_code); 4285 HiliteControl (SCROLL_BAR_CONTROL_HANDLE (bar), part_code);
4410 set_scroll_bar_timer (SCROLL_BAR_CONTINUOUS_DELAY); 4286 set_scroll_bar_timer (SCROLL_BAR_CONTINUOUS_DELAY);
@@ -4475,11 +4351,11 @@ x_scroll_bar_create (w, top, left, width, height, disp_top, disp_height)
4475 r.bottom = disp_top + disp_height; 4351 r.bottom = disp_top + disp_height;
4476 4352
4477#if TARGET_API_MAC_CARBON 4353#if TARGET_API_MAC_CARBON
4478 ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", 1, 0, 0, 0, 4354 ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", width < disp_height,
4479 kControlScrollBarProc, (long) bar); 4355 0, 0, 0, kControlScrollBarProc, (long) bar);
4480#else 4356#else
4481 ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", 1, 0, 0, 0, 4357 ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", width < disp_height,
4482 scrollBarProc, (long) bar); 4358 0, 0, 0, scrollBarProc, (long) bar);
4483#endif 4359#endif
4484 SET_SCROLL_BAR_CONTROL_HANDLE (bar, ch); 4360 SET_SCROLL_BAR_CONTROL_HANDLE (bar, ch);
4485 4361
@@ -4604,10 +4480,12 @@ x_scroll_bar_remove (bar)
4604 UNBLOCK_INPUT; 4480 UNBLOCK_INPUT;
4605} 4481}
4606 4482
4483
4607/* Set the handle of the vertical scroll bar for WINDOW to indicate 4484/* Set the handle of the vertical scroll bar for WINDOW to indicate
4608 that we are displaying PORTION characters out of a total of WHOLE 4485 that we are displaying PORTION characters out of a total of WHOLE
4609 characters, starting at POSITION. If WINDOW has no scroll bar, 4486 characters, starting at POSITION. If WINDOW has no scroll bar,
4610 create one. */ 4487 create one. */
4488
4611static void 4489static void
4612XTset_vertical_scroll_bar (w, portion, whole, position) 4490XTset_vertical_scroll_bar (w, portion, whole, position)
4613 struct window *w; 4491 struct window *w;
@@ -4702,7 +4580,8 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
4702 MoveControl (ch, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, disp_top); 4580 MoveControl (ch, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, disp_top);
4703 SizeControl (ch, sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, 4581 SizeControl (ch, sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2,
4704 disp_height); 4582 disp_height);
4705 ShowControl (ch); 4583 if (sb_width < disp_height)
4584 ShowControl (ch);
4706 4585
4707 /* Remember new settings. */ 4586 /* Remember new settings. */
4708 XSETINT (bar->left, sb_left); 4587 XSETINT (bar->left, sb_left);
@@ -4805,6 +4684,7 @@ XTredeem_scroll_bar (window)
4805 struct window *window; 4684 struct window *window;
4806{ 4685{
4807 struct scroll_bar *bar; 4686 struct scroll_bar *bar;
4687 struct frame *f;
4808 4688
4809 /* We can't redeem this window's scroll bar if it doesn't have one. */ 4689 /* We can't redeem this window's scroll bar if it doesn't have one. */
4810 if (NILP (window->vertical_scroll_bar)) 4690 if (NILP (window->vertical_scroll_bar))
@@ -4813,36 +4693,33 @@ XTredeem_scroll_bar (window)
4813 bar = XSCROLL_BAR (window->vertical_scroll_bar); 4693 bar = XSCROLL_BAR (window->vertical_scroll_bar);
4814 4694
4815 /* Unlink it from the condemned list. */ 4695 /* Unlink it from the condemned list. */
4816 { 4696 f = XFRAME (WINDOW_FRAME (window));
4817 FRAME_PTR f = XFRAME (WINDOW_FRAME (window)); 4697 if (NILP (bar->prev))
4818 4698 {
4819 if (NILP (bar->prev)) 4699 /* If the prev pointer is nil, it must be the first in one of
4820 { 4700 the lists. */
4821 /* If the prev pointer is nil, it must be the first in one of 4701 if (EQ (FRAME_SCROLL_BARS (f), window->vertical_scroll_bar))
4822 the lists. */ 4702 /* It's not condemned. Everything's fine. */
4823 if (EQ (FRAME_SCROLL_BARS (f), window->vertical_scroll_bar)) 4703 return;
4824 /* It's not condemned. Everything's fine. */ 4704 else if (EQ (FRAME_CONDEMNED_SCROLL_BARS (f),
4825 return; 4705 window->vertical_scroll_bar))
4826 else if (EQ (FRAME_CONDEMNED_SCROLL_BARS (f), 4706 FRAME_CONDEMNED_SCROLL_BARS (f) = bar->next;
4827 window->vertical_scroll_bar)) 4707 else
4828 FRAME_CONDEMNED_SCROLL_BARS (f) = bar->next; 4708 /* If its prev pointer is nil, it must be at the front of
4829 else 4709 one or the other! */
4830 /* If its prev pointer is nil, it must be at the front of 4710 abort ();
4831 one or the other! */ 4711 }
4832 abort (); 4712 else
4833 } 4713 XSCROLL_BAR (bar->prev)->next = bar->next;
4834 else
4835 XSCROLL_BAR (bar->prev)->next = bar->next;
4836 4714
4837 if (! NILP (bar->next)) 4715 if (! NILP (bar->next))
4838 XSCROLL_BAR (bar->next)->prev = bar->prev; 4716 XSCROLL_BAR (bar->next)->prev = bar->prev;
4839 4717
4840 bar->next = FRAME_SCROLL_BARS (f); 4718 bar->next = FRAME_SCROLL_BARS (f);
4841 bar->prev = Qnil; 4719 bar->prev = Qnil;
4842 XSETVECTOR (FRAME_SCROLL_BARS (f), bar); 4720 XSETVECTOR (FRAME_SCROLL_BARS (f), bar);
4843 if (! NILP (bar->next)) 4721 if (! NILP (bar->next))
4844 XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar); 4722 XSETVECTOR (XSCROLL_BAR (bar->next)->prev, bar);
4845 }
4846} 4723}
4847 4724
4848/* Remove all scroll bars on FRAME that haven't been saved since the 4725/* Remove all scroll bars on FRAME that haven't been saved since the
@@ -4981,8 +4858,8 @@ x_scroll_bar_note_movement (bar, y_pos, t)
4981 4858
4982#endif /* !USE_TOOLKIT_SCROLL_BARS */ 4859#endif /* !USE_TOOLKIT_SCROLL_BARS */
4983 4860
4984/* Return information to the user about the current position of the 4861/* Return information to the user about the current position of the mouse
4985 mouse on the scroll bar. */ 4862 on the scroll bar. */
4986 4863
4987static void 4864static void
4988x_scroll_bar_report_motion (fp, bar_window, part, x, y, time) 4865x_scroll_bar_report_motion (fp, bar_window, part, x, y, time)
@@ -5500,6 +5377,7 @@ mac_get_window_bounds (f, inner, outer)
5500} 5377}
5501 5378
5502 5379
5380
5503/* Calculate the absolute position in frame F 5381/* Calculate the absolute position in frame F
5504 from its current recorded position values and gravity. */ 5382 from its current recorded position values and gravity. */
5505 5383
@@ -5731,7 +5609,6 @@ x_set_mouse_pixel_position (f, pix_x, pix_y)
5731 UNBLOCK_INPUT; 5609 UNBLOCK_INPUT;
5732#endif 5610#endif
5733} 5611}
5734
5735 5612
5736/* focus shifting, raising and lowering. */ 5613/* focus shifting, raising and lowering. */
5737 5614
@@ -5758,6 +5635,7 @@ x_unfocus_frame (f)
5758} 5635}
5759 5636
5760/* Raise frame F. */ 5637/* Raise frame F. */
5638
5761void 5639void
5762x_raise_frame (f) 5640x_raise_frame (f)
5763 struct frame *f; 5641 struct frame *f;
@@ -5771,6 +5649,7 @@ x_raise_frame (f)
5771} 5649}
5772 5650
5773/* Lower frame F. */ 5651/* Lower frame F. */
5652
5774void 5653void
5775x_lower_frame (f) 5654x_lower_frame (f)
5776 struct frame *f; 5655 struct frame *f;
@@ -6179,9 +6058,9 @@ x_get_font_info (f, font_idx)
6179} 6058}
6180 6059
6181/* the global font name table */ 6060/* the global font name table */
6182char **font_name_table = NULL; 6061static char **font_name_table = NULL;
6183int font_name_table_size = 0; 6062static int font_name_table_size = 0;
6184int font_name_count = 0; 6063static int font_name_count = 0;
6185 6064
6186/* Alist linking character set strings to Mac text encoding and Emacs 6065/* Alist linking character set strings to Mac text encoding and Emacs
6187 coding system. */ 6066 coding system. */
@@ -7435,22 +7314,6 @@ x_find_ccl_program (fontp)
7435#define MIN_DOC_SIZE 64 7314#define MIN_DOC_SIZE 64
7436#define MAX_DOC_SIZE 32767 7315#define MAX_DOC_SIZE 32767
7437 7316
7438#if 0
7439/* sleep time for WaitNextEvent */
7440#define WNE_SLEEP_AT_SUSPEND 10
7441#define WNE_SLEEP_AT_RESUME 1
7442
7443/* the flag appl_is_suspended is used both for determining the sleep
7444 time to be passed to WaitNextEvent and whether the cursor should be
7445 drawn when updating the display. The cursor is turned off when
7446 Emacs is suspended. Redrawing it is unnecessary and what needs to
7447 be done depends on whether the cursor lies inside or outside the
7448 redraw region. So we might as well skip drawing it when Emacs is
7449 suspended. */
7450static Boolean app_is_suspended = false;
7451static long app_sleep_time = WNE_SLEEP_AT_RESUME;
7452#endif
7453
7454#define EXTRA_STACK_ALLOC (256 * 1024) 7317#define EXTRA_STACK_ALLOC (256 * 1024)
7455 7318
7456#define ARGV_STRING_LIST_ID 129 7319#define ARGV_STRING_LIST_ID 129
@@ -7487,8 +7350,8 @@ Lisp_Object Vmac_pass_command_to_system;
7487Lisp_Object Vmac_pass_control_to_system; 7350Lisp_Object Vmac_pass_control_to_system;
7488 7351
7489/* Points to the variable `inev' in the function XTread_socket. It is 7352/* Points to the variable `inev' in the function XTread_socket. It is
7490 used for passing an input event to the function back from a Carbon 7353 used for passing an input event to the function back from
7491 event handler. */ 7354 Carbon/Apple event handlers. */
7492static struct input_event *read_socket_inev = NULL; 7355static struct input_event *read_socket_inev = NULL;
7493#endif 7356#endif
7494 7357
@@ -7496,8 +7359,6 @@ static struct input_event *read_socket_inev = NULL;
7496 drag and drop events. */ 7359 drag and drop events. */
7497Lisp_Object Qmac_ready_for_drag_n_drop; 7360Lisp_Object Qmac_ready_for_drag_n_drop;
7498 7361
7499Lisp_Object drag_and_drop_file_list;
7500
7501Point saved_menu_event_location; 7362Point saved_menu_event_location;
7502 7363
7503/* Apple Events */ 7364/* Apple Events */
@@ -7833,20 +7694,12 @@ static void
7833do_app_resume () 7694do_app_resume ()
7834{ 7695{
7835 /* Window-activate events will do the job. */ 7696 /* Window-activate events will do the job. */
7836#if 0
7837 app_is_suspended = false;
7838 app_sleep_time = WNE_SLEEP_AT_RESUME;
7839#endif
7840} 7697}
7841 7698
7842static void 7699static void
7843do_app_suspend () 7700do_app_suspend ()
7844{ 7701{
7845 /* Window-deactivate events will do the job. */ 7702 /* Window-deactivate events will do the job. */
7846#if 0
7847 app_is_suspended = true;
7848 app_sleep_time = WNE_SLEEP_AT_SUSPEND;
7849#endif
7850} 7703}
7851 7704
7852 7705
@@ -8400,8 +8253,6 @@ mac_handle_mouse_event (next_handler, event, data)
8400 XSETINT (read_socket_inev->x, point.h); 8253 XSETINT (read_socket_inev->x, point.h);
8401 XSETINT (read_socket_inev->y, point.v); 8254 XSETINT (read_socket_inev->y, point.v);
8402 XSETFRAME (read_socket_inev->frame_or_window, f); 8255 XSETFRAME (read_socket_inev->frame_or_window, f);
8403 read_socket_inev->timestamp =
8404 EventTimeToTicks (GetEventTime (event)) * (1000/60);
8405 8256
8406 return noErr; 8257 return noErr;
8407 } 8258 }
@@ -8475,11 +8326,6 @@ do_ae_open_application(const AppleEvent *pae, AppleEvent *preply, long prefcon)
8475} 8326}
8476 8327
8477 8328
8478/* Defined in mac.c. */
8479extern int
8480path_from_vol_dir_name (char *, int, short, long, char *);
8481
8482
8483/* Called when we receive an AppleEvent with an ID of 8329/* Called when we receive an AppleEvent with an ID of
8484 "kAEOpenDocuments". This routine gets the direct parameter, 8330 "kAEOpenDocuments". This routine gets the direct parameter,
8485 extracts the FSSpecs in it, and puts their names on a list. */ 8331 extracts the FSSpecs in it, and puts their names on a list. */
@@ -8503,6 +8349,9 @@ do_ae_open_documents(AppleEvent *message, AppleEvent *reply, long refcon)
8503 DescType actual_type; 8349 DescType actual_type;
8504 Size actual_size; 8350 Size actual_size;
8505 SelectionRange position; 8351 SelectionRange position;
8352 Lisp_Object file_list = Qnil;
8353
8354 xassert (read_socket_inev);
8506 8355
8507 err = AEGetParamDesc (message, keyDirectObject, typeAEList, &the_desc); 8356 err = AEGetParamDesc (message, keyDirectObject, typeAEList, &the_desc);
8508 if (err != noErr) 8357 if (err != noErr)
@@ -8510,10 +8359,10 @@ do_ae_open_documents(AppleEvent *message, AppleEvent *reply, long refcon)
8510 8359
8511 err = AEGetParamPtr (message, keyAEPosition, typeChar, &actual_type, &position, sizeof(SelectionRange), &actual_size); 8360 err = AEGetParamPtr (message, keyAEPosition, typeChar, &actual_type, &position, sizeof(SelectionRange), &actual_size);
8512 if (err == noErr) 8361 if (err == noErr)
8513 drag_and_drop_file_list = Fcons (list3 (make_number (position.lineNum + 1), 8362 file_list = Fcons (list3 (make_number (position.lineNum + 1),
8514 make_number (position.startRange + 1), 8363 make_number (position.startRange + 1),
8515 make_number (position.endRange + 1)), 8364 make_number (position.endRange + 1)),
8516 drag_and_drop_file_list); 8365 file_list);
8517 8366
8518 /* Check to see that we got all of the required parameters from the 8367 /* Check to see that we got all of the required parameters from the
8519 event descriptor. For an 'odoc' event this should just be the 8368 event descriptor. For an 'odoc' event this should just be the
@@ -8567,12 +8416,49 @@ do_ae_open_documents(AppleEvent *message, AppleEvent *reply, long refcon)
8567 sizeof (unix_path_name) - 1) == noErr) 8416 sizeof (unix_path_name) - 1) == noErr)
8568#endif 8417#endif
8569 /* x-dnd functions expect undecoded filenames. */ 8418 /* x-dnd functions expect undecoded filenames. */
8570 drag_and_drop_file_list = 8419 file_list = Fcons (make_unibyte_string (unix_path_name,
8571 Fcons (make_unibyte_string (unix_path_name, 8420 strlen (unix_path_name)),
8572 strlen (unix_path_name)), 8421 file_list);
8573 drag_and_drop_file_list);
8574 } 8422 }
8575 } 8423 }
8424
8425 /* Build a DRAG_N_DROP_EVENT type event as is done in
8426 constuct_drag_n_drop in w32term.c. */
8427 if (!NILP (file_list))
8428 {
8429 struct frame *f = mac_focus_frame (&one_mac_display_info);
8430 WindowPtr wp;
8431 Lisp_Object frame;
8432
8433 read_socket_inev->kind = DRAG_N_DROP_EVENT;
8434 read_socket_inev->code = 0;
8435 read_socket_inev->modifiers = 0;
8436
8437 XSETINT (read_socket_inev->x, 0);
8438 XSETINT (read_socket_inev->y, 0);
8439
8440 XSETFRAME (frame, f);
8441 read_socket_inev->frame_or_window = Fcons (frame, file_list);
8442
8443#if 0
8444 /* Regardless of whether Emacs was suspended or in the
8445 foreground, ask it to redraw its entire screen. Otherwise
8446 parts of the screen can be left in an inconsistent
8447 state. */
8448 wp = FRAME_MAC_WINDOW (f);
8449 if (wp)
8450#if TARGET_API_MAC_CARBON
8451 {
8452 Rect r;
8453
8454 GetWindowPortBounds (wp, &r);
8455 InvalWindowRect (wp, &r);
8456 }
8457#else /* not TARGET_API_MAC_CARBON */
8458 InvalRect (&(wp->portRect));
8459#endif /* not TARGET_API_MAC_CARBON */
8460#endif
8461 }
8576 } 8462 }
8577 8463
8578error_exit: 8464error_exit:
@@ -8665,11 +8551,12 @@ mac_do_receive_drag (WindowPtr window, void *handlerRefCon,
8665 ItemReference theItem; 8551 ItemReference theItem;
8666 HFSFlavor data; 8552 HFSFlavor data;
8667 Size size = sizeof (HFSFlavor); 8553 Size size = sizeof (HFSFlavor);
8554 Lisp_Object file_list;
8668 8555
8669 if (GetFrontWindowOfClass (kMovableModalWindowClass, false)) 8556 if (GetFrontWindowOfClass (kMovableModalWindowClass, false))
8670 return dragNotAcceptedErr; 8557 return dragNotAcceptedErr;
8671 8558
8672 drag_and_drop_file_list = Qnil; 8559 file_list = Qnil;
8673 GetDragMouse (theDrag, &mouse, 0L); 8560 GetDragMouse (theDrag, &mouse, 0L);
8674 CountDragItems (theDrag, &items); 8561 CountDragItems (theDrag, &items);
8675 for (index = 1; index <= items; index++) 8562 for (index = 1; index <= items; index++)
@@ -8695,15 +8582,14 @@ mac_do_receive_drag (WindowPtr window, void *handlerRefCon,
8695 sizeof (unix_path_name) - 1) == noErr) 8582 sizeof (unix_path_name) - 1) == noErr)
8696#endif 8583#endif
8697 /* x-dnd functions expect undecoded filenames. */ 8584 /* x-dnd functions expect undecoded filenames. */
8698 drag_and_drop_file_list = 8585 file_list = Fcons (make_unibyte_string (unix_path_name,
8699 Fcons (make_unibyte_string (unix_path_name, 8586 strlen (unix_path_name)),
8700 strlen (unix_path_name)), 8587 file_list);
8701 drag_and_drop_file_list);
8702 } 8588 }
8703 } 8589 }
8704 /* If there are items in the list, construct an event and post it to 8590 /* If there are items in the list, construct an event and post it to
8705 the queue like an interrupt using kbd_buffer_store_event. */ 8591 the queue like an interrupt using kbd_buffer_store_event. */
8706 if (!NILP (drag_and_drop_file_list)) 8592 if (!NILP (file_list))
8707 { 8593 {
8708 struct input_event event; 8594 struct input_event event;
8709 Lisp_Object frame; 8595 Lisp_Object frame;
@@ -8720,7 +8606,7 @@ mac_do_receive_drag (WindowPtr window, void *handlerRefCon,
8720 XSETINT (event.x, mouse.h); 8606 XSETINT (event.x, mouse.h);
8721 XSETINT (event.y, mouse.v); 8607 XSETINT (event.y, mouse.v);
8722 XSETFRAME (frame, f); 8608 XSETFRAME (frame, f);
8723 event.frame_or_window = Fcons (frame, drag_and_drop_file_list); 8609 event.frame_or_window = Fcons (frame, file_list);
8724 event.arg = Qnil; 8610 event.arg = Qnil;
8725 /* Post to the interrupt queue */ 8611 /* Post to the interrupt queue */
8726 kbd_buffer_store_event (&event); 8612 kbd_buffer_store_event (&event);
@@ -8979,6 +8865,7 @@ XTread_socket (sd, expected, hold_quit)
8979 { 8865 {
8980 int do_help = 0; 8866 int do_help = 0;
8981 struct frame *f; 8867 struct frame *f;
8868 unsigned long timestamp;
8982 8869
8983 /* It is necessary to set this (additional) argument slot of an 8870 /* It is necessary to set this (additional) argument slot of an
8984 event to nil because keyboard.c protects incompletely 8871 event to nil because keyboard.c protects incompletely
@@ -8989,6 +8876,12 @@ XTread_socket (sd, expected, hold_quit)
8989 inev.arg = Qnil; 8876 inev.arg = Qnil;
8990 8877
8991#if USE_CARBON_EVENTS 8878#if USE_CARBON_EVENTS
8879 timestamp = GetEventTime (eventRef) / kEventDurationMillisecond;
8880#else
8881 timestamp = er.when * (1000 / 60); /* ticks to milliseconds */
8882#endif
8883
8884#if USE_CARBON_EVENTS
8992 /* Handle new events */ 8885 /* Handle new events */
8993 if (!mac_convert_event_ref (eventRef, &er)) 8886 if (!mac_convert_event_ref (eventRef, &er))
8994 { 8887 {
@@ -9089,8 +8982,6 @@ XTread_socket (sd, expected, hold_quit)
9089#endif 8982#endif
9090 XSETINT (inev.x, mouse_loc.h); 8983 XSETINT (inev.x, mouse_loc.h);
9091 XSETINT (inev.y, mouse_loc.v); 8984 XSETINT (inev.y, mouse_loc.v);
9092 inev.timestamp = er.when * (1000 / 60);
9093 /* ticks to milliseconds */
9094 8985
9095 if (dpyinfo->grabbed && tracked_scroll_bar 8986 if (dpyinfo->grabbed && tracked_scroll_bar
9096 || ch != 0 8987 || ch != 0
@@ -9124,10 +9015,9 @@ XTread_socket (sd, expected, hold_quit)
9124 &er, &inev); 9015 &er, &inev);
9125 else if (er.what == mouseDown) 9016 else if (er.what == mouseDown)
9126 x_scroll_bar_handle_press (bar, control_part_code, 9017 x_scroll_bar_handle_press (bar, control_part_code,
9127 inev.timestamp, &inev); 9018 &inev);
9128 else 9019 else
9129 x_scroll_bar_handle_release (bar, inev.timestamp, 9020 x_scroll_bar_handle_release (bar, &inev);
9130 &inev);
9131#else /* not USE_TOOLKIT_SCROLL_BARS */ 9021#else /* not USE_TOOLKIT_SCROLL_BARS */
9132 x_scroll_bar_handle_click (bar, control_part_code, 9022 x_scroll_bar_handle_click (bar, control_part_code,
9133 &er, &inev); 9023 &er, &inev);
@@ -9301,8 +9191,7 @@ XTread_socket (sd, expected, hold_quit)
9301 if (dpyinfo->grabbed && tracked_scroll_bar) 9191 if (dpyinfo->grabbed && tracked_scroll_bar)
9302#ifdef USE_TOOLKIT_SCROLL_BARS 9192#ifdef USE_TOOLKIT_SCROLL_BARS
9303 x_scroll_bar_handle_drag (wp, tracked_scroll_bar, 9193 x_scroll_bar_handle_drag (wp, tracked_scroll_bar,
9304 mouse_pos, er.when * (1000 / 60), 9194 mouse_pos, &inev);
9305 &inev);
9306#else /* not USE_TOOLKIT_SCROLL_BARS */ 9195#else /* not USE_TOOLKIT_SCROLL_BARS */
9307 x_scroll_bar_note_movement (tracked_scroll_bar, 9196 x_scroll_bar_note_movement (tracked_scroll_bar,
9308 mouse_pos.v 9197 mouse_pos.v
@@ -9390,11 +9279,10 @@ XTread_socket (sd, expected, hold_quit)
9390 9279
9391 EVENT_INIT (event); 9280 EVENT_INIT (event);
9392 event.kind = NO_EVENT; 9281 event.kind = NO_EVENT;
9393 x_scroll_bar_handle_release (tracked_scroll_bar, 9282 x_scroll_bar_handle_release (tracked_scroll_bar, &event);
9394 er.when * (1000 / 60),
9395 &event);
9396 if (event.kind != NO_EVENT) 9283 if (event.kind != NO_EVENT)
9397 { 9284 {
9285 event.timestamp = timestamp;
9398 kbd_buffer_store_event_hold (&event, hold_quit); 9286 kbd_buffer_store_event_hold (&event, hold_quit);
9399 count++; 9287 count++;
9400 } 9288 }
@@ -9470,6 +9358,7 @@ XTread_socket (sd, expected, hold_quit)
9470 event.kind = LANGUAGE_CHANGE_EVENT; 9358 event.kind = LANGUAGE_CHANGE_EVENT;
9471 event.arg = Qnil; 9359 event.arg = Qnil;
9472 event.code = current_key_script; 9360 event.code = current_key_script;
9361 event.timestamp = timestamp;
9473 kbd_buffer_store_event (&event); 9362 kbd_buffer_store_event (&event);
9474 count++; 9363 count++;
9475 } 9364 }
@@ -9534,58 +9423,18 @@ XTread_socket (sd, expected, hold_quit)
9534#else 9423#else
9535 inev.modifiers = mac_to_emacs_modifiers (er.modifiers); 9424 inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
9536#endif 9425#endif
9426 inev.modifiers |= (extra_keyboard_modifiers
9427 & (meta_modifier | alt_modifier
9428 | hyper_modifier | super_modifier));
9537 XSETFRAME (inev.frame_or_window, mac_focus_frame (dpyinfo)); 9429 XSETFRAME (inev.frame_or_window, mac_focus_frame (dpyinfo));
9538 inev.timestamp = er.when * (1000 / 60); /* ticks to milliseconds */
9539 break; 9430 break;
9540 9431
9541 case kHighLevelEvent: 9432 case kHighLevelEvent:
9542 drag_and_drop_file_list = Qnil; 9433 read_socket_inev = &inev;
9543 9434 AEProcessAppleEvent (&er);
9544 AEProcessAppleEvent(&er); 9435 read_socket_inev = NULL;
9545 9436 break;
9546 /* Build a DRAG_N_DROP_EVENT type event as is done in
9547 constuct_drag_n_drop in w32term.c. */
9548 if (!NILP (drag_and_drop_file_list))
9549 {
9550 struct frame *f = mac_focus_frame (dpyinfo);
9551 WindowPtr wp;
9552 Lisp_Object frame;
9553
9554 inev.kind = DRAG_N_DROP_EVENT;
9555 inev.code = 0;
9556 inev.timestamp = er.when * (1000 / 60);
9557 /* ticks to milliseconds */
9558#if USE_CARBON_EVENTS
9559 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
9560#else
9561 inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
9562#endif
9563
9564 XSETINT (inev.x, 0);
9565 XSETINT (inev.y, 0);
9566
9567 XSETFRAME (frame, f);
9568 inev.frame_or_window = Fcons (frame, drag_and_drop_file_list);
9569
9570#if 0
9571 /* Regardless of whether Emacs was suspended or in the
9572 foreground, ask it to redraw its entire screen.
9573 Otherwise parts of the screen can be left in an
9574 inconsistent state. */
9575 wp = FRAME_MAC_WINDOW (f);
9576 if (wp)
9577#if TARGET_API_MAC_CARBON
9578 {
9579 Rect r;
9580 9437
9581 GetWindowPortBounds (wp, &r);
9582 InvalWindowRect (wp, &r);
9583 }
9584#else /* not TARGET_API_MAC_CARBON */
9585 InvalRect (&(wp->portRect));
9586#endif /* not TARGET_API_MAC_CARBON */
9587#endif
9588 }
9589 default: 9438 default:
9590 break; 9439 break;
9591 } 9440 }
@@ -9595,6 +9444,7 @@ XTread_socket (sd, expected, hold_quit)
9595 9444
9596 if (inev.kind != NO_EVENT) 9445 if (inev.kind != NO_EVENT)
9597 { 9446 {
9447 inev.timestamp = timestamp;
9598 kbd_buffer_store_event_hold (&inev, hold_quit); 9448 kbd_buffer_store_event_hold (&inev, hold_quit);
9599 count++; 9449 count++;
9600 } 9450 }
@@ -10067,7 +9917,7 @@ mac_check_for_quit_char ()
10067 kbd_buffer_store_event (&e); 9917 kbd_buffer_store_event (&e);
10068 } 9918 }
10069} 9919}
10070#endif /* MAC_OSX */ 9920#endif /* MAC_OSX */
10071 9921
10072static void 9922static void
10073init_menu_bar () 9923init_menu_bar ()
@@ -10170,7 +10020,6 @@ mac_initialize ()
10170 off the bottom */ 10020 off the bottom */
10171 baud_rate = 19200; 10021 baud_rate = 19200;
10172 10022
10173 x_noop_count = 0;
10174 last_tool_bar_item = -1; 10023 last_tool_bar_item = -1;
10175 any_help_event_p = 0; 10024 any_help_event_p = 0;
10176 10025
@@ -10242,12 +10091,6 @@ syms_of_macterm ()
10242 staticpro (&last_mouse_scroll_bar); 10091 staticpro (&last_mouse_scroll_bar);
10243 last_mouse_scroll_bar = Qnil; 10092 last_mouse_scroll_bar = Qnil;
10244 10093
10245 staticpro (&Qvendor_specific_keysyms);
10246 Qvendor_specific_keysyms = intern ("vendor-specific-keysyms");
10247
10248 staticpro (&last_mouse_press_frame);
10249 last_mouse_press_frame = Qnil;
10250
10251 Qmac_ready_for_drag_n_drop = intern ("mac-ready-for-drag-n-drop"); 10094 Qmac_ready_for_drag_n_drop = intern ("mac-ready-for-drag-n-drop");
10252 staticpro (&Qmac_ready_for_drag_n_drop); 10095 staticpro (&Qmac_ready_for_drag_n_drop);
10253 10096
@@ -10259,14 +10102,6 @@ syms_of_macterm ()
10259 Vx_toolkit_scroll_bars = Qnil; 10102 Vx_toolkit_scroll_bars = Qnil;
10260#endif 10103#endif
10261 10104
10262 DEFVAR_BOOL ("x-use-underline-position-properties",
10263 &x_use_underline_position_properties,
10264 doc: /* *Non-nil means make use of UNDERLINE_POSITION font properties.
10265nil means ignore them. If you encounter fonts with bogus
10266UNDERLINE_POSITION font properties, for example 7x13 on XFree prior
10267to 4.1, set this to nil. */);
10268 x_use_underline_position_properties = 0;
10269
10270 staticpro (&last_mouse_motion_frame); 10105 staticpro (&last_mouse_motion_frame);
10271 last_mouse_motion_frame = Qnil; 10106 last_mouse_motion_frame = Qnil;
10272 10107