xvimagesink mouse button events

szanto.cosmin szanto.cosmin at gmail.com
Mon Feb 18 23:27:51 PST 2013


I have managed to "solve" this problem. In a bus listener do the following:

GstBusSyncReply busListener(GstBus*, GstMessage *message, gpointer data) {

  if (GST_MESSAGE_TYPE(message) != GST_MESSAGE_ELEMENT) // if it is not a
message for the element
    return GST_BUS_PASS;

  if (!gst_structure_has_name(message->structure, "prepare-xwindow-id")) //
if is not prepare
    return GST_BUS_PASS;

  gst_x_overlay_set_window_handle(GST_X_OVERLAY(GST_MESSAGE_SRC(message)),
window_handle);

  // now change the GstXvImageSink
  GstXvImageSink* xvimagesink =
reinterpret_cast<GstXvImageSink*>(GST_X_OVERLAY(GST_MESSAGE_SRC(message)));
  g_mutex_lock(xvimagesink->flow_lock);
  XWindowAttributes attr;

  GstXWindow* xwindow = g_new0(GstXWindow, 1);
  xwindow->win = window_handle;
  g_mutex_lock(xvimagesink->x_lock);
  XGetWindowAttributes(xvimagesink->xcontext->disp, xwindow->win, &attr);
  xwindow->width = attr.width;
  xwindow->height = attr.height;
  xwindow->internal = FALSE;
  if (!xvimagesink->have_render_rect) {
    xvimagesink->render_rect.x = xvimagesink->render_rect.y = 0;
    xvimagesink->render_rect.w = attr.width;
    xvimagesink->render_rect.h = attr.height;
  }
  if (xvimagesink->handle_events) {
    // add extra masks here
    XSelectInput (xvimagesink->xcontext->disp, xwindow->win, ExposureMask |
        StructureNotifyMask | PointerMotionMask | KeyPressMask |
        KeyReleaseMask | ButtonPressMask | ButtonReleaseMask);
  }

  xwindow->gc = XCreateGC (xvimagesink->xcontext->disp, xwindow->win, 0,
NULL);
  g_mutex_unlock(xvimagesink->x_lock);
  if (xwindow)
    xvimagesink->xwindow = xwindow;
  g_mutex_unlock(xvimagesink->flow_lock);

  gst_message_unref(message);
  return GST_BUS_DROP;
}

Unfortunately you have to include xvimagesink.h for this, and also work
directly with GstXvImageSink instead of GstXOverlay, which is a bad idea
because we're using private data from this object.
Also I have seen that this problem appears in the "ximagesink" plugin.



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/xvimagesink-mouse-button-events-tp4658555p4658614.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list