One simple possibility is to set/unset the _GTK_HIDE_TITLEBAR_WHEN_MAXIMIZED property. I think there is also a corresponding gtk api for that but maybe the property could be set using standard X machinery already exposed to elisp(?). Probably all this would be ineffective under waylan but it's simply enough to fix the problem for X with low effort.