[gst-devel] x input events processing in sinks with xoverlay interface [patch]

Radek Doulík rodo at novell.com
Mon Dec 18 17:49:04 CET 2006


On Mon, 2006-12-18 at 15:50 +0100, Julien Moutte wrote:
> I really don't understand why this is such a problem to you guys...
> 
> When passing an XID to x[v]imagesink those plugins are selecting ONLY
> the event mask that are not exclusive to a single client (all but mouse
> buttons basically).

I think the problem is that the events in the application which created
the window are not propagated to the parent window if at least one
client is interested in these events on that (child) window (gstreamer
sink is that client in this case).

> So that means that you can pass an XID to x[v]imagesink and listen to
> those keypress events on that same window from your application while
> letting the video sink handle them too.
> 
> Can you please try that before adding stuff to the XOverlay interface ?

That would not be helpful in OOo case, as I only have the XID available
from toolkit/graphics layer. Besides that, it seems weird that the
library processes the input, what if there are conflicts between how I
want to react to particular keyboard input in the application and in the
library? Unfortunately sinks already process it, so I think adding the
possibility to disable that "feature" seems to be valid.

Cheers
Radek

> Thanks
> 
> Julien.
> 
> On Mon, 2006-12-18 at 14:06 +0100, Radek Doulík wrote:
> > Hi Stefan,
> > 
> > On Sun, 2006-12-17 at 11:48 +0200, Stefan Kost wrote:
> > > Hi Radek,
> > > 
> > > Radek Doulík wrote:
> > > > Hi all,
> > > >
> > > > 	while working on gstreamer support for OpenOffice I run into problem
> > > > where xvimagesink and ximagesink are eating keypress/keyrelease events
> > > > in OOo embedded window (I set xwindow ID with GstXOverlay iface) and I
> > > > am unable to receive them in OOo.
> > > >
> > > > 	I am attaching a patch which introduces new method
> > > > gst_x_overlay_set_process_input in GstXOverlay interface. This method
> > > > can be used to tell X based video sinks to not process input events. The
> > > > patch also implements this new function in xvimage and ximage sinks.
> > > >   
> > > Sounds like a good idea to me, will review the patch once its in
> > > bugzilla. 
> > 
> > Good idea, I filed http://bugzilla.gnome.org/show_bug.cgi?id=387138 for
> > it.
> > 
> > > We (nokia) currently hardcoded disable the input processing,
> > > because it causes trouble in our product. 
> > 
> > Good to know I am not alone having troubles with it ;-)
> > 
> > > Two comments now already:
> > > * why don#t use a boolean iface property?
> > 
> > I am not sure if I understand correctly your question, but I thought it
> > will make more sense to add it to the X overlay interface, instead of
> > adding it directly to sinks properties, as it is needed in case where
> > processing the X input events conflicts with the application which
> > creates the embedded window (and pass it to gstreamer thru x overlay
> > iface).
> > 
> > > * shouldn't it be an instance specific setting and not class wide?
> > 
> > It is instance specific, it just adds new virtual method to the iface
> > class.
> > 
> > Cheers
> > Radek
> > 
> > > Stefan
> > > > 	Please review my patch. Would it be possible to merge it in gstreamer?
> > > >
> > > > Cheers
> > > > Radek
> > > >
> > > >   
> > > > ------------------------------------------------------------------------
> > > >
> > > > diff -rup gst-plugins-base-0.10.5-orig/gst-libs/gst/interfaces/xoverlay.c gst-plugins-base-0.10.5/gst-libs/gst/interfaces/xoverlay.c
> > > > --- gst-plugins-base-0.10.5-orig/gst-libs/gst/interfaces/xoverlay.c	2006-01-22 15:50:53.000000000 +0100
> > > > +++ gst-plugins-base-0.10.5/gst-libs/gst/interfaces/xoverlay.c	2006-12-14 17:32:06.000000000 +0100
> > > > @@ -232,3 +232,25 @@ gst_x_overlay_expose (GstXOverlay * over
> > > >      klass->expose (overlay);
> > > >    }
> > > >  }
> > > > +
> > > > +/**
> > > > + * gst_x_overlay_set_process_input:
> > > > + * @overlay: a #GstXOverlay to set the process input on.
> > > > + * @process_input: a flag enabling/disabling processing of input events.
> > > > + *
> > > > + * This will call the video overlay's set_process_input method. You should
> > > > + * use this method to tell to a XOverlay whether you want it to process
> > > > + * input events (such as PointerMotion, KeyPress, KeyRelease, ButtonPress,
> > > > + * ButtonRelease events). You should call this function before setting window
> > > > + * #XID. It will only work with window created in application and set with
> > > > + * gst_x_overlay_set_xwindow_id, not with the window created by sinks.
> > > > + */
> > > > +void
> > > > +gst_x_overlay_set_process_input (GstXOverlay * overlay, gboolean process_input)
> > > > +{
> > > > +  GstXOverlayClass *klass = GST_X_OVERLAY_GET_CLASS (overlay);
> > > > +
> > > > +  if (klass->set_process_input) {
> > > > +    klass->set_process_input (overlay, process_input);
> > > > +  }
> > > > +}
> > > > diff -rup gst-plugins-base-0.10.5-orig/gst-libs/gst/interfaces/xoverlay.h gst-plugins-base-0.10.5/gst-libs/gst/interfaces/xoverlay.h
> > > > --- gst-plugins-base-0.10.5-orig/gst-libs/gst/interfaces/xoverlay.h	2005-12-06 20:42:00.000000000 +0100
> > > > +++ gst-plugins-base-0.10.5/gst-libs/gst/interfaces/xoverlay.h	2006-12-14 17:21:27.000000000 +0100
> > > > @@ -47,13 +47,16 @@ typedef struct _GstXOverlayClass {
> > > >    GTypeInterface klass;
> > > >  
> > > >    /* virtual functions */
> > > > -  void (* set_xwindow_id) (GstXOverlay *overlay,
> > > > -                           gulong       xwindow_id);
> > > > +  void (* set_xwindow_id)    (GstXOverlay *overlay,
> > > > +                              gulong       xwindow_id);
> > > >  
> > > > -  void (* expose)         (GstXOverlay *overlay);
> > > > +  void (* expose)            (GstXOverlay *overlay);
> > > > +
> > > > +  void (* set_process_input) (GstXOverlay *overlay,
> > > > +                              gboolean process_input);
> > > >  
> > > >    /*< private >*/
> > > > -  gpointer                 _gst_reserved[GST_PADDING];
> > > > +  gpointer                   _gst_reserved[GST_PADDING];
> > > >  } GstXOverlayClass;
> > > >  
> > > >  GType   gst_x_overlay_get_type          (void);
> > > > @@ -63,6 +66,8 @@ void gst_x_overlay_set_xwindow_id     (G
> > > >  
> > > >  void gst_x_overlay_expose             (GstXOverlay *overlay);
> > > >  
> > > > +void gst_x_overlay_set_process_input  (GstXOverlay *overlay, gboolean process_input);
> > > > +
> > > >  /* public methods to dispatch bus messages */
> > > >  void gst_x_overlay_got_xwindow_id     (GstXOverlay *overlay, gulong xwindow_id);
> > > >  
> > > > diff -rup gst-plugins-base-0.10.5-orig/sys/ximage/ximagesink.c gst-plugins-base-0.10.5/sys/ximage/ximagesink.c
> > > > --- gst-plugins-base-0.10.5-orig/sys/ximage/ximagesink.c	2006-03-07 20:18:22.000000000 +0100
> > > > +++ gst-plugins-base-0.10.5/sys/ximage/ximagesink.c	2006-12-14 17:46:48.000000000 +0100
> > > > @@ -1719,8 +1719,8 @@ gst_ximagesink_set_xwindow_id (GstXOverl
> > > >      xwindow->height = attr.height;
> > > >      xwindow->internal = FALSE;
> > > >      XSelectInput (ximagesink->xcontext->disp, xwindow->win, ExposureMask |
> > > > -        StructureNotifyMask | PointerMotionMask | KeyPressMask |
> > > > -        KeyReleaseMask);
> > > > +        StructureNotifyMask | (ximagesink->process_input ?
> > > > +            (PointerMotionMask | KeyPressMask | KeyReleaseMask) : 0));
> > > >  
> > > >      xwindow->gc = XCreateGC (ximagesink->xcontext->disp, xwindow->win, 0, NULL);
> > > >      g_mutex_unlock (ximagesink->x_lock);
> > > > @@ -1744,10 +1744,19 @@ gst_ximagesink_expose (GstXOverlay * ove
> > > >  }
> > > >  
> > > >  static void
> > > > +gst_ximagesink_set_process_input (GstXOverlay * overlay, gboolean process_input)
> > > > +{
> > > > +  GstXImageSink *ximagesink = GST_XIMAGESINK (overlay);
> > > > +
> > > > +  ximagesink->process_input = process_input;
> > > > +}
> > > > +
> > > > +static void
> > > >  gst_ximagesink_xoverlay_init (GstXOverlayClass * iface)
> > > >  {
> > > >    iface->set_xwindow_id = gst_ximagesink_set_xwindow_id;
> > > >    iface->expose = gst_ximagesink_expose;
> > > > +  iface->set_process_input = gst_ximagesink_set_process_input;
> > > >  }
> > > >  
> > > >  /* =========================================== */
> > > > @@ -1895,6 +1904,8 @@ gst_ximagesink_init (GstXImageSink * xim
> > > >  
> > > >    ximagesink->synchronous = FALSE;
> > > >    ximagesink->keep_aspect = FALSE;
> > > > +
> > > > +  ximagesink->process_input = TRUE;
> > > >  }
> > > >  
> > > >  static void
> > > > diff -rup gst-plugins-base-0.10.5-orig/sys/ximage/ximagesink.h gst-plugins-base-0.10.5/sys/ximage/ximagesink.h
> > > > --- gst-plugins-base-0.10.5-orig/sys/ximage/ximagesink.h	2005-11-28 18:32:55.000000000 +0100
> > > > +++ gst-plugins-base-0.10.5/sys/ximage/ximagesink.h	2006-12-14 17:47:33.000000000 +0100
> > > > @@ -211,6 +211,8 @@ struct _GstXImageSink {
> > > >  
> > > >    gboolean synchronous;
> > > >    gboolean keep_aspect;
> > > > +
> > > > +  gboolean process_input;
> > > >  };
> > > >  
> > > >  struct _GstXImageSinkClass {
> > > > diff -rup gst-plugins-base-0.10.5-orig/sys/xvimage/xvimagesink.c gst-plugins-base-0.10.5/sys/xvimage/xvimagesink.c
> > > > --- gst-plugins-base-0.10.5-orig/sys/xvimage/xvimagesink.c	2006-03-07 20:18:22.000000000 +0100
> > > > +++ gst-plugins-base-0.10.5/sys/xvimage/xvimagesink.c	2006-12-15 10:52:13.000000000 +0100
> > > > @@ -2143,9 +2143,11 @@ gst_xvimagesink_set_xwindow_id (GstXOver
> > > >      xwindow->width = attr.width;
> > > >      xwindow->height = attr.height;
> > > >      xwindow->internal = FALSE;
> > > > +
> > > >      XSelectInput (xvimagesink->xcontext->disp, xwindow->win, ExposureMask |
> > > > -        StructureNotifyMask | PointerMotionMask | KeyPressMask |
> > > > -        KeyReleaseMask);
> > > > +        StructureNotifyMask | (xvimagesink->process_input ?
> > > > +            (PointerMotionMask | KeyPressMask |
> > > > +             KeyReleaseMask) : 0));
> > > >  
> > > >      xwindow->gc = XCreateGC (xvimagesink->xcontext->disp,
> > > >          xwindow->win, 0, NULL);
> > > > @@ -2170,10 +2172,19 @@ gst_xvimagesink_expose (GstXOverlay * ov
> > > >  }
> > > >  
> > > >  static void
> > > > +gst_xvimagesink_set_process_input (GstXOverlay * overlay, gboolean process_input)
> > > > +{
> > > > +  GstXvImageSink *xvimagesink = GST_XVIMAGESINK (overlay);
> > > > +
> > > > +  xvimagesink->process_input = process_input;
> > > > +}
> > > > +
> > > > +static void
> > > >  gst_xvimagesink_xoverlay_init (GstXOverlayClass * iface)
> > > >  {
> > > >    iface->set_xwindow_id = gst_xvimagesink_set_xwindow_id;
> > > >    iface->expose = gst_xvimagesink_expose;
> > > > +  iface->set_process_input = gst_xvimagesink_set_process_input;
> > > >  }
> > > >  
> > > >  static const GList *
> > > > @@ -2432,6 +2443,8 @@ gst_xvimagesink_init (GstXvImageSink * x
> > > >    xvimagesink->running = FALSE;
> > > >    xvimagesink->keep_aspect = FALSE;
> > > >    xvimagesink->par = NULL;
> > > > +
> > > > +  xvimagesink->process_input = TRUE;
> > > >  }
> > > >  
> > > >  static void
> > > > diff -rup gst-plugins-base-0.10.5-orig/sys/xvimage/xvimagesink.h gst-plugins-base-0.10.5/sys/xvimage/xvimagesink.h
> > > > --- gst-plugins-base-0.10.5-orig/sys/xvimage/xvimagesink.h	2005-11-28 18:32:55.000000000 +0100
> > > > +++ gst-plugins-base-0.10.5/sys/xvimage/xvimagesink.h	2006-12-14 17:47:53.000000000 +0100
> > > > @@ -252,6 +252,8 @@ struct _GstXvImageSink {
> > > >  
> > > >    guint video_width, video_height;     /* size of incoming video;
> > > >                                          * used as the size for XvImage */
> > > > +
> > > > +  gboolean process_input;
> > > >  };
> > > >  
> > > >  struct _GstXvImageSinkClass {
> > > >   
> > > > ------------------------------------------------------------------------
> > > >
> > > > -------------------------------------------------------------------------
> > > > Take Surveys. Earn Cash. Influence the Future of IT
> > > > Join SourceForge.net's Techsay panel and you'll get the chance to share your
> > > > opinions on IT & business topics through brief surveys - and earn cash
> > > > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> > > > ------------------------------------------------------------------------
> > > >
> > > > _______________________________________________
> > > > gstreamer-devel mailing list
> > > > gstreamer-devel at lists.sourceforge.net
> > > > https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
> > > >   
> > > 
-- 
Radek Doulík <rodo at novell.com>
Novell, Inc.





More information about the gstreamer-devel mailing list