Set mapped before firing map/unmap events
This allows whatever the user calls from the signal handlers to react to observe the new state rather than the old, e.g. that a surface is no longer mapped in the unmap handler.
We also move xdg popup destroy to happen after the event in xdg_surface, aligning with layer-shell.
Reference: #3471 (closed)