comparison src/event-Xt.c @ 185:3d6bfa290dbd r20-3b19

Import from CVS: tag r20-3b19
author cvs
date Mon, 13 Aug 2007 09:55:28 +0200
parents e121b013d1f0
children b405438285a2
comparison
equal deleted inserted replaced
184:bcd2674570bf 185:3d6bfa290dbd
632 return make_char (keysym); 632 return make_char (keysym);
633 633
634 switch (keysym) 634 switch (keysym)
635 { 635 {
636 /* These would be handled correctly by the default case, but by 636 /* These would be handled correctly by the default case, but by
637 special-casing them here we don't garbage a string or call intern(). 637 special-casing them here we don't garbage a string or call
638 */ 638 intern(). */
639 case XK_BackSpace: return QKbackspace; 639 case XK_BackSpace: return QKbackspace;
640 case XK_Tab: return QKtab; 640 case XK_Tab: return QKtab;
641 case XK_Linefeed: return QKlinefeed; 641 case XK_Linefeed: return QKlinefeed;
642 case XK_Return: return QKreturn; 642 case XK_Return: return QKreturn;
643 case XK_Escape: return QKescape; 643 case XK_Escape: return QKescape;
698 (get_device_from_display (event->display), 698 (get_device_from_display (event->display),
699 event->window)); 699 event->window));
700 #endif /* XIM_XLIB */ 700 #endif /* XIM_XLIB */
701 #endif /* HAVE_XIM */ 701 #endif /* HAVE_XIM */
702 702
703 if ( 703 /* We use XLookupString if we're not using XIM, or are using
704 #ifndef HAVE_XIM 704 XIM_XLIB but input context creation failed. */
705 1 705 #if ! (defined (HAVE_XIM) && defined (XIM_MOTIF))
706 #elif defined (XIM_MOTIF) 706 #if defined (HAVE_XIM) && defined (XIM_XLIB)
707 0 707 if (!xic)
708 #else /* XIM_XLIB */ 708 #endif /* XIM_XLIB */
709 !xic
710 #endif
711 )
712 { 709 {
713 /* Apparently it's necessary to specify a dummy here (rather 710 /* Apparently it's necessary to specify a dummy here (rather
714 than passing in 0) to avoid crashes on German IRIX */ 711 than passing in 0) to avoid crashes on German IRIX */
715 char dummy[256]; 712 char dummy[256];
716 XLookupString (event, dummy, 200, &keysym, 0); 713 XLookupString (event, dummy, 200, &keysym, 0);
717 return x_keysym_to_emacs_keysym (keysym, simple_p); 714 return x_keysym_to_emacs_keysym (keysym, simple_p);
718 } 715 }
716 #endif /* ! XIM_MOTIF */
719 717
720 #ifdef HAVE_XIM 718 #ifdef HAVE_XIM
721 Lookup_String: /* Come-From XBufferOverflow */ 719 Lookup_String: /* Come-From XBufferOverflow */
722 #ifdef XIM_MOTIF 720 #ifdef XIM_MOTIF
723 len = XmImMbLookupString (XtWindowToWidget (event->display, event->window), 721 len = XmImMbLookupString (XtWindowToWidget (event->display, event->window),
724 event, bufptr, bufsiz, &keysym, &status); 722 event, bufptr, bufsiz, &keysym, &status);
725 #else /* XIM_XLIB */ 723 #else /* XIM_XLIB */
726 len = XmbLookupString (xic, event, bufptr, bufsiz, &keysym, &status); 724 len = XmbLookupString (xic, event, bufptr, bufsiz, &keysym, &status);
727 #endif /* XIM_XLIB */ 725 #endif /* HAVE_XIM */
728 726
729 #ifdef DEBUG_XEMACS 727 #ifdef DEBUG_XEMACS
730 if (x_debug_events > 0) 728 if (x_debug_events > 0)
731 { 729 {
732 stderr_out (" status="); 730 stderr_out (" status=");
767 case XLookupChars: 765 case XLookupChars:
768 { 766 {
769 /* Generate multiple emacs events */ 767 /* Generate multiple emacs events */
770 struct device *d = get_device_from_display (event->display); 768 struct device *d = get_device_from_display (event->display);
771 Emchar ch; 769 Emchar ch;
772 Lisp_Object instream = 770 Lisp_Object instream, fb_instream;
771 Lstream *istr;
772 struct gcpro gcpro1, gcpro2;
773
774 fb_instream =
773 make_fixed_buffer_input_stream ((unsigned char *) bufptr, len); 775 make_fixed_buffer_input_stream ((unsigned char *) bufptr, len);
774 776
775 /* ### Use Fget_coding_system (Vcomposed_input_coding_system) */ 777 /* ### Use Fget_coding_system (Vcomposed_input_coding_system) */
776 instream = 778 instream =
777 make_decoding_input_stream (XLSTREAM (instream), 779 make_decoding_input_stream (XLSTREAM (fb_instream),
778 Fget_coding_system (Qautomatic_conversion)); 780 Fget_coding_system (Qautomatic_conversion));
779 781
780 while ((ch = Lstream_get_emchar (XLSTREAM (instream))) != EOF) 782 istr = XLSTREAM (instream);
783
784 GCPRO2 (instream, fb_instream);
785 while ((ch = Lstream_get_emchar (istr)) != EOF)
781 { 786 {
782 Lisp_Object emacs_event = Fmake_event (); 787 Lisp_Object emacs_event = Fmake_event ();
783 XEVENT (emacs_event)->channel = DEVICE_CONSOLE (d); 788 struct Lisp_Event *ev = XEVENT (emacs_event);
784 XEVENT (emacs_event)->event_type = key_press_event; 789 ev->channel = DEVICE_CONSOLE (d);
785 XEVENT (emacs_event)->timestamp = event->time; 790 ev->event_type = key_press_event;
786 XEVENT (emacs_event)->event.key.modifiers = 0; 791 ev->timestamp = event->time;
787 XEVENT (emacs_event)->event.key.keysym = make_char (ch); 792 ev->event.key.modifiers = 0;
793 ev->event.key.keysym = make_char (ch);
788 enqueue_Xt_dispatch_event (emacs_event); 794 enqueue_Xt_dispatch_event (emacs_event);
789 } 795 }
790 Lstream_close (XLSTREAM (instream)); 796 Lstream_close (istr);
797 UNGCPRO;
798 Lstream_delete (istr);
799 Lstream_delete (XLSTREAM (fb_instream));
791 return Qnil; 800 return Qnil;
792 } 801 }
793 case XLookupNone: return Qnil; 802 case XLookupNone: return Qnil;
794 case XBufferOverflow: 803 case XBufferOverflow:
795 bufptr = alloca (len+1); 804 bufptr = (char *) alloca (len+1);
796 bufsiz = len+1; 805 bufsiz = len+1;
797 goto Lookup_String; 806 goto Lookup_String;
798 } 807 }
808 return Qnil; /* not reached */
799 #endif /* HAVE_XIM */ 809 #endif /* HAVE_XIM */
800 } 810 }
801 811
802 static void 812 static void
803 set_last_server_timestamp (struct device *d, XEvent *x_event) 813 set_last_server_timestamp (struct device *d, XEvent *x_event)
1231 to determine whether the frame is currently iconified, 1241 to determine whether the frame is currently iconified,
1232 rather than consulting some internal (and likely 1242 rather than consulting some internal (and likely
1233 inaccurate) state flag. Therefore, ignoring the MapNotify 1243 inaccurate) state flag. Therefore, ignoring the MapNotify
1234 is correct. */ 1244 is correct. */
1235 if (!FRAME_VISIBLE_P (f) && NILP (Fframe_iconified_p (frame))) 1245 if (!FRAME_VISIBLE_P (f) && NILP (Fframe_iconified_p (frame)))
1236 #endif 1246 #endif /* 0 */
1237 change_frame_visibility (f, 1); 1247 change_frame_visibility (f, 1);
1238 } 1248 }
1239 else 1249 else
1240 { 1250 {
1241 FRAME_X_TOTALLY_VISIBLE_P (f) = 0; 1251 FRAME_X_TOTALLY_VISIBLE_P (f) = 0;
1404 1414
1405 case ConfigureNotify: 1415 case ConfigureNotify:
1406 #ifdef HAVE_XIM 1416 #ifdef HAVE_XIM
1407 XIM_SetGeometry (f); 1417 XIM_SetGeometry (f);
1408 #endif 1418 #endif
1409 #if 0
1410 /* ### If the following code fails to work, simply always call
1411 x_smash_bastardly_shell_position always. In this case we no
1412 longer rely on the data in the events, merely on their
1413 occurrence. */
1414 /* ### Well, actually we shouldn't have to ever call
1415 x_smash_bastardly_shell_position. We should just call
1416 XtTranslateCoordinates and only access the core.{x,y} fields
1417 using XtGetValue -- mrb */
1418 {
1419 XConfigureEvent *ev = &event->xconfigure;
1420 if (ev->window == XtWindow (FRAME_X_SHELL_WIDGET (f)) &&
1421 ! (ev->x == 0 && ev->y == 0 && !ev->send_event))
1422 {
1423 FRAME_X_SHELL_WIDGET (f)->core.x = ev->x;
1424 FRAME_X_SHELL_WIDGET (f)->core.y = ev->y;
1425 }
1426 }
1427 #endif
1428 break; 1419 break;
1429 1420
1430 default: 1421 default:
1431 break; 1422 break;
1432 } 1423 }
1556 static void 1547 static void
1557 init_what_input_once (void) 1548 init_what_input_once (void)
1558 { 1549 {
1559 int i; 1550 int i;
1560 1551
1561 filedesc_with_input = (Lisp_Object *) 1552 filedesc_with_input = xnew_array (Lisp_Object, MAXDESC);
1562 xmalloc (MAXDESC * sizeof (Lisp_Object)); 1553 filedesc_to_what_closure =
1563 filedesc_to_what_closure = (struct what_is_ready_closure **) 1554 xnew_array (struct what_is_ready_closure *, MAXDESC);
1564 xmalloc (MAXDESC * sizeof (struct what_is_ready_closure *));
1565 1555
1566 for (i = 0; i < MAXDESC; i++) 1556 for (i = 0; i < MAXDESC; i++)
1567 { 1557 {
1568 filedesc_to_what_closure[i] = 0; 1558 filedesc_to_what_closure[i] = 0;
1569 filedesc_with_input[i] = Qnil; 1559 filedesc_with_input[i] = Qnil;
1632 /* If somebody is trying to select something that's already selected 1622 /* If somebody is trying to select something that's already selected
1633 for, then something went wrong. The generic routines ought to 1623 for, then something went wrong. The generic routines ought to
1634 detect this and error before here. */ 1624 detect this and error before here. */
1635 assert (!filedesc_to_what_closure[fd]); 1625 assert (!filedesc_to_what_closure[fd]);
1636 1626
1637 closure = (struct what_is_ready_closure *) xmalloc (sizeof (*closure)); 1627 closure = xnew (struct what_is_ready_closure);
1638 closure->fd = fd; 1628 closure->fd = fd;
1639 closure->what = what; 1629 closure->what = what;
1640 closure->id = 1630 closure->id =
1641 XtAppAddInput (Xt_app_con, fd, 1631 XtAppAddInput (Xt_app_con, fd,
1642 (XtPointer) (XtInputReadMask /* | XtInputExceptMask */), 1632 (XtPointer) (XtInputReadMask /* | XtInputExceptMask */),
2274 int queued; 2264 int queued;
2275 Bool critical_quit = False; 2265 Bool critical_quit = False;
2276 XEventsQueued (display, QueuedAfterReading); 2266 XEventsQueued (display, QueuedAfterReading);
2277 queued = XCheckIfEvent (display, &event, 2267 queued = XCheckIfEvent (display, &event,
2278 quit_char_predicate, 2268 quit_char_predicate,
2279 (XtPointer)&critical_quit); 2269 (char *) &critical_quit);
2280 if (queued) 2270 if (queued)
2281 { 2271 {
2282 Vquit_flag = (critical_quit ? Qcritical : Qt); 2272 Vquit_flag = (critical_quit ? Qcritical : Qt);
2283 /* don't put the event back onto the queue. Those functions that 2273 /* don't put the event back onto the queue. Those functions that
2284 wanted to read a ^G directly have arranged to do this. */ 2274 wanted to read a ^G directly have arranged to do this. */
2634 dispatch_event_queue_tail = Qnil; 2624 dispatch_event_queue_tail = Qnil;
2635 2625
2636 /* this function only makes safe calls */ 2626 /* this function only makes safe calls */
2637 init_what_input_once (); 2627 init_what_input_once ();
2638 2628
2639 Xt_event_stream = 2629 Xt_event_stream = xnew (struct event_stream);
2640 (struct event_stream *) xmalloc (sizeof (struct event_stream));
2641 Xt_event_stream->event_pending_p = emacs_Xt_event_pending_p; 2630 Xt_event_stream->event_pending_p = emacs_Xt_event_pending_p;
2642 Xt_event_stream->next_event_cb = emacs_Xt_next_event; 2631 Xt_event_stream->next_event_cb = emacs_Xt_next_event;
2643 Xt_event_stream->handle_magic_event_cb= emacs_Xt_handle_magic_event; 2632 Xt_event_stream->handle_magic_event_cb= emacs_Xt_handle_magic_event;
2644 Xt_event_stream->add_timeout_cb = emacs_Xt_add_timeout; 2633 Xt_event_stream->add_timeout_cb = emacs_Xt_add_timeout;
2645 Xt_event_stream->remove_timeout_cb = emacs_Xt_remove_timeout; 2634 Xt_event_stream->remove_timeout_cb = emacs_Xt_remove_timeout;