comparison src/event-msw.c @ 400:a86b2b5e0111 r21-2-30

Import from CVS: tag r21-2-30
author cvs
date Mon, 13 Aug 2007 11:14:34 +0200
parents 74fd4e045ea6
children 2f8bb876ab1d
comparison
equal deleted inserted replaced
399:376370fb5946 400:a86b2b5e0111
116 * one. 116 * one.
117 */ 117 */
118 static Lisp_Object mswindows_u_dispatch_event_queue, mswindows_u_dispatch_event_queue_tail; 118 static Lisp_Object mswindows_u_dispatch_event_queue, mswindows_u_dispatch_event_queue_tail;
119 static Lisp_Object mswindows_s_dispatch_event_queue, mswindows_s_dispatch_event_queue_tail; 119 static Lisp_Object mswindows_s_dispatch_event_queue, mswindows_s_dispatch_event_queue_tail;
120 120
121 /* For speed: whether there is a WM_PAINT magic message in the system queue */
122 static int mswindows_paint_pending = 0;
123
124 /* The number of things we can wait on */ 121 /* The number of things we can wait on */
125 #define MAX_WAITABLE (MAXIMUM_WAIT_OBJECTS - 1) 122 #define MAX_WAITABLE (MAXIMUM_WAIT_OBJECTS - 1)
126 123
127 #ifndef HAVE_MSG_SELECT 124 #ifndef HAVE_MSG_SELECT
128 /* List of mswindows waitable handles. */ 125 /* List of mswindows waitable handles. */
634 { 631 {
635 LPARAM user_data; /* Any user data stored in the stream object */ 632 LPARAM user_data; /* Any user data stored in the stream object */
636 SOCKET s; /* Socket handle (which is a Win32 handle) */ 633 SOCKET s; /* Socket handle (which is a Win32 handle) */
637 OVERLAPPED ov; /* Overlapped I/O structure */ 634 OVERLAPPED ov; /* Overlapped I/O structure */
638 void* buffer; /* Buffer. Allocated for input stream only */ 635 void* buffer; /* Buffer. Allocated for input stream only */
639 unsigned int bufsize; /* Number of bytes last read */ 636 unsigned long bufsize; /* Number of bytes last read */
640 unsigned int bufpos; /* Position in buffer for next fetch */ 637 unsigned long bufpos; /* Position in buffer for next fetch */
641 unsigned int error_p :1; /* I/O Error seen */ 638 unsigned int error_p :1; /* I/O Error seen */
642 unsigned int eof_p :1; /* EOF Error seen */ 639 unsigned int eof_p :1; /* EOF Error seen */
643 unsigned int pending_p :1; /* There is a pending I/O operation */ 640 unsigned int pending_p :1; /* There is a pending I/O operation */
644 unsigned int blocking_p :1; /* Last write attempt would block */ 641 unsigned int blocking_p :1; /* Last write attempt would block */
645 }; 642 };
1255 { 1252 {
1256 /* hdc will be NULL unless this is a subwindow - in which case we 1253 /* hdc will be NULL unless this is a subwindow - in which case we
1257 shouldn't have received a paint message for it here. */ 1254 shouldn't have received a paint message for it here. */
1258 assert (msg.wParam == 0); 1255 assert (msg.wParam == 0);
1259 1256
1260 if (!mswindows_paint_pending) 1257 /* Queue a magic event for handling when safe */
1261 { 1258 mswindows_enqueue_magic_event (msg.hwnd, WM_PAINT);
1262 /* Queue a magic event for handling when safe */
1263 mswindows_enqueue_magic_event (msg.hwnd, WM_PAINT);
1264 mswindows_paint_pending = 1;
1265 }
1266 1259
1267 /* Don't dispatch. WM_PAINT is always the last message in the 1260 /* Don't dispatch. WM_PAINT is always the last message in the
1268 queue so it's OK to just return. */ 1261 queue so it's OK to just return. */
1269 return; 1262 return;
1270 } 1263 }
1521 /* We only support one {service,topic} pair */ 1514 /* We only support one {service,topic} pair */
1522 HSZPAIR pairs[2] = { 1515 HSZPAIR pairs[2] = {
1523 { mswindows_dde_service, mswindows_dde_topic_system }, { 0, 0 } }; 1516 { mswindows_dde_service, mswindows_dde_topic_system }, { 0, 0 } };
1524 1517
1525 if (!(hszItem || DdeCmpStringHandles (hszItem, mswindows_dde_service)) && 1518 if (!(hszItem || DdeCmpStringHandles (hszItem, mswindows_dde_service)) &&
1526 !(hszTopic || DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system))); 1519 !(hszTopic || DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system)))
1527 return (DdeCreateDataHandle (mswindows_dde_mlid, (LPBYTE)pairs, 1520 return (DdeCreateDataHandle (mswindows_dde_mlid, (LPBYTE)pairs,
1528 sizeof (pairs), 0L, 0, uFmt, 0)); 1521 sizeof (pairs), 0L, 0, uFmt, 0));
1529 } 1522 }
1530 return (HDDEDATA)NULL; 1523 return (HDDEDATA)NULL;
1531 1524
1532 case XTYP_EXECUTE: 1525 case XTYP_EXECUTE:
1533 if (!DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system)) 1526 if (!DdeCmpStringHandles (hszTopic, mswindows_dde_topic_system))
1534 { 1527 {
1535 DWORD len = DdeGetData (hdata, NULL, 0, 0); 1528 DWORD len = DdeGetData (hdata, NULL, 0, 0);
1536 char *cmd = alloca (len+1); 1529 LPBYTE cmd = (LPBYTE) alloca (len+1);
1537 char *end; 1530 char *end;
1538 char *filename; 1531 char *filename;
1539 struct gcpro gcpro1, gcpro2; 1532 struct gcpro gcpro1, gcpro2;
1540 Lisp_Object l_dndlist = Qnil; 1533 Lisp_Object l_dndlist = Qnil;
1541 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil); 1534 Lisp_Object emacs_event = Fmake_event (Qnil, Qnil);
2365 emacs_event = Fmake_event (Qnil, Qnil); 2358 emacs_event = Fmake_event (Qnil, Qnil);
2366 event = XEVENT(emacs_event); 2359 event = XEVENT(emacs_event);
2367 2360
2368 GCPRO3 (emacs_event, l_dndlist, l_item); 2361 GCPRO3 (emacs_event, l_dndlist, l_item);
2369 2362
2370 if (!DragQueryPoint ((HANDLE) wParam, &point)) 2363 if (!DragQueryPoint ((HDROP) wParam, &point))
2371 point.x = point.y = -1; /* outside client area */ 2364 point.x = point.y = -1; /* outside client area */
2372 2365
2373 event->event_type = misc_user_event; 2366 event->event_type = misc_user_event;
2374 event->channel = mswindows_find_frame(hwnd); 2367 event->channel = mswindows_find_frame(hwnd);
2375 event->timestamp = GetMessageTime(); 2368 event->timestamp = GetMessageTime();
2377 event->event.misc.modifiers = mswindows_modifier_state (NULL, 0); 2370 event->event.misc.modifiers = mswindows_modifier_state (NULL, 0);
2378 event->event.misc.x = point.x; 2371 event->event.misc.x = point.x;
2379 event->event.misc.y = point.y; 2372 event->event.misc.y = point.y;
2380 event->event.misc.function = Qdragdrop_drop_dispatch; 2373 event->event.misc.function = Qdragdrop_drop_dispatch;
2381 2374
2382 filecount = DragQueryFile ((HANDLE) wParam, 0xffffffff, NULL, 0); 2375 filecount = DragQueryFile ((HDROP) wParam, 0xffffffff, NULL, 0);
2383 for (i=0; i<filecount; i++) 2376 for (i=0; i<filecount; i++)
2384 { 2377 {
2385 len = DragQueryFile ((HANDLE) wParam, i, NULL, 0); 2378 len = DragQueryFile ((HDROP) wParam, i, NULL, 0);
2386 /* The URLs that we make here aren't correct according to section 2379 /* The URLs that we make here aren't correct according to section
2387 * 3.10 of rfc1738 because they're missing the //<host>/ part and 2380 * 3.10 of rfc1738 because they're missing the //<host>/ part and
2388 * because they may contain reserved characters. But that's OK. */ 2381 * because they may contain reserved characters. But that's OK. */
2389 #ifdef __CYGWIN32__ 2382 #ifdef __CYGWIN32__
2390 fname = (char *)xmalloc (len+1); 2383 fname = (char *)xmalloc (len+1);
2394 cygwin32_win32_to_posix_path_list (fname, filename+5); 2387 cygwin32_win32_to_posix_path_list (fname, filename+5);
2395 xfree (fname); 2388 xfree (fname);
2396 #else 2389 #else
2397 filename = (char *)xmalloc (len+6); 2390 filename = (char *)xmalloc (len+6);
2398 strcpy (filename, "file:"); 2391 strcpy (filename, "file:");
2399 DragQueryFile ((HANDLE) wParam, i, filename+5, len+1); 2392 DragQueryFile ((HDROP) wParam, i, filename+5, len+1);
2400 dostounix_filename (filename+5); 2393 dostounix_filename (filename+5);
2401 #endif 2394 #endif
2402 l_item = make_string (filename, strlen (filename)); 2395 l_item = make_string (filename, strlen (filename));
2403 l_dndlist = Fcons (l_item, l_dndlist); 2396 l_dndlist = Fcons (l_item, l_dndlist);
2404 xfree (filename); 2397 xfree (filename);
2405 } 2398 }
2406 DragFinish ((HANDLE) wParam); 2399 DragFinish ((HDROP) wParam);
2407 2400
2408 event->event.misc.object = Fcons (Qdragdrop_URL, l_dndlist); 2401 event->event.misc.object = Fcons (Qdragdrop_URL, l_dndlist);
2409 mswindows_enqueue_dispatch_event (emacs_event); 2402 mswindows_enqueue_dispatch_event (emacs_event);
2410 UNGCPRO; 2403 UNGCPRO;
2411 } 2404 }
2723 case XM_BUMPQUEUE: 2716 case XM_BUMPQUEUE:
2724 break; 2717 break;
2725 2718
2726 case WM_PAINT: 2719 case WM_PAINT:
2727 mswindows_handle_paint (XFRAME (EVENT_CHANNEL (emacs_event))); 2720 mswindows_handle_paint (XFRAME (EVENT_CHANNEL (emacs_event)));
2728 mswindows_paint_pending = 0;
2729 break; 2721 break;
2730 2722
2731 case WM_SETFOCUS: 2723 case WM_SETFOCUS:
2732 case WM_KILLFOCUS: 2724 case WM_KILLFOCUS:
2733 { 2725 {