Mercurial > emacs
comparison src/macterm.c @ 69301:9082ca3ebeed
(get_control_part_bounds): Fix type of return value.
(x_set_toolkit_scroll_bar_thumb, x_scroll_bar_create)
(XTset_vertical_scroll_bar) [USE_TOOLKIT_SCROLL_BARS]: Don't show
scroll bar if it is not tall enough to display scroll bar thumb.
[USE_CARBON_EVENTS] (mac_convert_event_ref)
(mac_handle_command_event, mac_handle_window_event)
(mac_handle_mouse_event): Check error code of GetEventParameter.
(convert_fn_keycode) [MAC_OSX]: Likewise.
author | YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
---|---|
date | Mon, 06 Mar 2006 07:56:29 +0000 |
parents | eb6e7cc98bbf |
children | 7902af5c098e 414faf8dce4e a7364c1a561e |
comparison
equal
deleted
inserted
replaced
69300:38934aa6d767 | 69301:9082ca3ebeed |
---|---|
4263 static OSStatus install_scroll_bar_timer P_ ((void)); | 4263 static OSStatus install_scroll_bar_timer P_ ((void)); |
4264 static OSStatus set_scroll_bar_timer P_ ((EventTimerInterval)); | 4264 static OSStatus set_scroll_bar_timer P_ ((EventTimerInterval)); |
4265 static int control_part_code_to_scroll_bar_part P_ ((ControlPartCode)); | 4265 static int control_part_code_to_scroll_bar_part P_ ((ControlPartCode)); |
4266 static void construct_scroll_bar_click P_ ((struct scroll_bar *, int, | 4266 static void construct_scroll_bar_click P_ ((struct scroll_bar *, int, |
4267 struct input_event *)); | 4267 struct input_event *)); |
4268 static OSErr get_control_part_bounds P_ ((ControlHandle, ControlPartCode, | 4268 static OSStatus get_control_part_bounds P_ ((ControlHandle, ControlPartCode, |
4269 Rect *)); | 4269 Rect *)); |
4270 static void x_scroll_bar_handle_press P_ ((struct scroll_bar *, | 4270 static void x_scroll_bar_handle_press P_ ((struct scroll_bar *, |
4271 ControlPartCode, | 4271 ControlPartCode, |
4272 struct input_event *)); | 4272 struct input_event *)); |
4273 static void x_scroll_bar_handle_release P_ ((struct scroll_bar *, | 4273 static void x_scroll_bar_handle_release P_ ((struct scroll_bar *, |
4274 struct input_event *)); | 4274 struct input_event *)); |
4385 XSETINT (bufp->x, 0); | 4385 XSETINT (bufp->x, 0); |
4386 XSETINT (bufp->y, 0); | 4386 XSETINT (bufp->y, 0); |
4387 bufp->modifiers = 0; | 4387 bufp->modifiers = 0; |
4388 } | 4388 } |
4389 | 4389 |
4390 static OSErr | 4390 static OSStatus |
4391 get_control_part_bounds (ch, part_code, rect) | 4391 get_control_part_bounds (ch, part_code, rect) |
4392 ControlHandle ch; | 4392 ControlHandle ch; |
4393 ControlPartCode part_code; | 4393 ControlPartCode part_code; |
4394 Rect *rect; | 4394 Rect *rect; |
4395 { | 4395 { |
4529 int portion, position, whole; | 4529 int portion, position, whole; |
4530 { | 4530 { |
4531 ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar); | 4531 ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar); |
4532 int value, viewsize, maximum; | 4532 int value, viewsize, maximum; |
4533 | 4533 |
4534 if (whole == 0 || XINT (bar->track_height) == 0) | 4534 if (XINT (bar->track_height) == 0) |
4535 return; | |
4536 | |
4537 if (whole == 0) | |
4535 value = 0, viewsize = 1, maximum = 0; | 4538 value = 0, viewsize = 1, maximum = 0; |
4536 else | 4539 else |
4537 { | 4540 { |
4538 value = position; | 4541 value = position; |
4539 viewsize = portion; | 4542 viewsize = portion; |
4540 maximum = max (0, whole - portion); | 4543 maximum = max (0, whole - portion); |
4541 } | 4544 } |
4542 | 4545 |
4543 BLOCK_INPUT; | 4546 BLOCK_INPUT; |
4544 | 4547 |
4545 if (IsControlVisible (ch) | 4548 if (GetControlViewSize (ch) != viewsize |
4546 && (GetControlViewSize (ch) != viewsize | 4549 || GetControl32BitValue (ch) != value |
4547 || GetControl32BitValue (ch) != value | 4550 || GetControl32BitMaximum (ch) != maximum) |
4548 || GetControl32BitMaximum (ch) != maximum)) | |
4549 { | 4551 { |
4550 /* Temporarily hide the scroll bar to avoid multiple redraws. */ | 4552 /* Temporarily hide the scroll bar to avoid multiple redraws. */ |
4551 SetControlVisibility (ch, false, false); | 4553 SetControlVisibility (ch, false, false); |
4552 | 4554 |
4553 SetControl32BitMaximum (ch, maximum); | 4555 SetControl32BitMaximum (ch, maximum); |
4590 r.top = disp_top; | 4592 r.top = disp_top; |
4591 r.right = left + width; | 4593 r.right = left + width; |
4592 r.bottom = disp_top + disp_height; | 4594 r.bottom = disp_top + disp_height; |
4593 | 4595 |
4594 #if TARGET_API_MAC_CARBON | 4596 #if TARGET_API_MAC_CARBON |
4595 ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", width < disp_height, | 4597 ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", |
4598 #if USE_TOOLKIT_SCROLL_BARS | |
4599 false, | |
4600 #else | |
4601 width < disp_height, | |
4602 #endif | |
4596 0, 0, 0, kControlScrollBarProc, (long) bar); | 4603 0, 0, 0, kControlScrollBarProc, (long) bar); |
4597 #else | 4604 #else |
4598 ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", width < disp_height, | 4605 ch = NewControl (FRAME_MAC_WINDOW (f), &r, "\p", width < disp_height, |
4599 0, 0, 0, scrollBarProc, (long) bar); | 4606 0, 0, 0, scrollBarProc, (long) bar); |
4600 #endif | 4607 #endif |
4760 sb_left = left + width - sb_width; | 4767 sb_left = left + width - sb_width; |
4761 | 4768 |
4762 /* Adjustments according to Inside Macintosh to make it look nice */ | 4769 /* Adjustments according to Inside Macintosh to make it look nice */ |
4763 disp_top = top; | 4770 disp_top = top; |
4764 disp_height = height; | 4771 disp_height = height; |
4772 #ifdef MAC_OS8 | |
4765 if (disp_top == 0) | 4773 if (disp_top == 0) |
4766 { | 4774 { |
4767 disp_top = -1; | 4775 disp_top = -1; |
4768 disp_height++; | 4776 disp_height++; |
4769 } | 4777 } |
4773 disp_height--; | 4781 disp_height--; |
4774 } | 4782 } |
4775 | 4783 |
4776 if (sb_left + sb_width == FRAME_PIXEL_WIDTH (f)) | 4784 if (sb_left + sb_width == FRAME_PIXEL_WIDTH (f)) |
4777 sb_left++; | 4785 sb_left++; |
4786 #endif | |
4778 | 4787 |
4779 /* Does the scroll bar exist yet? */ | 4788 /* Does the scroll bar exist yet? */ |
4780 if (NILP (w->vertical_scroll_bar)) | 4789 if (NILP (w->vertical_scroll_bar)) |
4781 { | 4790 { |
4782 BLOCK_INPUT; | 4791 BLOCK_INPUT; |
4808 | 4817 |
4809 HideControl (ch); | 4818 HideControl (ch); |
4810 MoveControl (ch, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, disp_top); | 4819 MoveControl (ch, sb_left + VERTICAL_SCROLL_BAR_WIDTH_TRIM, disp_top); |
4811 SizeControl (ch, sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, | 4820 SizeControl (ch, sb_width - VERTICAL_SCROLL_BAR_WIDTH_TRIM * 2, |
4812 disp_height); | 4821 disp_height); |
4822 #ifndef USE_TOOLKIT_SCROLL_BARS | |
4813 if (sb_width < disp_height) | 4823 if (sb_width < disp_height) |
4814 ShowControl (ch); | 4824 ShowControl (ch); |
4825 #endif | |
4815 | 4826 |
4816 /* Remember new settings. */ | 4827 /* Remember new settings. */ |
4817 XSETINT (bar->left, sb_left); | 4828 XSETINT (bar->left, sb_left); |
4818 XSETINT (bar->top, top); | 4829 XSETINT (bar->top, top); |
4819 XSETINT (bar->width, sb_width); | 4830 XSETINT (bar->width, sb_width); |
4827 UNBLOCK_INPUT; | 4838 UNBLOCK_INPUT; |
4828 } | 4839 } |
4829 | 4840 |
4830 #ifdef USE_TOOLKIT_SCROLL_BARS | 4841 #ifdef USE_TOOLKIT_SCROLL_BARS |
4831 if (NILP (bar->track_top)) | 4842 if (NILP (bar->track_top)) |
4832 { | 4843 if (sb_width >= disp_height) |
4833 ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar); | 4844 { |
4834 Rect r0, r1; | 4845 XSETINT (bar->track_top, 0); |
4835 | 4846 XSETINT (bar->track_height, 0); |
4836 BLOCK_INPUT; | 4847 } |
4837 | 4848 else |
4838 SetControl32BitMinimum (ch, 0); | 4849 { |
4839 SetControl32BitMaximum (ch, 1); | 4850 ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar); |
4840 SetControlViewSize (ch, 1); | 4851 Rect r0, r1; |
4841 | 4852 |
4842 /* Move the scroll bar thumb to the top. */ | 4853 BLOCK_INPUT; |
4843 SetControl32BitValue (ch, 0); | 4854 |
4844 get_control_part_bounds (ch, kControlIndicatorPart, &r0); | 4855 SetControl32BitMinimum (ch, 0); |
4845 | 4856 SetControl32BitMaximum (ch, 1); |
4846 /* Move the scroll bar thumb to the bottom. */ | 4857 SetControlViewSize (ch, 1); |
4847 SetControl32BitValue (ch, 1); | 4858 |
4848 get_control_part_bounds (ch, kControlIndicatorPart, &r1); | 4859 /* Move the scroll bar thumb to the top. */ |
4849 | 4860 SetControl32BitValue (ch, 0); |
4850 UnionRect (&r0, &r1, &r0); | 4861 get_control_part_bounds (ch, kControlIndicatorPart, &r0); |
4851 XSETINT (bar->track_top, r0.top); | 4862 |
4852 XSETINT (bar->track_height, r0.bottom - r0.top); | 4863 /* Move the scroll bar thumb to the bottom. */ |
4853 | 4864 SetControl32BitValue (ch, 1); |
4854 UNBLOCK_INPUT; | 4865 get_control_part_bounds (ch, kControlIndicatorPart, &r1); |
4855 } | 4866 |
4867 UnionRect (&r0, &r1, &r0); | |
4868 XSETINT (bar->track_top, r0.top); | |
4869 XSETINT (bar->track_height, r0.bottom - r0.top); | |
4870 | |
4871 /* Don't show the scroll bar if its height is not enough to | |
4872 display the scroll bar thumb. */ | |
4873 if (r0.bottom - r0.top > 0) | |
4874 ShowControl (ch); | |
4875 | |
4876 UNBLOCK_INPUT; | |
4877 } | |
4856 | 4878 |
4857 x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole); | 4879 x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole); |
4858 #else /* not USE_TOOLKIT_SCROLL_BARS */ | 4880 #else /* not USE_TOOLKIT_SCROLL_BARS */ |
4859 /* Set the scroll bar's current state, unless we're currently being | 4881 /* Set the scroll bar's current state, unless we're currently being |
4860 dragged. */ | 4882 dragged. */ |
8385 up/down, or a dead key down carbon event that has not been | 8407 up/down, or a dead key down carbon event that has not been |
8386 converted, and if so, converts it by hand (to be picked up in the | 8408 converted, and if so, converts it by hand (to be picked up in the |
8387 XTread_socket loop). */ | 8409 XTread_socket loop). */ |
8388 static Boolean mac_convert_event_ref (EventRef eventRef, EventRecord *eventRec) | 8410 static Boolean mac_convert_event_ref (EventRef eventRef, EventRecord *eventRec) |
8389 { | 8411 { |
8412 OSStatus err; | |
8390 Boolean result = ConvertEventRefToEventRecord (eventRef, eventRec); | 8413 Boolean result = ConvertEventRefToEventRecord (eventRef, eventRec); |
8391 | 8414 |
8392 if (result) | 8415 if (result) |
8393 return result; | 8416 return result; |
8394 | 8417 |
8418 case kEventRawKeyDown: | 8441 case kEventRawKeyDown: |
8419 { | 8442 { |
8420 unsigned char char_codes; | 8443 unsigned char char_codes; |
8421 UInt32 key_code; | 8444 UInt32 key_code; |
8422 | 8445 |
8423 eventRec->what = keyDown; | 8446 err = GetEventParameter (eventRef, kEventParamKeyMacCharCodes, |
8424 GetEventParameter (eventRef, kEventParamKeyMacCharCodes, typeChar, | 8447 typeChar, NULL, sizeof (char), |
8425 NULL, sizeof (char), NULL, &char_codes); | 8448 NULL, &char_codes); |
8426 GetEventParameter (eventRef, kEventParamKeyCode, typeUInt32, | 8449 if (err == noErr) |
8427 NULL, sizeof (UInt32), NULL, &key_code); | 8450 err = GetEventParameter (eventRef, kEventParamKeyCode, |
8428 eventRec->message = char_codes | ((key_code & 0xff) << 8); | 8451 typeUInt32, NULL, sizeof (UInt32), |
8429 result = 1; | 8452 NULL, &key_code); |
8453 if (err == noErr) | |
8454 { | |
8455 eventRec->what = keyDown; | |
8456 eventRec->message = char_codes | ((key_code & 0xff) << 8); | |
8457 result = 1; | |
8458 } | |
8430 } | 8459 } |
8431 break; | 8460 break; |
8432 | 8461 |
8433 default: | 8462 default: |
8434 break; | 8463 break; |
8440 } | 8469 } |
8441 | 8470 |
8442 if (result) | 8471 if (result) |
8443 { | 8472 { |
8444 /* Need where and when. */ | 8473 /* Need where and when. */ |
8445 UInt32 mods; | 8474 UInt32 mods = 0; |
8446 | 8475 |
8447 GetEventParameter (eventRef, kEventParamMouseLocation, typeQDPoint, | 8476 GetEventParameter (eventRef, kEventParamMouseLocation, typeQDPoint, |
8448 NULL, sizeof (Point), NULL, &eventRec->where); | 8477 NULL, sizeof (Point), NULL, &eventRec->where); |
8449 /* Use two step process because new event modifiers are 32-bit | 8478 /* Use two step process because new event modifiers are 32-bit |
8450 and old are 16-bit. Currently, only loss is NumLock & Fn. */ | 8479 and old are 16-bit. Currently, only loss is NumLock & Fn. */ |
8850 mac_handle_command_event (next_handler, event, data) | 8879 mac_handle_command_event (next_handler, event, data) |
8851 EventHandlerCallRef next_handler; | 8880 EventHandlerCallRef next_handler; |
8852 EventRef event; | 8881 EventRef event; |
8853 void *data; | 8882 void *data; |
8854 { | 8883 { |
8855 OSStatus result; | 8884 OSStatus result, err; |
8856 OSErr err; | |
8857 HICommand command; | 8885 HICommand command; |
8858 Lisp_Object class_key, id_key, binding; | 8886 Lisp_Object class_key, id_key, binding; |
8859 | 8887 |
8860 result = CallNextEventHandler (next_handler, event); | 8888 result = CallNextEventHandler (next_handler, event); |
8861 if (result != eventNotHandledErr) | 8889 if (result != eventNotHandledErr) |
8862 return result; | 8890 return result; |
8863 | 8891 |
8864 GetEventParameter (event, kEventParamDirectObject, typeHICommand, NULL, | 8892 err = GetEventParameter (event, kEventParamDirectObject, typeHICommand, |
8865 sizeof (HICommand), NULL, &command); | 8893 NULL, sizeof (HICommand), NULL, &command); |
8866 | 8894 |
8867 if (command.commandID == 0) | 8895 if (err != noErr || command.commandID == 0) |
8868 return eventNotHandledErr; | 8896 return eventNotHandledErr; |
8869 | 8897 |
8870 /* A HICommand event is mapped to an Apple event whose event class | 8898 /* A HICommand event is mapped to an Apple event whose event class |
8871 symbol is `hicommand' and event ID is its command ID. */ | 8899 symbol is `hicommand' and event ID is its command ID. */ |
8872 class_key = Qhicommand; | 8900 class_key = Qhicommand; |
8916 EventHandlerCallRef next_handler; | 8944 EventHandlerCallRef next_handler; |
8917 EventRef event; | 8945 EventRef event; |
8918 void *data; | 8946 void *data; |
8919 { | 8947 { |
8920 WindowPtr wp; | 8948 WindowPtr wp; |
8921 OSStatus result; | 8949 OSStatus result, err; |
8922 UInt32 attributes; | 8950 UInt32 attributes; |
8923 XSizeHints *size_hints; | 8951 XSizeHints *size_hints; |
8924 | 8952 |
8925 GetEventParameter (event, kEventParamDirectObject, typeWindowRef, | 8953 err = GetEventParameter (event, kEventParamDirectObject, typeWindowRef, |
8926 NULL, sizeof (WindowPtr), NULL, &wp); | 8954 NULL, sizeof (WindowPtr), NULL, &wp); |
8955 if (err != noErr) | |
8956 return eventNotHandledErr; | |
8927 | 8957 |
8928 switch (GetEventKind (event)) | 8958 switch (GetEventKind (event)) |
8929 { | 8959 { |
8930 case kEventWindowUpdate: | 8960 case kEventWindowUpdate: |
8931 result = CallNextEventHandler (next_handler, event); | 8961 result = CallNextEventHandler (next_handler, event); |
8938 case kEventWindowBoundsChanging: | 8968 case kEventWindowBoundsChanging: |
8939 result = CallNextEventHandler (next_handler, event); | 8969 result = CallNextEventHandler (next_handler, event); |
8940 if (result != eventNotHandledErr) | 8970 if (result != eventNotHandledErr) |
8941 return result; | 8971 return result; |
8942 | 8972 |
8943 GetEventParameter (event, kEventParamAttributes, typeUInt32, | 8973 err = GetEventParameter (event, kEventParamAttributes, typeUInt32, |
8944 NULL, sizeof (UInt32), NULL, &attributes); | 8974 NULL, sizeof (UInt32), NULL, &attributes); |
8975 if (err != noErr) | |
8976 break; | |
8977 | |
8945 size_hints = FRAME_SIZE_HINTS (mac_window_to_frame (wp)); | 8978 size_hints = FRAME_SIZE_HINTS (mac_window_to_frame (wp)); |
8946 if ((attributes & kWindowBoundsChangeUserResize) | 8979 if ((attributes & kWindowBoundsChangeUserResize) |
8947 && ((size_hints->flags & (PResizeInc | PBaseSize | PMinSize)) | 8980 && ((size_hints->flags & (PResizeInc | PBaseSize | PMinSize)) |
8948 == (PResizeInc | PBaseSize | PMinSize))) | 8981 == (PResizeInc | PBaseSize | PMinSize))) |
8949 { | 8982 { |
8950 Rect bounds; | 8983 Rect bounds; |
8951 int width, height; | 8984 int width, height; |
8952 | 8985 |
8953 GetEventParameter (event, kEventParamCurrentBounds, | 8986 err = GetEventParameter (event, kEventParamCurrentBounds, |
8954 typeQDRectangle, | 8987 typeQDRectangle, NULL, sizeof (Rect), |
8955 NULL, sizeof (Rect), NULL, &bounds); | 8988 NULL, &bounds); |
8989 if (err != noErr) | |
8990 break; | |
8991 | |
8956 width = bounds.right - bounds.left; | 8992 width = bounds.right - bounds.left; |
8957 height = bounds.bottom - bounds.top; | 8993 height = bounds.bottom - bounds.top; |
8958 | 8994 |
8959 if (width < size_hints->min_width) | 8995 if (width < size_hints->min_width) |
8960 width = size_hints->min_width; | 8996 width = size_hints->min_width; |
8999 mac_handle_mouse_event (next_handler, event, data) | 9035 mac_handle_mouse_event (next_handler, event, data) |
9000 EventHandlerCallRef next_handler; | 9036 EventHandlerCallRef next_handler; |
9001 EventRef event; | 9037 EventRef event; |
9002 void *data; | 9038 void *data; |
9003 { | 9039 { |
9004 OSStatus result; | 9040 OSStatus result, err; |
9005 | 9041 |
9006 switch (GetEventKind (event)) | 9042 switch (GetEventKind (event)) |
9007 { | 9043 { |
9008 case kEventMouseWheelMoved: | 9044 case kEventMouseWheelMoved: |
9009 { | 9045 { |
9015 | 9051 |
9016 result = CallNextEventHandler (next_handler, event); | 9052 result = CallNextEventHandler (next_handler, event); |
9017 if (result != eventNotHandledErr || read_socket_inev == NULL) | 9053 if (result != eventNotHandledErr || read_socket_inev == NULL) |
9018 return result; | 9054 return result; |
9019 | 9055 |
9020 GetEventParameter (event, kEventParamWindowRef, typeWindowRef, | 9056 err = GetEventParameter (event, kEventParamWindowRef, typeWindowRef, |
9021 NULL, sizeof (WindowRef), NULL, &wp); | 9057 NULL, sizeof (WindowRef), NULL, &wp); |
9058 if (err != noErr) | |
9059 break; | |
9060 | |
9022 f = mac_window_to_frame (wp); | 9061 f = mac_window_to_frame (wp); |
9023 if (f != mac_focus_frame (&one_mac_display_info)) | 9062 if (f != mac_focus_frame (&one_mac_display_info)) |
9024 break; | 9063 break; |
9025 | 9064 |
9026 GetEventParameter (event, kEventParamMouseWheelAxis, | 9065 err = GetEventParameter (event, kEventParamMouseWheelAxis, |
9027 typeMouseWheelAxis, NULL, | 9066 typeMouseWheelAxis, NULL, |
9028 sizeof (EventMouseWheelAxis), NULL, &axis); | 9067 sizeof (EventMouseWheelAxis), NULL, &axis); |
9029 if (axis != kEventMouseWheelAxisY) | 9068 if (err != noErr || axis != kEventMouseWheelAxisY) |
9030 break; | 9069 break; |
9031 | 9070 |
9032 GetEventParameter (event, kEventParamMouseWheelDelta, typeSInt32, | 9071 err = GetEventParameter (event, kEventParamMouseWheelDelta, |
9033 NULL, sizeof (SInt32), NULL, &delta); | 9072 typeSInt32, NULL, sizeof (SInt32), |
9034 GetEventParameter (event, kEventParamMouseLocation, typeQDPoint, | 9073 NULL, &delta); |
9035 NULL, sizeof (Point), NULL, &point); | 9074 if (err != noErr) |
9075 break; | |
9076 err = GetEventParameter (event, kEventParamMouseLocation, | |
9077 typeQDPoint, NULL, sizeof (Point), | |
9078 NULL, &point); | |
9079 if (err != noErr) | |
9080 break; | |
9036 read_socket_inev->kind = WHEEL_EVENT; | 9081 read_socket_inev->kind = WHEEL_EVENT; |
9037 read_socket_inev->code = 0; | 9082 read_socket_inev->code = 0; |
9038 read_socket_inev->modifiers = | 9083 read_socket_inev->modifiers = |
9039 (mac_event_to_emacs_modifiers (event) | 9084 (mac_event_to_emacs_modifiers (event) |
9040 | ((delta < 0) ? down_modifier : up_modifier)); | 9085 | ((delta < 0) ? down_modifier : up_modifier)); |
9492 around? KeyTranslate isn't of much help here, as it only takes a 16-bit | 9537 around? KeyTranslate isn't of much help here, as it only takes a 16-bit |
9493 value for keycode with the modifiers in he high byte, i.e. no room for the | 9538 value for keycode with the modifiers in he high byte, i.e. no room for the |
9494 Fn modifier. That's why we need the table. | 9539 Fn modifier. That's why we need the table. |
9495 | 9540 |
9496 */ | 9541 */ |
9497 | 9542 OSStatus err; |
9498 UInt32 mods = 0; | 9543 UInt32 mods = 0; |
9499 if (!NILP(Vmac_function_modifier)) | 9544 if (!NILP(Vmac_function_modifier)) |
9500 { | 9545 { |
9501 GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, NULL, | 9546 err = GetEventParameter (eventRef, kEventParamKeyModifiers, typeUInt32, |
9502 sizeof (UInt32), NULL, &mods); | 9547 NULL, sizeof (UInt32), NULL, &mods); |
9503 if (mods & kEventKeyModifierFnMask) | 9548 if (err != noErr && mods & kEventKeyModifierFnMask) |
9504 { *newCode = fn_keycode_to_xkeysym_table [keyCode & 0x7f]; | 9549 { *newCode = fn_keycode_to_xkeysym_table [keyCode & 0x7f]; |
9505 | 9550 |
9506 return (*newCode != 0); | 9551 return (*newCode != 0); |
9507 } | 9552 } |
9508 } | 9553 } |