Described is a mechanism that preserves the state of computer system
shared resources and/or settings, and ensures that changes thereto are
reverted when an application exits. A shared resource change bubble
logically surrounds application code that causes system resource and/or
setting data to change. The bubble preserves existing data before it gets
changed, and restores the data when the application program code exits.
In one implementation, the bubble is implemented as a library loaded by
the application. In an alternative implementation, the bubble is run in a
separate process, whereby the bubble can restore changed data even if the
application program crashes. In another implementation, a bubble is
automatically run for any application that the user has specified needs a
bubble. Multiple settings and states may be preserved in a bubble for
multiple applications, allowing changes to be undone and reapplied per
application, e.g., whenever focus changes.