Commit 95085023 authored by YAMAMOTO Mitsuharu's avatar YAMAMOTO Mitsuharu
Browse files

(mac_compute_glyph_string_overhangs): Don't set

overhangs unless the given glyph type is noncomposite CHAR_GLYPH.
[USE_CARBON_EVENTS] (mac_convert_event_ref): Convert dead key down
events.
(XTread_socket): Don't pass keyboard events with the option
modifier to the system when Vmac_command_key_is_meta is nil or
Vmac_option_modifier is non-nil.
[USE_CARBON_EVENTS] (read_socket_inev): New variable.
[USE_CARBON_EVENTS] (init_command_handler): Fix argument.
[USE_CARBON_EVENTS] (mac_handle_mouse_event): New Carbon event
handler function.
(install_window_handler) [USE_CARBON_EVENTS]: Install it.
(XTread_socket) [USE_CARBON_EVENTS]: Move mouse wheel event
handler part to mac_handle_mouse_event.
parent e6572f79
2005-06-15 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
* macterm.c (mac_compute_glyph_string_overhangs): Don't set
overhangs unless the given glyph type is noncomposite CHAR_GLYPH.
[USE_CARBON_EVENTS] (mac_convert_event_ref): Convert dead key down
events.
(XTread_socket): Don't pass keyboard events with the option
modifier to the system when Vmac_command_key_is_meta is nil or
Vmac_option_modifier is non-nil.
[USE_CARBON_EVENTS] (read_socket_inev): New variable.
[USE_CARBON_EVENTS] (init_command_handler): Fix argument.
[USE_CARBON_EVENTS] (mac_handle_mouse_event): New Carbon event
handler function.
(install_window_handler) [USE_CARBON_EVENTS]: Install it.
(XTread_socket) [USE_CARBON_EVENTS]: Move mouse wheel event
handler part to mac_handle_mouse_event.
2005-06-14 Juanma Barranquero <lekktu@gmail.com> 2005-06-14 Juanma Barranquero <lekktu@gmail.com>
   
