-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define a Flatpak App Manifest for Gearsystem #95
Conversation
This manifest allows for the Gearsystem application to start and execute ROMs without hanging or being unable to render windows. The `--share=ipc`, `--socket=x11` and `--device=dri` arguments along with the GLEW and GLU shared modules are necessary for the GUI to appear whereas the `--socket=pulseaudio` and SDL2 shared module are necessary for audio to be processed without hitting an indefinite lock. Filesystem access is still in development, meaning that the `--filesystem=home` or some equivalent command is required to find ROMs to load into Gearsystem.
My current item of investigation is the File Dialog and how to integrate this with the Flatpak Portal APIs. This project uses source code from another project, Native File Dialog Extended (NFDe) to abstract over the GTK API so that it may work as intended across multiple operating systems. However, this version of NFDe that is being used is using GTK's FileChooserDialog which does not support the Portal APIs. Later versions of the library appear to support this API, so there may be a good reason to update the dependency on this library rather than using this specific version of it's source code. Despite this however, the options for the File Dialog from the Portal API are limited to "OpenFile", "SaveFile" and "SaveFiles", each returning a URI to the file contained in I think this will likely require a change in UX for loading ROMs and their SAV files, at the very least for the Flatpak package. I'm happy to explore some potential options. |
I got NFDe v1.1.1 to work with the build and correctly use the Flatpak Portal API mostly building NFDe as a separate module, excluding any source files in In particular, this involves the addition of the following module in the Flatpak manifest: - name: nfde
buildsystem: cmake
config-opts:
- -DNFD_PORTAL=ON
- -DCMAKE_BUILD_TYPE=Release
- -DNFD_BUILD_TESTS=OFF
sources:
- type: git
url: https://github.com/btzy/nativefiledialog-extended.git
tag: v1.1.1
commit: 5786fabceeaee4d892f3c7a16b243796244cdddc ...and a new Makefile for flatpak containing: include ../desktop-shared/Makefile.sources
CPPFLAGS += `pkg-config --cflags gtk+-3.0` # Can be removed
LDFLAGS += `pkg-config --libs gtk+-3.0` # Can be removed
LDFLAGS += -lnfd -ldbus-1
include ../desktop-shared/Makefile.common
include ../desktop-shared/Makefile.install This would make for a very clean alternative for the Flatpak builds, if it weren't for the fact I needed to alter Edit: I found out I don't even need the GTK includes or libraries now as NFD was the only component using them. I've commented the Makefile as appropriate. |
Turns out that having the |
Given that there are some platform and/or code changes that are only present on this branch, it makes sense to refer to the current directory. I believe it's possible to refer a specific commit eventually though.
Later versions of Native File Dialog Extended (NFDe) have support for the Flatpak Portal APIs, allowing for native file chooser dialogs that grant permission to the chosen file without requiring a wide-range of permissions. This does not allow for SAV file discovery or saving, however. This will be addressed later. This is implemented as a separate module—compiled to a static library rather than as additional source files—to minimise additional dependencies that would otherwise be handled in its CMake configuration. As a result, the source files under `nfd/` are not required for the Flatpak platform and are excluded. Given the Portal API does not use GTK3 either, the dependencies on this library have also be removed. A CMake option of `-DCMAKE_INSTALL_INCLUDEDIR=include/nfd` is required due to the application expecting headers for NFDe to be in a subdirectory of `nfd/`. This is to mimic the existing include structure, though it may be argued that keeping them at the root may be better practice. This commit necessitates a specific Makefile for the Flatpak platform given it requires different libraries to link.
Looking at game controllers now, external controllers are not currently detected, but can be if |
The issue flatpak/xdg-desktop-portal#1238 looks quite relevant to my internal desires, but—like they mention—it is probably more appropriate to wait for an Input portal to exist given that controllers could be coming from bluetooth. From that, I reckon that |
The more relevant issue to the above point looks to be flatpak/xdg-desktop-portal#536 for those interested. |
This utilises the `--device=all` option for Flatpak. It's not ideal since it grants permission to *all devices*, but there is no better option available just yet. It is kept separate as a means for a simple update in the future.
Thanks for your work, this is turning out quite well! But I want to share some feedback about git submodules: I don't really like them at all 😆 They add a lot of complexity and most of the users of my emulators don't know how to deal with them. I don't know if this is something common when using Flatpak but is there any way to avoid them? I really don't want to add git modules to the project. As you can see all other dependencies are in the repo one way or another. |
I like it being a different platform directory. You can add any additional include or source file you need (like those for NFD portal) and it's fine using the preprocessor and makefiles to choose between different platforms. |
And regarding CMake, I'm also trying to avoid it as much as possible, sorry 😆 |
Thanks for the comments!
I can understand that, they are a weird construct. I have been using it mostly since that's what Flathub recommends, but it was something I have been meaning to ask. Not using the submodule is fine in my eyes and I can migrate what is existing there into the modules by hand.
That's fair. I have been taking the opportunity to do minimal changes to the codebase where I can avoid it. I did attempt to include the NFDe source files earlier but was having trouble. In retrospect, I believe I forgot to include some of the source files in If I introduce that newer NFDe version as source files, I might raise that as a separate pull request so that support on other platforms can be verified independently of this Flatpak build. Again, thanks for the feedback! I'll make sure to take that into account. |
This is to avoid needing to rely on a Git submodule to build this project. Instead, the equivalent files from these modules have been placed in this repository.
This allows the Flatpak application to be added to a desktop environment such as via a menu item. This is automatically added and removed as the Flatpak application is installed and uninstalled respectively. The method of installation was based off of the `.desktop` entry defined for [Visual Studio Code's Flatpak app][1]. There are currently no icons associated with this application, so it will appear blank for now. [1]: https://github.com/flathub/com.visualstudio.code/blob/6ace278a5768a266188e18bc8864ff643cfe22e3/com.visualstudio.code.yaml#L57
@drhelius, I'm not having much luck finding an icon for Gearsystem at the moment. Is there one defined for it that I'm missing? |
There is an icon for Mac, but honestly, it is quite poor. https://github.com/drhelius/Gearsystem/blob/master/platforms/macos/iconfile.icns |
Now that these source files are in the project, the use of the module sourced from the project's Git repository is no longer needed. Appropriate libraries are included and linked as appropriate (i.e. `dbus-1`).
This adds a series of PNG files to represent the Gearsystem application. These adhere to [the Freedesktop Icon specification][1] and come in a variety of sizes. The icons are based on the existing icon used for the MacOS release. Notably, this icon is not used in the panel/taskbar/menubar, but this is to be investigated. [1]: https://specifications.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
Took me a while to figure out what was going on for the window icon, but I believe I have something worked out now (in particular bit depth and the RGBA masks). I do have a couple of questions I would like to hear your opinion on before I push the commit for it though (the previous commit being icons kept for the desktop environment):
|
Okay, turns out my icon troubles with the panel/taskbar (whatever the bottom menu bar is called) were due to having Gearsystem installed via snap and it overwriting the existing icon set. Uninstalling that uses the icons I provided in the previous commit. As such, all that's left is the MetaInfo and SDL icons, though the latter could be their own pull request potentially. |
This file describes the metadata of the project. This can be used on a variety of repositories, but is currently just used for the Flatpak application for the time being. I currently have this MetaInfo file distributed under the "CC0 1.0 Universal" license, essentially putting it in the public domain. This only covers the metadata file itself and does not impact the license of the project. I would also like to mention in this commit that the prior commit does not have issues with icons. It was instead a local configuration issue.
Okay, functionality-wise, I think it's time to think about the elephant in the room: SAV files. The Portal API used for Flatpak applications only permits access to a set of files or directories specifically selected by the user; other files cannot be accessed. As such, if a user chooses a ROM file, Gearsystem cannot see an adjacent SAV file. Similarly, Gearsystem does not get visibility where nor does it get permission to write a SAV file related to that file. I think the only way for this to work would require a UX change for Gearsystem (at the very least when run in Flatpak). I have the following experiences written down as options:
The Explicit experience is close to the existing experience and likely has the least amount of programming overhead to implement. It is a little awkward to choose a SAV each time, however, and it can be unknown if one is truly necessary until the ROM has started. Multi-Select can reduce the number of clicks, but I think it's a bit unintuitive, personally. SAV Memory gets closer to the current experience compared to Explicit, but it requires additional implementation to take advantage of a persisted, Gearsystem-only filesystem to memorise these locations. It is also unclear how users would control this memory. The Directory option is one that a few popular emulators are already using to good effect. However, this is a large deviation to how Gearsystem currently works and would really only make sense to implement if the non-Flatpak releases also wanted this experience. When implemented however, I believe that experience would be entirely consistent across all platforms. Do you think there would be other options to explore, or does one of these stick out to you as the way to go? It would be great to hear your opinion on this. |
Could a fixed location for saves and savestates may be used when using Flatpak? For example something like The desktop app has an option to choose between this folder, a custom folder and the folder where the rom is. I'm using |
Possibly. It appears that Flatpak apps tend toward XDG directories such as To be honest: I was never aware of the feature to store saves in another location. I might familiarise myself with it a bit as that fits perfectly architecturally (aside from the same folder) from my perspective. |
I've just taken a look at the save and save state folders and it looks like, when in a Flatpak application, SDL manages to choose an appropriate default location! For example: Given that reading these files from the ROM folder is infeasible, would it be a good idea to disable that option as a preprocessor flag? |
This removes the option to store save and savestate files next to the ROM being loaded. This is because the Flatpak containerisation cannot support this natively, so indicating that it could would be a bad user experience.
This guide will be very useful for other developers to define their development environment when supporting the Flatpak application. I have attempted to include all points that have been useful for me during the setup of this Flatpak application.
Something I have noticed during the final steps of this build is that—as of right now—I require the source to be a relative directory (i.e. I have also noticed I will likely need to update the MetaInfo file to include the latest release and its notes. |
This is a copy of the releases notes on the GitHub release.
I missed a forward slash to end a paragraph, unfortunately.
These are to pass the linting process for the AppStream MetaInfo file. For the content rating, I used [an OARS tool][OARS] to generate the appropriate tag. In particular, I saw this as an application without internet connectivity and without any advertising or in-app purchases. This appears to have generated the most basic content rating. [OARS]: <https://hughsie.github.io/oars/generate.html>
Just reviewing all open issues... sorry I didn't notice before. Is this ready to merge? |
Now that I look at it again, there are a couple of things I want to tweak on the documentation side (i.e. newline inconsistencies and outdated comments), but otherwise it is in a merge-ready state. The most obvious outstanding item is the "sources" reference in the manifest file. In particular, this should point to a specific commit for Gearsystem, but the only commits with the After that, there would be requirements to maintain these files and distribute them as Gearsystem is updated. I personally feel that this case be automated off of GitHub releases, but I want you to know this in advance in case that influences whether you want to merge this or not. |
These comments are now more reflective of the current state of the manifest, describing why there is a relative source and an ideal target state.
There it goes!! |
This closes #93 by introducing a Flatpak App manifest, thereby allowing Gearsystem to be packaged and distributed as a Flatpak App. This enables the application to be available for use on a variety of Linux distributions within a sandbox containing all of its dependencies; there is no prerequisite to download any dependencies beforehand.
This Flatpak application is intended to work out-of-the-box, with the greatest amount of feature parity available all whilst maintaining a secure working environment for its users. This includes the ability to load and run the same ROMs as its native release and its ability to use controllers for input.
Although this is very similar to the
linux
platform, it is kept in its own distinctflatpak
platform so that any Flatpak-specific functionality does not impact the existing build.For testing purposes, this Flatpak app can be built with the following commands in the
platforms/flatpak
directory:This will create a temporary directory,
build-dir
, where build files are kept. When run, the--filesystem=home
will grant access to the "$HOME" directory. Additional options for--filesystem
can be found in the Flatpak Command Reference.TO-DO
Functional
Documentation
Release