Ejemplo n.º 1
0
int
read_event_from_tty_or_stream_desc (Lisp_Event *event,
				    struct console *con, int fd)
{
  unsigned char ch;
  int nread;
  Lisp_Object console;

  XSETCONSOLE (console, con);

  nread = read (fd, &ch, 1);
  if (nread <= 0)
    {
      /* deleting the console might not be safe right now ... */
      enqueue_magic_eval_event (io_error_delete_console, console);
      /* but we definitely need to unselect it to avoid infinite
	 loops reading EOF's */
      Fconsole_disable_input (console);
    }
  else
    {
      character_to_event (ch, event, con, 1, 1);
      event->channel = console;
      return 1;
    }
  return 0;
}
Ejemplo n.º 2
0
/*
 * Return value is Qt if we have dispatched the command,
 * or Qnil if id has not been mapped to a callback.
 * Window procedure may try other targets to route the
 * command if we return nil
 */
Lisp_Object
mswindows_handle_gui_wm_command (struct frame* f, HWND ctrl, LPARAM id)
{
  /* Try to map the command id through the proper hash table */
  Lisp_Object callback, callback_ex, image_instance, frame, event;

  XSETFRAME (frame, f);

  /* #### make_int should assert that --kkm */
  assert (XINT (make_int (id)) == id);

  image_instance = Fgethash (make_int (id), 
			     FRAME_MSWINDOWS_WIDGET_HASH_TABLE1 (f), Qnil);
  /* It is possible for a widget action to cause it to get out of sync
     with its instantiator. Thus it is necessary to signal this
     possibility. */
  if (IMAGE_INSTANCEP (image_instance))
    XIMAGE_INSTANCE_WIDGET_ACTION_OCCURRED (image_instance) = 1;
  callback = Fgethash (make_int (id), 
		       FRAME_MSWINDOWS_WIDGET_HASH_TABLE2 (f), Qnil);
  callback_ex = Fgethash (make_int (id), 
			  FRAME_MSWINDOWS_WIDGET_HASH_TABLE3 (f), Qnil);

  if (!NILP (callback_ex) && !UNBOUNDP (callback_ex))
    {
      event = Fmake_event (Qnil, Qnil);

      XEVENT (event)->event_type = misc_user_event;
      XEVENT (event)->channel = frame;
      XEVENT (event)->timestamp = GetTickCount ();
      XEVENT (event)->event.eval.function = Qeval;
      XEVENT (event)->event.eval.object =
	list4 (Qfuncall, callback_ex, image_instance, event);
    }
  else if (NILP (callback) || UNBOUNDP (callback))
    return Qnil;
  else
    {
      Lisp_Object fn, arg;

      event = Fmake_event (Qnil, Qnil);

      get_gui_callback (callback, &fn, &arg);
      XEVENT (event)->event_type = misc_user_event;
      XEVENT (event)->channel = frame;
      XEVENT (event)->timestamp = GetTickCount ();
      XEVENT (event)->event.eval.function = fn;
      XEVENT (event)->event.eval.object = arg;
    }

  mswindows_enqueue_dispatch_event (event);
  /* The result of this evaluation could cause other instances to change so 
     enqueue an update callback to check this. */
  enqueue_magic_eval_event (update_widget_instances, frame);
  return Qt;
}
Ejemplo n.º 3
0
void
popup_selection_callback(Widget widget, LWLIB_ID ignored_id,
			 XtPointer client_data)
{
	Lisp_Object data, image_instance, callback, callback_ex;
	Lisp_Object frame, event;
	int update_subwindows_p = 0;
	struct device *d = get_device_from_display(XtDisplay(widget));
	struct frame *f = x_any_widget_or_parent_to_frame(d, widget);

	/* set in lwlib to the time stamp associated with the most recent menu
	   operation */
	extern Time x_focus_timestamp_really_sucks_fix_me_better;

	if (!f)
		return;
	if (((EMACS_INT) client_data) == 0)
		return;
	VOID_TO_LISP(data, client_data);
	XSETFRAME(frame, f);

#if 0
	/* #### What the hell?  I can't understand why this call is here,
	   and doing it is really courting disaster in the new event
	   model, since popup_selection_callback is called from
	   within next_event_internal() and Faccept_process_output()
	   itself calls next_event_internal().  --Ben */

	/* Flush the X and process input */
	Faccept_process_output(Qnil, Qnil, Qnil);
#endif

	if (((EMACS_INT) client_data) == -1) {
		event = Fmake_event(Qnil, Qnil);

		XEVENT(event)->event_type = misc_user_event;
		XEVENT(event)->channel = frame;
		XEVENT(event)->event.eval.function = Qrun_hooks;
		XEVENT(event)->event.eval.object = Qmenu_no_selection_hook;
	} else {
		image_instance = XCAR(data);
		callback = XCAR(XCDR(data));
		callback_ex = XCDR(XCDR(data));
		update_subwindows_p = 1;
		/* It is possible for a widget action to cause it to get out of
		   sync with its instantiator. Thus it is necessary to signal
		   this possibility. */
		if (IMAGE_INSTANCEP(image_instance))
			XIMAGE_INSTANCE_WIDGET_ACTION_OCCURRED(image_instance) =
			    1;

		if (!NILP(callback_ex) && !UNBOUNDP(callback_ex)) {
			event = Fmake_event(Qnil, Qnil);

			XEVENT(event)->event_type = misc_user_event;
			XEVENT(event)->channel = frame;
			XEVENT(event)->event.eval.function = Qeval;
			XEVENT(event)->event.eval.object =
			    list4(Qfuncall, callback_ex, image_instance, event);
		} else if (NILP(callback) || UNBOUNDP(callback))
			event = Qnil;
		else {
			Lisp_Object fn, arg;

			event = Fmake_event(Qnil, Qnil);

			get_gui_callback(callback, &fn, &arg);
			XEVENT(event)->event_type = misc_user_event;
			XEVENT(event)->channel = frame;
			XEVENT(event)->event.eval.function = fn;
			XEVENT(event)->event.eval.object = arg;
		}
	}

	/* This is the timestamp used for asserting focus so we need to get an
	   up-to-date value event if no events have been dispatched to emacs
	 */
#if defined(HAVE_MENUBARS)
	DEVICE_X_MOUSE_TIMESTAMP(d) =
	    x_focus_timestamp_really_sucks_fix_me_better;
#else
	DEVICE_X_MOUSE_TIMESTAMP(d) = DEVICE_X_GLOBAL_MOUSE_TIMESTAMP(d);
#endif
	if (!NILP(event))
		enqueue_Xt_dispatch_event(event);
	/* The result of this evaluation could cause other instances to change so
	   enqueue an update callback to check this. */
	if (update_subwindows_p && !NILP(event))
		enqueue_magic_eval_event(update_widget_instances, frame);
}