mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 17:20:36 +00:00
First draft at renegotiation on XConfigure event and navigation events.
Original commit message from CVS: First draft at renegotiation on XConfigure event and navigation events.
This commit is contained in:
parent
3f9d4cbd08
commit
9def6e3c3e
1 changed files with 64 additions and 5 deletions
|
@ -288,6 +288,10 @@ gst_ximagesink_xwindow_new (GstXImageSink *ximagesink, gint width, gint height)
|
||||||
0, 0, xwindow->width, xwindow->height,
|
0, 0, xwindow->width, xwindow->height,
|
||||||
0, 0, ximagesink->xcontext->black);
|
0, 0, ximagesink->xcontext->black);
|
||||||
|
|
||||||
|
XSelectInput (ximagesink->xcontext->disp, xwindow->win, ExposureMask |
|
||||||
|
StructureNotifyMask | PointerMotionMask | KeyPressMask |
|
||||||
|
KeyReleaseMask | ButtonPressMask | ButtonReleaseMask);
|
||||||
|
|
||||||
xwindow->gc = XCreateGC (ximagesink->xcontext->disp,
|
xwindow->gc = XCreateGC (ximagesink->xcontext->disp,
|
||||||
xwindow->win, 0, &values);
|
xwindow->win, 0, &values);
|
||||||
|
|
||||||
|
@ -456,9 +460,9 @@ gst_ximagesink_getcaps (GstPad *pad, GstCaps *caps)
|
||||||
return gst_caps_copy (ximagesink->xcontext->caps);
|
return gst_caps_copy (ximagesink->xcontext->caps);
|
||||||
|
|
||||||
return GST_CAPS_NEW ("ximagesink_rgbsink", "video/x-raw-rgb",
|
return GST_CAPS_NEW ("ximagesink_rgbsink", "video/x-raw-rgb",
|
||||||
"framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT),
|
"framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT),
|
||||||
"width", GST_PROPS_INT_RANGE (0, G_MAXINT),
|
"width", GST_PROPS_INT_RANGE (0, G_MAXINT),
|
||||||
"height", GST_PROPS_INT_RANGE (0, G_MAXINT));
|
"height", GST_PROPS_INT_RANGE (0, G_MAXINT));
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstPadLinkReturn
|
static GstPadLinkReturn
|
||||||
|
@ -548,6 +552,7 @@ gst_ximagesink_chain (GstPad *pad, GstData *_data)
|
||||||
GstBuffer *buf = GST_BUFFER (_data);
|
GstBuffer *buf = GST_BUFFER (_data);
|
||||||
GstClockTime time = GST_BUFFER_TIMESTAMP (buf);
|
GstClockTime time = GST_BUFFER_TIMESTAMP (buf);
|
||||||
GstXImageSink *ximagesink;
|
GstXImageSink *ximagesink;
|
||||||
|
XEvent e;
|
||||||
|
|
||||||
g_return_if_fail (pad != NULL);
|
g_return_if_fail (pad != NULL);
|
||||||
g_return_if_fail (GST_IS_PAD (pad));
|
g_return_if_fail (GST_IS_PAD (pad));
|
||||||
|
@ -602,6 +607,60 @@ gst_ximagesink_chain (GstPad *pad, GstData *_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
|
|
||||||
|
/* We get all events on our window to throw them upstream */
|
||||||
|
g_mutex_lock (ximagesink->x_lock);
|
||||||
|
while (XCheckWindowEvent (ximagesink->xcontext->disp,
|
||||||
|
ximagesink->xwindow->win,
|
||||||
|
ExposureMask | StructureNotifyMask |
|
||||||
|
PointerMotionMask | KeyPressMask |
|
||||||
|
KeyReleaseMask | ButtonPressMask |
|
||||||
|
ButtonReleaseMask, &e))
|
||||||
|
{
|
||||||
|
GstEvent *event = NULL;
|
||||||
|
|
||||||
|
/* We lock only for the X function call */
|
||||||
|
g_mutex_unlock (ximagesink->x_lock);
|
||||||
|
|
||||||
|
switch (e.type)
|
||||||
|
{
|
||||||
|
case ConfigureNotify:
|
||||||
|
/* Window got resized or moved. We do caps negotiation
|
||||||
|
again to get video scaler to fit that new size */
|
||||||
|
GST_DEBUG ("ximagesink window is at %d, %d with geometry : %d,%d",
|
||||||
|
e.xconfigure.x, e.xconfigure.y,
|
||||||
|
e.xconfigure.width, e.xconfigure.height);
|
||||||
|
event = gst_event_new (GST_EVENT_RENEGOTIATE);
|
||||||
|
event->src = GST_OBJECT (ximagesink);
|
||||||
|
event->event_data.caps.caps = GST_CAPS_NEW (
|
||||||
|
"ximagesink_videoscaling",
|
||||||
|
"video/x-raw-rgb",
|
||||||
|
"width", GST_PROPS_INT (e.xconfigure.width),
|
||||||
|
"height", GST_PROPS_INT (e.xconfigure.height));
|
||||||
|
break;
|
||||||
|
case MotionNotify:
|
||||||
|
/* Mouse pointer moved over our window. We send upstream
|
||||||
|
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->src = GST_OBJECT (ximagesink);
|
||||||
|
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));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
GST_DEBUG ("ximagesink unhandled X event (%d)", e.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event)
|
||||||
|
gst_pad_send_event (gst_pad_get_peer (pad), event);
|
||||||
|
|
||||||
|
g_mutex_lock (ximagesink->x_lock);
|
||||||
|
}
|
||||||
|
g_mutex_unlock (ximagesink->x_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in a new issue