frang75 / nappgui_src

SDK for building cross-platform desktop apps in ANSI-C
https://www.nappgui.com
MIT License
506 stars 50 forks source link

Applications not sized correctly Ubuntu 18.04. #12

Closed g8kig closed 2 years ago

g8kig commented 2 years ago

For example the hello demo app only displays the title bar. Build from source is successful. I am surprised the application can not be resized/maximised either. Otherwise nice job Screenshot from 2022-04-10 18 57 11 Screenshot from 2022-04-10 18 57 50 !

frang75 commented 2 years ago

Hi @g8kig! Thank you very much for your feedback and for your time. These tests help me improve the software.

I am testing the demos on Ubuntu 18.04.6 LTS and the windows size correctly. Neither HelloCpp nor Products allow resizing the window (fixed size). You can try Die or Bode which do allow it. I have tried different themes through gnome-tweeks (Ambiance, Adwaita, HighContrast), all of them correct.

In order to be able to reproduce your case, please I would ask you to:

Screenshot from 2022-04-11 20-19-58

Screenshot from 2022-04-11 20-33-11

Screenshot from 2022-04-11 20-34-27

Screenshot from 2022-04-11 20-35-05

Screenshot from 2022-04-11 20-42-51

g8kig commented 2 years ago
Exact version of the operating system.

Manjaro Linux (rolling release: latest) Elementary OS 5.1.7 Hera

GTK+3 version (pkg-config --modversion gtk+-3.0)

Manjaro: 3.24.33 Elementary: 3.22.30

Desktop theme

The default Manjaro/Elementary one.

Application binaries (Manjaro)

Products.zip GuiHello.zip

Other information: I wish I knew more about GTK3 programming!

frang75 commented 2 years ago

Testing in latest Manjaro (Gnome), window sizing work fine.

Manjaro_00 Manjaro_01

ragsaq commented 2 years ago

Maybe it has something to do with HiDPI?

g8kig commented 2 years ago

Sorry closed in error. No I am not using HiDpi my display is 1280x800. I will retest on a HD monitor,

g8kig commented 2 years ago

This is an absolutely terrible hack but it works around the problem for now gtk3 oswindow.c line 733

    gtk_widget_set_size_request(window->control.widget, (gint)width + 155, (gint)height + 190);

Sorry.

Tim-Paik commented 2 years ago

I also encountered this problem, Archlinux Latest, GTK 3.24.34, WhiteSur Theme System scaling 100%, resolution 1920*1080, refresh rate 120hz Using Demo form there: https://nappgui.com/en/download/download.html

Great software!

ragsaq commented 2 years ago

I also get this in Ubuntu 22.04 simply following the instructions in the readme to build all the examples.

in my case, I'm using the images that comes with lxd:

just run this, if you have lxd/lxc installed:

lxc launch images:ubuntu/22.04/desktop ubuntu --vm --console=vga

and GCC 12

frang75 commented 2 years ago

Thanks for the feedback. This weekend I'll try to reproduce the error.

frang75 commented 2 years ago

Hi @ragsaq ! It seems I have problems to execute lxc

At the moment, I don't have any "native" Linux machine. Have them all in VirtualBox. Can you share a VirtualBox image where this problem appears? I have tried to install ArchLinux in VirtualBox, but the process is a bit tricky.

fran@fran-VirtualBox:~$ lxc launch images:ubuntu/22.04/desktop ubuntu --vm --console=vga
If this is your first time running LXD on this machine, you should also run: lxd init

Creating ubuntu
Error: Failed instance creation: No storage pool found. Please create a new storage pool
fran@fran-VirtualBox:~$ lxd init
Would you like to use LXD clustering? (yes/no) [default=no]: 
Do you want to configure a new storage pool? (yes/no) [default=yes]: 
Name of the new storage pool [default=default]: 
Name of the storage backend to use (dir, lvm, zfs, ceph, btrfs) [default=zfs]: 
Create a new ZFS pool? (yes/no) [default=yes]: 
Would you like to use an existing empty block device (e.g. a disk or partition)? (yes/no) [default=no]: 
Size in GB of the new loop device (1GB minimum) [default=9GB]: 20
Would you like to connect to a MAAS server? (yes/no) [default=no]: 
Would you like to create a new local network bridge? (yes/no) [default=yes]: 
What should the new bridge be called? [default=lxdbr0]: 
What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: 
What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: 
Would you like the LXD server to be available over the network? (yes/no) [default=no]: 
Would you like stale cached images to be updated automatically? (yes/no) [default=yes] 
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]: 
fran@fran-VirtualBox:~$ lxc launch images:ubuntu/22.04/desktop ubuntu --vm --console=vga
Creating ubuntu
Error: Failed instance creation: Failed creating instance record: Instance type "virtual-machine" is not supported on this server
fran@fran-VirtualBox:~$ 
ragsaq commented 2 years ago

