layerwidget: Fixed calculation of event position for simulated mouse-clicks.  Also, lots of little cleanups.