interstellar icon indicating copy to clipboard operation
interstellar copied to clipboard

Application shows headerbar on mobile linux

Open heldderarbeit opened this issue 8 months ago • 7 comments

Describe the bug

On postmarketOS edge with Phosh and Interstellar installed from Flathub, the application shows constantly a headerbar on the top of the screen. The headerbar has no functionality, it only shows the name of the app. This is unexpected, because GTK and Kde applications never show a headerbar (it simply not needed, apps can be closed by swiping them away in the overview). Is it possible to hide the headerbar for flutter applications?

Image

Steps to Reproduce

Just open the app

Version

0.9.1

What client platform(s) are you seeing the problem on?

Linux

What server platform(s) are you seeing the problem on?

Mbin

Additional context

No response

heldderarbeit avatar Apr 21 '25 23:04 heldderarbeit

I'm not really sure how to fix this one. I'm sure there's a way to hide that header bar at the top of the window, but the question is, how do we know when to hide it? You obviously need the header bar on desktop, in order to move around the window, and close, minimize, and maximize it; so I can't just hide it completely. The tricky part is that there is just one Linux version (which is used for both Desktop and Mobile Linux), so I can't just change something like I could with Linux vs. Android.

jwr1 avatar Apr 24 '25 02:04 jwr1

We could either check on some kind of env. variable maybe like $DESKTOP_SESSION:

echo $DESKTOP_SESSION
cinnamon

Or we check on screen geometry. So GTK3 has this method for example: https://docs.gtk.org/gdk3/method.Display.get_monitor_at_window.html Which returns a https://docs.gtk.org/gdk3/class.Monitor.html class.

And eventually call: https://docs.gtk.org/gdk3/method.Monitor.get_geometry.html

And I quote:

Retrieves the size and position of an individual monitor within the display coordinate space. The returned geometry is in ”application pixels”, not in ”device pixels” (see gdk_monitor_get_scale_factor()).

melroy89 avatar Apr 24 '25 17:04 melroy89

Fast and quick getting started code..?

Try to add this to linux/runner/my_application.cc:

  gtk_widget_realize(GTK_WIDGET(window));
  GdkWindow* gdk_window = gtk_widget_get_window(GTK_WIDGET(window));
  if (gdk_window) {
    GdkDisplay* display = gdk_window_get_display(gdk_window);
    GdkMonitor* monitor = gdk_display_get_monitor_at_window(display, gdk_window);
    if (monitor) {
      GdkRectangle geometry;
      gdk_monitor_get_geometry(monitor, &geometry);
      g_print("Monitor geometry: x=%d y=%d width=%d height=%d\n", geometry.x, geometry.y, geometry.width, geometry.height);
    } else {
      g_print("No monitor found for window.\n");
    }
  } else {
    g_print("No GdkWindow available for GtkWindow.\n");
  }

Just to get you off the ground. THat being said, I think I was right, you can use Qemu to start a local postmarketOS image.

melroy89 avatar Apr 24 '25 18:04 melroy89

As mentioned on Matrix, checking the desktop type is not a foolproof solution as Phosh has a desktop mode and desktop GNOME can be run on phones quite well with some patches. Monitor geometry is probably more likely to provide good results in most situations.

Newbytee avatar Apr 24 '25 18:04 Newbytee

@Newbytee does that mean title bars are not displayed on apps, even in desktop mode? What do most Gnome or KDE mobile apps do?

Using display geometry would mean there's no title bar in both mobile and desktop modes, but I'm assuming in desktop mode, there should be a title bar?

jwr1 avatar Apr 24 '25 18:04 jwr1

@Newbytee does that mean title bars are not displayed on apps, even in desktop mode? What do most Gnome or KDE mobile apps do?

GNOME doesn't have this problem since it doesn't have separate title bars, that is, the title bar is part of the program's UI, so hiding it is neither necessary nor practical. As for KDE, in postmarketOS we set two environment variables to "fix" this for Qt apps:

  1. Disable window decorations: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/blob/1b69da95117c82b552e3df78061d388a7edfc282/main/postmarketos-base-ui/rootfs-etc-profile.d-qt-wayland.sh#L2
  2. Enable Qt Quick mobile controls: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/blob/1b69da95117c82b552e3df78061d388a7edfc282/main/postmarketos-base-ui/rootfs-etc-profile.d-qt-mobile-controls.sh#L2

Using display geometry would mean there's no title bar in both mobile and desktop modes, but I'm assuming in desktop mode, there should be a title bar?

Yes, but usually if you're using desktop mode you'd be on a larger screen, not a small one. However, it won't always produce the right results like you say. There might be some better solution to this which I'm not aware of.

Newbytee avatar Apr 24 '25 19:04 Newbytee

This is a flutter issue, it also happens on the flatpak version of interstellar on KDE (but probably also happens in general on KDE/non-gtk based distros): https://github.com/flutter/flutter/issues/111453. For some reason interstellar doesnt even respond to the env var GTK_CSD=0 unlike some other flutter apps.

This how the AppFlowy seemingly fixed it: https://github.com/AppFlowy-IO/AppFlowy/pull/5991.

newart3 avatar Jul 13 '25 08:07 newart3