-- Leo's gemini proxy

-- Connecting to auragem.letz.dev:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini; lang=en

2024-04-12 Profectus Browser Alpha 0.3 Update


This is another small update to Profectus that contains very basic CSV/TSV/PSV file support, and more fixes to DPI/High DPI on macOS and Linux Wayland.


On Wayland and macOS, SDL gives the window size and mouse positions in points, and these points are based on the DPI scaling; a scale of 1.0 would just mean that 1 pixel equals 1 point, and so the window size matches the rendering pixel size. You can get this pixels-per-point scale by dividing the Renderer's Output size with the Window Size SDL has provided you. SDL will also give the mouse events' X and Y positions in *points* rather than pixels. Lastly, all of the SDL drawing functions want their rects and positions in *pixels* and not points!


If you chose not to change any of your rendering code and turn on the HIGHDPI setting, then the result is that everything will be rendered smaller in the top-left corner of the window on High DPI systems that use Wayland or macOS, because every UI element is being calculated and rendered in *points* rather than pixels. Interestingly, SDL seems to use the same size for the Window and the renderer's Output on X11 and Windows, so I just scale my UI elements based on the Display DPI instead.


There seems to be two ways to handle High DPI in SDL:

In Alpha 0.2, I kept the UI elements being calculated in points, which was mostly the default due to my UI library using the Window Size passed to SDL, which is in points. I then scaled those points up to pixels when the elements are rendered. This also meant that I did not have to change mouse events from points to pixels because element positions are already in points. However, this created a lot of weird sizing issues where the spacing between paragraphs and certain elements was larger than it should have been. This led me to re-asses the way I do this...

In Alpha 0.3, instead of keeping the points system, I automatically convert the window size to pixels based on the pixels-per-point scaling, and then the rest of the UI is calculated based on that. This results in all UI element positions and sizes being calculated in pixels rather than points. I do the same with the mouse events. This also meant that I could completely remove all of the code I wrote to scale element positions and sizes from points to pixels when they are rendered, because they are now already in pixels from the very beginning. Using this method has solved most of the issues I had with alpha 0.2.


So, to simplify, I now do these two things:

1. When SDL creates the Window, I get the points-to-pixels scaling and convert the Window Size and all mouse events to pixels using this scale factor.

2. I use the Display DPI (given from SDL) to actually scale things like padding, font sizes, and any pixel max/min widths, etc., so that it is consistent across all platforms, since the pixels-per-points scale is always 1.0 on Windows and X11. This will need to be changed/tweaked, as it doesn't work so well on Wayland afaik.


I will be tweaking the size of elements in the next alpha update, as these changes have revealed that the default scaling of UI elements seems to be quite small. I will also be adding a way to manually increase or decrease the UI scale. There is also one more fix for DPI scaling that needs to be taken care of, and I hope to get that out in the next alpha as well.


Anyways, you can download the alpha via Gemini here:

Profectus Homepage

Precompiled Binaries Downloads

Profectus Gitlab Repository

-- Response ended

-- Page fetched on Mon May 6 18:26:11 2024