Hi,

I think that is because probably you need to enable nested virtualization in virtual box:

https://serverfault.com/questions/1049528/how-to-enable-nested-virtualization-in-order-to-use-virtualbox-inside-of-a-kvm-v

lxc uses the hypervisor too, so you can't mix lxc with virtualBox on the same OS.

Having said that, I think you can try and install a VM in virtualBox of Ubuntu 22.04, since what lxc does is use a clean image that's already made.

frang75 commented 2 years ago

Hi all! Sorry for the delay, but it has been very difficult for me to reproduce the error. In the end, I was able to reproduce it on Ubuntu 22. It seems like a very strange behavior of the latest versions of GTK. If you launch the same app from VSCode's built-in terminal, then it works fine. The fact is that I always debugged from this tool and it always worked fine.

I have opened an issue in the GTK GitLab. https://gitlab.gnome.org/GNOME/gtk/-/issues/5181

Any news, I will comment on this thread. Regards

frang75 commented 2 years ago

Finally I found the solution. In the lastest versions of GTK/Gnome/Ubuntu the enviroment variable GDK_BACKEND=x11 have to be defined. If not, NAppGUI windows are not sized correctly.

No_GDK_BACKEND

But, if you export GDK_BACKEND=x11 before running the application, it works fine

Yes_GDK_BACKEND

In next days I will updoad a patch for setting this environment variable inside a NAppGUI application. putenv("GDK_BACKEND=x11");

Tim-Paik commented 2 years ago

Finally I found the solution. In the lastest versions of GTK/Gnome/Ubuntu the enviroment variable GDK_BACKEND=x11 have to be defined. If not, NAppGUI windows are not sized correctly.

No_GDK_BACKEND

But, if you export GDK_BACKEND=x11 before running the application, it works fine

Yes_GDK_BACKEND

In next days I will updoad a patch for setting this environment variable inside a NAppGUI application. putenv("GDK_BACKEND=x11");

I think setting GDK_BACKEND to x11 is definitely a wrong and unwise action, it will break wayland compatibility and lead to using xwayland compatible layer in wayland session, which will not only lead to graphics performance and security degradation, but also make the APP unavailable in pure wayland session.

I think this bug is caused by the different scaling methods of wayland and x11, because wayland supports fractional scaling while x11 does not, and there are many differences in the implementation of these two, which need to be adapted separately.

frang75 commented 2 years ago

Thanks for the comment @Tim-Paik. Until now, I was unaware of the existence of wayland. I'm going to investigate to see how to adapt NAppGUI to both backends (x11, wayland)

Tim-Paik commented 2 years ago

Thanks for the comment @Tim-Paik. Until now, I was unaware of the existence of wayland. I'm going to investigate to see how to adapt NAppGUI to both backends (x11, wayland)

Thanks for the development, it will be a great work! Yes, wayland is still new, but the entire linux desktop ecosystem is already migrating to wayland.

Thanks again for your work.

g8kig commented 2 years ago

So I have checked and Visual Studio Code sets the environment variable GDK_BACKEND=x11 which is why you did not see the problem. It seems that lots of other applications also require it to be set with Wayland. Therefore, I think the fix of setting the environment variable NAppGui is a perfectly reasonable work around pending the development of a Wayland port of NAppGui.

frang75 commented 2 years ago

Hi! I have opened a new issue to investigate the problem. https://github.com/frang75/nappgui_src/issues/23

After spending several hours on this case, I still can't determine if it's really a NAppGUI issue or a Wayland issue. I would need to create a small "pure" GTK3 application that shows this problem. At the moment, I have uploaded a patch that forces the backend to X11. At least it ensures that the applications work properly until this case is resolved.

Thank you all very much for your feedback.

g8kig commented 2 years ago

Works correctly now in the listed environments, thanks!