a question about gdk_event_put
- From: zhanglei <zhanglei sict ac cn>
- To: gtk-app-devel-list gnome org
- Subject: a question about gdk_event_put
- Date: Tue, 05 Jul 2005 16:39:17 -0400
hi,i have a question about gdk_event_put.
i don't know when to free the memory gdk_event_new allocated.
if i use local variable for the event structure,warning
message will be printed as follow,
(test2:3871): Gdk-CRITICAL **: file gdkkeys-x11.c: line 1171
(gdk_keymap_translate_keyboard_state): assertion `group < 4' failed
...
help,
here is the code i use,
int send_keyevent( GtkWidget *widget, GdkWindow *window, guint keyval,
guint mode )
{
GdkKeymapKey *keys;
gint nkeys;
GdkEventKey *e = (gpointer)gdk_event_new(GDK_KEY_PRESS);
if( e == NULL ){
g_print( "event new error!\n" );
return -1;
}
g_print( "e=%x\n", e );
if( ! gdk_keymap_get_entries_for_keyval(
gdk_keymap_get_default(),
keyval,
&keys,
&nkeys ) ){
return -1;
}
e->type = GDK_KEY_PRESS;
e->window = window;
e->state = mode;
e->hardware_keycode = keys[0].keycode;
e->keyval = keyval; //gdk_unicode_to_keyval(keyval);
e->time = GDK_CURRENT_TIME;
e->length = 0;
e->string = "";
e->send_event = FALSE;
gtk_widget_grab_focus(widget);
gdk_event_put((gpointer)e);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]