aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim F. Storm2004-02-27 23:49:20 +0000
committerKim F. Storm2004-02-27 23:49:20 +0000
commit004b1d3853dbb7ef5c5b2e3b5d011718e602c33a (patch)
treea0a44f8c7a4099170fa66800fdf615886b27b45c /src
parent156395866238fa97dbe03276c7e0c53679dd32ab (diff)
downloademacs-004b1d3853dbb7ef5c5b2e3b5d011718e602c33a.tar.gz
emacs-004b1d3853dbb7ef5c5b2e3b5d011718e602c33a.zip
(w32_read_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. Update count in one place. Postpone call to gen_help_event until inev is stored; use new local do_help for this. Remove local emacs_event in handing of ButtonPress event; just use inev instead (so no reason to copy it later).
Diffstat (limited to 'src')
-rw-r--r--src/w32term.c250
1 files changed, 92 insertions, 158 deletions
diff --git a/src/w32term.c b/src/w32term.c
index 62a4f41a6a9..b9077a1e0b6 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -4122,8 +4122,6 @@ static short temp_buffer[100];
4122 This routine is called by the SIGIO handler. 4122 This routine is called by the SIGIO handler.
4123 We return as soon as there are no more events to be read. 4123 We return as soon as there are no more events to be read.
4124 4124
4125 Events representing keys are stored in buffer BUFP,
4126 which can hold up to NUMCHARS characters.
4127 We return the number of characters stored into the buffer, 4125 We return the number of characters stored into the buffer,
4128 thus pretending to be `read'. 4126 thus pretending to be `read'.
4129 4127
@@ -4139,11 +4137,10 @@ static short temp_buffer[100];
4139*/ 4137*/
4140 4138
4141int 4139int
4142w32_read_socket (sd, bufp, numchars, expected) 4140w32_read_socket (sd, expected, hold_quit)
4143 register int sd; 4141 register int sd;
4144 /* register */ struct input_event *bufp;
4145 /* register */ int numchars;
4146 int expected; 4142 int expected;
4143 struct input_event *hold_quit;
4147{ 4144{
4148 int count = 0; 4145 int count = 0;
4149 int check_visibility = 0; 4146 int check_visibility = 0;
@@ -4163,13 +4160,17 @@ w32_read_socket (sd, bufp, numchars, expected)
4163 /* So people can tell when we have read the available input. */ 4160 /* So people can tell when we have read the available input. */
4164 input_signal_count++; 4161 input_signal_count++;
4165 4162
4166 if (numchars <= 0)
4167 abort (); /* Don't think this happens. */
4168
4169 /* TODO: tool-bars, ghostscript integration, mouse 4163 /* TODO: tool-bars, ghostscript integration, mouse
4170 cursors. */ 4164 cursors. */
4171 while (get_next_msg (&msg, FALSE)) 4165 while (get_next_msg (&msg, FALSE))
4172 { 4166 {
4167 struct input_event inev;
4168 int do_help = 0;
4169
4170 EVENT_INIT (inev);
4171 inev.kind = NO_EVENT;
4172 inev.arg = Qnil;
4173
4173 switch (msg.msg.message) 4174 switch (msg.msg.message)
4174 { 4175 {
4175 case WM_PAINT: 4176 case WM_PAINT:
@@ -4198,12 +4199,8 @@ w32_read_socket (sd, bufp, numchars, expected)
4198 visibility changes properly. */ 4199 visibility changes properly. */
4199 if (f->iconified) 4200 if (f->iconified)
4200 { 4201 {
4201 bufp->kind = DEICONIFY_EVENT; 4202 inev.kind = DEICONIFY_EVENT;
4202 XSETFRAME (bufp->frame_or_window, f); 4203 XSETFRAME (inev.frame_or_window, f);
4203 bufp->arg = Qnil;
4204 bufp++;
4205 count++;
4206 numchars--;
4207 } 4204 }
4208 else if (! NILP (Vframe_list) 4205 else if (! NILP (Vframe_list)
4209 && ! NILP (XCDR (Vframe_list))) 4206 && ! NILP (XCDR (Vframe_list)))
@@ -4233,17 +4230,10 @@ w32_read_socket (sd, bufp, numchars, expected)
4233 4230
4234 if (f) 4231 if (f)
4235 { 4232 {
4236 if (numchars == 0) 4233 inev.kind = LANGUAGE_CHANGE_EVENT;
4237 abort (); 4234 XSETFRAME (inev.frame_or_window, f);
4238 4235 inev.code = msg.msg.wParam;
4239 bufp->kind = LANGUAGE_CHANGE_EVENT; 4236 inev.modifiers = msg.msg.lParam & 0xffff;
4240 XSETFRAME (bufp->frame_or_window, f);
4241 bufp->arg = Qnil;
4242 bufp->code = msg.msg.wParam;
4243 bufp->modifiers = msg.msg.lParam & 0xffff;
4244 bufp++;
4245 count++;
4246 numchars--;
4247 } 4237 }
4248 break; 4238 break;
4249 4239
@@ -4262,15 +4252,11 @@ w32_read_socket (sd, bufp, numchars, expected)
4262 if (temp_index == sizeof temp_buffer / sizeof (short)) 4252 if (temp_index == sizeof temp_buffer / sizeof (short))
4263 temp_index = 0; 4253 temp_index = 0;
4264 temp_buffer[temp_index++] = msg.msg.wParam; 4254 temp_buffer[temp_index++] = msg.msg.wParam;
4265 bufp->kind = NON_ASCII_KEYSTROKE_EVENT; 4255 inev.kind = NON_ASCII_KEYSTROKE_EVENT;
4266 bufp->code = msg.msg.wParam; 4256 inev.code = msg.msg.wParam;
4267 bufp->modifiers = msg.dwModifiers; 4257 inev.modifiers = msg.dwModifiers;
4268 XSETFRAME (bufp->frame_or_window, f); 4258 XSETFRAME (inev.frame_or_window, f);
4269 bufp->arg = Qnil; 4259 inev.timestamp = msg.msg.time;
4270 bufp->timestamp = msg.msg.time;
4271 bufp++;
4272 numchars--;
4273 count++;
4274 } 4260 }
4275 break; 4261 break;
4276 4262
@@ -4289,15 +4275,11 @@ w32_read_socket (sd, bufp, numchars, expected)
4289 if (temp_index == sizeof temp_buffer / sizeof (short)) 4275 if (temp_index == sizeof temp_buffer / sizeof (short))
4290 temp_index = 0; 4276 temp_index = 0;
4291 temp_buffer[temp_index++] = msg.msg.wParam; 4277 temp_buffer[temp_index++] = msg.msg.wParam;
4292 bufp->kind = ASCII_KEYSTROKE_EVENT; 4278 inev.kind = ASCII_KEYSTROKE_EVENT;
4293 bufp->code = msg.msg.wParam; 4279 inev.code = msg.msg.wParam;
4294 bufp->modifiers = msg.dwModifiers; 4280 inev.modifiers = msg.dwModifiers;
4295 XSETFRAME (bufp->frame_or_window, f); 4281 XSETFRAME (inev.frame_or_window, f);
4296 bufp->arg = Qnil; 4282 inev.timestamp = msg.msg.time;
4297 bufp->timestamp = msg.msg.time;
4298 bufp++;
4299 numchars--;
4300 count++;
4301 } 4283 }
4302 break; 4284 break;
4303 4285
@@ -4343,13 +4325,10 @@ w32_read_socket (sd, bufp, numchars, expected)
4343 iff it is active. */ 4325 iff it is active. */
4344 if (WINDOWP(window) 4326 if (WINDOWP(window)
4345 && !EQ (window, last_window) 4327 && !EQ (window, last_window)
4346 && !EQ (window, selected_window) 4328 && !EQ (window, selected_window))
4347 && numchars > 0)
4348 { 4329 {
4349 bufp->kind = SELECT_WINDOW_EVENT; 4330 inev.kind = SELECT_WINDOW_EVENT;
4350 bufp->frame_or_window = window; 4331 inev.frame_or_window = window;
4351 bufp->arg = Qnil;
4352 ++bufp, ++count, --numchars;
4353 } 4332 }
4354 4333
4355 last_window=window; 4334 last_window=window;
@@ -4367,27 +4346,8 @@ w32_read_socket (sd, bufp, numchars, expected)
4367 has changed, generate a HELP_EVENT. */ 4346 has changed, generate a HELP_EVENT. */
4368 if (help_echo_string != previous_help_echo_string || 4347 if (help_echo_string != previous_help_echo_string ||
4369 (!NILP (help_echo_string) && !STRINGP (help_echo_string) && f->mouse_moved)) 4348 (!NILP (help_echo_string) && !STRINGP (help_echo_string) && f->mouse_moved))
4370 { 4349 do_help = 1;
4371 Lisp_Object frame;
4372 int n;
4373
4374 if (help_echo_string == Qnil)
4375 {
4376 help_echo_object = help_echo_window = Qnil;
4377 help_echo_pos = -1;
4378 }
4379
4380 if (f)
4381 XSETFRAME (frame, f);
4382 else
4383 frame = Qnil;
4384 4350
4385 any_help_event_p = 1;
4386 n = gen_help_event (bufp, numchars, help_echo_string, frame,
4387 help_echo_window, help_echo_object,
4388 help_echo_pos);
4389 bufp += n, count += n, numchars -= n;
4390 }
4391 break; 4351 break;
4392 4352
4393 case WM_LBUTTONDOWN: 4353 case WM_LBUTTONDOWN:
@@ -4401,13 +4361,10 @@ w32_read_socket (sd, bufp, numchars, expected)
4401 { 4361 {
4402 /* If we decide we want to generate an event to be seen 4362 /* If we decide we want to generate an event to be seen
4403 by the rest of Emacs, we put it here. */ 4363 by the rest of Emacs, we put it here. */
4404 struct input_event emacs_event;
4405 int tool_bar_p = 0; 4364 int tool_bar_p = 0;
4406 int button; 4365 int button;
4407 int up; 4366 int up;
4408 4367
4409 emacs_event.kind = NO_EVENT;
4410
4411 if (dpyinfo->grabbed && last_mouse_frame 4368 if (dpyinfo->grabbed && last_mouse_frame
4412 && FRAME_LIVE_P (last_mouse_frame)) 4369 && FRAME_LIVE_P (last_mouse_frame))
4413 f = last_mouse_frame; 4370 f = last_mouse_frame;
@@ -4416,35 +4373,29 @@ w32_read_socket (sd, bufp, numchars, expected)
4416 4373
4417 if (f) 4374 if (f)
4418 { 4375 {
4419 construct_mouse_click (&emacs_event, &msg, f); 4376 construct_mouse_click (&inev, &msg, f);
4420 4377
4421 /* Is this in the tool-bar? */ 4378 /* Is this in the tool-bar? */
4422 if (WINDOWP (f->tool_bar_window) 4379 if (WINDOWP (f->tool_bar_window)
4423 && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window))) 4380 && WINDOW_TOTAL_LINES (XWINDOW (f->tool_bar_window)))
4424 { 4381 {
4425 Lisp_Object window; 4382 Lisp_Object window;
4426 int x = XFASTINT (emacs_event.x); 4383 int x = XFASTINT (inev.x);
4427 int y = XFASTINT (emacs_event.y); 4384 int y = XFASTINT (inev.y);
4428 4385
4429 window = window_from_coordinates (f, x, y, 0, 0, 0, 1); 4386 window = window_from_coordinates (f, x, y, 0, 0, 0, 1);
4430 4387
4431 if (EQ (window, f->tool_bar_window)) 4388 if (EQ (window, f->tool_bar_window))
4432 { 4389 {
4433 w32_handle_tool_bar_click (f, &emacs_event); 4390 w32_handle_tool_bar_click (f, &inev);
4434 tool_bar_p = 1; 4391 tool_bar_p = 1;
4435 } 4392 }
4436 } 4393 }
4437 4394
4438 if (!tool_bar_p) 4395 if (tool_bar_p
4439 if (!dpyinfo->w32_focus_frame 4396 || (dpyinfo->w32_focus_frame
4440 || f == dpyinfo->w32_focus_frame 4397 && f == dpyinfo->w32_focus_frame))
4441 && (numchars >= 1)) 4398 inev.kind = NO_EVENT;
4442 {
4443 construct_mouse_click (bufp, &msg, f);
4444 bufp++;
4445 count++;
4446 numchars--;
4447 }
4448 } 4399 }
4449 4400
4450 parse_button (msg.msg.message, HIWORD (msg.msg.wParam), 4401 parse_button (msg.msg.message, HIWORD (msg.msg.wParam),
@@ -4482,15 +4433,11 @@ w32_read_socket (sd, bufp, numchars, expected)
4482 if (f) 4433 if (f)
4483 { 4434 {
4484 4435
4485 if ((!dpyinfo->w32_focus_frame 4436 if (!dpyinfo->w32_focus_frame
4486 || f == dpyinfo->w32_focus_frame) 4437 || f == dpyinfo->w32_focus_frame)
4487 && (numchars >= 1))
4488 { 4438 {
4489 /* Emit an Emacs wheel-up/down event. */ 4439 /* Emit an Emacs wheel-up/down event. */
4490 construct_mouse_wheel (bufp, &msg, f); 4440 construct_mouse_wheel (&inev, &msg, f);
4491 bufp++;
4492 count++;
4493 numchars--;
4494 } 4441 }
4495 /* Ignore any mouse motion that happened before this 4442 /* Ignore any mouse motion that happened before this
4496 event; any subsequent mouse-movement Emacs events 4443 event; any subsequent mouse-movement Emacs events
@@ -4507,12 +4454,7 @@ w32_read_socket (sd, bufp, numchars, expected)
4507 f = x_window_to_frame (dpyinfo, msg.msg.hwnd); 4454 f = x_window_to_frame (dpyinfo, msg.msg.hwnd);
4508 4455
4509 if (f) 4456 if (f)
4510 { 4457 construct_drag_n_drop (&inev, &msg, f);
4511 construct_drag_n_drop (bufp, &msg, f);
4512 bufp++;
4513 count++;
4514 numchars--;
4515 }
4516 break; 4458 break;
4517 4459
4518 case WM_VSCROLL: 4460 case WM_VSCROLL:
@@ -4520,15 +4462,8 @@ w32_read_socket (sd, bufp, numchars, expected)
4520 struct scroll_bar *bar = 4462 struct scroll_bar *bar =
4521 x_window_to_scroll_bar ((HWND)msg.msg.lParam); 4463 x_window_to_scroll_bar ((HWND)msg.msg.lParam);
4522 4464
4523 if (bar && numchars >= 1) 4465 if (bar)
4524 { 4466 w32_scroll_bar_handle_click (bar, &msg, &inev);
4525 if (w32_scroll_bar_handle_click (bar, &msg, bufp))
4526 {
4527 bufp++;
4528 count++;
4529 numchars--;
4530 }
4531 }
4532 break; 4467 break;
4533 } 4468 }
4534 4469
@@ -4604,12 +4539,8 @@ w32_read_socket (sd, bufp, numchars, expected)
4604 f->async_visible = 0; 4539 f->async_visible = 0;
4605 f->async_iconified = 1; 4540 f->async_iconified = 1;
4606 4541
4607 bufp->kind = ICONIFY_EVENT; 4542 inev.kind = ICONIFY_EVENT;
4608 XSETFRAME (bufp->frame_or_window, f); 4543 XSETFRAME (inev.frame_or_window, f);
4609 bufp->arg = Qnil;
4610 bufp++;
4611 count++;
4612 numchars--;
4613 break; 4544 break;
4614 4545
4615 case SIZE_MAXIMIZED: 4546 case SIZE_MAXIMIZED:
@@ -4634,12 +4565,8 @@ w32_read_socket (sd, bufp, numchars, expected)
4634 f->left_pos = x; 4565 f->left_pos = x;
4635 f->top_pos = y; 4566 f->top_pos = y;
4636 4567
4637 bufp->kind = DEICONIFY_EVENT; 4568 inev.kind = DEICONIFY_EVENT;
4638 XSETFRAME (bufp->frame_or_window, f); 4569 XSETFRAME (inev.frame_or_window, f);
4639 bufp->arg = Qnil;
4640 bufp++;
4641 count++;
4642 numchars--;
4643 } 4570 }
4644 else if (! NILP (Vframe_list) 4571 else if (! NILP (Vframe_list)
4645 && ! NILP (XCDR (Vframe_list))) 4572 && ! NILP (XCDR (Vframe_list)))
@@ -4707,16 +4634,7 @@ w32_read_socket (sd, bufp, numchars, expected)
4707 Otherwise, the startup message is cleared when 4634 Otherwise, the startup message is cleared when
4708 the mouse leaves the frame. */ 4635 the mouse leaves the frame. */
4709 if (any_help_event_p) 4636 if (any_help_event_p)
4710 { 4637 do_help = -1;
4711 Lisp_Object frame;
4712 int n;
4713
4714 XSETFRAME (frame, f);
4715 help_echo_string = Qnil;
4716 n = gen_help_event (bufp, numchars,
4717 Qnil, frame, Qnil, Qnil, 0);
4718 bufp += n, count += n, numchars -= n;
4719 }
4720 } 4638 }
4721 break; 4639 break;
4722 4640
@@ -4766,16 +4684,7 @@ w32_read_socket (sd, bufp, numchars, expected)
4766 Otherwise, the startup message is cleared when 4684 Otherwise, the startup message is cleared when
4767 the mouse leaves the frame. */ 4685 the mouse leaves the frame. */
4768 if (any_help_event_p) 4686 if (any_help_event_p)
4769 { 4687 do_help = -1;
4770 Lisp_Object frame;
4771 int n;
4772
4773 XSETFRAME (frame, f);
4774 help_echo_string = Qnil;
4775 n = gen_help_event (bufp, numchars,
4776 Qnil, frame, Qnil, Qnil, 0);
4777 bufp += n, count += n, numchars -=n;
4778 }
4779 } 4688 }
4780 4689
4781 dpyinfo->grabbed = 0; 4690 dpyinfo->grabbed = 0;
@@ -4787,15 +4696,8 @@ w32_read_socket (sd, bufp, numchars, expected)
4787 4696
4788 if (f) 4697 if (f)
4789 { 4698 {
4790 if (numchars == 0) 4699 inev.kind = DELETE_WINDOW_EVENT;
4791 abort (); 4700 XSETFRAME (inev.frame_or_window, f);
4792
4793 bufp->kind = DELETE_WINDOW_EVENT;
4794 XSETFRAME (bufp->frame_or_window, f);
4795 bufp->arg = Qnil;
4796 bufp++;
4797 count++;
4798 numchars--;
4799 } 4701 }
4800 break; 4702 break;
4801 4703
@@ -4804,15 +4706,8 @@ w32_read_socket (sd, bufp, numchars, expected)
4804 4706
4805 if (f) 4707 if (f)
4806 { 4708 {
4807 if (numchars == 0) 4709 inev.kind = MENU_BAR_ACTIVATE_EVENT;
4808 abort (); 4710 XSETFRAME (inev.frame_or_window, f);
4809
4810 bufp->kind = MENU_BAR_ACTIVATE_EVENT;
4811 XSETFRAME (bufp->frame_or_window, f);
4812 bufp->arg = Qnil;
4813 bufp++;
4814 count++;
4815 numchars--;
4816 } 4711 }
4817 break; 4712 break;
4818 4713
@@ -4854,6 +4749,42 @@ w32_read_socket (sd, bufp, numchars, expected)
4854 } 4749 }
4855 break; 4750 break;
4856 } 4751 }
4752
4753 if (inev.kind != NO_EVENT)
4754 {
4755 kbd_buffer_store_event_hold (&inev, hold_quit);
4756 count++;
4757 }
4758
4759 if (do_help
4760 && !(hold_quit && hold_quit->kind != NO_EVENT))
4761 {
4762 Lisp_Object frame;
4763
4764 if (f)
4765 XSETFRAME (frame, f);
4766 else
4767 frame = Qnil;
4768
4769 if (do_help > 0)
4770 {
4771 if (help_echo_string == Qnil)
4772 {
4773 help_echo_object = help_echo_window = Qnil;
4774 help_echo_pos = -1;
4775 }
4776
4777 any_help_event_p = 1;
4778 gen_help_event (help_echo_string, frame, help_echo_window,
4779 help_echo_object, help_echo_pos);
4780 }
4781 else
4782 {
4783 help_echo_string = Qnil;
4784 gen_help_event (Qnil, frame, Qnil, Qnil, 0);
4785 }
4786 count++;
4787 }
4857 } 4788 }
4858 4789
4859 /* If the focus was just given to an autoraising frame, 4790 /* If the focus was just given to an autoraising frame,
@@ -5145,6 +5076,9 @@ w32_draw_window_cursor (w, glyph_row, x, y, cursor_type, cursor_width, on_p, act
5145 cursor remains invisible. */ 5076 cursor remains invisible. */
5146 if (w32_use_visible_system_caret) 5077 if (w32_use_visible_system_caret)
5147 { 5078 {
5079 /* Call to erase_phys_cursor here seems to use the
5080 wrong values of w->phys_cursor, as they have been
5081 overwritten before this function was called. */
5148 if (w->phys_cursor_type != NO_CURSOR) 5082 if (w->phys_cursor_type != NO_CURSOR)
5149 erase_phys_cursor (w); 5083 erase_phys_cursor (w);
5150 5084