Skip to content

Add basic Ubuntu Touch functions#12543

Open
Semphriss wants to merge 1 commit intolibsdl-org:mainfrom
Semphriss:ubuntu-touch
Open

Add basic Ubuntu Touch functions#12543
Semphriss wants to merge 1 commit intolibsdl-org:mainfrom
Semphriss:ubuntu-touch

Conversation

@Semphriss
Copy link
Copy Markdown
Contributor

Description

This adds support for:

  • System theme
  • Sandbox detection
  • Device form factor detection

Many things aren't properly supported yet, but changes and upgrades will happen on the Ubuntu Touch side, so SDL should automatically support more Ubuntu Touch features as time goes.

Existing Issue(s)

Works towards #12272

@Semphriss Semphriss force-pushed the ubuntu-touch branch 12 times, most recently from 1b21648 to cb156e6 Compare March 17, 2025 04:58
Comment thread include/SDL3/SDL_system.h
*
* \since This function is available since SDL 3.4.0.
*/
extern SDL_DECLSPEC bool SDLCALL SDL_IsUbuntuTouch(void);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under what conditions does the application need to know this is Ubuntu Touch?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used internally by SDL to detect when to use certain tweaks for Ubuntu Touch, like the Wayland driver bug. Since Ubuntu Touch is just Linux, it doesn't expose any compiler macro like __UBUNTU_TOUCH__ that could help determine when to use these tweaks.

Since app developers may also want to tweak their apps on Ubuntu Touch, I considered it might help to expose that function in the API.

Comment thread include/SDL3/SDL_system.h Outdated
*
* \sa SDL_UTFormFactor
*/
extern SDL_DECLSPEC SDL_UTFormFactor SDLCALL SDL_GetUbuntuTouchFormFactor(void);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be considered as a more general function in the API. Can you please split this out as a separate PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean I should replace this with something like SDL_GetFormFactor()?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the code from this PR and I've made an initial implementation in #12584.

@slouken slouken added this to the 3.4.0 milestone Mar 17, 2025
@Semphriss Semphriss force-pushed the ubuntu-touch branch 6 times, most recently from 465ea30 to 44c7913 Compare March 19, 2025 17:13
@Semphriss Semphriss force-pushed the ubuntu-touch branch 2 times, most recently from 1951691 to bd4b995 Compare March 27, 2025 01:51
@Semphriss Semphriss force-pushed the ubuntu-touch branch 2 times, most recently from 94c263e to de9ce9e Compare June 15, 2025 21:34
@slouken slouken modified the milestones: 3.4.0, 3.6.0 Aug 26, 2025
@Semphriss Semphriss force-pushed the ubuntu-touch branch 2 times, most recently from 514f3e7 to 13537b8 Compare March 8, 2026 16:45
@Semphriss Semphriss force-pushed the ubuntu-touch branch 5 times, most recently from f7ef97b to 4a1cff1 Compare March 11, 2026 22:20
This adds support for:
- System theme
- Sandbox detection
- Platform detection
- Writable directory (SDL_GetPrefPath)

static char **SDL_ubuntu_touch_get_app_info(void)
{
static char appname[257] = "";
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't add almost 1K of static data here. Instead this should be dynamically allocated if necessary and cleaned up in SDL_Quit()

Comment thread include/SDL3/SDL_system.h
* \sa SDL_GetUbuntuTouchAppHook
* \sa SDL_GetUbuntuTouchAppVersion
*/
extern SDL_DECLSPEC const char *SDLCALL SDL_GetUbuntuTouchAppID(void);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than adding API entries for these 3, instead let's make them global properties, like SDL_PROP_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER and the app metadata?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a place where it would be best to initialize the new global properties?

I looked into creating them from SDL_Init(), but the code there expects the metadata to be already set, so an app calling SDL_Init wouldn't have the time to grab the information before calling SDL_SetAppMetadata.

Another option would be to automatically fill the app metadata values with the relevant options within SDL_Init before doing anything else, but this would contradict the documentation for SDL_SetAppMetadataProperty that says the properties have no default value, at least on Ubuntu Touch.

What would be the best to do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants