From 862cc7ddd221435ea5ecf2cc031949d07cfa27fa Mon Sep 17 00:00:00 2001 From: Thijs Vermeir Date: Thu, 6 Nov 2008 22:54:39 +0000 Subject: Fix basic navigation events Original commit message from CVS: * configure.ac: * gst/librfb/Makefile.am: * gst/librfb/gstrfbsrc.c: Fix basic navigation events --- gst/librfb/Makefile.am | 4 ++-- gst/librfb/gstrfbsrc.c | 42 ++++++++++++++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 12 deletions(-) (limited to 'gst/librfb') 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 #include +#ifdef HAVE_X11 +#include +#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, -- cgit v1.2.1