skyjake/lagrange Issue #618: Lagrange on Mobile Linux: Does not adapt well to small screens

Repo Home
Issues

2023-08-31 05:58:16 huntekye

Hi!

Thanks for making this great client for Gemini (and friends)! I am experiencing some issues with using Lagrange on a device with a very small screen: A pinephone pro running Linux v6.4.1-1-danctnix (a derivative of Arch) with the sway window manager (Wayland based). The screen causing issues is 720x1440 px, 68x136 mm, with a scaling factor of 2.0 configured in sway

Basically, the Lagrange window is cut off. Changing the UI scaling does not fix the problem (actually setting the scaling to 0.5 creates a huge left margin and the text is still cut off), nor does rotating the screen though this gets close to showing all of the text. There appear to be similar problems with other windows that Lagrange creates, e.g., the preferences window.

I think that potentially there are two things going on: 1) The windows Lagrange makes are not designed to be really small in Linux, though I imagine there must already be some kind of solution for this in iOS and Android; 2) I guess that historically there is only sort of so-so support for Wayland/sway in SDL.

For a bit of background on SDL and window size problems in sway see for example https://github.com/libsdl-org/SDL/issues/3448 . On my laptop running sway I can confirm that even though the Lagrange window has some sort of minimum dimensions, sway is not aware of them, and Lagrange is not fully aware of the window that sway wants it to be in. This means that I can try to make the Lagrange window very small and sway will let me and the window's frame can be as small as I want, but eventually the window that Lagrange renders stops shrinking and renders outside of the frame that sway gives it. Similarly, opening the preferences window (on my laptop), it is tiled by default, generally leading to a window that is far too large. This is handled surprisingly well, and the extra space is filled with a background color, but here again sway allows me to change the size of the window but the rendered window does not react and simply renders outside it's frame (or does not fill the larger frame). This demonstrates that SDL is not correctly communicating minimum and maximum sizes of these windows to sway. These are not really practical issues on a laptop, but I think they provide some context for what is likely happening on a phone screen.

If there's any other information that would be useful, just let me know!

Comments (6)

2023-09-01 10:50:48 skyjake

Unfortunately this seems like a shortcoming in SDL, since it is responsible for the low-level window management. The best chance of fixing this is manually compiling the app using the latest release of SDL.

Also, Lagrange needs to be compiled with the `-DENABLE_MOBILE_PHONE=YES` CMake option, so the correct UI variant is used. However, this only affects UI layout inside the window, not window management.

2023-09-01 15:45:18 huntekye

Ah yeah, compiling with that option basically fixes the problem! I guess that that would have been apparent if I had tried reading through `CMakeLists.txt`, but perhaps that option should be added to the table in the README? Ideally it is nice if this sort of thing is detected dynamically, but with how different the UIs are I get that it probably isn't easy to do. Potentially would it be possible to compile both UIs and switch between them with a runtime flag?

One problem I am still seeing is that it seems I can't open the Settings menu: selecting Settings from the hamburger menu closes the hamburger menu and then nothing happens. Also, ever time I try to close a tab it seg faults, but perhaps these would be better addressed in separate issues if you want.

2024-12-23 14:08:03 magdesign

Also build on xiaomi pocof1 running pmos/linux sway with the mobile flags:

cmake 
-DENABLE_MOBILE_PHONE=YES
 -DCMAKE_BUILD_TYPE=Release 

it looks quite good compared to running the desktop version.

but i am not able to open settings... when clicking on settings, i get a long list of

Lagrange: A Beautiful Gemini Client
failed to find 000065e5 (日)
failed to find 0000672c (本)
failed to find 00008a9e (語)
failed to find 00007b80 (简)
failed to find 00004f53 (体)
failed to find 00004e2d (中)
failed to find 00006587 (文)
failed to find 00007e41 (繁)
failed to find 00009ad4 (體)
failed to find 00006b63 (正)
failed to find 00009ad4 (體)

do i just have to install some sort of fonts?

![2024-12-23-08:59:37](https://github.com/user-attachments/assets/a2fa076d-ea34-4047-8c47-051abffde23a)

![2024-12-23-08:59:54](https://github.com/user-attachments/assets/ba152750-3548-4946-b84f-2dbd7562d1a3)

2024-12-23 14:22:07 magdesign

after installing:

`apk add font-noto-cjk`

the font error disappears, but settings still do not open...

can i go into any kind of verbose mode or provide any sorts of logs to fix this?

built with `-DCMAKE_BUILD_TYPE=Debug`

but no debug/error output appears

2024-12-23 15:08:31 skyjake

@magdesign The first thing to check is if the CMake config makes sense. I've only ensured that the configurations works on iOS and Android. If any other mobile platform is working, it is only by accident, so to speak.

Setting `ENABLE_MOBILE_PHONE=YES` enables some phone UI behaviors, but the app still thinks the core platform type is "desktop" unless one is compiling on iOS or Android (as detected by CMake). The result is a hybrid where some code works like on the desktop (mouse-based) while other code does mobile-oriented things (touch-based).

You could first try modifying the main CMakeLists.txt to add something like this around line 335:

if (MOBILE_LINUX) # you'll need to manually define this on the command line
    set (MOBILE 1)
    add_definitions (-DiPlatformLinuxMobile=1)  # this can be used for customizations
endif ()

However, this is totally untested so something may well break in the build as a result. Nevertheless, it is the first necessary step to correctly building the app for mobile Linux.

2024-12-23 16:11:14 magdesign

thanks for the quick response. i leave this open to people more familiar with C and stick to the tui version...

Thank you very much for creating Lagrange!