Example #1
0
        void SendButtonEvent(Widget target, Gdk.EventType eventType, double x, double y, Gdk.ModifierType state, uint button)
        {
            Gdk.Window win = target.GdkWindow;

            int rx, ry;

            win.GetRootOrigin(out rx, out ry);

            var nativeEvent = new NativeEventButtonStruct {
                type       = eventType,
                send_event = 1,
                window     = win.Handle,
                state      = (uint)state,
                button     = button,
                x          = x,
                y          = y,
                axes       = IntPtr.Zero,
                device     = IntPtr.Zero,
                time       = Global.CurrentEventTime,
                x_root     = x + rx,
                y_root     = y + ry
            };

            IntPtr ptr = GLib.Marshaller.StructureToPtrAlloc(nativeEvent);

            try {
                Gdk.EventHelper.Put(new Gdk.EventButton(ptr));
            } finally {
                Marshal.FreeHGlobal(ptr);
            }
        }