aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2006-03-06 07:56:29 +0000
committerYAMAMOTO Mitsuharu2006-03-06 07:56:29 +0000
commita3510ffafb7f71cc71a51ac9af73f2c07ff0a1e0 (patch)
treec82fc82899b75c23415448fd446a9c5da6576af0 /src
parent8950bc736331c96d4bc36bed4f64adec70b6f7d9 (diff)
downloademacs-a3510ffafb7f71cc71a51ac9af73f2c07ff0a1e0.tar.gz
emacs-a3510ffafb7f71cc71a51ac9af73f2c07ff0a1e0.zip
(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.
Diffstat (limited to 'src')
-rw-r--r--src/macterm.c171
1 files changed, 108 insertions, 63 deletions
diff --git a/src/macterm.c b/src/macterm.c
index 3bd7d3b2e24..985421b12c5 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -4265,8 +4265,8 @@ static OSStatus set_scroll_bar_timer P_ ((EventTimerInterval));
4265static int control_part_code_to_scroll_bar_part P_ ((ControlPartCode)); 4265static int control_part_code_to_scroll_bar_part P_ ((ControlPartCode));
4266static void construct_scroll_bar_click P_ ((struct scroll_bar *, int, 4266static void construct_scroll_bar_click P_ ((struct scroll_bar *, int,
4267 struct input_event *)); 4267 struct input_event *));
4268static OSErr get_control_part_bounds P_ ((ControlHandle, ControlPartCode, 4268static OSStatus get_control_part_bounds P_ ((ControlHandle, ControlPartCode,
4269 Rect *)); 4269 Rect *));
4270static void x_scroll_bar_handle_press P_ ((struct scroll_bar *, 4270static void x_scroll_bar_handle_press P_ ((struct scroll_bar *,
4271 ControlPartCode, 4271 ControlPartCode,
4272 struct input_event *)); 4272 struct input_event *));
@@ -4387,7 +4387,7 @@ construct_scroll_bar_click (bar, part, bufp)
4387 bufp->modifiers = 0; 4387 bufp->modifiers = 0;
4388} 4388}
4389 4389
4390static OSErr 4390static OSStatus
4391get_control_part_bounds (ch, part_code, rect) 4391get_control_part_bounds (ch, part_code, rect)
4392 ControlHandle ch; 4392 ControlHandle ch;
4393 ControlPartCode part_code; 4393 ControlPartCode part_code;
@@ -4531,7 +4531,10 @@ x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole)
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 {
@@ -4542,10 +4545,9 @@ x_set_toolkit_scroll_bar_thumb (bar, portion, position, whole)
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);
@@ -4592,7 +4594,12 @@ x_scroll_bar_create (w, top, left, width, height, disp_top, disp_height)
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,
@@ -4762,6 +4769,7 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
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;
@@ -4775,6 +4783,7 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
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))
@@ -4810,8 +4819,10 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
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);
@@ -4829,30 +4840,41 @@ XTset_vertical_scroll_bar (w, portion, whole, position)
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);
4846 XSETINT (bar->track_height, 0);
4847 }
4848 else
4849 {
4850 ControlHandle ch = SCROLL_BAR_CONTROL_HANDLE (bar);
4851 Rect r0, r1;
4835 4852
4836 BLOCK_INPUT; 4853 BLOCK_INPUT;
4837 4854
4838 SetControl32BitMinimum (ch, 0); 4855 SetControl32BitMinimum (ch, 0);
4839 SetControl32BitMaximum (ch, 1); 4856 SetControl32BitMaximum (ch, 1);
4840 SetControlViewSize (ch, 1); 4857 SetControlViewSize (ch, 1);
4841 4858
4842 /* Move the scroll bar thumb to the top. */ 4859 /* Move the scroll bar thumb to the top. */
4843 SetControl32BitValue (ch, 0); 4860 SetControl32BitValue (ch, 0);
4844 get_control_part_bounds (ch, kControlIndicatorPart, &r0); 4861 get_control_part_bounds (ch, kControlIndicatorPart, &r0);
4845 4862
4846 /* Move the scroll bar thumb to the bottom. */ 4863 /* Move the scroll bar thumb to the bottom. */
4847 SetControl32BitValue (ch, 1); 4864 SetControl32BitValue (ch, 1);
4848 get_control_part_bounds (ch, kControlIndicatorPart, &r1); 4865 get_control_part_bounds (ch, kControlIndicatorPart, &r1);
4849 4866
4850 UnionRect (&r0, &r1, &r0); 4867 UnionRect (&r0, &r1, &r0);
4851 XSETINT (bar->track_top, r0.top); 4868 XSETINT (bar->track_top, r0.top);
4852 XSETINT (bar->track_height, r0.bottom - r0.top); 4869 XSETINT (bar->track_height, r0.bottom - r0.top);
4853 4870
4854 UNBLOCK_INPUT; 4871 /* Don't show the scroll bar if its height is not enough to
4855 } 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 */
@@ -8387,6 +8409,7 @@ mac_get_mouse_btn (EventRef ref)
8387 XTread_socket loop). */ 8409 XTread_socket loop). */
8388static Boolean mac_convert_event_ref (EventRef eventRef, EventRecord *eventRec) 8410static 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)
@@ -8420,13 +8443,19 @@ static Boolean mac_convert_event_ref (EventRef eventRef, EventRecord *eventRec)
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
@@ -8442,7 +8471,7 @@ static Boolean mac_convert_event_ref (EventRef eventRef, EventRecord *eventRec)
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);
@@ -8852,8 +8881,7 @@ mac_handle_command_event (next_handler, event, data)
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
@@ -8861,10 +8889,10 @@ mac_handle_command_event (next_handler, event, data)
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
@@ -8918,12 +8946,14 @@ mac_handle_window_event (next_handler, event, data)
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 {
@@ -8940,8 +8970,11 @@ mac_handle_window_event (next_handler, event, data)
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))
@@ -8950,9 +8983,12 @@ mac_handle_window_event (next_handler, event, data)
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
@@ -9001,7 +9037,7 @@ mac_handle_mouse_event (next_handler, event, data)
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 {
@@ -9017,22 +9053,31 @@ mac_handle_mouse_event (next_handler, event, data)
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 =
@@ -9494,13 +9539,13 @@ convert_fn_keycode (EventRef eventRef, int keyCode, int *newCode)
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);