You can’t see an ui_events.c file because these ‘built-in’ callbacks are created in ui.c. The ui_events.c file is kept for CALL_FUNCTION actions. (So if you want to customize it and/ore use it from outside, you can create a CALL_FUNCTION action for the event and put the _ui_state_modify toggler code into that function.)
(Nete: I answered the other part of your question here: Change container back to default without button press)