On Wed, Feb 21, 2007 at 08:54:05AM +1100, Justin Clift wrote: > > This is the code for xkey, a very simple X keyboard sniffer Google > turned up last weekend while trying to figure out how to get around this > problem: > > http://wiki.hping.org/135 > > That's able to receive key events... again except for when a gtk menu is > open. (ugh)
What exactly makes you think Gtk+ menus are special? It cannot catch key events when a Qt menu is open, it cannot catch key events eaten by the window manager, etc. The sniffer simply can read only keys they get to it. Try the (quite simplistic) attached example of a `safe' password entry of which the sniffer cannot sniff the typed text. Yeti -- Whatever. ========================================================================== #include <gtk/gtk.h> static gboolean entry_focused(GtkWidget *widget) { if (gdk_keyboard_grab(widget->window, TRUE, GDK_CURRENT_TIME) != 0) g_printerr("Keyboard grab not successful, anyone can see the keys!\n"); return FALSE; } static gboolean entry_unfocused(G_GNUC_UNUSED GtkWidget *widget) { gdk_keyboard_ungrab(GDK_CURRENT_TIME); return FALSE; } int main(int argc, char *argv[]) { GtkWidget *dialog, *hbox, *entry; gint response; gtk_init(&argc, &argv); dialog = gtk_dialog_new_with_buttons("Password Dialog", NULL, GTK_DIALOG_NO_SEPARATOR, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); hbox = gtk_hbox_new(FALSE, 6); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), gtk_label_new("Password:"), FALSE, FALSE, 0); entry = gtk_entry_new(); gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE); gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0); g_signal_connect(entry, "focus-in-event", G_CALLBACK(entry_focused), NULL); g_signal_connect(entry, "focus-out-event", G_CALLBACK(entry_unfocused), NULL); gtk_widget_show_all(dialog); response = gtk_dialog_run(GTK_DIALOG(dialog)); /* Do something with the result... */ return 0; } _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list