So custom window manager openbox running and margin set on left side of the screen using openbox configuration manager.
Having to switch displays implies that you have a dualmon hardware setup.
Is this a laptop that is sometimes disconnected/reconnected to an external monitor or docking station? Or otherwise maybe a dodgy VGA/HDMI/DVI/Display cable to one monitor?
What I think is happening is that the display application temporarily sees one single monitor (for whatever reason).
The margin setting in openbox is always applied to the screen and not to a specific/static monitor.
So (and you can test this) if you disconnect/disable (not power down) the left monitor of a left-right dualmon setup by using the Applications/Settings/Displays application, the 30px left margin will then be applied to the right monitor which now is the entire screen.
Now turn the disabled monitor on again using the same Displays application and this monitor now becomes the right monitor in the Displays application.
The margin during that session though is still being applied to the "wrong" monitor as it is now the left side of the screen. Now drag the monitors (as you do) et voila! "fixed"...
Read about some scripts that switch ~/config/monitors.xml by keyboard shortcut or startup script but seems cumbersome. Best is probably just to shutdown your PC, disconnect screen/docking, reconnect at different location and power on. Should be OK then with settings remembered (not tested).
When windows are maximized and the problem is present, the maximized window may or may not slip under a side panel, but it never slips under my top or bottom panels, as can be seen in the second screen shot above.
True, same here. Not really a problem though in my book, probably even by design.
On occasion when I'm moving a window from one monitor to another, in un-maximized mode, I some times accidentally let it go under the top menu bar. Then I'm screwed because you cant grab the title bar to move it again. So while moving an un-maximized window it can slip under top menu bar, but it does not slip if window is maximized.
Workaround would be to (temporarily) auto-hide your top panel through it's properties so you can reach the window bar again but yes, I can reproduce that using Openbox WM.