This solutions implies to modify wine, so do you think that this patch or an improved version could be merged into wine? Because I don't want to require a custom version of wine.
Even if it were merged, that would not give you the ability to use it from within a Windows or winelib program. For that you would need either some extra Wine-specific API's to allow this or an approach that does not rely on Wine (which may be possible using X11 to reparent Wine's windows, but would be a hacky approach).