* eval.c (Fdefvaralias): Rename arguments SYMBOL and ALIASED to * eval.c (Fdefvaralias): Rename arguments SYMBOL and ALIASED to
......
...@@ -1996,33 +1996,37 @@ static void ...@@ -1996,33 +1996,37 @@ static void
mac_compute_glyph_string_overhangs (s) mac_compute_glyph_string_overhangs (s)
struct glyph_string *s; struct glyph_string *s;
{ {
Rect r; if (s->cmp == NULL
MacFontStruct *font = s->font; && s->first_glyph->type == CHAR_GLYPH)
TextFont (font->mac_fontnum);
TextSize (font->mac_fontsize);
TextFace (font->mac_fontface);
if (s->two_byte_p)
QDTextBounds (s->nchars * 2, (char *)s->char2b, &r);
else
{ {
int i; Rect r;
char *buf = xmalloc (s->nchars); MacFontStruct *font = s->font;
if (buf == NULL) TextFont (font->mac_fontnum);
SetRect (&r, 0, 0, 0, 0); TextSize (font->mac_fontsize);
TextFace (font->mac_fontface);
if (s->two_byte_p)
QDTextBounds (s->nchars * 2, (char *)s->char2b, &r);
else else
{ {
for (i = 0; i < s->nchars; ++i) int i;
buf[i] = s->char2b[i].byte2; char *buf = xmalloc (s->nchars);
QDTextBounds (s->nchars, buf, &r);
xfree (buf); if (buf == NULL)
SetRect (&r, 0, 0, 0, 0);
else
{
for (i = 0; i < s->nchars; ++i)
buf[i] = s->char2b[i].byte2;
QDTextBounds (s->nchars, buf, &r);
xfree (buf);
}
} }
}
s->right_overhang = r.right > s->width ? r.right - s->width : 0; s->right_overhang = r.right > s->width ? r.right - s->width : 0;
s->left_overhang = r.left < 0 ? -r.left : 0; s->left_overhang = r.left < 0 ? -r.left : 0;
}
} }
...@@ -7469,6 +7473,11 @@ Lisp_Object Vmac_pass_command_to_system; ...@@ -7469,6 +7473,11 @@ Lisp_Object Vmac_pass_command_to_system;
/* If Non-nil, the Mac "Control" key is passed on to the Mac Toolbox /* If Non-nil, the Mac "Control" key is passed on to the Mac Toolbox
for processing before Emacs sees it. */ for processing before Emacs sees it. */
Lisp_Object Vmac_pass_control_to_system; Lisp_Object Vmac_pass_control_to_system;
/* Points to the variable `inev' in the function XTread_socket. It is
used for passing an input event to the function back from a Carbon
event handler. */
static struct input_event *read_socket_inev = NULL;
#endif #endif
/* Set in term/mac-win.el to indicate that event loop can now generate /* Set in term/mac-win.el to indicate that event loop can now generate
...@@ -7601,45 +7610,79 @@ mac_get_mouse_btn (EventRef ref) ...@@ -7601,45 +7610,79 @@ mac_get_mouse_btn (EventRef ref)
/* Normally, ConvertEventRefToEventRecord will correctly handle all /* Normally, ConvertEventRefToEventRecord will correctly handle all
events. However the click of the mouse wheel is not converted to a events. However the click of the mouse wheel is not converted to a
mouseDown or mouseUp event. This calls ConvertEventRef, but then mouseDown or mouseUp event. Likewise for dead key down events.
checks to see if it is a mouse up or down carbon event that has not This calls ConvertEventRef, but then checks to see if it is a mouse
been converted, and if so, converts it by hand (to be picked up in up/down, or a dead key down carbon event that has not been
the XTread_socket loop). */ converted, and if so, converts it by hand (to be picked up in the
XTread_socket loop). */
static Boolean mac_convert_event_ref (EventRef eventRef, EventRecord *eventRec) static Boolean mac_convert_event_ref (EventRef eventRef, EventRecord *eventRec)
{ {
Boolean result = ConvertEventRefToEventRecord (eventRef, eventRec); Boolean result = ConvertEventRefToEventRecord (eventRef, eventRec);
/* Do special case for mouse wheel button. */
if (!result && GetEventClass (eventRef) == kEventClassMouse) if (result)
return result;
switch (GetEventClass (eventRef))
{ {
UInt32 kind = GetEventKind (eventRef); case kEventClassMouse:
if (kind == kEventMouseDown && !(eventRec->what == mouseDown)) switch (GetEventKind (eventRef))
{ {
case kEventMouseDown:
eventRec->what = mouseDown; eventRec->what = mouseDown;
result=1; result = 1;
} break;
if (kind == kEventMouseUp && !(eventRec->what == mouseUp))
{ case kEventMouseUp:
eventRec->what = mouseUp; eventRec->what = mouseUp;
result=1; result = 1;
break;
default:
break;
} }
if (result)
case kEventClassKeyboard:
switch (GetEventKind (eventRef))
{ {
/* Need where and when. */ case kEventRawKeyDown:
UInt32 mods; {
GetEventParameter (eventRef, kEventParamMouseLocation, unsigned char char_codes;
typeQDPoint, NULL, sizeof (Point), UInt32 key_code;
NULL, &eventRec->where);
/* Use two step process because new event modifiers are eventRec->what = keyDown;
32-bit and old are 16-bit. Currently, only loss is GetEventParameter (eventRef, kEventParamKeyMacCharCodes, typeChar,
NumLock & Fn. */ NULL, sizeof (char), NULL, &char_codes);
GetEventParameter (eventRef, kEventParamKeyModifiers, GetEventParameter (eventRef, kEventParamKeyCode, typeUInt32,
typeUInt32, NULL, sizeof (UInt32), NULL, sizeof (UInt32), NULL, &key_code);
NULL, &mods); eventRec->message = char_codes | ((key_code & 0xff) << 8);
eventRec->modifiers = mods; result = 1;
}
eventRec->when = EventTimeToTicks (GetEventTime (eventRef)); break;
default:
break;
} }
default:
break;
} }
if (result)
{
/* Need where and when. */
UInt32 mods;
GetEventParameter (eventRef, kEventParamMouseLocation, typeQDPoint,
NULL, sizeof (Point), NULL, &eventRec->where);
/* Use two step process because new event modifiers are 32-bit
and old are 16-bit. Currently, only loss is NumLock & Fn. */
GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32,
NULL, sizeof (UInt32), NULL, &mods);
eventRec->modifiers = mods;
eventRec->when = EventTimeToTicks (GetEventTime (eventRef));
}
return result; return result;
} }
...@@ -8209,8 +8252,7 @@ mac_handle_command_event (next_handler, event, data) ...@@ -8209,8 +8252,7 @@ mac_handle_command_event (next_handler, event, data)
} }
static OSErr static OSErr
init_command_handler (window) init_command_handler ()
WindowPtr window;
{ {
OSErr err = noErr; OSErr err = noErr;
EventTypeSpec specs[] = {{kEventClassCommand, kEventCommandProcess}}; EventTypeSpec specs[] = {{kEventClassCommand, kEventCommandProcess}};
...@@ -8295,6 +8337,68 @@ mac_handle_window_event (next_handler, event, data) ...@@ -8295,6 +8337,68 @@ mac_handle_window_event (next_handler, event, data)
return eventNotHandledErr; return eventNotHandledErr;
} }
static pascal OSStatus
mac_handle_mouse_event (next_handler, event, data)
EventHandlerCallRef next_handler;
EventRef event;
void *data;
{
OSStatus result;
switch (GetEventKind (event))
{
case kEventMouseWheelMoved:
{
WindowPtr wp;
struct frame *f;
EventMouseWheelAxis axis;
SInt32 delta;
Point point;
result = CallNextEventHandler (next_handler, event);
if (result != eventNotHandledErr || read_socket_inev == NULL)
return result;
GetEventParameter (event, kEventParamWindowRef, typeWindowRef,
NULL, sizeof (WindowRef), NULL, &wp);
f = mac_window_to_frame (wp);
if (f != mac_focus_frame (&one_mac_display_info))
break;
GetEventParameter (event, kEventParamMouseWheelAxis,
typeMouseWheelAxis, NULL,
sizeof (EventMouseWheelAxis), NULL, &axis);
if (axis != kEventMouseWheelAxisY)
break;
GetEventParameter (event, kEventParamMouseWheelDelta, typeSInt32,
NULL, sizeof (SInt32), NULL, &delta);
GetEventParameter (event, kEventParamMouseLocation, typeQDPoint,
NULL, sizeof (Point), NULL, &point);
read_socket_inev->kind = WHEEL_EVENT;
read_socket_inev->code = 0;
read_socket_inev->modifiers =
(mac_event_to_emacs_modifiers (event)
| ((delta < 0) ? down_modifier : up_modifier));
SetPortWindowPort (wp);
GlobalToLocal (&point);
XSETINT (read_socket_inev->x, point.h);
XSETINT (read_socket_inev->y, point.v);
XSETFRAME (read_socket_inev->frame_or_window, f);
read_socket_inev->timestamp =
EventTimeToTicks (GetEventTime (event)) * (1000/60);
return noErr;
}
break;
default:
break;
}
return eventNotHandledErr;
}
#endif /* USE_CARBON_EVENTS */ #endif /* USE_CARBON_EVENTS */
...@@ -8304,16 +8408,24 @@ install_window_handler (window) ...@@ -8304,16 +8408,24 @@ install_window_handler (window)
{ {
OSErr err = noErr; OSErr err = noErr;
#if USE_CARBON_EVENTS #if USE_CARBON_EVENTS
EventTypeSpec specs[] = {{kEventClassWindow, kEventWindowUpdate}, EventTypeSpec specs_window[] =
{kEventClassWindow, kEventWindowBoundsChanging}}; {{kEventClassWindow, kEventWindowUpdate},
static EventHandlerUPP handle_window_event_UPP = NULL; {kEventClassWindow, kEventWindowBoundsChanging}};
EventTypeSpec specs_mouse[] = {{kEventClassMouse, kEventMouseWheelMoved}};
if (handle_window_event_UPP == NULL) static EventHandlerUPP handle_window_eventUPP = NULL;
handle_window_event_UPP = NewEventHandlerUPP (mac_handle_window_event); static EventHandlerUPP handle_mouse_eventUPP = NULL;
err = InstallWindowEventHandler (window, handle_window_event_UPP, if (handle_window_eventUPP == NULL)
GetEventTypeCount (specs), specs, handle_window_eventUPP = NewEventHandlerUPP (mac_handle_window_event);
NULL, NULL); if (handle_mouse_eventUPP == NULL)
handle_mouse_eventUPP = NewEventHandlerUPP (mac_handle_mouse_event);
err = InstallWindowEventHandler (window, handle_window_eventUPP,
GetEventTypeCount (specs_window),
specs_window, NULL, NULL);
if (err == noErr)
err = InstallWindowEventHandler (window, handle_mouse_eventUPP,
GetEventTypeCount (specs_mouse),
specs_mouse, NULL, NULL);
#endif #endif
#if TARGET_API_MAC_CARBON #if TARGET_API_MAC_CARBON
if (mac_do_track_dragUPP == NULL) if (mac_do_track_dragUPP == NULL)
...@@ -8865,68 +8977,19 @@ XTread_socket (sd, expected, hold_quit) ...@@ -8865,68 +8977,19 @@ XTread_socket (sd, expected, hold_quit)
#if USE_CARBON_EVENTS #if USE_CARBON_EVENTS
/* Handle new events */ /* Handle new events */
if (!mac_convert_event_ref (eventRef, &er)) if (!mac_convert_event_ref (eventRef, &er))
switch (GetEventClass (eventRef)) {
{ /* There used to be a handler for the kEventMouseWheelMoved
case kEventClassWindow: event here. But as of Mac OS X 10.4, this kind of event
if (GetEventKind (eventRef) == kEventWindowBoundsChanged) is not directly posted to the main event queue by
{ two-finger scrolling on the trackpad. Instead, some
WindowPtr window_ptr; private event is posted and it is converted to a wheel
GetEventParameter(eventRef, kEventParamDirectObject, event by the default handler for the application target.
typeWindowRef, NULL, sizeof(WindowPtr), The converted one can be received by a Carbon event
NULL, &window_ptr); handler installed on a window target. */
f = mac_window_to_frame (window_ptr); read_socket_inev = &inev;
if (f && !f->async_iconified) SendEventToEventTarget (eventRef, toolbox_dispatcher);
x_real_positions (f, &f->left_pos, &f->top_pos); read_socket_inev = NULL;
SendEventToEventTarget (eventRef, toolbox_dispatcher); }
}
break;
case kEventClassMouse:
if (GetEventKind (eventRef) == kEventMouseWheelMoved)
{
SInt32 delta;
Point point;
struct frame *f = mac_focus_frame (dpyinfo);
WindowPtr window_ptr;
#if 0
if (dpyinfo->x_focus_frame == NULL)
{
/* Beep if wheel move occurs when all the frames
are invisible. */
SysBeep(1);
break;
}
#endif
GetEventParameter(eventRef, kEventParamMouseWheelDelta,
typeSInt32, NULL, sizeof (SInt32),
NULL, &delta);
GetEventParameter(eventRef, kEventParamMouseLocation,
typeQDPoint, NULL, sizeof (Point),
NULL, &point);
inev.kind = WHEEL_EVENT;
inev.code = 0;
inev.modifiers = (mac_event_to_emacs_modifiers (eventRef)
| ((delta < 0) ? down_modifier
: up_modifier));
window_ptr = FRAME_MAC_WINDOW (f);
SetPortWindowPort (window_ptr);
GlobalToLocal (&point);
XSETINT (inev.x, point.h);
XSETINT (inev.y, point.v);
XSETFRAME (inev.frame_or_window,
mac_window_to_frame (window_ptr));
inev.timestamp = EventTimeToTicks (GetEventTime (eventRef))*(1000/60);
}
else
SendEventToEventTarget (eventRef, toolbox_dispatcher);
break;
default:
/* Send the event to the appropriate receiver. */
SendEventToEventTarget (eventRef, toolbox_dispatcher);
}
else else
#endif /* USE_CARBON_EVENTS */ #endif /* USE_CARBON_EVENTS */
switch (er.what) switch (er.what)
...@@ -9362,7 +9425,10 @@ XTread_socket (sd, expected, hold_quit) ...@@ -9362,7 +9425,10 @@ XTread_socket (sd, expected, hold_quit)
if ((!NILP (Vmac_pass_command_to_system) if ((!NILP (Vmac_pass_command_to_system)
|| !(er.modifiers & cmdKey)) || !(er.modifiers & cmdKey))
&& (!NILP (Vmac_pass_control_to_system) && (!NILP (Vmac_pass_control_to_system)
|| !(er.modifiers & controlKey))) || !(er.modifiers & controlKey))
&& (!NILP (Vmac_command_key_is_meta)
&& NILP (Vmac_option_modifier)
|| !(er.modifiers & optionKey)))
if (SendEventToEventTarget (eventRef, toolbox_dispatcher) if (SendEventToEventTarget (eventRef, toolbox_dispatcher)
!= eventNotHandledErr) != eventNotHandledErr)
break; break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment