Re: Catch mouse events



On Thu, Apr 30, 2009 at 01:38:23PM +0200, Marton Balint wrote:
> Hi,
> 
> Is there a simple way to capture mouse events just like the example 
> application does with keyboard events?
> 
> I tried  
> 
> gtk_signal_connect(GTK_OBJECT(window), "button-press-event",
>    GTK_SIGNAL_FUNC(vnc_click), vnc);
> 
> but it only works if the vnc client is in read only mode.

What version of GTK-VNC have you got ?  We fixed that problem in 0.3.7
I just confirmed that i can received events by trying this patch against
our example viewer program in GIT


Daniel

diff --git a/examples/gvncviewer.c b/examples/gvncviewer.c
index 7ccdb50..30bcd7a 100644
--- a/examples/gvncviewer.c
+++ b/examples/gvncviewer.c
@@ -287,6 +287,33 @@ static gboolean window_state_event(GtkWidget *widget,
 }
 #endif
 
+static gboolean
+do_mouse(GtkWidget *widget,
+        GdkEventMotion *motion)
+{
+       fprintf(stderr, "Do mouse\n");
+       return TRUE;
+}
+
+static gboolean
+do_button(GtkWidget *widget,
+         GdkEventButton *button)
+{
+       fprintf(stderr, "Do button\n");
+       return TRUE;
+}
+
+
+static gboolean
+do_key(GtkWidget *widget,
+       GdkEventKey *key)
+{
+       fprintf(stderr, "Do key\n");
+       return TRUE;
+}
+
+
+
 int main(int argc, char **argv)
 {
        GOptionContext *context;
@@ -436,6 +463,14 @@ int main(int argc, char **argv)
                           GTK_SIGNAL_FUNC(window_state_event), layout);
 #endif
 
+
+       gtk_signal_connect(GTK_OBJECT(vnc), "motion-notify-event",
+                          GTK_SIGNAL_FUNC(do_mouse), NULL);
+       gtk_signal_connect(GTK_OBJECT(vnc), "button-press-event",
+                          GTK_SIGNAL_FUNC(do_button), NULL);
+       gtk_signal_connect(GTK_OBJECT(vnc), "key-press-event",
+                          GTK_SIGNAL_FUNC(do_key), NULL);
+
        gtk_main();
 
        return 0;



-- 
|: http://berrange.com/     -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://freshmeat.net/~danielpb/    -o-   http://gtk-vnc.sourceforge.net :|

Attachment: signature.asc
Description: Digital signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]