GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Fri Dec 19, 2014 5:32 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Event buffer and simulated events.
PostPosted: Tue Mar 17, 2009 11:14 pm 
Offline

Joined: Tue Mar 17, 2009 11:06 pm
Posts: 1
I have a very simple app with just a window. I'm testing some code which grabs input from a remote and inserts events as keystrokes. Here's some sample code:

[code=]while(true){

keyVal = getRemoteData();
GdkEvent *event = gdk_event_new(GDK_KEY_PRESS);
GdkEventKey *tmpKey = (GdkEventKey*)event;
tmpKey->window = gdk_get_default_root_window();
tmpKey->send_event = 1;
tmpKey->time = CUR_TIME;
tmpKey->keyval = keyVal;
tmpKey->state = 0;
tmpKey->length = 0;
tmpKey->string = "";
tmpKey->hardware_keycode = 0;
tmpKey->group = 0;
fprintf(stderr, "Put keypress\n");
gdk_event_put(event);

usleep(20000);
}[/code]


I've added code to gdk_event_peek and my event gets placed on the queue. However, it never gets removed. I have code which peeks at the queue everytime and the first entry is always the entry I get back.

Any idea why my queue isn't emptying? I have attached a "key-press-event" signal to the window, added GDK_KEY_PRESS_MASK events to the window, and grabbed focus.

Any help would be greatly appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 19, 2009 9:08 am 
Offline
Never Seen the Sunlight

Joined: Wed Jul 23, 2008 10:31 am
Posts: 2406
Location: Slovenia
Hello and welcome to the Gtk+ forums.

What value are you returning from your "key-press-event" callback? I think you need to return TRUE to remove current event from the cue (but I'm not sure, since I've never done anything similar to what you're doing).


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group