예제 #1
0
static void
handle_host_xevent (MetaBackend *backend,
                    XEvent      *event)
{
  MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
  MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
  gboolean bypass_clutter = FALSE;

  XGetEventData (priv->xdisplay, &event->xcookie);

  {
    MetaDisplay *display = meta_get_display ();

    if (display)
      {
        MetaCompositor *compositor = display->compositor;
        if (meta_plugin_manager_xevent_filter (compositor->plugin_mgr, event))
          bypass_clutter = TRUE;
      }
  }

  if (event->type == (priv->xsync_event_base + XSyncAlarmNotify))
    handle_alarm_notify (backend, event);

  if (event->type == priv->xkb_event_base)
    {
      XkbAnyEvent *xkb_ev = (XkbAnyEvent *) event;

      if (xkb_ev->device == META_VIRTUAL_CORE_KEYBOARD_ID)
        {
          switch (xkb_ev->xkb_type)
            {
            case XkbNewKeyboardNotify:
            case XkbMapNotify:
              keymap_changed (backend);
            default:
              break;
            }
        }
    }

  {
    MetaMonitorManager *manager = meta_backend_get_monitor_manager (backend);
    if (META_IS_MONITOR_MANAGER_XRANDR (manager) &&
        meta_monitor_manager_xrandr_handle_xevent (META_MONITOR_MANAGER_XRANDR (manager), event))
      bypass_clutter = TRUE;
  }

  if (!bypass_clutter)
    {
      handle_input_event (x11, event);
      clutter_x11_handle_event (event);
    }

  XFreeEventData (priv->xdisplay, &event->xcookie);
}
예제 #2
0
static void
handle_host_xevent (MetaBackend *backend,
                    XEvent      *event)
{
  MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
  MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
  gboolean bypass_clutter = FALSE;

  XGetEventData (priv->xdisplay, &event->xcookie);

  {
    MetaDisplay *display = meta_get_display ();

    if (display)
      {
        MetaCompositor *compositor = display->compositor;
        if (meta_plugin_manager_xevent_filter (compositor->plugin_mgr, event))
          bypass_clutter = TRUE;
      }
  }

  if (priv->mode == META_BACKEND_X11_MODE_NESTED && event->type == FocusIn)
    {
#ifdef HAVE_WAYLAND
      Window xwin = meta_backend_x11_get_xwindow(x11);
      XEvent xev;

      if (event->xfocus.window == xwin)
        {
          /* Since we've selected for KeymapStateMask, every FocusIn is followed immediately
           * by a KeymapNotify event */
          XMaskEvent(priv->xdisplay, KeymapStateMask, &xev);
          MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default ();
          meta_wayland_compositor_update_key_state (compositor, xev.xkeymap.key_vector, 32, 8);
        }
#else
      g_assert_not_reached ();
#endif
    }

  if (event->type == (priv->xsync_event_base + XSyncAlarmNotify))
    handle_alarm_notify (backend, event);

  if (event->type == priv->xkb_event_base)
    {
      XkbEvent *xkb_ev = (XkbEvent *) event;

      if (xkb_ev->any.device == META_VIRTUAL_CORE_KEYBOARD_ID)
        {
          switch (xkb_ev->any.xkb_type)
            {
            case XkbNewKeyboardNotify:
            case XkbMapNotify:
              keymap_changed (backend);
              break;
            case XkbStateNotify:
              if (xkb_ev->state.changed & XkbGroupLockMask)
                {
                  if (priv->locked_group != xkb_ev->state.locked_group)
                    XkbLockGroup (priv->xdisplay, XkbUseCoreKbd, priv->locked_group);
                }
              break;
            default:
              break;
            }
        }
    }

  {
    MetaMonitorManager *manager = meta_backend_get_monitor_manager (backend);
    if (META_IS_MONITOR_MANAGER_XRANDR (manager) &&
        meta_monitor_manager_xrandr_handle_xevent (META_MONITOR_MANAGER_XRANDR (manager), event))
      bypass_clutter = TRUE;
  }

  if (!bypass_clutter)
    {
      handle_input_event (x11, event);
      clutter_x11_handle_event (event);
    }

  XFreeEventData (priv->xdisplay, &event->xcookie);
}
예제 #3
0
int amiga_handle_input_event (int nr, int state, int max,
        int autofire, bool canstopplayback, bool playbackevent) {
    return handle_input_event(nr, state, max, autofire, canstopplayback,
            playbackevent);
}
예제 #4
0
static int usf_get_tx_update(struct usf_type *usf, unsigned long arg)
{
    struct us_tx_update_info_type upd_tx_info;
    unsigned long prev_jiffies = 0;
    uint32_t timeout = 0;
    struct usf_xx_type *usf_xx =  &usf->usf_tx;
    int rc = copy_from_user(&upd_tx_info, (void *) arg,
                            sizeof(upd_tx_info));

    if (rc) {
        pr_err("%s: copy upd_tx_info from user; rc=%d\n",
               __func__, rc);
        return -EFAULT;
    }

    if (!usf_xx->user_upd_info_na) {
        usf_set_event_filters(usf, upd_tx_info.event_filters);
        handle_input_event(usf,
                           upd_tx_info.event_counter,
                           upd_tx_info.event);

        /* Release available regions */
        rc = q6usm_read(usf_xx->usc,
                        upd_tx_info.free_region);
        if (rc)
            return rc;
    } else
        usf_xx->user_upd_info_na = 0;

    /* Get data ready regions */
    if (upd_tx_info.timeout == USF_INFINITIVE_TIMEOUT) {
        rc = wait_event_interruptible(usf_xx->wait,
                                      (usf_xx->prev_region !=
                                       usf_xx->new_region) ||
                                      (usf_xx->usf_state !=
                                       USF_WORK_STATE));
    } else {
        if (upd_tx_info.timeout == USF_NO_WAIT_TIMEOUT)
            rc = (usf_xx->prev_region != usf_xx->new_region);
        else {
            prev_jiffies = jiffies;
            if (upd_tx_info.timeout == USF_DEFAULT_TIMEOUT) {
                timeout = USF_TIMEOUT_JIFFIES;
                rc = wait_event_timeout(
                         usf_xx->wait,
                         (usf_xx->prev_region !=
                          usf_xx->new_region) ||
                         (usf_xx->usf_state !=
                          USF_WORK_STATE),
                         timeout);
            } else {
                timeout = upd_tx_info.timeout * HZ;
                rc = wait_event_interruptible_timeout(
                         usf_xx->wait,
                         (usf_xx->prev_region !=
                          usf_xx->new_region) ||
                         (usf_xx->usf_state !=
                          USF_WORK_STATE),
                         timeout);
            }
        }
        if (!rc) {
            pr_debug("%s: timeout. prev_j=%lu; j=%lu\n",
                     __func__, prev_jiffies, jiffies);
            pr_debug("%s: timeout. prev=%d; new=%d\n",
                     __func__, usf_xx->prev_region,
                     usf_xx->new_region);
            pr_debug("%s: timeout. free_region=%d;\n",
                     __func__, upd_tx_info.free_region);
            if (usf_xx->prev_region ==
                    usf_xx->new_region) {
                pr_err("%s:read data: timeout\n",
                       __func__);
                return -ETIME;
            }
        }
    }

    if ((usf_xx->usf_state != USF_WORK_STATE) ||
            (rc == -ERESTARTSYS)) {
        pr_err("%s: Get ready region failure; state[%d]; rc[%d]\n",
               __func__, usf_xx->usf_state, rc);
        return -EINTR;
    }

    upd_tx_info.ready_region = usf_xx->new_region;
    usf_xx->prev_region = upd_tx_info.ready_region;

    if (upd_tx_info.ready_region == USM_WRONG_TOKEN) {
        pr_err("%s: TX path corrupted; prev=%d\n",
               __func__, usf_xx->prev_region);
        return -EIO;
    }

    rc = copy_to_user((void __user *)arg, &upd_tx_info,
                      sizeof(upd_tx_info));
    if (rc) {
        pr_err("%s: copy upd_tx_info to user; rc=%d\n",
               __func__, rc);
        rc = -EFAULT;
    }

    return rc;
} /* usf_get_tx_update */
예제 #5
0
static int usf_get_tx_update(struct usf_type *usf, unsigned long arg)
{
	struct us_tx_update_info_type upd_tx_info;
	unsigned long prev_jiffies = 0;
	struct usf_xx_type *usf_xx =  &usf->usf_tx;
	int rc = copy_from_user(&upd_tx_info, (void *) arg,
			    sizeof(upd_tx_info));

	if (rc) {
		pr_err("%s: get_update: copy_from_user() failed[%d]\n",
		       __func__, rc);
		return -EINVAL;
	}

	if (!usf_xx->user_upd_info_na) {
		handle_input_event(usf,
				   upd_tx_info.event_counter,
				   upd_tx_info.event);

		/* Release available regions */
		rc = q6usm_read(usf_xx->usc,
				upd_tx_info.free_region);
		if (rc)
			return rc;
	} else
		usf_xx->user_upd_info_na = 0;

	/* Get data ready regions */
	prev_jiffies = jiffies;
	rc = wait_event_timeout(usf_xx->wait,
				(usf_xx->prev_region !=
				 usf_xx->new_region) ||
				(usf_xx->usf_state !=
				 USF_WORK_STATE),
				USF_TIMEOUT_JIFFIES);

	if (!rc) {
		pr_debug("%s: timeout. prev_j=%lu; j=%lu\n",
			__func__, prev_jiffies, jiffies);
		pr_debug("%s: timeout. prev=%d; new=%d\n",
			__func__, usf_xx->prev_region,
			usf_xx->new_region);
		pr_debug("%s: timeout. free_region=%d;\n",
			__func__, upd_tx_info.free_region);
		if (usf_xx->prev_region ==
		    usf_xx->new_region) {
			pr_err("%s:read data: timeout\n",
			       __func__);
			return -ETIME;
		}
	}

	if (usf_xx->usf_state != USF_WORK_STATE) {
		pr_err("%s: TX device is in not work state[%d]\n",
		       __func__, usf_xx->usf_state);
		return -EINTR;
	}

	upd_tx_info.ready_region = usf_xx->new_region;
	rc = copy_to_user((void __user *)arg, &upd_tx_info,
			  sizeof(upd_tx_info));
	if (upd_tx_info.ready_region == USM_WRONG_TOKEN) {
		pr_err("%s: TX path corrupted; prev=%d\n",
		       __func__, usf_xx->prev_region);
		rc = -EIO;
	}
	usf_xx->prev_region = upd_tx_info.ready_region;

	return rc;
} /* usf_get_tx_update */