aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim F. Storm2004-02-27 23:47:13 +0000
committerKim F. Storm2004-02-27 23:47:13 +0000
commitff158530cbc6f357fba722e867be0673568345d1 (patch)
treeba71ec1d716f972dba2b203d6a070820e5e1b94a /src
parente0de7f88fe9935b9d400ebe80899d70b4ce88b4b (diff)
downloademacs-ff158530cbc6f357fba722e867be0673568345d1.tar.gz
emacs-ff158530cbc6f357fba722e867be0673568345d1.zip
(XTread_socket): Remove bufp_r and numcharsp args. Add hold_quit arg.
Rework to use just one, local, inev input_event. Store inev directly in fifo using kbd_buffer_store_event_hold.
Diffstat (limited to 'src')
-rw-r--r--src/macterm.c149
1 files changed, 72 insertions, 77 deletions
diff --git a/src/macterm.c b/src/macterm.c
index a22a1cfafe8..4ff8972dacb 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -8016,8 +8016,9 @@ keycode_to_xkeysym (int keyCode, int *xKeySym)
8016/* Emacs calls this whenever it wants to read an input event from the 8016/* Emacs calls this whenever it wants to read an input event from the
8017 user. */ 8017 user. */
8018int 8018int
8019XTread_socket (int sd, struct input_event *bufp, int numchars, int expected) 8019XTread_socket (int sd, int expected, struct input_event *hold_quit)
8020{ 8020{
8021 struct input_event inev;
8021 int count = 0; 8022 int count = 0;
8022#if USE_CARBON_EVENTS 8023#if USE_CARBON_EVENTS
8023 OSStatus rneResult; 8024 OSStatus rneResult;
@@ -8042,9 +8043,6 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
8042 /* So people can tell when we have read the available input. */ 8043 /* So people can tell when we have read the available input. */
8043 input_signal_count++; 8044 input_signal_count++;
8044 8045
8045 if (numchars <= 0)
8046 abort ();
8047
8048 /* Don't poll for events to process (specifically updateEvt) if 8046 /* Don't poll for events to process (specifically updateEvt) if
8049 window update currently already in progress. A call to redisplay 8047 window update currently already in progress. A call to redisplay
8050 (in do_window_update) can be preempted by another call to 8048 (in do_window_update) can be preempted by another call to
@@ -8063,7 +8061,9 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
8063 event to nil because keyboard.c protects incompletely processed 8061 event to nil because keyboard.c protects incompletely processed
8064 event from being garbage collected by placing them in the 8062 event from being garbage collected by placing them in the
8065 kbd_buffer_gcpro vector. */ 8063 kbd_buffer_gcpro vector. */
8066 bufp->arg = Qnil; 8064 EVENT_INIT (inev);
8065 inev.kind = NO_EVENT;
8066 inev.arg = Qnil;
8067 8067
8068 event_mask = everyEvent; 8068 event_mask = everyEvent;
8069 if (NILP (Fboundp (Qmac_ready_for_drag_n_drop))) 8069 if (NILP (Fboundp (Qmac_ready_for_drag_n_drop)))
@@ -8101,18 +8101,17 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
8101 GetEventParameter(eventRef, kEventParamMouseLocation, 8101 GetEventParameter(eventRef, kEventParamMouseLocation,
8102 typeQDPoint, NULL, sizeof (Point), 8102 typeQDPoint, NULL, sizeof (Point),
8103 NULL, &point); 8103 NULL, &point);
8104 bufp->kind = WHEEL_EVENT; 8104 inev.kind = WHEEL_EVENT;
8105 bufp->code = 0; 8105 inev.code = 0;
8106 bufp->modifiers = (mac_event_to_emacs_modifiers(eventRef) 8106 inev.modifiers = (mac_event_to_emacs_modifiers(eventRef)
8107 | ((delta < 0) ? down_modifier 8107 | ((delta < 0) ? down_modifier
8108 : up_modifier)); 8108 : up_modifier));
8109 SetPort (GetWindowPort (window_ptr)); 8109 SetPort (GetWindowPort (window_ptr));
8110 GlobalToLocal (&point); 8110 GlobalToLocal (&point);
8111 XSETINT (bufp->x, point.h); 8111 XSETINT (inev.x, point.h);
8112 XSETINT (bufp->y, point.v); 8112 XSETINT (inev.y, point.v);
8113 XSETFRAME (bufp->frame_or_window, mwp->mFP); 8113 XSETFRAME (inev.frame_or_window, mwp->mFP);
8114 bufp->timestamp = EventTimeToTicks (GetEventTime (eventRef))*(1000/60); 8114 inev.timestamp = EventTimeToTicks (GetEventTime (eventRef))*(1000/60);
8115 count++;
8116 } 8115 }
8117 else 8116 else
8118 SendEventToEventTarget (eventRef, GetEventDispatcherTarget ()); 8117 SendEventToEventTarget (eventRef, GetEventDispatcherTarget ());
@@ -8161,28 +8160,27 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
8161 GlobalToLocal (&mouse_loc); 8160 GlobalToLocal (&mouse_loc);
8162 8161
8163#if USE_CARBON_EVENTS 8162#if USE_CARBON_EVENTS
8164 bufp->code = mac_get_mouse_btn (eventRef); 8163 inev.code = mac_get_mouse_btn (eventRef);
8165#else 8164#else
8166 bufp_.code = mac_get_emulate_btn (er.modifiers); 8165 inev.code = mac_get_emulate_btn (er.modifiers);
8167#endif 8166#endif
8168 bufp->kind = SCROLL_BAR_CLICK_EVENT; 8167 inev.kind = SCROLL_BAR_CLICK_EVENT;
8169 bufp->frame_or_window = tracked_scroll_bar->window; 8168 inev.frame_or_window = tracked_scroll_bar->window;
8170 bufp->part = scroll_bar_handle; 8169 inev.part = scroll_bar_handle;
8171#if USE_CARBON_EVENTS 8170#if USE_CARBON_EVENTS
8172 bufp->modifiers = mac_event_to_emacs_modifiers (eventRef); 8171 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
8173#else 8172#else
8174 bufp->modifiers = mac_to_emacs_modifiers (er.modifiers); 8173 inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
8175#endif 8174#endif
8176 bufp->modifiers |= up_modifier; 8175 inev.modifiers |= up_modifier;
8177 bufp->timestamp = er.when * (1000 / 60); 8176 inev.timestamp = er.when * (1000 / 60);
8178 /* ticks to milliseconds */ 8177 /* ticks to milliseconds */
8179 8178
8180 XSETINT (bufp->x, tracked_scroll_bar->left + 2); 8179 XSETINT (inev.x, tracked_scroll_bar->left + 2);
8181 XSETINT (bufp->y, mouse_loc.v - 24); 8180 XSETINT (inev.y, mouse_loc.v - 24);
8182 tracked_scroll_bar->dragging = Qnil; 8181 tracked_scroll_bar->dragging = Qnil;
8183 mouse_tracking_in_progress = mouse_tracking_none; 8182 mouse_tracking_in_progress = mouse_tracking_none;
8184 tracked_scroll_bar = NULL; 8183 tracked_scroll_bar = NULL;
8185 count++;
8186 break; 8184 break;
8187 } 8185 }
8188 8186
@@ -8196,9 +8194,8 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
8196 struct frame *f = ((mac_output *) 8194 struct frame *f = ((mac_output *)
8197 GetWRefCon (FrontWindow ()))->mFP; 8195 GetWRefCon (FrontWindow ()))->mFP;
8198 saved_menu_event_location = er.where; 8196 saved_menu_event_location = er.where;
8199 bufp->kind = MENU_BAR_ACTIVATE_EVENT; 8197 inev.kind = MENU_BAR_ACTIVATE_EVENT;
8200 XSETFRAME (bufp->frame_or_window, f); 8198 XSETFRAME (inev.frame_or_window, f);
8201 count++;
8202 } 8199 }
8203 break; 8200 break;
8204 8201
@@ -8229,13 +8226,13 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
8229#endif 8226#endif
8230 8227
8231#if USE_CARBON_EVENTS 8228#if USE_CARBON_EVENTS
8232 bufp->code = mac_get_mouse_btn (eventRef); 8229 inev.code = mac_get_mouse_btn (eventRef);
8233#else 8230#else
8234 bufp_.code = mac_get_emulate_btn (er.modifiers); 8231 inev.code = mac_get_emulate_btn (er.modifiers);
8235#endif 8232#endif
8236 XSETINT (bufp->x, mouse_loc.h); 8233 XSETINT (inev.x, mouse_loc.h);
8237 XSETINT (bufp->y, mouse_loc.v); 8234 XSETINT (inev.y, mouse_loc.v);
8238 bufp->timestamp = er.when * (1000 / 60); 8235 inev.timestamp = er.when * (1000 / 60);
8239 /* ticks to milliseconds */ 8236 /* ticks to milliseconds */
8240 8237
8241#if TARGET_API_MAC_CARBON 8238#if TARGET_API_MAC_CARBON
@@ -8247,7 +8244,7 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
8247 struct scroll_bar *bar = (struct scroll_bar *) 8244 struct scroll_bar *bar = (struct scroll_bar *)
8248 GetControlReference (ch); 8245 GetControlReference (ch);
8249 x_scroll_bar_handle_click (bar, control_part_code, &er, 8246 x_scroll_bar_handle_click (bar, control_part_code, &er,
8250 bufp); 8247 &inev);
8251 if (er.what == mouseDown 8248 if (er.what == mouseDown
8252 && control_part_code == kControlIndicatorPart) 8249 && control_part_code == kControlIndicatorPart)
8253 { 8250 {
@@ -8264,22 +8261,22 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
8264 else 8261 else
8265 { 8262 {
8266 Lisp_Object window; 8263 Lisp_Object window;
8267 8264
8268 bufp->kind = MOUSE_CLICK_EVENT; 8265 inev.kind = MOUSE_CLICK_EVENT;
8269 XSETFRAME (bufp->frame_or_window, mwp->mFP); 8266 XSETFRAME (inev.frame_or_window, mwp->mFP);
8270 if (er.what == mouseDown) 8267 if (er.what == mouseDown)
8271 mouse_tracking_in_progress 8268 mouse_tracking_in_progress
8272 = mouse_tracking_mouse_movement; 8269 = mouse_tracking_mouse_movement;
8273 else 8270 else
8274 mouse_tracking_in_progress = mouse_tracking_none; 8271 mouse_tracking_in_progress = mouse_tracking_none;
8275 window = window_from_coordinates (mwp->mFP, bufp->x, bufp->y, 0, 0, 0, 1); 8272 window = window_from_coordinates (mwp->mFP, inev.x, inev.y, 0, 0, 0, 1);
8276 8273
8277 if (EQ (window, mwp->mFP->tool_bar_window)) 8274 if (EQ (window, mwp->mFP->tool_bar_window))
8278 { 8275 {
8279 if (er.what == mouseDown) 8276 if (er.what == mouseDown)
8280 handle_tool_bar_click (mwp->mFP, bufp->x, bufp->y, 1, 0); 8277 handle_tool_bar_click (mwp->mFP, inev.x, inev.y, 1, 0);
8281 else 8278 else
8282 handle_tool_bar_click (mwp->mFP, bufp->x, bufp->y, 0, 8279 handle_tool_bar_click (mwp->mFP, inev.x, inev.y, 0,
8283#if USE_CARBON_EVENTS 8280#if USE_CARBON_EVENTS
8284 mac_event_to_emacs_modifiers (eventRef) 8281 mac_event_to_emacs_modifiers (eventRef)
8285#else 8282#else
@@ -8291,22 +8288,20 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
8291 } 8288 }
8292 8289
8293#if USE_CARBON_EVENTS 8290#if USE_CARBON_EVENTS
8294 bufp->modifiers = mac_event_to_emacs_modifiers (eventRef); 8291 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
8295#else 8292#else
8296 bufp->modifiers = mac_to_emacs_modifiers (er.modifiers); 8293 inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
8297#endif 8294#endif
8298 8295
8299 switch (er.what) 8296 switch (er.what)
8300 { 8297 {
8301 case mouseDown: 8298 case mouseDown:
8302 bufp->modifiers |= down_modifier; 8299 inev.modifiers |= down_modifier;
8303 break; 8300 break;
8304 case mouseUp: 8301 case mouseUp:
8305 bufp->modifiers |= up_modifier; 8302 inev.modifiers |= up_modifier;
8306 break; 8303 break;
8307 } 8304 }
8308
8309 count++;
8310 } 8305 }
8311 break; 8306 break;
8312 8307
@@ -8327,10 +8322,9 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
8327 case inGoAway: 8322 case inGoAway:
8328 if (TrackGoAway (window_ptr, er.where)) 8323 if (TrackGoAway (window_ptr, er.where))
8329 { 8324 {
8330 bufp->kind = DELETE_WINDOW_EVENT; 8325 inev.kind = DELETE_WINDOW_EVENT;
8331 XSETFRAME (bufp->frame_or_window, 8326 XSETFRAME (inev.frame_or_window,
8332 ((mac_output *) GetWRefCon (window_ptr))->mFP); 8327 ((mac_output *) GetWRefCon (window_ptr))->mFP);
8333 count++;
8334 } 8328 }
8335 break; 8329 break;
8336 8330
@@ -8399,8 +8393,8 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
8399 8393
8400 if (keycode_to_xkeysym (keycode, &xkeysym)) 8394 if (keycode_to_xkeysym (keycode, &xkeysym))
8401 { 8395 {
8402 bufp->code = 0xff00 | xkeysym; 8396 inev.code = 0xff00 | xkeysym;
8403 bufp->kind = NON_ASCII_KEYSTROKE_EVENT; 8397 inev.kind = NON_ASCII_KEYSTROKE_EVENT;
8404 } 8398 }
8405 else 8399 else
8406 { 8400 {
@@ -8419,12 +8413,12 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
8419 int new_keycode = keycode | new_modifiers; 8413 int new_keycode = keycode | new_modifiers;
8420 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache); 8414 Ptr kchr_ptr = (Ptr) GetScriptManagerVariable (smKCHRCache);
8421 unsigned long some_state = 0; 8415 unsigned long some_state = 0;
8422 bufp->code = KeyTranslate (kchr_ptr, new_keycode, 8416 inev.code = KeyTranslate (kchr_ptr, new_keycode,
8423 &some_state) & 0xff; 8417 &some_state) & 0xff;
8424 } 8418 }
8425 else 8419 else
8426 bufp->code = er.message & charCodeMask; 8420 inev.code = er.message & charCodeMask;
8427 bufp->kind = ASCII_KEYSTROKE_EVENT; 8421 inev.kind = ASCII_KEYSTROKE_EVENT;
8428 } 8422 }
8429 } 8423 }
8430 8424
@@ -8435,7 +8429,7 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
8435 Mac keyboard to be used to enter non-ASCII iso-latin-1 8429 Mac keyboard to be used to enter non-ASCII iso-latin-1
8436 characters directly. */ 8430 characters directly. */
8437 if (mac_keyboard_text_encoding != kTextEncodingMacRoman 8431 if (mac_keyboard_text_encoding != kTextEncodingMacRoman
8438 && bufp->kind == ASCII_KEYSTROKE_EVENT && bufp->code >= 128) 8432 && inev.kind == ASCII_KEYSTROKE_EVENT && inev.code >= 128)
8439 { 8433 {
8440 static TECObjectRef converter = NULL; 8434 static TECObjectRef converter = NULL;
8441 OSStatus the_err = noErr; 8435 OSStatus the_err = noErr;
@@ -8464,7 +8458,7 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
8464 8458
8465 if (the_err == noErr) 8459 if (the_err == noErr)
8466 { 8460 {
8467 unsigned char ch = bufp->code; 8461 unsigned char ch = inev.code;
8468 ByteCount actual_input_length, actual_output_length; 8462 ByteCount actual_input_length, actual_output_length;
8469 unsigned char outch; 8463 unsigned char outch;
8470 8464
@@ -8475,25 +8469,23 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
8475 if (convert_status == noErr 8469 if (convert_status == noErr
8476 && actual_input_length == 1 8470 && actual_input_length == 1
8477 && actual_output_length == 1) 8471 && actual_output_length == 1)
8478 bufp->code = outch; 8472 inev.code = outch;
8479 } 8473 }
8480 } 8474 }
8481 8475
8482#if USE_CARBON_EVENTS 8476#if USE_CARBON_EVENTS
8483 bufp->modifiers = mac_event_to_emacs_modifiers (eventRef); 8477 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
8484#else 8478#else
8485 bufp->modifiers = mac_to_emacs_modifiers (er.modifiers); 8479 inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
8486#endif 8480#endif
8487 8481
8488 { 8482 {
8489 mac_output *mwp 8483 mac_output *mwp
8490 = (mac_output *) GetWRefCon (FrontNonFloatingWindow ()); 8484 = (mac_output *) GetWRefCon (FrontNonFloatingWindow ());
8491 XSETFRAME (bufp->frame_or_window, mwp->mFP); 8485 XSETFRAME (inev.frame_or_window, mwp->mFP);
8492 } 8486 }
8493 8487
8494 bufp->timestamp = er.when * (1000 / 60); /* ticks to milliseconds */ 8488 inev.timestamp = er.when * (1000 / 60); /* ticks to milliseconds */
8495
8496 count++;
8497 break; 8489 break;
8498 8490
8499 case kHighLevelEvent: 8491 case kHighLevelEvent:
@@ -8521,21 +8513,21 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
8521 if (wp && is_emacs_window(wp)) 8513 if (wp && is_emacs_window(wp))
8522 f = ((mac_output *) GetWRefCon (wp))->mFP; 8514 f = ((mac_output *) GetWRefCon (wp))->mFP;
8523 8515
8524 bufp->kind = DRAG_N_DROP_EVENT; 8516 inev.kind = DRAG_N_DROP_EVENT;
8525 bufp->code = 0; 8517 inev.code = 0;
8526 bufp->timestamp = er.when * (1000 / 60); 8518 inev.timestamp = er.when * (1000 / 60);
8527 /* ticks to milliseconds */ 8519 /* ticks to milliseconds */
8528#if USE_CARBON_EVENTS 8520#if USE_CARBON_EVENTS
8529 bufp->modifiers = mac_event_to_emacs_modifiers (eventRef); 8521 inev.modifiers = mac_event_to_emacs_modifiers (eventRef);
8530#else 8522#else
8531 bufp->modifiers = mac_to_emacs_modifiers (er.modifiers); 8523 inev.modifiers = mac_to_emacs_modifiers (er.modifiers);
8532#endif 8524#endif
8533 8525
8534 XSETINT (bufp->x, 0); 8526 XSETINT (inev.x, 0);
8535 XSETINT (bufp->y, 0); 8527 XSETINT (inev.y, 0);
8536 8528
8537 XSETFRAME (frame, f); 8529 XSETFRAME (frame, f);
8538 bufp->frame_or_window = Fcons (frame, drag_and_drop_file_list); 8530 inev.frame_or_window = Fcons (frame, drag_and_drop_file_list);
8539 8531
8540 /* Regardless of whether Emacs was suspended or in the 8532 /* Regardless of whether Emacs was suspended or in the
8541 foreground, ask it to redraw its entire screen. 8533 foreground, ask it to redraw its entire screen.
@@ -8552,8 +8544,6 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
8552#else /* not TARGET_API_MAC_CARBON */ 8544#else /* not TARGET_API_MAC_CARBON */
8553 InvalRect (&(wp->portRect)); 8545 InvalRect (&(wp->portRect));
8554#endif /* not TARGET_API_MAC_CARBON */ 8546#endif /* not TARGET_API_MAC_CARBON */
8555
8556 count++;
8557 } 8547 }
8558 default: 8548 default:
8559 break; 8549 break;
@@ -8622,8 +8612,13 @@ XTread_socket (int sd, struct input_event *bufp, int numchars, int expected)
8622 } 8612 }
8623 } 8613 }
8624 8614
8625 UNBLOCK_INPUT; 8615 if (inev.kind != NO_EVENT)
8616 {
8617 kbd_buffer_store_event_hold (&inev, hold_quit);
8618 count++;
8619 }
8626 8620
8621 UNBLOCK_INPUT;
8627 return count; 8622 return count;
8628} 8623}
8629 8624