W-topological matter and gravity