mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 19:20:35 +00:00
Change GstCaps to GstStructure in navigation events. Fix x[v]imagesink to scale navigation events.
Original commit message from CVS: Change GstCaps to GstStructure in navigation events. Fix x[v]imagesink to scale navigation events.
This commit is contained in:
parent
5a0d7c7c1e
commit
6f07363ea2
6 changed files with 83 additions and 73 deletions
|
@ -61,31 +61,31 @@ gst_navigation_class_init (GstNavigationInterface *iface)
|
|||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ typedef struct _GstNavigationInterface {
|
|||
GTypeInterface g_iface;
|
||||
|
||||
/* virtual functions */
|
||||
void (*send_event) (GstNavigation *navigation, GstCaps *caps);
|
||||
void (*send_event) (GstNavigation *navigation, GstStructure *structure);
|
||||
|
||||
GST_CLASS_PADDING
|
||||
} GstNavigationInterface;
|
||||
|
@ -50,7 +50,7 @@ typedef struct _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,
|
||||
|
|
|
@ -61,31 +61,31 @@ gst_navigation_class_init (GstNavigationInterface *iface)
|
|||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ typedef struct _GstNavigationInterface {
|
|||
GTypeInterface g_iface;
|
||||
|
||||
/* virtual functions */
|
||||
void (*send_event) (GstNavigation *navigation, GstCaps *caps);
|
||||
void (*send_event) (GstNavigation *navigation, GstStructure *structure);
|
||||
|
||||
GST_CLASS_PADDING
|
||||
} GstNavigationInterface;
|
||||
|
@ -50,7 +50,7 @@ typedef struct _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,
|
||||
|
|
|
@ -74,13 +74,31 @@ gst_ximagesink_interface_init (GstInterfaceClass *klass)
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -351,6 +369,7 @@ gst_ximagesink_handle_xevents (GstXImageSink *ximagesink, GstPad *pad)
|
|||
ButtonReleaseMask, &e))
|
||||
{
|
||||
GstEvent *event = NULL;
|
||||
KeySym keysym;
|
||||
|
||||
/* We lock only for the X function call */
|
||||
g_mutex_unlock (ximagesink->x_lock);
|
||||
|
@ -383,13 +402,8 @@ gst_ximagesink_handle_xevents (GstXImageSink *ximagesink, GstPad *pad)
|
|||
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:
|
||||
|
@ -397,29 +411,21 @@ gst_ximagesink_handle_xevents (GstXImageSink *ximagesink, GstPad *pad)
|
|||
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);
|
||||
|
|
|
@ -78,13 +78,31 @@ gst_xvimagesink_interface_init (GstInterfaceClass *klass)
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -359,6 +377,7 @@ gst_xvimagesink_handle_xevents (GstXvImageSink *xvimagesink, GstPad *pad)
|
|||
ButtonReleaseMask, &e))
|
||||
{
|
||||
GstEvent *event = NULL;
|
||||
KeySym keysym;
|
||||
|
||||
/* We lock only for the X function call */
|
||||
g_mutex_unlock (xvimagesink->x_lock);
|
||||
|
@ -370,43 +389,28 @@ gst_xvimagesink_handle_xevents (GstXvImageSink *xvimagesink, GstPad *pad)
|
|||
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);
|
||||
|
|
Loading…
Reference in a new issue