Mercurial > hg > xemacs-beta
comparison src/event-msw.c @ 647:b39c14581166
[xemacs-hg @ 2001-08-13 04:45:47 by ben]
removal of unsigned, size_t, etc.
author | ben |
---|---|
date | Mon, 13 Aug 2001 04:46:48 +0000 |
parents | 38db05db9cb5 |
children | 4035041996d8 |
comparison
equal
deleted
inserted
replaced
646:00c54252fe4f | 647:b39c14581166 |
---|---|
365 { | 365 { |
366 struct ntpipe_slurp_stream* s = NTPIPE_SLURP_STREAM_DATA(stream); | 366 struct ntpipe_slurp_stream* s = NTPIPE_SLURP_STREAM_DATA(stream); |
367 return s->thread_data->hev_caller; | 367 return s->thread_data->hev_caller; |
368 } | 368 } |
369 | 369 |
370 static Lstream_data_count | 370 static Lstream_Data_Count |
371 ntpipe_slurp_reader (Lstream *stream, unsigned char *data, | 371 ntpipe_slurp_reader (Lstream *stream, unsigned char *data, |
372 Lstream_data_count size) | 372 Lstream_Data_Count size) |
373 { | 373 { |
374 /* This function must be called from the main thread only */ | 374 /* This function must be called from the main thread only */ |
375 struct ntpipe_slurp_stream_shared_data* s = | 375 struct ntpipe_slurp_stream_shared_data* s = |
376 NTPIPE_SLURP_STREAM_DATA(stream)->thread_data; | 376 NTPIPE_SLURP_STREAM_DATA(stream)->thread_data; |
377 | 377 |
427 | 427 |
428 /* Fetch available bytes. The same consideration applies, | 428 /* Fetch available bytes. The same consideration applies, |
429 so do not check for errors. ReadFile in the thread will | 429 so do not check for errors. ReadFile in the thread will |
430 fail if the next call fails. */ | 430 fail if the next call fails. */ |
431 if (bytes_available) | 431 if (bytes_available) |
432 ReadFile (s->hpipe, data, min (bytes_available, size), | 432 ReadFile (s->hpipe, data, min (bytes_available, (DWORD) size), |
433 &bytes_read, NULL); | 433 &bytes_read, NULL); |
434 } | 434 } |
435 | 435 |
436 /* Now we can unblock thread, so it attempts to read more */ | 436 /* Now we can unblock thread, so it attempts to read more */ |
437 SetEvent (s->hev_thread); | 437 SetEvent (s->hev_thread); |
580 struct ntpipe_shove_stream* s = NTPIPE_SHOVE_STREAM_DATA(stream); | 580 struct ntpipe_shove_stream* s = NTPIPE_SHOVE_STREAM_DATA(stream); |
581 return s->user_data; | 581 return s->user_data; |
582 } | 582 } |
583 #endif | 583 #endif |
584 | 584 |
585 static Lstream_data_count | 585 static Lstream_Data_Count |
586 ntpipe_shove_writer (Lstream *stream, const unsigned char *data, | 586 ntpipe_shove_writer (Lstream *stream, const unsigned char *data, |
587 Lstream_data_count size) | 587 Lstream_Data_Count size) |
588 { | 588 { |
589 struct ntpipe_shove_stream* s = NTPIPE_SHOVE_STREAM_DATA(stream); | 589 struct ntpipe_shove_stream* s = NTPIPE_SHOVE_STREAM_DATA(stream); |
590 | 590 |
591 if (s->error_p) | 591 if (s->error_p) |
592 return -1; | 592 return -1; |
664 struct winsock_stream | 664 struct winsock_stream |
665 { | 665 { |
666 LPARAM user_data; /* Any user data stored in the stream object */ | 666 LPARAM user_data; /* Any user data stored in the stream object */ |
667 SOCKET s; /* Socket handle (which is a Win32 handle) */ | 667 SOCKET s; /* Socket handle (which is a Win32 handle) */ |
668 OVERLAPPED ov; /* Overlapped I/O structure */ | 668 OVERLAPPED ov; /* Overlapped I/O structure */ |
669 void* buffer; /* Buffer. */ | 669 void *buffer; /* Buffer. */ |
670 unsigned long bufsize; /* Number of bytes last read */ | 670 DWORD bufsize; /* Number of bytes last read */ |
671 unsigned long bufpos; /* Position in buffer for next fetch */ | 671 DWORD bufpos; /* Position in buffer for next fetch */ |
672 unsigned int error_p :1; /* I/O Error seen */ | 672 unsigned int error_p :1; /* I/O Error seen */ |
673 unsigned int eof_p :1; /* EOF Error seen */ | 673 unsigned int eof_p :1; /* EOF Error seen */ |
674 unsigned int pending_p :1; /* There is a pending I/O operation */ | 674 unsigned int pending_p :1; /* There is a pending I/O operation */ |
675 unsigned int blocking_p :1; /* Last write attempt would block */ | 675 unsigned int blocking_p :1; /* Last write attempt would block */ |
676 }; | 676 }; |
698 } | 698 } |
699 else if (str->bufsize == 0) | 699 else if (str->bufsize == 0) |
700 str->eof_p = 1; | 700 str->eof_p = 1; |
701 } | 701 } |
702 | 702 |
703 static Lstream_data_count | 703 static Lstream_Data_Count |
704 winsock_reader (Lstream *stream, unsigned char *data, Lstream_data_count size) | 704 winsock_reader (Lstream *stream, unsigned char *data, Lstream_Data_Count size) |
705 { | 705 { |
706 struct winsock_stream *str = WINSOCK_STREAM_DATA (stream); | 706 struct winsock_stream *str = WINSOCK_STREAM_DATA (stream); |
707 | 707 |
708 /* If the current operation is not yet complete, there's nothing to | 708 /* If the current operation is not yet complete, there's nothing to |
709 give back */ | 709 give back */ |
733 return 0; | 733 return 0; |
734 if (str->error_p) | 734 if (str->error_p) |
735 return -1; | 735 return -1; |
736 | 736 |
737 /* Return as much of buffer as we have */ | 737 /* Return as much of buffer as we have */ |
738 size = min (size, (Lstream_data_count) (str->bufsize - str->bufpos)); | 738 size = min (size, (Lstream_Data_Count) (str->bufsize - str->bufpos)); |
739 memcpy (data, (void*)((BYTE*)str->buffer + str->bufpos), size); | 739 memcpy (data, (void*)((BYTE*)str->buffer + str->bufpos), size); |
740 str->bufpos += size; | 740 str->bufpos += size; |
741 | 741 |
742 /* Read more if buffer is exhausted */ | 742 /* Read more if buffer is exhausted */ |
743 if (str->bufsize == str->bufpos) | 743 if (str->bufsize == str->bufpos) |
744 winsock_initiate_read (str); | 744 winsock_initiate_read (str); |
745 | 745 |
746 return size; | 746 return size; |
747 } | 747 } |
748 | 748 |
749 static Lstream_data_count | 749 static Lstream_Data_Count |
750 winsock_writer (Lstream *stream, const unsigned char *data, | 750 winsock_writer (Lstream *stream, const unsigned char *data, |
751 Lstream_data_count size) | 751 Lstream_Data_Count size) |
752 { | 752 { |
753 struct winsock_stream *str = WINSOCK_STREAM_DATA (stream); | 753 struct winsock_stream *str = WINSOCK_STREAM_DATA (stream); |
754 | 754 |
755 if (str->pending_p) | 755 if (str->pending_p) |
756 { | 756 { |
1384 * Used by emacs_mswindows_event_pending_p and emacs_mswindows_next_event | 1384 * Used by emacs_mswindows_event_pending_p and emacs_mswindows_next_event |
1385 */ | 1385 */ |
1386 static void | 1386 static void |
1387 mswindows_need_event (int badly_p) | 1387 mswindows_need_event (int badly_p) |
1388 { | 1388 { |
1389 int active; | |
1390 | |
1391 while (NILP (mswindows_u_dispatch_event_queue) | 1389 while (NILP (mswindows_u_dispatch_event_queue) |
1392 && NILP (mswindows_s_dispatch_event_queue)) | 1390 && NILP (mswindows_s_dispatch_event_queue)) |
1393 { | 1391 { |
1394 #ifdef HAVE_MSG_SELECT | 1392 #ifdef HAVE_MSG_SELECT |
1395 int i; | 1393 int i; |
1394 int active; | |
1396 SELECT_TYPE temp_mask = input_wait_mask; | 1395 SELECT_TYPE temp_mask = input_wait_mask; |
1397 EMACS_TIME sometime; | 1396 EMACS_TIME sometime; |
1398 EMACS_SELECT_TIME select_time_to_block, *pointer_to_this; | 1397 EMACS_SELECT_TIME select_time_to_block, *pointer_to_this; |
1399 | 1398 |
1400 if (badly_p) | 1399 if (badly_p) |
1485 } | 1484 } |
1486 else | 1485 else |
1487 { | 1486 { |
1488 assert(0); | 1487 assert(0); |
1489 } | 1488 } |
1490 #else | 1489 #else /* not HAVE_MSG_SELECT */ |
1491 /* Now try getting a message or process event */ | 1490 /* Now try getting a message or process event */ |
1491 DWORD active; | |
1492 DWORD what_events; | 1492 DWORD what_events; |
1493 if (mswindows_in_modal_loop) | 1493 if (mswindows_in_modal_loop) |
1494 /* In a modal loop, only look for timer events, and only if | 1494 /* In a modal loop, only look for timer events, and only if |
1495 we really need one. */ | 1495 we really need one. */ |
1496 { | 1496 { |
1568 /* Have to return something: there may be no accompanying | 1568 /* Have to return something: there may be no accompanying |
1569 process event */ | 1569 process event */ |
1570 mswindows_enqueue_magic_event (NULL, XM_BUMPQUEUE); | 1570 mswindows_enqueue_magic_event (NULL, XM_BUMPQUEUE); |
1571 } | 1571 } |
1572 } | 1572 } |
1573 #endif | 1573 #endif /* not HAVE_MSG_SELECT */ |
1574 } /* while */ | 1574 } /* while */ |
1575 } | 1575 } |
1576 | 1576 |
1577 /************************************************************************/ | 1577 /************************************************************************/ |
1578 /* Event generators */ | 1578 /* Event generators */ |
2057 Lisp_Object emacs_event = Qnil; | 2057 Lisp_Object emacs_event = Qnil; |
2058 Lisp_Object fobj = Qnil; | 2058 Lisp_Object fobj = Qnil; |
2059 | 2059 |
2060 Lisp_Event *event; | 2060 Lisp_Event *event; |
2061 struct frame *frame; | 2061 struct frame *frame; |
2062 struct mswindows_frame* msframe; | 2062 struct mswindows_frame *msframe; |
2063 | 2063 |
2064 /* If you hit this, rewrite the offending API call to occur after GC, | 2064 /* If you hit this, rewrite the offending API call to occur after GC, |
2065 using register_post_gc_action(). */ | 2065 using register_post_gc_action(). */ |
2066 assert (!gc_in_progress); | 2066 assert (!gc_in_progress); |
2067 | 2067 |
2248 while (PeekMessage (&tranmsg, hwnd, WM_CHAR, WM_CHAR, PM_REMOVE) | 2248 while (PeekMessage (&tranmsg, hwnd, WM_CHAR, WM_CHAR, PM_REMOVE) |
2249 || PeekMessage (&tranmsg, hwnd, WM_SYSCHAR, WM_SYSCHAR, | 2249 || PeekMessage (&tranmsg, hwnd, WM_SYSCHAR, WM_SYSCHAR, |
2250 PM_REMOVE)) | 2250 PM_REMOVE)) |
2251 { | 2251 { |
2252 int mods_with_quit = mods; | 2252 int mods_with_quit = mods; |
2253 WPARAM ch = tranmsg.wParam; | 2253 Emchar ch = (Emchar) tranmsg.wParam; |
2254 | 2254 |
2255 #ifdef DEBUG_XEMACS | 2255 #ifdef DEBUG_XEMACS |
2256 if (debug_mswindows_events) | 2256 if (debug_mswindows_events) |
2257 { | 2257 { |
2258 stderr_out ("-> "); | 2258 stderr_out ("-> "); |
2550 Qcancel_mode_internal, Qnil); | 2550 Qcancel_mode_internal, Qnil); |
2551 break; | 2551 break; |
2552 | 2552 |
2553 case WM_NOTIFY: | 2553 case WM_NOTIFY: |
2554 { | 2554 { |
2555 LPNMHDR nmhdr = (LPNMHDR)lParam; | 2555 LPNMHDR nmhdr = (LPNMHDR) lParam; |
2556 | 2556 |
2557 if (nmhdr->code == TTN_NEEDTEXT) | 2557 if ((int) nmhdr->code == TTN_NEEDTEXT) |
2558 { | 2558 { |
2559 #ifdef HAVE_TOOLBARS | 2559 #ifdef HAVE_TOOLBARS |
2560 LPTOOLTIPTEXT tttext = (LPTOOLTIPTEXT)lParam; | 2560 LPTOOLTIPTEXT tttext = (LPTOOLTIPTEXT) lParam; |
2561 Lisp_Object btext; | 2561 Lisp_Object btext; |
2562 | 2562 |
2563 /* find out which toolbar */ | 2563 /* find out which toolbar */ |
2564 frame = XFRAME (mswindows_find_frame (hwnd)); | 2564 frame = XFRAME (mswindows_find_frame (hwnd)); |
2565 btext = mswindows_get_toolbar_button_text ( frame, | 2565 btext = mswindows_get_toolbar_button_text (frame, nmhdr->idFrom); |
2566 nmhdr->idFrom ); | |
2567 | 2566 |
2568 tttext->lpszText = NULL; | 2567 tttext->lpszText = NULL; |
2569 tttext->hinst = NULL; | 2568 tttext->hinst = NULL; |
2570 | 2569 |
2571 if (!NILP(btext)) | 2570 if (!NILP(btext)) |
2575 LISP_STRING_TO_EXTERNAL (btext, tttext->lpszText, Qnative); | 2574 LISP_STRING_TO_EXTERNAL (btext, tttext->lpszText, Qnative); |
2576 } | 2575 } |
2577 #endif | 2576 #endif |
2578 } | 2577 } |
2579 /* handle tree view callbacks */ | 2578 /* handle tree view callbacks */ |
2580 else if (nmhdr->code == TVN_SELCHANGED) | 2579 else if ((int) nmhdr->code == TVN_SELCHANGED) |
2581 { | 2580 { |
2582 NM_TREEVIEW* ptree = (NM_TREEVIEW*)lParam; | 2581 NM_TREEVIEW *ptree = (NM_TREEVIEW *) lParam; |
2583 frame = XFRAME (mswindows_find_frame (hwnd)); | 2582 frame = XFRAME (mswindows_find_frame (hwnd)); |
2584 mswindows_handle_gui_wm_command (frame, 0, ptree->itemNew.lParam); | 2583 mswindows_handle_gui_wm_command (frame, 0, ptree->itemNew.lParam); |
2585 } | 2584 } |
2586 /* handle tab control callbacks */ | 2585 /* handle tab control callbacks */ |
2587 else if (nmhdr->code == TCN_SELCHANGE) | 2586 else if ((int) nmhdr->code == TCN_SELCHANGE) |
2588 { | 2587 { |
2589 TC_ITEM item; | 2588 TC_ITEM item; |
2590 int idx = SendMessage (nmhdr->hwndFrom, TCM_GETCURSEL, 0, 0); | 2589 int idx = SendMessage (nmhdr->hwndFrom, TCM_GETCURSEL, 0, 0); |
2591 frame = XFRAME (mswindows_find_frame (hwnd)); | 2590 frame = XFRAME (mswindows_find_frame (hwnd)); |
2592 | 2591 |
3090 | 3089 |
3091 if (xGetKeyboardLayout) /* not in NT 3.5 */ | 3090 if (xGetKeyboardLayout) /* not in NT 3.5 */ |
3092 current_hkl = xGetKeyboardLayout (0); | 3091 current_hkl = xGetKeyboardLayout (0); |
3093 if (current_hkl != last_hkl) | 3092 if (current_hkl != last_hkl) |
3094 { | 3093 { |
3095 TCHAR c; | 3094 int c; |
3096 last_hkl_has_AltGr = 0; | 3095 last_hkl_has_AltGr = 0; |
3097 /* In this loop, we query whether a character requires | 3096 /* In this loop, we query whether a character requires |
3098 AltGr to be down to generate it. If at least such one | 3097 AltGr to be down to generate it. If at least such one |
3099 found, this means that the layout does regard AltGr */ | 3098 found, this means that the layout does regard AltGr */ |
3100 for (c = ' '; c <= 0xFFU && c != 0 && !last_hkl_has_AltGr; ++c) | 3099 for (c = ' '; c <= 255 && !last_hkl_has_AltGr; ++c) |
3101 if (HIBYTE (VkKeyScan (c)) == 6) | 3100 /* #### This is not really such a good check. What about under |
3101 CJK locales? It may not matter there, though. We always | |
3102 call VkKeyScanA so that we check the locale-specific characters | |
3103 in non-Latin-1 locales, instead of just the Latin-1 characters. */ | |
3104 if (HIBYTE (VkKeyScanA ((char) c)) == 6) | |
3102 last_hkl_has_AltGr = 1; | 3105 last_hkl_has_AltGr = 1; |
3103 last_hkl = current_hkl; | 3106 last_hkl = current_hkl; |
3104 } | 3107 } |
3105 return last_hkl_has_AltGr; | 3108 return last_hkl_has_AltGr; |
3106 } | 3109 } |
3956 char *str = 0; | 3959 char *str = 0; |
3957 /* struct mswin_message_debug *i_hate_cranking_out_code_like_this; */ | 3960 /* struct mswin_message_debug *i_hate_cranking_out_code_like_this; */ |
3958 | 3961 |
3959 for (i = 0; i < countof (debug_mswin_messages); i++) | 3962 for (i = 0; i < countof (debug_mswin_messages); i++) |
3960 { | 3963 { |
3961 if (debug_mswin_messages[i].mess == message_) | 3964 if (debug_mswin_messages[i].mess == (int) message_) |
3962 { | 3965 { |
3963 str = debug_mswin_messages[i].string; | 3966 str = debug_mswin_messages[i].string; |
3964 break; | 3967 break; |
3965 } | 3968 } |
3966 } | 3969 } |