private ZxdgShellV6Implementation managedImplementation; // Store managed copy of implementation so delegates are not GC'd public ZxdgShellV6Implementation InitializeImplementation() { ZxdgShellV6Implementation impl = new ZxdgShellV6Implementation(); impl.destroy = this.Destroy; impl.createPositioner = this.CreatePositioner; impl.getXdgSurface = this.GetXdgSurface; impl.pong = this.Pong; return(impl); }
public ZxdgShellV6(IntPtr clientPtr, Int32 version, UInt32 id, IntPtr otherResource, bool addToClient = true) { this.client = Display.GetClient(clientPtr); this.resource = Resource.Create(clientPtr, XdgShellUnstableV6Interfaces.zxdgShellV6Interface.ifaceNative, version, id); managedImplementation = this.InitializeImplementation(); this.deleteFunction = new DeleteFunction(this.Delete); this.implementation = Marshal.AllocHGlobal(Marshal.SizeOf(managedImplementation)); Marshal.StructureToPtr(managedImplementation, this.implementation, false); Resource.SetImplementation(resource, this.implementation, otherResource, this.deleteFunction); if (addToClient) { client.resources.Add(this); } }