}
void
-gst_navigation_send_event (GstNavigation *navigation, GstCaps *caps)
+gst_navigation_send_event (GstNavigation *navigation, GstStructure *structure)
{
GstNavigationInterface *iface = GST_NAVIGATION_GET_IFACE (navigation);
if (iface->send_event) {
- iface->send_event (navigation, caps);
+ iface->send_event (navigation, structure);
}
}
void
gst_navigation_send_key_event (GstNavigation *navigation, const char *key)
{
- gst_navigation_send_event (navigation, GST_CAPS_NEW ("key_event",
- "application/x-gst-navigation",
- "key", GST_PROPS_STRING (key)));
+ gst_navigation_send_event (navigation, gst_structure_new (
+ "application/x-gst-navigation",
+ "key", G_TYPE_STRING, key, NULL));
}
void
gst_navigation_send_mouse_event (GstNavigation *navigation, double x,
double y)
{
- gst_navigation_send_event (navigation, GST_CAPS_NEW ("mouse_event",
+ gst_navigation_send_event (navigation, gst_structure_new (
"application/x-gst-navigation",
- "pointer_x", GST_PROPS_FLOAT (x),
- "pointer_y", GST_PROPS_FLOAT (y)));
+ "pointer_x", G_TYPE_DOUBLE, x,
+ "pointer_y", G_TYPE_DOUBLE, y, NULL));
}
GTypeInterface g_iface;
/* virtual functions */
- void (*send_event) (GstNavigation *navigation, GstCaps *caps);
+ void (*send_event) (GstNavigation *navigation, GstStructure *structure);
GST_CLASS_PADDING
} GstNavigationInterface;
GType gst_navigation_get_type (void);
/* virtual class function wrappers */
-void gst_navigation_send_event (GstNavigation *navigation, GstCaps *caps);
+void gst_navigation_send_event (GstNavigation *navigation, GstStructure *structure);
void gst_navigation_send_key_event (GstNavigation *navigation, const char *key);
void gst_navigation_send_mouse_event (GstNavigation *navigation, double x,
}
void
-gst_navigation_send_event (GstNavigation *navigation, GstCaps *caps)
+gst_navigation_send_event (GstNavigation *navigation, GstStructure *structure)
{
GstNavigationInterface *iface = GST_NAVIGATION_GET_IFACE (navigation);
if (iface->send_event) {
- iface->send_event (navigation, caps);
+ iface->send_event (navigation, structure);
}
}
void
gst_navigation_send_key_event (GstNavigation *navigation, const char *key)
{
- gst_navigation_send_event (navigation, GST_CAPS_NEW ("key_event",
- "application/x-gst-navigation",
- "key", GST_PROPS_STRING (key)));
+ gst_navigation_send_event (navigation, gst_structure_new (
+ "application/x-gst-navigation",
+ "key", G_TYPE_STRING, key, NULL));
}
void
gst_navigation_send_mouse_event (GstNavigation *navigation, double x,
double y)
{
- gst_navigation_send_event (navigation, GST_CAPS_NEW ("mouse_event",
+ gst_navigation_send_event (navigation, gst_structure_new (
"application/x-gst-navigation",
- "pointer_x", GST_PROPS_FLOAT (x),
- "pointer_y", GST_PROPS_FLOAT (y)));
+ "pointer_x", G_TYPE_DOUBLE, x,
+ "pointer_y", G_TYPE_DOUBLE, y, NULL));
}
GTypeInterface g_iface;
/* virtual functions */
- void (*send_event) (GstNavigation *navigation, GstCaps *caps);
+ void (*send_event) (GstNavigation *navigation, GstStructure *structure);
GST_CLASS_PADDING
} GstNavigationInterface;
GType gst_navigation_get_type (void);
/* virtual class function wrappers */
-void gst_navigation_send_event (GstNavigation *navigation, GstCaps *caps);
+void gst_navigation_send_event (GstNavigation *navigation, GstStructure *structure);
void gst_navigation_send_key_event (GstNavigation *navigation, const char *key);
void gst_navigation_send_mouse_event (GstNavigation *navigation, double x,
}
static void
-gst_ximagesink_navigation_send_event (GstNavigation *navigation, GstCaps *caps)
+gst_ximagesink_navigation_send_event (GstNavigation *navigation, GstStructure *structure)
{
GstXImageSink *ximagesink = GST_XIMAGESINK (navigation);
+ XWindowAttributes attr;
GstEvent *event;
+ double x, y;
+
+ g_mutex_lock (ximagesink->x_lock);
+ XGetWindowAttributes (ximagesink->xcontext->disp,
+ ximagesink->xwindow->win, &attr);
+ g_mutex_unlock (ximagesink->x_lock);
event = gst_event_new (GST_EVENT_NAVIGATION);
- event->event_data.caps.caps = caps;
+ event->event_data.structure.structure = structure;
+ if(gst_structure_get_double(structure, "pointer_x", &x)){
+ x *= ximagesink->width;
+ x /= attr.width;
+ gst_structure_set(structure, "pointer_x", G_TYPE_DOUBLE, x, NULL);
+ }
+ if(gst_structure_get_double(structure, "pointer_y", &y)){
+ y *= ximagesink->height;
+ y /= attr.height;
+ gst_structure_set(structure, "pointer_y", G_TYPE_DOUBLE, y, NULL);
+ }
+
gst_pad_send_event (gst_pad_get_peer (ximagesink->sinkpad), event);
}
ButtonReleaseMask, &e))
{
GstEvent *event = NULL;
+ KeySym keysym;
/* We lock only for the X function call */
g_mutex_unlock (ximagesink->x_lock);
events for interactivity/navigation */
GST_DEBUG ("ximagesink pointer moved over window at %d,%d",
e.xmotion.x, e.xmotion.y);
- event = gst_event_new (GST_EVENT_NAVIGATION);
- event->event_data.caps.caps = GST_CAPS_NEW (
- "ximagesink_navigation",
- "video/x-raw-rgb",
- "pointer_x", GST_PROPS_INT (e.xmotion.x),
- "pointer_y", GST_PROPS_INT (e.xmotion.y),
- "state", GST_PROPS_INT (e.xmotion.state));
+ gst_navigation_send_mouse_event(GST_NAVIGATION(ximagesink),
+ e.xmotion.x, e.xmotion.y);
break;
case ButtonPress:
case ButtonRelease:
events for interactivity/navigation */
GST_DEBUG ("ximagesink button %d pressed over window at %d,%d",
e.xbutton.button, e.xbutton.x, e.xbutton.x);
- event = gst_event_new (GST_EVENT_NAVIGATION);
- event->event_data.caps.caps = GST_CAPS_NEW (
- "ximagesink_navigation",
- "video/x-raw-rgb",
- "pointer_x", GST_PROPS_INT (e.xbutton.x),
- "pointer_y", GST_PROPS_INT (e.xbutton.y),
- "button", GST_PROPS_INT (e.xbutton.button),
- "state", GST_PROPS_INT (e.xbutton.state));
+ gst_navigation_send_mouse_event(GST_NAVIGATION(ximagesink),
+ e.xmotion.x, e.xmotion.y);
break;
case KeyPress:
case KeyRelease:
/* Key pressed/released over our window. We send upstream
events for interactivity/navigation */
GST_DEBUG ("ximagesink key %d pressed over window at %d,%d",
- e.xbutton.button, e.xbutton.x, e.xbutton.x);
- event = gst_event_new (GST_EVENT_NAVIGATION);
- event->event_data.caps.caps = GST_CAPS_NEW (
- "ximagesink_navigation",
- "video/x-raw-rgb",
- "pointer_x", GST_PROPS_INT (e.xkey.x),
- "pointer_y", GST_PROPS_INT (e.xkey.y),
- "keycode", GST_PROPS_INT (e.xkey.keycode),
- "state", GST_PROPS_INT (e.xkey.state));
+ e.xkey.keycode, e.xkey.x, e.xkey.x);
+ keysym = XKeycodeToKeysym(ximagesink->xcontext->disp,
+ e.xkey.keycode, 0);
+ gst_navigation_send_key_event (GST_NAVIGATION (ximagesink),
+ XKeysymToString (keysym));
+ gst_navigation_send_key_event(GST_NAVIGATION(ximagesink),
+ "unknown");
break;
default:
GST_DEBUG ("ximagesink unhandled X event (%d)", e.type);
}
static void
-gst_xvimagesink_navigation_send_event (GstNavigation *navigation, GstCaps *caps)
+gst_xvimagesink_navigation_send_event (GstNavigation *navigation, GstStructure *structure)
{
GstXvImageSink *xvimagesink = GST_XVIMAGESINK (navigation);
+ XWindowAttributes attr;
GstEvent *event;
+ double x,y;
+
+ g_mutex_lock (xvimagesink->x_lock);
+ XGetWindowAttributes (xvimagesink->xcontext->disp,
+ xvimagesink->xwindow->win, &attr);
+ g_mutex_unlock (xvimagesink->x_lock);
event = gst_event_new (GST_EVENT_NAVIGATION);
- event->event_data.caps.caps = caps;
+ event->event_data.structure.structure = structure;
+ if(gst_structure_get_double(structure, "pointer_x", &x)){
+ x *= xvimagesink->width;
+ x /= attr.width;
+ gst_structure_set(structure, "pointer_x", G_TYPE_DOUBLE, x, NULL);
+ }
+ if(gst_structure_get_double(structure, "pointer_y", &y)){
+ y *= xvimagesink->height;
+ y /= attr.height;
+ gst_structure_set(structure, "pointer_y", G_TYPE_DOUBLE, y, NULL);
+ }
+
gst_pad_send_event (gst_pad_get_peer (xvimagesink->sinkpad), event);
}
ButtonReleaseMask, &e))
{
GstEvent *event = NULL;
+ KeySym keysym;
/* We lock only for the X function call */
g_mutex_unlock (xvimagesink->x_lock);
events for interactivity/navigation */
GST_DEBUG ("xvimagesink pointer moved over window at %d,%d",
e.xmotion.x, e.xmotion.y);
- event = gst_event_new (GST_EVENT_NAVIGATION);
- event->event_data.caps.caps = GST_CAPS_NEW (
- "xvimagesink_navigation",
- "video/x-raw-rgb",
- "pointer_x", GST_PROPS_FLOAT (e.xmotion.x),
- "pointer_y", GST_PROPS_FLOAT (e.xmotion.y),
- "state", GST_PROPS_INT (e.xmotion.state));
+ gst_navigation_send_mouse_event (GST_NAVIGATION (xvimagesink),
+ e.xmotion.x, e.xmotion.y);
break;
case ButtonPress:
case ButtonRelease:
/* Mouse button pressed/released over our window. We send upstream
events for interactivity/navigation */
GST_DEBUG ("xvimagesink button %d pressed over window at %d,%d",
- e.xbutton.button, e.xbutton.x, e.xbutton.x);
- event = gst_event_new (GST_EVENT_NAVIGATION);
- event->event_data.caps.caps = GST_CAPS_NEW (
- "xvimagesink_navigation",
- "video/x-raw-rgb",
- "pointer_x", GST_PROPS_FLOAT (e.xbutton.x),
- "pointer_y", GST_PROPS_FLOAT (e.xbutton.y),
- "button", GST_PROPS_INT (e.xbutton.button),
- "state", GST_PROPS_INT (e.xbutton.state));
+ e.xbutton.button, e.xbutton.x, e.xbutton.y);
+ gst_navigation_send_mouse_event (GST_NAVIGATION (xvimagesink),
+ e.xbutton.x, e.xbutton.y);
break;
case KeyPress:
case KeyRelease:
/* Key pressed/released over our window. We send upstream
events for interactivity/navigation */
GST_DEBUG ("xvimagesink key %d pressed over window at %d,%d",
- e.xbutton.button, e.xbutton.x, e.xbutton.x);
- event = gst_event_new (GST_EVENT_NAVIGATION);
- event->event_data.caps.caps = GST_CAPS_NEW (
- "xvimagesink_navigation",
- "video/x-raw-rgb",
- "pointer_x", GST_PROPS_INT (e.xkey.x),
- "pointer_y", GST_PROPS_INT (e.xkey.y),
- "keycode", GST_PROPS_INT (e.xkey.keycode),
- "state", GST_PROPS_INT (e.xkey.state));
+ e.xkey.keycode, e.xkey.x, e.xkey.y);
+ keysym = XKeycodeToKeysym(xvimagesink->xcontext->disp,
+ e.xkey.keycode, 0);
+ gst_navigation_send_key_event (GST_NAVIGATION (xvimagesink),
+ XKeysymToString (keysym));
break;
default:
GST_DEBUG ("xvimagesink unhandled X event (%d)", e.type);