Basically implements the proposal outlined in this comment.
- The basic rule for setting the workspace mode is: The last active mode that is not object-mode (OB_MODE_OBJECT) becomes the workspace mode. (Therefore the workspace mode must never be OB_MODE_OBJECT.)
- By default, a new workspace uses edit-mode as workspace mode.
- When opening old files, the mode of the active object is set for the workspace (or its restore mode if in OB_MODE_OBJECT)
- Object.restore_mode is deprecated now.
Now, some parts of the design I'm not sure yet. Mainly:
- The implementation makes the workspace remember if the workspace mode or OB_MODE_OBJECT is active. Pressing TAB toggles between them. However the workspace doesn't try to keep the workspace mode active while only using OB_MODE_OBJECT as fall-back or when the user explicitly sets it. This differes from what I wrote in mentioned comment. Maybe that's better maybe not.
- If the workspace mode isn't compatible with the currently active object, pressing TAB does nothing. In theory this may make sense, in practice it might be quite annoying though.
- [Technical] In current Blender, objects can have multiple modes set using bitwise operations. Could we get rid of that?
Without having investigated this really, I don't understand why we do this. Would appreciate if somebody could explain it to me.
I'm not submitting that for code review really. Just for feedback on the general design approach and the discussion points mentioned above.