Mapping between LCL Coordinates and Cocoa non-flipped coordinates not always correct
Original Reporter info from Mantis: djenkins @dfjenkins
-
Reporter name: David Jenkins
Original Reporter info from Mantis: djenkins @dfjenkins
- Reporter name: David Jenkins
Description:
My system has two monitors of different size and pitch. I noticed that with our app, pop up windows didn't always display as expected depending on which screen the app was located on. So I went through and reviewed all of the code that maps back and forth between LCL coordinates (origin at top) and Cocoa (origin at bottom). The attached patch are fixes for what I found (and fixes the problems I was seeing with multiple screens).
Things I found:
- Cocoa screen layout is always referenced with an origin set by NSScreens.screens.objectAtIndex(0). NSScreens.mainscreen is the current screen that has focus. Whenever mapping between LCL screen coords and Cocoa screen coords NSScreen0 should be used and not NSScreen.mainscreen.
I added a NSScreenZeroHeight() function to minimize the text needed to get Screen0
-
LCLViewExtension.lclframe and LCLViewExtension.lclSetFrame were not consistent in checking for flipped. lclframe only checked if Assigned(superview) but did not check for superview.isflipped before using superview.frame. This is different from lclsetFrame that checks for superview.isflipped.
-
LCLViewExtension.lclRelativePos() wasn't flipping coords but results as used are expected to be LCL Coordinates.
-
It was difficult stepping through some code to figure out which coordinate systems they were mapping to or from: LCL screen, Cocoa screen, LCL view, LCL Cocoa, etc. So some of patch is just adding comments to make it more explicit and also expanding some code steps to make it more explicit.