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:
David Schleef 2003-11-11 00:43:29 +00:00
parent 5a0d7c7c1e
commit 6f07363ea2
6 changed files with 83 additions and 73 deletions

View file

@ -61,31 +61,31 @@ gst_navigation_class_init (GstNavigationInterface *iface)
} }
void void
gst_navigation_send_event (GstNavigation *navigation, GstCaps *caps) gst_navigation_send_event (GstNavigation *navigation, GstStructure *structure)
{ {
GstNavigationInterface *iface = GST_NAVIGATION_GET_IFACE (navigation); GstNavigationInterface *iface = GST_NAVIGATION_GET_IFACE (navigation);
if (iface->send_event) { if (iface->send_event) {
iface->send_event (navigation, caps); iface->send_event (navigation, structure);
} }
} }
void void
gst_navigation_send_key_event (GstNavigation *navigation, const char *key) gst_navigation_send_key_event (GstNavigation *navigation, const char *key)
{ {
gst_navigation_send_event (navigation, GST_CAPS_NEW ("key_event", gst_navigation_send_event (navigation, gst_structure_new (
"application/x-gst-navigation", "application/x-gst-navigation",
"key", GST_PROPS_STRING (key))); "key", G_TYPE_STRING, key, NULL));
} }
void void
gst_navigation_send_mouse_event (GstNavigation *navigation, double x, gst_navigation_send_mouse_event (GstNavigation *navigation, double x,
double y) double y)
{ {
gst_navigation_send_event (navigation, GST_CAPS_NEW ("mouse_event", gst_navigation_send_event (navigation, gst_structure_new (
"application/x-gst-navigation", "application/x-gst-navigation",
"pointer_x", GST_PROPS_FLOAT (x), "pointer_x", G_TYPE_DOUBLE, x,
"pointer_y", GST_PROPS_FLOAT (y))); "pointer_y", G_TYPE_DOUBLE, y, NULL));
} }

View file

