summaryrefslogtreecommitdiffstats
path: root/gst/librfb
diff options
context:
space:
mode:
authorThijs Vermeir <thijsvermeir@gmail.com>2008-11-06 22:54:39 +0000
committerThijs Vermeir <thijsvermeir@gmail.com>2008-11-06 22:54:39 +0000
commit862cc7ddd221435ea5ecf2cc031949d07cfa27fa (patch)
treed9a2707898990d00833f61c23c73d07452ea00c0 /gst/librfb
parent761df7a066e1bd005db8f8b2b09ce61fafe1af20 (diff)
downloadgst-plugins-bad-862cc7ddd221435ea5ecf2cc031949d07cfa27fa.tar.gz
gst-plugins-bad-862cc7ddd221435ea5ecf2cc031949d07cfa27fa.tar.bz2
gst-plugins-bad-862cc7ddd221435ea5ecf2cc031949d07cfa27fa.zip
Fix basic navigation events
Original commit message from CVS: * configure.ac: * gst/librfb/Makefile.am: * gst/librfb/gstrfbsrc.c: Fix basic navigation events
Diffstat (limited to 'gst/librfb')
-rw-r--r--gst/librfb/Makefile.am4
-rw-r--r--gst/librfb/gstrfbsrc.c42
2 files changed, 34 insertions, 12 deletions
diff --git a/gst/librfb/Makefile.am b/gst/librfb/Makefile.am
index 373b0bc6..351beeec 100644
--- a/gst/librfb/Makefile.am
+++ b/gst/librfb/Makefile.am
@@ -4,8 +4,8 @@ noinst_LTLIBRARIES = librfb.la
plugin_LTLIBRARIES = libgstrfbsrc.la
libgstrfbsrc_la_SOURCES = gstrfbsrc.c
-libgstrfbsrc_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) -I$(srcdir)/..
-libgstrfbsrc_la_LIBADD = $(GST_BASE_LIBS) librfb.la
+libgstrfbsrc_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(X11_CFLAGS) -I$(srcdir)/..
+libgstrfbsrc_la_LIBADD = $(GST_BASE_LIBS) $(X11_LIBS) librfb.la
libgstrfbsrc_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstrfbsrc_la_LIBTOOLFLAGS = --tag=disable-static
diff --git a/gst/librfb/gstrfbsrc.c b/gst/librfb/gstrfbsrc.c
index 8c5e11eb..5edd9f0a 100644
--- a/gst/librfb/gstrfbsrc.c
+++ b/gst/librfb/gstrfbsrc.c
@@ -30,6 +30,9 @@
#include <string.h>
#include <stdlib.h>
+#ifdef HAVE_X11
+#include <X11/Xlib.h>
+#endif
enum
{
@@ -462,6 +465,9 @@ gst_rfb_src_event (GstBaseSrc * bsrc, GstEvent * event)
gint button;
GstStructure *structure;
const gchar *event_type;
+ gboolean key_event, key_press;
+
+ key_event = FALSE;
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_NAVIGATION:
@@ -472,33 +478,49 @@ gst_rfb_src_event (GstBaseSrc * bsrc, GstEvent * event)
structure = event->structure;
event_type = gst_structure_get_string (structure, "event");
+
+ if (strcmp (event_type, "key-press") == 0) {
+ key_event = key_press = TRUE;
+ } else if (strcmp (event_type, "key-release") == 0) {
+ key_event = TRUE;
+ key_press = FALSE;
+ }
+
+ if (key_event) {
+#ifdef HAVE_X11
+ const gchar *key;
+ KeySym key_sym;
+
+ key = gst_structure_get_string (structure, "key");
+ key_sym = XStringToKeysym (key);
+
+ if (key_sym != NoSymbol)
+ rfb_decoder_send_key_event (src->decoder, key_sym, key_press);
+#endif
+ break;
+ }
+
gst_structure_get_double (structure, "pointer_x", &x);
gst_structure_get_double (structure, "pointer_y", &y);
- button = 0;
+ gst_structure_get_int (structure, "button", &button);
/* we need to take care of the offset's */
x += src->decoder->offset_x;
y += src->decoder->offset_y;
- if (strcmp (event_type, "key-press") == 0) {
- const gchar *key = gst_structure_get_string (structure, "key");
-
- GST_LOG_OBJECT (src, "sending key event for key %d", key[0]);
- rfb_decoder_send_key_event (src->decoder, key[0], 1);
- rfb_decoder_send_key_event (src->decoder, key[0], 0);
- } else if (strcmp (event_type, "mouse-move") == 0) {
+ if (strcmp (event_type, "mouse-move") == 0) {
GST_LOG_OBJECT (src, "sending mouse-move event "
"button_mask=%d, x=%d, y=%d", src->button_mask, (gint) x, (gint) y);
rfb_decoder_send_pointer_event (src->decoder, src->button_mask,
(gint) x, (gint) y);
} else if (strcmp (event_type, "mouse-button-release") == 0) {
- src->button_mask &= ~(1 << button);
+ src->button_mask &= ~(1 << (button - 1));
GST_LOG_OBJECT (src, "sending mouse-button-release event "
"button_mask=%d, x=%d, y=%d", src->button_mask, (gint) x, (gint) y);
rfb_decoder_send_pointer_event (src->decoder, src->button_mask,
(gint) x, (gint) y);
} else if (strcmp (event_type, "mouse-button-press") == 0) {
- src->button_mask |= (1 << button);
+ src->button_mask |= (1 << (button - 1));
GST_LOG_OBJECT (src, "sending mouse-button-press event "
"button_mask=%d, x=%d, y=%d", src->button_mask, (gint) x, (gint) y);
rfb_decoder_send_pointer_event (src->decoder, src->button_mask,