comparison src/macterm.c @ 90195:a1b34dec1104

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-63 Merge from emacs--cvs-trunk--0 Patches applied: * emacs--cvs-trunk--0 (patch 358-423) - Update from CVS - Remove "-face" suffix from widget faces - Remove "-face" suffix from custom faces - Remove "-face" suffix from change-log faces - Remove "-face" suffix from compilation faces - Remove "-face" suffix from diff-mode faces - lisp/longlines.el (longlines-visible-face): Face removed - Remove "-face" suffix from woman faces - Remove "-face" suffix from whitespace-highlight face - Remove "-face" suffix from ruler-mode faces - Remove "-face" suffix from show-paren faces - Remove "-face" suffix from log-view faces - Remove "-face" suffix from smerge faces - Remove "-face" suffix from show-tabs faces - Remove "-face" suffix from highlight-changes faces - Remove "-face" suffix from and downcase info faces - Remove "-face" suffix from pcvs faces - Update uses of renamed pcvs faces - Tweak ChangeLog - Remove "-face" suffix from strokes-char face - Remove "-face" suffix from compare-windows face - Remove "-face" suffix from calendar faces - Remove "-face" suffix from diary-button face - Remove "-face" suffix from testcover faces - Remove "-face" suffix from viper faces - Remove "-face" suffix from org faces - Remove "-face" suffix from sgml-namespace face - Remove "-face" suffix from table-cell face - Remove "-face" suffix from tex-mode faces - Remove "-face" suffix from texinfo-heading face - Remove "-face" suffix from flyspell faces - Remove "-face" suffix from gomoku faces - Remove "-face" suffix from mpuz faces - Merge from gnus--rel--5.10 - Remove "-face" suffix from Buffer-menu-buffer face - Remove "-face" suffix from antlr-mode faces - Remove "-face" suffix from ebrowse faces - Remove "-face" suffix from flymake faces - Remove "-face" suffix from idlwave faces - Remove "-face" suffix from sh-script faces - Remove "-face" suffix from vhdl-mode faces - Remove "-face" suffix from which-func face - Remove "-face" suffix from cperl-mode faces - Remove "-face" suffix from ld-script faces - Fix cperl-mode font-lock problem - Tweak which-func face * gnus--rel--5.10 (patch 80-82) - Merge from emacs--cvs-trunk--0 - Update from CVS
author Miles Bader <miles@gnu.org>
date Wed, 15 Jun 2005 23:32:15 +0000
parents 173dee4e2611 8aa0953a6870
children bb71c6cf2009
comparison
equal deleted inserted replaced
90194:d940db5a66b9 90195:a1b34dec1104
2000 2000
2001 static void 2001 static void
2002 mac_compute_glyph_string_overhangs (s) 2002 mac_compute_glyph_string_overhangs (s)
2003 struct glyph_string *s; 2003 struct glyph_string *s;
2004 { 2004 {
2005 Rect r; 2005 if (s->cmp == NULL
2006 MacFontStruct *font = s->font; 2006 && s->first_glyph->type == CHAR_GLYPH)
2007 2007 {
2008 TextFont (font->mac_fontnum); 2008 Rect r;
2009 TextSize (font->mac_fontsize); 2009 MacFontStruct *font = s->font;
2010 TextFace (font->mac_fontface); 2010
2011 2011 TextFont (font->mac_fontnum);
2012 if (s->two_byte_p) 2012 TextSize (font->mac_fontsize);
2013 QDTextBounds (s->nchars * 2, (char *)s->char2b, &r); 2013 TextFace (font->mac_fontface);
2014 else 2014
2015 { 2015 if (s->two_byte_p)
2016 int i; 2016 QDTextBounds (s->nchars * 2, (char *)s->char2b, &r);
2017 char *buf = xmalloc (s->nchars);
2018
2019 if (buf == NULL)
2020 SetRect (&r, 0, 0, 0, 0);
2021 else 2017 else
2022 { 2018 {
2023 for (i = 0; i < s->nchars; ++i) 2019 int i;
2024 buf[i] = s->char2b[i].byte2; 2020 char *buf = xmalloc (s->nchars);
2025 QDTextBounds (s->nchars, buf, &r); 2021
2026 xfree (buf); 2022 if (buf == NULL)
2023 SetRect (&r, 0, 0, 0, 0);
2024 else
2025 {
2026 for (i = 0; i < s->nchars; ++i)
2027 buf[i] = s->char2b[i].byte2;
2028 QDTextBounds (s->nchars, buf, &r);
2029 xfree (buf);
2030 }
2027 } 2031 }
2028 } 2032
2029 2033 s->right_overhang = r.right > s->width ? r.right - s->width : 0;
2030 s->right_overhang = r.right > s->width ? r.right - s->width : 0; 2034 s->left_overhang = r.left < 0 ? -r.left : 0;
2031 s->left_overhang = r.left < 0 ? -r.left : 0; 2035 }
2032 } 2036 }
2033 2037
2034 2038
2035 /* Fill rectangle X, Y, W, H with background color of glyph string S. */ 2039 /* Fill rectangle X, Y, W, H with background color of glyph string S. */
2036 2040
7493 Lisp_Object Vmac_pass_command_to_system; 7497 Lisp_Object Vmac_pass_command_to_system;
7494 7498
7495 /* If Non-nil, the Mac "Control" key is passed on to the Mac Toolbox 7499 /* If Non-nil, the Mac "Control" key is passed on to the Mac Toolbox
7496 for processing before Emacs sees it. */ 7500 for processing before Emacs sees it. */
7497 Lisp_Object Vmac_pass_control_to_system; 7501 Lisp_Object Vmac_pass_control_to_system;
7502
7503 /* Points to the variable `inev' in the function XTread_socket. It is
7504 used for passing an input event to the function back from a Carbon
7505 event handler. */
7506 static struct input_event *read_socket_inev = NULL;
7498 #endif 7507 #endif
7499 7508
7500 /* Set in term/mac-win.el to indicate that event loop can now generate 7509 /* Set in term/mac-win.el to indicate that event loop can now generate
7501 drag and drop events. */ 7510 drag and drop events. */
7502 Lisp_Object Qmac_ready_for_drag_n_drop; 7511 Lisp_Object Qmac_ready_for_drag_n_drop;
7625 } 7634 }
7626 } 7635 }
7627 7636
7628 /* Normally, ConvertEventRefToEventRecord will correctly handle all 7637 /* Normally, ConvertEventRefToEventRecord will correctly handle all
7629 events. However the click of the mouse wheel is not converted to a 7638 events. However the click of the mouse wheel is not converted to a
7630 mouseDown or mouseUp event. This calls ConvertEventRef, but then 7639 mouseDown or mouseUp event. Likewise for dead key down events.
7631 checks to see if it is a mouse up or down carbon event that has not 7640 This calls ConvertEventRef, but then checks to see if it is a mouse
7632 been converted, and if so, converts it by hand (to be picked up in 7641 up/down, or a dead key down carbon event that has not been
7633 the XTread_socket loop). */ 7642 converted, and if so, converts it by hand (to be picked up in the
7643 XTread_socket loop). */
7634 static Boolean mac_convert_event_ref (EventRef eventRef, EventRecord *eventRec) 7644 static Boolean mac_convert_event_ref (EventRef eventRef, EventRecord *eventRec)
7635 { 7645 {
7636 Boolean result = ConvertEventRefToEventRecord (eventRef, eventRec); 7646 Boolean result = ConvertEventRefToEventRecord (eventRef, eventRec);
7637 /* Do special case for mouse wheel button. */ 7647
7638 if (!result && GetEventClass (eventRef) == kEventClassMouse) 7648 if (result)
7639 { 7649 return result;
7640 UInt32 kind = GetEventKind (eventRef); 7650
7641 if (kind == kEventMouseDown && !(eventRec->what == mouseDown)) 7651 switch (GetEventClass (eventRef))
7652 {
7653 case kEventClassMouse:
7654 switch (GetEventKind (eventRef))
7642 { 7655 {
7656 case kEventMouseDown:
7643 eventRec->what = mouseDown; 7657 eventRec->what = mouseDown;
7644 result=1; 7658 result = 1;
7659 break;
7660
7661 case kEventMouseUp:
7662 eventRec->what = mouseUp;
7663 result = 1;
7664 break;
7665
7666 default:
7667 break;
7645 } 7668 }
7646 if (kind == kEventMouseUp && !(eventRec->what == mouseUp)) 7669
7670 case kEventClassKeyboard:
7671 switch (GetEventKind (eventRef))
7647 { 7672 {
7648 eventRec->what = mouseUp; 7673 case kEventRawKeyDown:
7649 result=1; 7674 {
7675 unsigned char char_codes;
7676 UInt32 key_code;
7677
7678 eventRec->what = keyDown;
7679 GetEventParameter (eventRef, kEventParamKeyMacCharCodes, typeChar,
7680 NULL, sizeof (char), NULL, &char_codes);
7681 GetEventParameter (eventRef, kEventParamKeyCode, typeUInt32,
7682 NULL, sizeof (UInt32), NULL, &key_code);
7683 eventRec->message = char_codes | ((key_code & 0xff) << 8);
7684 result = 1;
7685 }
7686 break;
7687
7688 default:
7689 break;
7650 } 7690 }
7651 if (result) 7691
7652 { 7692 default:
7653 /* Need where and when. */ 7693 break;
7654 UInt32 mods; 7694 }
7655 GetEventParameter (eventRef, kEventParamMouseLocation, 7695
7656 typeQDPoint, NULL, sizeof (Point), 7696 if (result)
7657 NULL, &eventRec->where); 7697 {
7658 /* Use two step process because new event modifiers are 7698 /* Need where and when. */
7659 32-bit and old are 16-bit. Currently, only loss is 7699 UInt32 mods;
7660 NumLock & Fn. */ 7700
7661 GetEventParameter (eventRef, kEventParamKeyModifiers, 7701 GetEventParameter (eventRef, kEventParamMouseLocation, typeQDPoint,
7662 typeUInt32, NULL, sizeof (UInt32), 7702 NULL, sizeof (Point), NULL, &eventRec->where);
7663 NULL, &mods); 7703 /* Use two step process because new event modifiers are 32-bit
7664 eventRec->modifiers = mods; 7704 and old are 16-bit. Currently, only loss is NumLock & Fn. */
7665 7705 GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32,
7666 eventRec->when = EventTimeToTicks (GetEventTime (eventRef)); 7706 NULL, sizeof (UInt32), NULL, &mods);
7667 } 7707 eventRec->modifiers = mods;
7668 } 7708
7709 eventRec->when = EventTimeToTicks (GetEventTime (eventRef));
7710 }
7711
7669 return result; 7712 return result;
7670 } 7713 }
7671 7714
7672 #endif 7715 #endif
7673 7716
8233 8276
8234 return eventNotHandledErr; 8277 return eventNotHandledErr;
8235 } 8278 }
8236 8279
8237 static OSErr 8280 static OSErr
8238 init_command_handler (window) 8281 init_command_handler ()
8239 WindowPtr window;
8240 { 8282 {
8241 OSErr err = noErr; 8283 OSErr err = noErr;
8242 EventTypeSpec specs[] = {{kEventClassCommand, kEventCommandProcess}}; 8284 EventTypeSpec specs[] = {{kEventClassCommand, kEventCommandProcess}};
8243 static EventHandlerUPP handle_command_eventUPP = NULL; 8285 static EventHandlerUPP handle_command_eventUPP = NULL;
8244 8286
8319 break; 8361 break;
8320 } 8362 }
8321 8363
8322 return eventNotHandledErr; 8364 return eventNotHandledErr;
8323 } 8365 }
8366
8367 static pascal OSStatus
8368 mac_handle_mouse_event (next_handler, event, data)
8369 EventHandlerCallRef next_handler;
8370 EventRef event;
8371 void *data;
8372 {
8373 OSStatus result;
8374
8375 switch (GetEventKind (event))
8376 {
8377 case kEventMouseWheelMoved:
8378 {
8379 WindowPtr wp;
8380 struct frame *f;
8381 EventMouseWheelAxis axis;
8382 SInt32 delta;
8383 Point point;
8384
8385 result = CallNextEventHandler (next_handler, event);
8386 if (result != eventNotHandledErr || read_socket_inev == NULL)
8387 return result;
8388
8389 GetEventParameter (event, kEventParamWindowRef, typeWindowRef,
8390 NULL, sizeof (WindowRef), NULL, &wp);
8391 f = mac_window_to_frame (wp);
8392 if (f != mac_focus_frame (&one_mac_display_info))
8393 break;
8394
8395 GetEventParameter (event, kEventParamMouseWheelAxis,
8396 typeMouseWheelAxis, NULL,
8397 sizeof (EventMouseWheelAxis), NULL, &axis);
8398 if (axis != kEventMouseWheelAxisY)
8399 break;
8400
8401 GetEventParameter (event, kEventParamMouseWheelDelta, typeSInt32,
8402 NULL, sizeof (SInt32), NULL, &delta);
8403 GetEventParameter (event, kEventParamMouseLocation, typeQDPoint,
8404 NULL, sizeof (Point), NULL, &point);
8405 read_socket_inev->kind = WHEEL_EVENT;
8406 read_socket_inev->code = 0;
8407 read_socket_inev->modifiers =
8408 (mac_event_to_emacs_modifiers (event)
8409 | ((delta < 0) ? down_modifier : up_modifier));
8410 SetPortWindowPort (wp);
8411 GlobalToLocal (&point);
8412 XSETINT (read_socket_inev->x, point.h);
8413 XSETINT (read_socket_inev->y, point.v);
8414 XSETFRAME (read_socket_inev->frame_or_window, f);
8415 read_socket_inev->timestamp =
8416 EventTimeToTicks (GetEventTime (event)) * (1000/60);
8417
8418 return noErr;
8419 }
8420 break;
8421
8422 default:
8423 break;
8424 }
8425
8426 return eventNotHandledErr;
8427 }
8324 #endif /* USE_CARBON_EVENTS */ 8428 #endif /* USE_CARBON_EVENTS */
8325 8429
8326 8430
8327 OSErr 8431 OSErr
8328 install_window_handler (window) 8432 install_window_handler (window)
8329 WindowPtr window; 8433 WindowPtr window;
8330 { 8434 {
8331 OSErr err = noErr; 8435 OSErr err = noErr;
8332 #if USE_CARBON_EVENTS 8436 #if USE_CARBON_EVENTS
8333 EventTypeSpec specs[] = {{kEventClassWindow, kEventWindowUpdate}, 8437 EventTypeSpec specs_window[] =
8334 {kEventClassWindow, kEventWindowBoundsChanging}}; 8438 {{kEventClassWindow, kEventWindowUpdate},
8335 static EventHandlerUPP handle_window_event_UPP = NULL; 8439 {kEventClassWindow, kEventWindowBoundsChanging}};
8336 8440 EventTypeSpec specs_mouse[] = {{kEventClassMouse, kEventMouseWheelMoved}};
8337 if (handle_window_event_UPP == NULL) 8441 static EventHandlerUPP handle_window_eventUPP = NULL;
8338 handle_window_event_UPP = NewEventHandlerUPP (mac_handle_window_event); 8442 static EventHandlerUPP handle_mouse_eventUPP = NULL;
8339 8443
8340 err = InstallWindowEventHandler (window, handle_window_event_UPP, 8444 if (handle_window_eventUPP == NULL)
8341 GetEventTypeCount (specs), specs, 8445 handle_window_eventUPP = NewEventHandlerUPP (mac_handle_window_event);
8342 NULL, NULL); 8446 if (handle_mouse_eventUPP == NULL)
8447 handle_mouse_eventUPP = NewEventHandlerUPP (mac_handle_mouse_event);
8448 err = InstallWindowEventHandler (window, handle_window_eventUPP,
8449 GetEventTypeCount (specs_window),
8450 specs_window, NULL, NULL);
8451 if (err == noErr)
8452 err = InstallWindowEventHandler (window, handle_mouse_eventUPP,
8453 GetEventTypeCount (specs_mouse),
8454 specs_mouse, NULL, NULL);
8343 #endif 8455 #endif
8344 #if TARGET_API_MAC_CARBON 8456 #if TARGET_API_MAC_CARBON
8345 if (mac_do_track_dragUPP == NULL) 8457 if (mac_do_track_dragUPP == NULL)
8346 mac_do_track_dragUPP = NewDragTrackingHandlerUPP (mac_do_track_drag); 8458 mac_do_track_dragUPP = NewDragTrackingHandlerUPP (mac_do_track_drag);
8347 if (mac_do_receive_dragUPP == NULL) 8459 if (mac_do_receive_dragUPP == NULL)
8889 inev.arg = Qnil; 9001 inev.arg = Qnil;
8890 9002
8891 #if USE_CARBON_EVENTS 9003 #if USE_CARBON_EVENTS
8892 /* Handle new events */ 9004 /* Handle new events */
8893 if (!mac_convert_event_ref (eventRef, &er)) 9005 if (!mac_convert_event_ref (eventRef, &er))
8894 switch (GetEventClass (eventRef)) 9006 {
8895 { 9007 /* There used to be a handler for the kEventMouseWheelMoved
8896 case kEventClassWindow: 9008 event here. But as of Mac OS X 10.4, this kind of event
8897 if (GetEventKind (eventRef) == kEventWindowBoundsChanged) 9009 is not directly posted to the main event queue by
8898 { 9010 two-finger scrolling on the trackpad. Instead, some
8899 WindowPtr window_ptr; 9011 private event is posted and it is converted to a wheel
8900 GetEventParameter(eventRef, kEventParamDirectObject, 9012 event by the default handler for the application target.
8901 typeWindowRef, NULL, sizeof(WindowPtr), 9013 The converted one can be received by a Carbon event
8902 NULL, &window_ptr); 9014 handler installed on a window target. */
8903 f = mac_window_to_frame (window_ptr); 9015 read_socket_inev = &inev;
8904 if (f && !f->async_iconified) 9016 SendEventToEventTarget (eventRef, toolbox_dispatcher);
8905 x_real_positions (f, &f->left_pos, &f->top_pos); 9017 read_socket_inev = NULL;
8906 SendEventToEventTarget (eventRef, toolbox_dispatcher); 9018 }
8907 }
8908 break;
8909 case kEventClassMouse:
8910 if (GetEventKind (eventRef) == kEventMouseWheelMoved)
8911 {
8912 SInt32 delta;
8913 Point point;
8914 struct frame *f = mac_focus_frame (dpyinfo);
8915 WindowPtr window_ptr;
8916
8917 #if 0
8918 if (dpyinfo->x_focus_frame == NULL)
8919 {
8920 /* Beep if wheel move occurs when all the frames
8921 are invisible. */
8922 SysBeep(1);
8923 break;
8924 }
8925 #endif
8926
8927 GetEventParameter(eventRef, kEventParamMouseWheelDelta,
8928 typeSInt32, NULL, sizeof (SInt32),
8929 NULL, &delta);
8930 GetEventParameter(eventRef, kEventParamMouseLocation,
8931 typeQDPoint, NULL, sizeof (Point),
8932 NULL, &point);
8933 inev.kind = WHEEL_EVENT;
8934 inev.code = 0;
8935 inev.modifiers = (mac_event_to_emacs_modifiers (eventRef)
8936 | ((delta < 0) ? down_modifier
8937 : up_modifier));
8938 window_ptr = FRAME_MAC_WINDOW (f);
8939 SetPortWindowPort (window_ptr);
8940 GlobalToLocal (&point);
8941 XSETINT (inev.x, point.h);
8942 XSETINT (inev.y, point.v);
8943 XSETFRAME (inev.frame_or_window,
8944 mac_window_to_frame (window_ptr));
8945 inev.timestamp = EventTimeToTicks (GetEventTime (eventRef))*(1000/60);
8946 }
8947 else
8948 SendEventToEventTarget (eventRef, toolbox_dispatcher);
8949
8950 break;
8951
8952 default:
8953 /* Send the event to the appropriate receiver. */
8954 SendEventToEventTarget (eventRef, toolbox_dispatcher);
8955 }
8956 else 9019 else
8957 #endif /* USE_CARBON_EVENTS */ 9020 #endif /* USE_CARBON_EVENTS */
8958 switch (er.what) 9021 switch (er.what)
8959 { 9022 {
8960 case mouseDown: 9023 case mouseDown:
9386 "eventNotHandledErr" and we can process it 9449 "eventNotHandledErr" and we can process it
9387 normally. */ 9450 normally. */
9388 if ((!NILP (Vmac_pass_command_to_system) 9451 if ((!NILP (Vmac_pass_command_to_system)
9389 || !(er.modifiers & cmdKey)) 9452 || !(er.modifiers & cmdKey))
9390 && (!NILP (Vmac_pass_control_to_system) 9453 && (!NILP (Vmac_pass_control_to_system)
9391 || !(er.modifiers & controlKey))) 9454 || !(er.modifiers & controlKey))
9455 && (!NILP (Vmac_command_key_is_meta)
9456 && NILP (Vmac_option_modifier)
9457 || !(er.modifiers & optionKey)))
9392 if (SendEventToEventTarget (eventRef, toolbox_dispatcher) 9458 if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
9393 != eventNotHandledErr) 9459 != eventNotHandledErr)
9394 break; 9460 break;
9395 #endif 9461 #endif
9396 9462