[Gtk-sharp-list] How to increase Gdk.Window reference count ?

kmarecki marecki.krzysztof at gmail.com
Wed Dec 23 10:05:12 EST 2009


Thanks for your answer. It turned out that invoking g_object_ref was
unnecessary.
I had some problems with proper eventkey struct marshaling.

If someone needs to emulate key press event, this method will work.

void SendKeyEvent(Gtk.Widget widget, Gdk.Key key) 
{
	uint keyval=(uint)key;
	Gdk.Window window=widget.GdkWindow;
	Gdk.KeymapKey[] keymap=Gdk.Keymap.Default.GetEntriesForKeyval(keyval);
	
	EventKeyStruct native=new EventKeyStruct();
	native.type=(int)Gdk.EventType.KeyPress;
	native.window=window.Handle;
	native.send_event=1;
	native.state=(uint)Gdk.EventMask.KeyPressMask;
	native.keyval=keyval;
	native.length=0;
	native.str=null;
	native.hardware_keycode=(ushort)keymap[0].Keycode;
	native.group=(byte)keymap[0].Group;
			
	IntPtr ptr=GLib.Marshaller.StructureToPtrAlloc(native);
	try
	{
		EventKey evnt=new EventKey(ptr);
		EventHelper.Put(evnt);
	}
	finally
	{
		GLib.Marshaller.Free(ptr);
	}
}
-- 
View this message in context: http://old.nabble.com/How-to-increase-Gdk.Window-reference-count---tp26887589p26903298.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.



More information about the Gtk-sharp-list mailing list