Backported syswm support from master.