We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3325 - MISSING: a reliable method to determine if window opacity is supported on the user's platform
Summary: MISSING: a reliable method to determine if window opacity is supported on the...
Status: NEW
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.4
Hardware: x86 All
: P2 minor
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-09 00:50 UTC by Intellectual Kitty
Modified: 2016-05-09 00:50 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Intellectual Kitty 2016-05-09 00:50:23 UTC
Setting window opacity is not supported on all platforms.  There is currently no way to determine if the user's platform supports window opacity other than calling SDL_SetWindowOpacity() and seeing if an error occurs.  However, setting window opacity may also fail for reasons other than that it is not supported on the user's platform, which makes it difficult to determine at runtime if the failure is because of a lack of support or because of another problem.

Currently I'm using code that compares the result from SDL_GetError() to the string "That operation is not supported" (which I found hardcoded in the file src/SDL_error.c) in an attempt to determine if setting opacity is unsupported.  However, this is not a particularly reliable solution, especially if that string should change in the future.

An ideal solution to this problem would be providing a function to specifically determine if setting window opacity is supported on the current platform; in that case, a developer could avoid calling SDL_SetWindowOpacity() in the first place and also avoid providing the user with such an option.

A less ideal but still workable solution would be to provide a reliable numerical error code from SDL_SetWindowOpacity() that indicates that the operation is not supported on the current platform.  This is less desirable than the former solution since you would have to call SDL_SetWindowOpacity() with an opacity of 1.0 and check for an operation unsupported error code in order to test if setting window opacity is supported, but nevertheless it is still a workable solution.