@ -42,7 +42,7 @@ typedef struct _GstNavigationInterface {
GTypeInterface g_iface; GTypeInterface g_iface;
/* virtual functions */ /* virtual functions */
void (*send_event) (GstNavigation *navigation, GstCaps *caps); void (*send_event) (GstNavigation *navigation, GstStructure *structure);
GST_CLASS_PADDING GST_CLASS_PADDING
} GstNavigationInterface; } GstNavigationInterface;
@ -50,7 +50,7 @@ typedef struct _GstNavigationInterface {
GType gst_navigation_get_type (void); GType gst_navigation_get_type (void);
/* virtual class function wrappers */ /* 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_key_event (GstNavigation *navigation, const char *key);
void gst_navigation_send_mouse_event (GstNavigation *navigation, double x, void gst_navigation_send_mouse_event (GstNavigation *navigation, double x,

View file

@ -61,31 +61,31 @@ gst_navigation_class_init (GstNavigationInterface *iface)
} }
void void
gst_navigation_send_event (GstNavigation *navigation, GstCaps *caps) gst_navigation_send_event (GstNavigation *navigation, GstStructure *structure)
{ {
GstNavigationInterface *iface = GST_NAVIGATION_GET_IFACE (navigation); GstNavigationInterface *iface = GST_NAVIGATION_GET_IFACE (navigation);
if (iface->send_event) { if (iface->send_event) {
iface->send_event (navigation, caps); iface->send_event (navigation, structure);
} }
} }
void void
gst_navigation_send_key_event (GstNavigation *navigation, const char *key) gst_navigation_send_key_event (GstNavigation *navigation, const char *key)
{ {
gst_navigation_send_event (navigation, GST_CAPS_NEW ("key_event", gst_navigation_send_event (navigation, gst_structure_new (
"application/x-gst-navigation", "application/x-gst-navigation",
"key", GST_PROPS_STRING (key))); "key", G_TYPE_STRING, key, NULL));
} }
void void
gst_navigation_send_mouse_event (GstNavigation *navigation, double x, gst_navigation_send_mouse_event (GstNavigation *navigation, double x,
double y) double y)
{ {
gst_navigation_send_event (navigation, GST_CAPS_NEW ("mouse_event", gst_navigation_send_event (navigation, gst_structure_new (
"application/x-gst-navigation", "application/x-gst-navigation",
"pointer_x", GST_PROPS_FLOAT (x), "pointer_x", G_TYPE_DOUBLE, x,
"pointer_y", GST_PROPS_FLOAT (y))); "pointer_y", G_TYPE_DOUBLE, y, NULL));
} }

View file

@ -42,7 +42,7 @@ typedef struct _GstNavigationInterface {
GTypeInterface g_iface; GTypeInterface g_iface;
/* virtual functions */ /* virtual functions */
void (*send_event) (GstNavigation *navigation, GstCaps *caps); void (*send_event) (GstNavigation *navigation, GstStructure *structure);
GST_CLASS_PADDING GST_CLASS_PADDING
} GstNavigationInterface; } GstNavigationInterface;
@ -50,7 +50,7 @@ typedef struct _GstNavigationInterface {
GType gst_navigation_get_type (void); GType gst_navigation_get_type (void);
/* virtual class function wrappers */ /* 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_key_event (GstNavigation *navigation, const char *key);
void gst_navigation_send_mouse_event (GstNavigation *navigation, double x, void gst_navigation_send_mouse_event (GstNavigation *navigation, double x,

View file

@ -74,13 +74,31 @@ gst_ximagesink_interface_init (GstInterfaceClass *klass)
} }
static void 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); GstXImageSink *ximagesink = GST_XIMAGESINK (navigation);
XWindowAttributes attr;
GstEvent *event; 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 = 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); 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)) ButtonReleaseMask, &e))
{ {
GstEvent *event = NULL; GstEvent *event = NULL;
KeySym keysym;
/* We lock only for the X function call */ /* We lock only for the X function call */
g_mutex_unlock (ximagesink->x_lock); g_mutex_unlock (ximagesink->x_lock);
@ -383,13 +402,8 @@ gst_ximagesink_handle_xevents (GstXImageSink *ximagesink, GstPad *pad)
events for interactivity/navigation */ events for interactivity/navigation */
GST_DEBUG ("ximagesink pointer moved over window at %d,%d", GST_DEBUG ("ximagesink pointer moved over window at %d,%d",
e.xmotion.x, e.xmotion.y); e.xmotion.x, e.xmotion.y);
event = gst_event_new (GST_EVENT_NAVIGATION); gst_navigation_send_mouse_event(GST_NAVIGATION(ximagesink),
event->event_data.caps.caps = GST_CAPS_NEW ( e.xmotion.x, e.xmotion.y);
"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));
break; break;
case ButtonPress: case ButtonPress:
case ButtonRelease: case ButtonRelease:
@ -397,29 +411,21 @@ gst_ximagesink_handle_xevents (GstXImageSink *ximagesink, GstPad *pad)
events for interactivity/navigation */ events for interactivity/navigation */
GST_DEBUG ("ximagesink button %d pressed over window at %d,%d", GST_DEBUG ("ximagesink button %d pressed over window at %d,%d",
e.xbutton.button, e.xbutton.x, e.xbutton.x); e.xbutton.button, e.xbutton.x, e.xbutton.x);
event = gst_event_new (GST_EVENT_NAVIGATION); gst_navigation_send_mouse_event(GST_NAVIGATION(ximagesink),
event->event_data.caps.caps = GST_CAPS_NEW ( e.xmotion.x, e.xmotion.y);
"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));
break; break;
case KeyPress: case KeyPress:
case KeyRelease: case KeyRelease:
/* Key pressed/released over our window. We send upstream /* Key pressed/released over our window. We send upstream
events for interactivity/navigation */ events for interactivity/navigation */
GST_DEBUG ("ximagesink key %d pressed over window at %d,%d", GST_DEBUG ("ximagesink key %d pressed over window at %d,%d",
e.xbutton.button, e.xbutton.x, e.xbutton.x); e.xkey.keycode, e.xkey.x, e.xkey.x);
event = gst_event_new (GST_EVENT_NAVIGATION); keysym = XKeycodeToKeysym(ximagesink->xcontext->disp,
event->event_data.caps.caps = GST_CAPS_NEW ( e.xkey.keycode, 0);
"ximagesink_navigation", gst_navigation_send_key_event (GST_NAVIGATION (ximagesink),
"video/x-raw-rgb", XKeysymToString (keysym));
"pointer_x", GST_PROPS_INT (e.xkey.x), gst_navigation_send_key_event(GST_NAVIGATION(ximagesink),
"pointer_y", GST_PROPS_INT (e.xkey.y), "unknown");
"keycode", GST_PROPS_INT (e.xkey.keycode),
"state", GST_PROPS_INT (e.xkey.state));
break; break;
default: default:
GST_DEBUG ("ximagesink unhandled X event (%d)", e.type); GST_DEBUG ("ximagesink unhandled X event (%d)", e.type);

View file

@ -78,13 +78,31 @@ gst_xvimagesink_interface_init (GstInterfaceClass *klass)
} }
static void 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); GstXvImageSink *xvimagesink = GST_XVIMAGESINK (navigation);
XWindowAttributes attr;
GstEvent *event; 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 = 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); 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)) ButtonReleaseMask, &e))
{ {
GstEvent *event = NULL; GstEvent *event = NULL;
KeySym keysym;
/* We lock only for the X function call */ /* We lock only for the X function call */
g_mutex_unlock (xvimagesink->x_lock); g_mutex_unlock (xvimagesink->x_lock);
@ -370,43 +389,28 @@ gst_xvimagesink_handle_xevents (GstXvImageSink *xvimagesink, GstPad *pad)
events for interactivity/navigation */ events for interactivity/navigation */
GST_DEBUG ("xvimagesink pointer moved over window at %d,%d", GST_DEBUG ("xvimagesink pointer moved over window at %d,%d",
e.xmotion.x, e.xmotion.y); e.xmotion.x, e.xmotion.y);
event = gst_event_new (GST_EVENT_NAVIGATION); gst_navigation_send_mouse_event (GST_NAVIGATION (xvimagesink),
event->event_data.caps.caps = GST_CAPS_NEW ( e.xmotion.x, e.xmotion.y);
"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));
break; break;
case ButtonPress: case ButtonPress:
case ButtonRelease: case ButtonRelease:
/* Mouse button pressed/released over our window. We send upstream /* Mouse button pressed/released over our window. We send upstream
events for interactivity/navigation */ events for interactivity/navigation */
GST_DEBUG ("xvimagesink button %d pressed over window at %d,%d", GST_DEBUG ("xvimagesink button %d pressed over window at %d,%d",
e.xbutton.button, e.xbutton.x, e.xbutton.x); e.xbutton.button, e.xbutton.x, e.xbutton.y);
event = gst_event_new (GST_EVENT_NAVIGATION); gst_navigation_send_mouse_event (GST_NAVIGATION (xvimagesink),
event->event_data.caps.caps = GST_CAPS_NEW ( e.xbutton.x, e.xbutton.y);
"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));
break; break;
case KeyPress: case KeyPress:
case KeyRelease: case KeyRelease:
/* Key pressed/released over our window. We send upstream /* Key pressed/released over our window. We send upstream
events for interactivity/navigation */ events for interactivity/navigation */
GST_DEBUG ("xvimagesink key %d pressed over window at %d,%d", GST_DEBUG ("xvimagesink key %d pressed over window at %d,%d",
e.xbutton.button, e.xbutton.x, e.xbutton.x); e.xkey.keycode, e.xkey.x, e.xkey.y);
event = gst_event_new (GST_EVENT_NAVIGATION); keysym = XKeycodeToKeysym(xvimagesink->xcontext->disp,
event->event_data.caps.caps = GST_CAPS_NEW ( e.xkey.keycode, 0);
"xvimagesink_navigation", gst_navigation_send_key_event (GST_NAVIGATION (xvimagesink),
"video/x-raw-rgb", XKeysymToString (keysym));
"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));
break; break;
default: default:
GST_DEBUG ("xvimagesink unhandled X event (%d)", e.type); GST_DEBUG ("xvimagesink unhandled X event (%d)", e.type);