Hello Friends, 

As you may have read I have been working on getting some of the ScreenFactor 
bugs squashed. One of my theories is that a lot of GNUStep developers are 
assuming screen scaling of 1. This creates a problem where the values coming in 
from NSEvent, NSScreen are in pixels and not points. I noticed that apps like 
GWorkspace used the screen resolution (in pixels) to generate its desktop and 
center its dock which cause the dock and desktop items to disappear. 
Originally, I fixed this by going in my version and dividing by the correct 
scale. I then noticed that these little bugs were everywhere. I also noticed 
that sometimes the NSString value of a NSRect saved to Plists were in pixels as 
well, creating a problem when screen scaling would change. Suffices to say, I 
wanted a fix that would allow all these other projects to display correctly 
with out having to go to each one and divide by scale factor for the offending 
views. 

There are two libraries that this affects (my version of the projects are here)
(1) libs-back 
https://github.com/austintatiousness/libs-back/tree/improved-screen-maths
(2) libs-gui 
https://github.com/austintatiousness/libs-gui/tree/improved-screen-maths

To fix this, I proposed that we allow AppKit to assume that all geometry is in 
points instead of pixels according to the screen the window is on. This 
required only some minor changes actually. 

1) When libs-back constructs NSEvents that pertain to an NSWindow, it needs to 
ensure that all the math is scaled by the screen factor of that window. 
2) When libs-gui sends data to back, back knows that it will be in points and 
fixes it. 
3) NSWindow needed some minor changes to its drawing routines because the 
assumption is no longer that that decoration view (_wv) is scaled, but instead 
a theoretical layer just below it is. So no longer do we to a transform on the 
view, but instead just do a transform right before drawing. You will see a 
method added to NSView - (NSAffineTransform*) _baseMatrixForDrawing , that 
handles the math for each view so they draw at the correct scale. 

When I finished fixing all of this, some of the other changes that I had 
previously proposed were no longer needed. 

Some caveats: In my tests, I only changed the X11 code, I am only using frames 
drawn by GNUSteap instead of the window manager. 

I have compiled and tested the code against GNUStep Desktop, and it all is 
working great. There are still a few bug fixes (I cannot figure out why items 
loaded from gorm sometimes are divided by the screen factor), but some of the 
issues I encountered in other apps are now fixed when I change my screen 
resolution. 

I would really love it if my code could be reviewed and possibly taken into 
consideration to being added to the official reposatory.

As it is right now, I'm not going to be using an old monitor for my work, and I 
am working on a Swift bridge so I can port some of my software. I will be using 
my version of the frameworks for this project because unfortunately, as the 
bugs currently are, my ports wouldn't work correctly. 

Lastly, I am hoping that I copied all the code back into my repository, please 
let me know know if something doesn't build. 

Thanks!

Reply via email to