private ZxdgPositionerV6Implementation managedImplementation; // Store managed copy of implementation so delegates are not GC'd public ZxdgPositionerV6Implementation InitializeImplementation() { ZxdgPositionerV6Implementation impl = new ZxdgPositionerV6Implementation(); impl.destroy = this.Destroy; impl.setSize = this.SetSize; impl.setAnchorRect = this.SetAnchorRect; impl.setAnchor = this.SetAnchor; impl.setGravity = this.SetGravity; impl.setConstraintAdjustment = this.SetConstraintAdjustment; impl.setOffset = this.SetOffset; return(impl); }
public ZxdgPositionerV6(IntPtr clientPtr, Int32 version, UInt32 id, IntPtr otherResource, bool addToClient = true) { this.client = Display.GetClient(clientPtr); this.resource = Resource.Create(clientPtr, XdgShellUnstableV6Interfaces.zxdgPositionerV6Interface.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); } }