瀏覽代碼

Revert "Add SDL_IsTraySupported"

This reverts commit 47d8bdd1c3e9c799ecaa7cb10d84ae8d88165b5c.

There are runtime reasons why creating a tray can fail, so the correct approach is not to assume that just because a platform supports a tray that trays are available. Instead, you should create a tray at application startup, for the lifetime of the application, and handle failures at that point.

Closes https://github.com/libsdl-org/SDL/pull/13632
Sam Lantinga 1 月之前
父節點
當前提交
9a71e3fd50

+ 0 - 19
include/SDL3/SDL_tray.h

@@ -96,25 +96,6 @@ typedef Uint32 SDL_TrayEntryFlags;
  */
 typedef void (SDLCALL *SDL_TrayCallback)(void *userdata, SDL_TrayEntry *entry);
 
-/**
- * Check whether or not tray icons can be created.
- *
- * Note that this function does not guarantee that SDL_CreateTray() will or
- * will not work; you should still check SDL_CreateTray() for errors.
- *
- * Using tray icons require the video subsystem.
- *
- * \returns true if trays are available, false otherwise.
- *
- * \threadsafety This function should only be called on the main thread. It
- *               will return false if not called on the main thread.
- *
- * \since This function is available since SDL 3.4.0.
- *
- * \sa SDL_CreateTray
- */
-extern SDL_DECLSPEC bool SDLCALL SDL_IsTraySupported(void);
-
 /**
  * Create an icon to be placed in the operating system's tray, or equivalent.
  *

+ 0 - 1
src/dynapi/SDL_dynapi.sym

@@ -1253,7 +1253,6 @@ SDL3_0.0.0 {
     SDL_PutAudioStreamPlanarData;
     SDL_GetEventDescription;
     SDL_PutAudioStreamDataNoCopy;
-    SDL_IsTraySupported;
     # extra symbols go here (don't modify this line)
   local: *;
 };

+ 0 - 1
src/dynapi/SDL_dynapi_overrides.h

@@ -1278,4 +1278,3 @@
 #define SDL_PutAudioStreamPlanarData SDL_PutAudioStreamPlanarData_REAL
 #define SDL_GetEventDescription SDL_GetEventDescription_REAL
 #define SDL_PutAudioStreamDataNoCopy SDL_PutAudioStreamDataNoCopy_REAL
-#define SDL_IsTraySupported SDL_IsTraySupported_REAL

+ 0 - 1
src/dynapi/SDL_dynapi_procs.h

@@ -1286,4 +1286,3 @@ SDL_DYNAPI_PROC(SDL_Renderer*,SDL_CreateGPURenderer,(SDL_Window *a,SDL_GPUShader
 SDL_DYNAPI_PROC(bool,SDL_PutAudioStreamPlanarData,(SDL_AudioStream *a,const void * const*b,int c,int d),(a,b,c,d),return)
 SDL_DYNAPI_PROC(int,SDL_GetEventDescription,(const SDL_Event *a,char *b,int c),(a,b,c),return)
 SDL_DYNAPI_PROC(bool,SDL_PutAudioStreamDataNoCopy,(SDL_AudioStream *a,const void *b,int c,SDL_AudioStreamDataCompleteCallback d,void *e),(a,b,c,d,e),return)
-SDL_DYNAPI_PROC(bool,SDL_IsTraySupported,(void),(),return)

+ 0 - 10
src/tray/cocoa/SDL_tray.m

@@ -82,16 +82,6 @@ void SDL_UpdateTrays(void)
 {
 }
 
-bool SDL_IsTraySupported(void)
-{
-    if (!SDL_IsMainThread()) {
-        SDL_SetError("This function should be called on the main thread");
-        return false;
-    }
-
-    return true;
-}
-
 SDL_Tray *SDL_CreateTray(SDL_Surface *icon, const char *tooltip)
 {
     if (!SDL_IsMainThread()) {

+ 0 - 5
src/tray/dummy/SDL_tray.c

@@ -29,11 +29,6 @@ void SDL_UpdateTrays(void)
 {
 }
 
-bool SDL_IsTraySupported(void)
-{
-    return false;
-}
-
 SDL_Tray *SDL_CreateTray(SDL_Surface *icon, const char *tooltip)
 {
     SDL_Unsupported();

+ 0 - 18
src/tray/unix/SDL_tray.c

@@ -240,24 +240,6 @@ void SDL_UpdateTrays(void)
     SDL_UpdateGtk();
 }
 
-bool SDL_IsTraySupported(void)
-{
-    if (!SDL_IsMainThread()) {
-        SDL_SetError("This function should be called on the main thread");
-        return false;
-    }
-
-    static bool has_trays = false;
-    static bool has_been_detected_once = false;
-
-    if (!has_been_detected_once) {
-        has_trays = init_appindicator() && SDL_Gtk_Init();
-        has_been_detected_once = true;
-    }
-
-    return has_trays;
-}
-
 SDL_Tray *SDL_CreateTray(SDL_Surface *icon, const char *tooltip)
 {
     if (!SDL_IsMainThread()) {

+ 0 - 10
src/tray/windows/SDL_tray.c

@@ -216,16 +216,6 @@ void SDL_UpdateTrays(void)
 {
 }
 
-bool SDL_IsTraySupported(void)
-{
-    if (!SDL_IsMainThread()) {
-        SDL_SetError("This function should be called on the main thread");
-        return false;
-    }
-
-    return true;
-}
-
 SDL_Tray *SDL_CreateTray(SDL_Surface *icon, const char *tooltip)
 {
     if (!SDL_IsMainThread()) {