Skip to content
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

SDL GUI backend #1251

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

SDL GUI backend #1251

wants to merge 19 commits into from

Conversation

mmuman
Copy link
Collaborator

@mmuman mmuman commented Oct 13, 2022

The idea is to be able to run Conky on ancient OSes and hardware (thinking about MiNT (not the GNU/Linux distro, the Atari OS) or AmigaOS), in a regular window but with minimal coding required, and also to allow testing the GUI backend without X11. I used SDL 1.2 because SDL2 only runs on Windows, OSX and Linux, which limits the interest for old platforms.

For now it only draws text with a hardcoded font. It also still needs to be compiled with X11 due to some variables here and there.

@netlify
Copy link

netlify bot commented Oct 13, 2022

Deploy Preview for conkyweb canceled.

Name Link
🔨 Latest commit 41b49ab
🔍 Latest deploy log https://app.netlify.com/sites/conkyweb/deploys/67963c4a1792480008511ac2

@github-actions github-actions bot added the sources PR modifies project sources label Oct 13, 2022
@mmuman mmuman force-pushed the gui-sdl branch 3 times, most recently from 8f1477e to cca610b Compare November 29, 2022 21:36
@mmuman
Copy link
Collaborator Author

mmuman commented Nov 29, 2022

I added some way to locate and load TTF files by the font name, it kinda works.
Screenshot_20221129_223721

@mmuman
Copy link
Collaborator Author

mmuman commented Jan 22, 2023

Just rebased, had to change some #ifdef info #if defined(BUILD_WAYLAND) || defined(BUILD_SDL) so maybe we'd need some BUILD_NONX11 define around to avoid these lists everywhere?

@brndnmtthws
Copy link
Owner

Just rebased, had to change some #ifdef info #if defined(BUILD_WAYLAND) || defined(BUILD_SDL) so maybe we'd need some BUILD_NONX11 define around to avoid these lists everywhere?

That could work, though it seems messy. There's also BUILD_GUI, but it sounds like that won't help here.

@mmuman
Copy link
Collaborator Author

mmuman commented Aug 4, 2023

The recent changes on color stuff just got rid of the #ifdef thing.

@mmuman
Copy link
Collaborator Author

mmuman commented Aug 5, 2023

And we have colors :-)

@Caellian
Copy link
Collaborator

Hi, I changed how registration of output displays works to avoid linker magic, you can check out how other backends are registered on main branch for reference.

Main differences are:

  • sdl-output.cc should be guarded by build flag in CMakeLists.txt
  • You need to provide a log message template fallback in display-output.cc for feature gated outputs

@github-actions github-actions bot added dependencies adds or removes dependencies, or suggests alternatives build system related to build system (CMake) and/or building process/assumptions labels Jul 6, 2024
@github-actions github-actions bot added the rendering related to code that handles rendering, excluding the used graphics API label Jan 23, 2025
@mmuman
Copy link
Collaborator Author

mmuman commented Jan 23, 2025

Rebased, updated to last renaming, and should be up to @Caellian 's changes too.
Still not finished.

@mmuman mmuman force-pushed the gui-sdl branch 2 times, most recently from 991a97c to c25df8a Compare January 23, 2025 23:19
@mmuman
Copy link
Collaborator Author

mmuman commented Jan 23, 2025

(of course, pushing from wrong machine…)

@mmuman mmuman marked this pull request as ready for review January 26, 2025 02:28
@mmuman
Copy link
Collaborator Author

mmuman commented Jan 26, 2025

Default config now renders just fine.
Copie d'écran_20250126_032910

@github-actions github-actions bot added documentation suggests documentation changes or improvements gh-actions suggest changing GitHub actions labels Jan 26, 2025
@brndnmtthws
Copy link
Owner

I fixed the font loading on macOS, and added some basic font caching.

However, I get a blank window on macOS with the default config:

Screenshot 2025-01-26 at 07 48 48

@brndnmtthws
Copy link
Owner

Not sure why the Nix build is failing, but it's fine to ignore it for now.

@mmuman
Copy link
Collaborator Author

mmuman commented Jan 26, 2025

Hmm probably something similar with how we accept GUI settings or not.

Btw, it fails to build on Haiku because ::map is not in <unordered_map>.

@mmuman
Copy link
Collaborator Author

mmuman commented Jan 26, 2025

Just to make sure, you might want to trace calls to set_foreground_color to see if it actually gets proper colors or just black.

@brndnmtthws
Copy link
Owner

Is there any reason we can't use SDL2 rather than 1.2? It seems like SDL 1.2 isn't as well supported by the distros.

Ubuntu doesn't appear to have SDL_ttf 1.2: https://packages.ubuntu.com/search?suite=noble&arch=any&searchon=names&keywords=libsdl-ttf

@brndnmtthws
Copy link
Owner

FWIW there's a decent migration guide here: https://wiki.libsdl.org/SDL2/MigrationGuide

@mmuman
Copy link
Collaborator Author

mmuman commented Jan 26, 2025

Yes, the idea is to run on very old OSes like Atari MiNT.

@brndnmtthws
Copy link
Owner

Yes, the idea is to run on very old OSes like Atari MiNT.

Ah, right, I see now that's in your original comment, but I had forgotten about it.

The SDL_ttf library is pretty tiny, I think we could just bundle it as a 3rd party source. It's literally just 2 source files (SDL_ttf.c and SDL_ttf.h). Then it can be used with the SDL 1.2 compat layer, which is widely available. What do you think of that?

@brndnmtthws
Copy link
Owner

One more thought: maybe we should make it more clear that we intentionally only support SDL 1.2, so that in the future we can support newer versions as well.

@brndnmtthws
Copy link
Owner

The SDL_ttf library is pretty tiny, I think we could just bundle it as a 3rd party source. It's literally just 2 source files (SDL_ttf.c and SDL_ttf.h). Then it can be used with the SDL 1.2 compat layer, which is widely available. What do you think of that?

Actually, this isn't as easy as I thought. SDL_ttf 1.2 depends on freetype 1, which is also somewhat deprecated.

At this point, I think it's better to just not support distros that don't ship with SDL1.2, or people can compile SDL1.2 (and its dependencies) themselves if they really want it in a modern distro that doesn't include all the SDL1.2 deps.

@mmuman
Copy link
Collaborator Author

mmuman commented Jan 28, 2025

I suppose we could support both with some #ifdef spaghetti.

@brndnmtthws
Copy link
Owner

I suppose we could support both with some #ifdef spaghetti.

This is less than ideal. It becomes really hard to maintain, and there are already a million different build options as it is.

I'd prefer to keep it simple, and since GitHub actions uses Ubuntu by default for the Linux CI, it would be good to make it compile on Ubuntu (and macOS too if possible). At least that way we can catch compiler errors.

Getting it to compile with Nix and macOS is pretty easy, but Ubuntu is a pain. Doing it in Docker would work, but I don't love that.

I guess we could use the ExternalProject feature of CMake, then it wouldn't be too hard to include both freetype 1 and SDL_ttf 1.2 as 3rdparty dependencies. While I don't like including 3rdparty code this way, in this case it makes some sense.

@mmuman
Copy link
Collaborator Author

mmuman commented Jan 31, 2025

Or just have a separate sdl2 display.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build system related to build system (CMake) and/or building process/assumptions dependencies adds or removes dependencies, or suggests alternatives documentation suggests documentation changes or improvements gh-actions suggest changing GitHub actions rendering related to code that handles rendering, excluding the used graphics API sources PR modifies project sources
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants