Do you think the issue is as simple as debugging the code that detect when pen is about to be used and store the object properties and then when pen stops being used making sure all object properties are restored back to the previous properties before pen was used?
Object… properties? It’s going to be some time until I focus my attention towards MyPaint’s HID code specifically, but it’s most likely a problem with GTK rather than with MyPaint.