SDL_tray.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2026 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * # CategoryTray
  20. *
  21. * SDL offers a way to add items to the "system tray" (more correctly called
  22. * the "notification area" on Windows). On platforms that offer this concept,
  23. * an SDL app can add a tray icon, submenus, checkboxes, and clickable
  24. * entries, and register a callback that is fired when the user clicks on
  25. * these pieces.
  26. */
  27. #ifndef SDL_tray_h_
  28. #define SDL_tray_h_
  29. #include <SDL3/SDL_stdinc.h>
  30. #include <SDL3/SDL_error.h>
  31. #include <SDL3/SDL_properties.h>
  32. #include <SDL3/SDL_surface.h>
  33. #include <SDL3/SDL_video.h>
  34. #include <SDL3/SDL_begin_code.h>
  35. /* Set up for C function definitions, even when using C++ */
  36. #ifdef __cplusplus
  37. extern "C" {
  38. #endif
  39. /**
  40. * An opaque handle representing a toplevel system tray object.
  41. *
  42. * \since This struct is available since SDL 3.2.0.
  43. */
  44. typedef struct SDL_Tray SDL_Tray;
  45. /**
  46. * An opaque handle representing a menu/submenu on a system tray object.
  47. *
  48. * \since This struct is available since SDL 3.2.0.
  49. */
  50. typedef struct SDL_TrayMenu SDL_TrayMenu;
  51. /**
  52. * An opaque handle representing an entry on a system tray object.
  53. *
  54. * \since This struct is available since SDL 3.2.0.
  55. */
  56. typedef struct SDL_TrayEntry SDL_TrayEntry;
  57. /**
  58. * Flags that control the creation of system tray entries.
  59. *
  60. * Some of these flags are required; exactly one of them must be specified at
  61. * the time a tray entry is created. Other flags are optional; zero or more of
  62. * those can be OR'ed together with the required flag.
  63. *
  64. * \since This datatype is available since SDL 3.2.0.
  65. *
  66. * \sa SDL_InsertTrayEntryAt
  67. */
  68. typedef Uint32 SDL_TrayEntryFlags;
  69. #define SDL_TRAYENTRY_BUTTON 0x00000001u /**< Make the entry a simple button. Required. */
  70. #define SDL_TRAYENTRY_CHECKBOX 0x00000002u /**< Make the entry a checkbox. Required. */
  71. #define SDL_TRAYENTRY_SUBMENU 0x00000004u /**< Prepare the entry to have a submenu. Required */
  72. #define SDL_TRAYENTRY_DISABLED 0x80000000u /**< Make the entry disabled. Optional. */
  73. #define SDL_TRAYENTRY_CHECKED 0x40000000u /**< Make the entry checked. This is valid only for checkboxes. Optional. */
  74. /**
  75. * A callback that is invoked when a tray entry is selected.
  76. *
  77. * \param userdata an optional pointer to pass extra data to the callback when
  78. * it will be invoked.
  79. * \param entry the tray entry that was selected.
  80. *
  81. * \since This datatype is available since SDL 3.2.0.
  82. *
  83. * \sa SDL_SetTrayEntryCallback
  84. */
  85. typedef void (SDLCALL *SDL_TrayCallback)(void *userdata, SDL_TrayEntry *entry);
  86. /**
  87. * A callback that is invoked when the tray icon is clicked.
  88. *
  89. * \param userdata an optional pointer to pass extra data to the callback when
  90. * it will be invoked. May be NULL.
  91. * \param tray the tray that was clicked.
  92. * \returns true to show the tray menu after the callback returns, false to
  93. * skip showing the menu. This return value is only used for left
  94. * and right click callbacks; other mouse events ignore the return
  95. * value.
  96. *
  97. * \since This datatype is available since SDL 3.6.0.
  98. *
  99. * \sa SDL_CreateTrayWithProperties
  100. */
  101. typedef bool (SDLCALL *SDL_TrayClickCallback)(void *userdata, SDL_Tray *tray);
  102. /**
  103. * Create an icon to be placed in the operating system's tray, or equivalent.
  104. *
  105. * Many platforms advise not using a system tray unless persistence is a
  106. * necessary feature. Avoid needlessly creating a tray icon, as the user may
  107. * feel like it clutters their interface.
  108. *
  109. * Using tray icons require the video subsystem.
  110. *
  111. * \param icon a surface to be used as icon. May be NULL.
  112. * \param tooltip a tooltip to be displayed when the mouse hovers the icon in
  113. * UTF-8 encoding. Not supported on all platforms. May be NULL.
  114. * \returns The newly created system tray icon.
  115. *
  116. * \threadsafety This function should only be called on the main thread.
  117. *
  118. * \since This function is available since SDL 3.2.0.
  119. *
  120. * \sa SDL_CreateTrayWithProperties
  121. * \sa SDL_CreateTrayMenu
  122. * \sa SDL_GetTrayMenu
  123. * \sa SDL_DestroyTray
  124. */
  125. extern SDL_DECLSPEC SDL_Tray * SDLCALL SDL_CreateTray(SDL_Surface *icon, const char *tooltip);
  126. /**
  127. * Create an icon to be placed in the operating system's tray, or equivalent.
  128. *
  129. * Many platforms advise not using a system tray unless persistence is a
  130. * necessary feature. Avoid needlessly creating a tray icon, as the user may
  131. * feel like it clutters their interface.
  132. *
  133. * Using tray icons require the video subsystem.
  134. *
  135. * These are the supported properties:
  136. *
  137. * - `SDL_PROP_TRAY_CREATE_ICON_POINTER`: an SDL_Surface to be used as the
  138. * tray icon. May be NULL.
  139. * - `SDL_PROP_TRAY_CREATE_TOOLTIP_STRING`: a tooltip to be displayed when
  140. * the mouse hovers the icon in UTF-8 encoding. Not supported on all
  141. * platforms. May be NULL.
  142. * - `SDL_PROP_TRAY_CREATE_USERDATA_POINTER`: an optional pointer to
  143. * associate with the tray, which will be passed to click callbacks.
  144. * May be NULL.
  145. * - `SDL_PROP_TRAY_CREATE_LEFTCLICK_CALLBACK_POINTER`: an SDL_TrayClickCallback
  146. * to be invoked when the tray icon is left-clicked. Not supported on all
  147. * platforms. The callback should return true to show the default menu, or
  148. * false to skip showing it. May be NULL.
  149. * - `SDL_PROP_TRAY_CREATE_RIGHTCLICK_CALLBACK_POINTER`: an SDL_TrayClickCallback
  150. * to be invoked when the tray icon is right-clicked. Not supported on all
  151. * platforms. The callback should return true to show the default menu, or
  152. * false to skip showing it. May be NULL.
  153. * - `SDL_PROP_TRAY_CREATE_MIDDLECLICK_CALLBACK_POINTER`: an SDL_TrayClickCallback
  154. * to be invoked when the tray icon is middle-clicked. Not supported on all
  155. * platforms. May be NULL.
  156. * - `SDL_PROP_TRAY_CREATE_DOUBLECLICK_CALLBACK_POINTER`: an SDL_TrayClickCallback
  157. * to be invoked when the tray icon is double-clicked. Not supported on all
  158. * platforms. May be NULL.
  159. *
  160. * \param props the properties to use.
  161. * \returns The newly created system tray icon.
  162. *
  163. * \threadsafety This function should only be called on the main thread.
  164. *
  165. * \since This function is available since SDL 3.6.0.
  166. *
  167. * \sa SDL_CreateTray
  168. * \sa SDL_CreateTrayMenu
  169. * \sa SDL_GetTrayMenu
  170. * \sa SDL_DestroyTray
  171. */
  172. extern SDL_DECLSPEC SDL_Tray * SDLCALL SDL_CreateTrayWithProperties(SDL_PropertiesID props);
  173. #define SDL_PROP_TRAY_CREATE_ICON_POINTER "SDL.tray.create.icon"
  174. #define SDL_PROP_TRAY_CREATE_TOOLTIP_STRING "SDL.tray.create.tooltip"
  175. #define SDL_PROP_TRAY_CREATE_USERDATA_POINTER "SDL.tray.create.userdata"
  176. #define SDL_PROP_TRAY_CREATE_LEFTCLICK_CALLBACK_POINTER "SDL.tray.create.leftclick_callback"
  177. #define SDL_PROP_TRAY_CREATE_RIGHTCLICK_CALLBACK_POINTER "SDL.tray.create.rightclick_callback"
  178. #define SDL_PROP_TRAY_CREATE_MIDDLECLICK_CALLBACK_POINTER "SDL.tray.create.middleclick_callback"
  179. #define SDL_PROP_TRAY_CREATE_DOUBLECLICK_CALLBACK_POINTER "SDL.tray.create.doubleclick_callback"
  180. /**
  181. * Updates the system tray icon's icon.
  182. *
  183. * \param tray the tray icon to be updated.
  184. * \param icon the new icon. May be NULL.
  185. *
  186. * \threadsafety This function should be called on the thread that created the
  187. * tray.
  188. *
  189. * \since This function is available since SDL 3.2.0.
  190. *
  191. * \sa SDL_CreateTray
  192. */
  193. extern SDL_DECLSPEC void SDLCALL SDL_SetTrayIcon(SDL_Tray *tray, SDL_Surface *icon);
  194. /**
  195. * Updates the system tray icon's tooltip.
  196. *
  197. * \param tray the tray icon to be updated.
  198. * \param tooltip the new tooltip in UTF-8 encoding. May be NULL.
  199. *
  200. * \threadsafety This function should be called on the thread that created the
  201. * tray.
  202. *
  203. * \since This function is available since SDL 3.2.0.
  204. *
  205. * \sa SDL_CreateTray
  206. */
  207. extern SDL_DECLSPEC void SDLCALL SDL_SetTrayTooltip(SDL_Tray *tray, const char *tooltip);
  208. /**
  209. * Create a menu for a system tray.
  210. *
  211. * This should be called at most once per tray icon.
  212. *
  213. * This function does the same thing as SDL_CreateTraySubmenu(), except that
  214. * it takes a SDL_Tray instead of a SDL_TrayEntry.
  215. *
  216. * A menu does not need to be destroyed; it will be destroyed with the tray.
  217. *
  218. * \param tray the tray to bind the menu to.
  219. * \returns the newly created menu.
  220. *
  221. * \threadsafety This function should be called on the thread that created the
  222. * tray.
  223. *
  224. * \since This function is available since SDL 3.2.0.
  225. *
  226. * \sa SDL_CreateTray
  227. * \sa SDL_GetTrayMenu
  228. * \sa SDL_GetTrayMenuParentTray
  229. */
  230. extern SDL_DECLSPEC SDL_TrayMenu * SDLCALL SDL_CreateTrayMenu(SDL_Tray *tray);
  231. /**
  232. * Create a submenu for a system tray entry.
  233. *
  234. * This should be called at most once per tray entry.
  235. *
  236. * This function does the same thing as SDL_CreateTrayMenu, except that it
  237. * takes a SDL_TrayEntry instead of a SDL_Tray.
  238. *
  239. * A menu does not need to be destroyed; it will be destroyed with the tray.
  240. *
  241. * \param entry the tray entry to bind the menu to.
  242. * \returns the newly created menu.
  243. *
  244. * \threadsafety This function should be called on the thread that created the
  245. * tray.
  246. *
  247. * \since This function is available since SDL 3.2.0.
  248. *
  249. * \sa SDL_InsertTrayEntryAt
  250. * \sa SDL_GetTraySubmenu
  251. * \sa SDL_GetTrayMenuParentEntry
  252. */
  253. extern SDL_DECLSPEC SDL_TrayMenu * SDLCALL SDL_CreateTraySubmenu(SDL_TrayEntry *entry);
  254. /**
  255. * Gets a previously created tray menu.
  256. *
  257. * You should have called SDL_CreateTrayMenu() on the tray object. This
  258. * function allows you to fetch it again later.
  259. *
  260. * This function does the same thing as SDL_GetTraySubmenu(), except that it
  261. * takes a SDL_Tray instead of a SDL_TrayEntry.
  262. *
  263. * A menu does not need to be destroyed; it will be destroyed with the tray.
  264. *
  265. * \param tray the tray entry to bind the menu to.
  266. * \returns the newly created menu.
  267. *
  268. * \threadsafety This function should be called on the thread that created the
  269. * tray.
  270. *
  271. * \since This function is available since SDL 3.2.0.
  272. *
  273. * \sa SDL_CreateTray
  274. * \sa SDL_CreateTrayMenu
  275. */
  276. extern SDL_DECLSPEC SDL_TrayMenu * SDLCALL SDL_GetTrayMenu(SDL_Tray *tray);
  277. /**
  278. * Gets a previously created tray entry submenu.
  279. *
  280. * You should have called SDL_CreateTraySubmenu() on the entry object. This
  281. * function allows you to fetch it again later.
  282. *
  283. * This function does the same thing as SDL_GetTrayMenu(), except that it
  284. * takes a SDL_TrayEntry instead of a SDL_Tray.
  285. *
  286. * A menu does not need to be destroyed; it will be destroyed with the tray.
  287. *
  288. * \param entry the tray entry to bind the menu to.
  289. * \returns the newly created menu.
  290. *
  291. * \threadsafety This function should be called on the thread that created the
  292. * tray.
  293. *
  294. * \since This function is available since SDL 3.2.0.
  295. *
  296. * \sa SDL_InsertTrayEntryAt
  297. * \sa SDL_CreateTraySubmenu
  298. */
  299. extern SDL_DECLSPEC SDL_TrayMenu * SDLCALL SDL_GetTraySubmenu(SDL_TrayEntry *entry);
  300. /**
  301. * Returns a list of entries in the menu, in order.
  302. *
  303. * \param menu The menu to get entries from.
  304. * \param count An optional pointer to obtain the number of entries in the
  305. * menu.
  306. * \returns a NULL-terminated list of entries within the given menu. The
  307. * pointer becomes invalid when any function that inserts or deletes
  308. * entries in the menu is called.
  309. *
  310. * \threadsafety This function should be called on the thread that created the
  311. * tray.
  312. *
  313. * \since This function is available since SDL 3.2.0.
  314. *
  315. * \sa SDL_RemoveTrayEntry
  316. * \sa SDL_InsertTrayEntryAt
  317. */
  318. extern SDL_DECLSPEC const SDL_TrayEntry ** SDLCALL SDL_GetTrayEntries(SDL_TrayMenu *menu, int *count);
  319. /**
  320. * Removes a tray entry.
  321. *
  322. * \param entry The entry to be deleted.
  323. *
  324. * \threadsafety This function should be called on the thread that created the
  325. * tray.
  326. *
  327. * \since This function is available since SDL 3.2.0.
  328. *
  329. * \sa SDL_GetTrayEntries
  330. * \sa SDL_InsertTrayEntryAt
  331. */
  332. extern SDL_DECLSPEC void SDLCALL SDL_RemoveTrayEntry(SDL_TrayEntry *entry);
  333. /**
  334. * Insert a tray entry at a given position.
  335. *
  336. * If label is NULL, the entry will be a separator. Many functions won't work
  337. * for an entry that is a separator.
  338. *
  339. * An entry does not need to be destroyed; it will be destroyed with the tray.
  340. *
  341. * \param menu the menu to append the entry to.
  342. * \param pos the desired position for the new entry. Entries at or following
  343. * this place will be moved. If pos is -1, the entry is appended.
  344. * \param label the text to be displayed on the entry, in UTF-8 encoding, or
  345. * NULL for a separator.
  346. * \param flags a combination of flags, some of which are mandatory.
  347. * \returns the newly created entry, or NULL if pos is out of bounds.
  348. *
  349. * \threadsafety This function should be called on the thread that created the
  350. * tray.
  351. *
  352. * \since This function is available since SDL 3.2.0.
  353. *
  354. * \sa SDL_TrayEntryFlags
  355. * \sa SDL_GetTrayEntries
  356. * \sa SDL_RemoveTrayEntry
  357. * \sa SDL_GetTrayEntryParent
  358. */
  359. extern SDL_DECLSPEC SDL_TrayEntry * SDLCALL SDL_InsertTrayEntryAt(SDL_TrayMenu *menu, int pos, const char *label, SDL_TrayEntryFlags flags);
  360. /**
  361. * Sets the label of an entry.
  362. *
  363. * An entry cannot change between a separator and an ordinary entry; that is,
  364. * it is not possible to set a non-NULL label on an entry that has a NULL
  365. * label (separators), or to set a NULL label to an entry that has a non-NULL
  366. * label. The function will silently fail if that happens.
  367. *
  368. * \param entry the entry to be updated.
  369. * \param label the new label for the entry in UTF-8 encoding.
  370. *
  371. * \threadsafety This function should be called on the thread that created the
  372. * tray.
  373. *
  374. * \since This function is available since SDL 3.2.0.
  375. *
  376. * \sa SDL_GetTrayEntries
  377. * \sa SDL_InsertTrayEntryAt
  378. * \sa SDL_GetTrayEntryLabel
  379. */
  380. extern SDL_DECLSPEC void SDLCALL SDL_SetTrayEntryLabel(SDL_TrayEntry *entry, const char *label);
  381. /**
  382. * Gets the label of an entry.
  383. *
  384. * If the returned value is NULL, the entry is a separator.
  385. *
  386. * \param entry the entry to be read.
  387. * \returns the label of the entry in UTF-8 encoding.
  388. *
  389. * \threadsafety This function should be called on the thread that created the
  390. * tray.
  391. *
  392. * \since This function is available since SDL 3.2.0.
  393. *
  394. * \sa SDL_GetTrayEntries
  395. * \sa SDL_InsertTrayEntryAt
  396. * \sa SDL_SetTrayEntryLabel
  397. */
  398. extern SDL_DECLSPEC const char * SDLCALL SDL_GetTrayEntryLabel(SDL_TrayEntry *entry);
  399. /**
  400. * Sets whether or not an entry is checked.
  401. *
  402. * The entry must have been created with the SDL_TRAYENTRY_CHECKBOX flag.
  403. *
  404. * \param entry the entry to be updated.
  405. * \param checked true if the entry should be checked; false otherwise.
  406. *
  407. * \threadsafety This function should be called on the thread that created the
  408. * tray.
  409. *
  410. * \since This function is available since SDL 3.2.0.
  411. *
  412. * \sa SDL_GetTrayEntries
  413. * \sa SDL_InsertTrayEntryAt
  414. * \sa SDL_GetTrayEntryChecked
  415. */
  416. extern SDL_DECLSPEC void SDLCALL SDL_SetTrayEntryChecked(SDL_TrayEntry *entry, bool checked);
  417. /**
  418. * Gets whether or not an entry is checked.
  419. *
  420. * The entry must have been created with the SDL_TRAYENTRY_CHECKBOX flag.
  421. *
  422. * \param entry the entry to be read.
  423. * \returns true if the entry is checked; false otherwise.
  424. *
  425. * \threadsafety This function should be called on the thread that created the
  426. * tray.
  427. *
  428. * \since This function is available since SDL 3.2.0.
  429. *
  430. * \sa SDL_GetTrayEntries
  431. * \sa SDL_InsertTrayEntryAt
  432. * \sa SDL_SetTrayEntryChecked
  433. */
  434. extern SDL_DECLSPEC bool SDLCALL SDL_GetTrayEntryChecked(SDL_TrayEntry *entry);
  435. /**
  436. * Sets whether or not an entry is enabled.
  437. *
  438. * \param entry the entry to be updated.
  439. * \param enabled true if the entry should be enabled; false otherwise.
  440. *
  441. * \threadsafety This function should be called on the thread that created the
  442. * tray.
  443. *
  444. * \since This function is available since SDL 3.2.0.
  445. *
  446. * \sa SDL_GetTrayEntries
  447. * \sa SDL_InsertTrayEntryAt
  448. * \sa SDL_GetTrayEntryEnabled
  449. */
  450. extern SDL_DECLSPEC void SDLCALL SDL_SetTrayEntryEnabled(SDL_TrayEntry *entry, bool enabled);
  451. /**
  452. * Gets whether or not an entry is enabled.
  453. *
  454. * \param entry the entry to be read.
  455. * \returns true if the entry is enabled; false otherwise.
  456. *
  457. * \threadsafety This function should be called on the thread that created the
  458. * tray.
  459. *
  460. * \since This function is available since SDL 3.2.0.
  461. *
  462. * \sa SDL_GetTrayEntries
  463. * \sa SDL_InsertTrayEntryAt
  464. * \sa SDL_SetTrayEntryEnabled
  465. */
  466. extern SDL_DECLSPEC bool SDLCALL SDL_GetTrayEntryEnabled(SDL_TrayEntry *entry);
  467. /**
  468. * Sets a callback to be invoked when the entry is selected.
  469. *
  470. * \param entry the entry to be updated.
  471. * \param callback a callback to be invoked when the entry is selected.
  472. * \param userdata an optional pointer to pass extra data to the callback when
  473. * it will be invoked.
  474. *
  475. * \threadsafety This function should be called on the thread that created the
  476. * tray.
  477. *
  478. * \since This function is available since SDL 3.2.0.
  479. *
  480. * \sa SDL_GetTrayEntries
  481. * \sa SDL_InsertTrayEntryAt
  482. */
  483. extern SDL_DECLSPEC void SDLCALL SDL_SetTrayEntryCallback(SDL_TrayEntry *entry, SDL_TrayCallback callback, void *userdata);
  484. /**
  485. * Simulate a click on a tray entry.
  486. *
  487. * \param entry The entry to activate.
  488. *
  489. * \threadsafety This function should be called on the thread that created the
  490. * tray.
  491. *
  492. * \since This function is available since SDL 3.2.0.
  493. */
  494. extern SDL_DECLSPEC void SDLCALL SDL_ClickTrayEntry(SDL_TrayEntry *entry);
  495. /**
  496. * Destroys a tray object.
  497. *
  498. * This also destroys all associated menus and entries.
  499. *
  500. * \param tray the tray icon to be destroyed.
  501. *
  502. * \threadsafety This function should be called on the thread that created the
  503. * tray.
  504. *
  505. * \since This function is available since SDL 3.2.0.
  506. *
  507. * \sa SDL_CreateTray
  508. */
  509. extern SDL_DECLSPEC void SDLCALL SDL_DestroyTray(SDL_Tray *tray);
  510. /**
  511. * Gets the menu containing a certain tray entry.
  512. *
  513. * \param entry the entry for which to get the parent menu.
  514. * \returns the parent menu.
  515. *
  516. * \threadsafety This function should be called on the thread that created the
  517. * tray.
  518. *
  519. * \since This function is available since SDL 3.2.0.
  520. *
  521. * \sa SDL_InsertTrayEntryAt
  522. */
  523. extern SDL_DECLSPEC SDL_TrayMenu * SDLCALL SDL_GetTrayEntryParent(SDL_TrayEntry *entry);
  524. /**
  525. * Gets the entry for which the menu is a submenu, if the current menu is a
  526. * submenu.
  527. *
  528. * Either this function or SDL_GetTrayMenuParentTray() will return non-NULL
  529. * for any given menu.
  530. *
  531. * \param menu the menu for which to get the parent entry.
  532. * \returns the parent entry, or NULL if this menu is not a submenu.
  533. *
  534. * \threadsafety This function should be called on the thread that created the
  535. * tray.
  536. *
  537. * \since This function is available since SDL 3.2.0.
  538. *
  539. * \sa SDL_CreateTraySubmenu
  540. * \sa SDL_GetTrayMenuParentTray
  541. */
  542. extern SDL_DECLSPEC SDL_TrayEntry * SDLCALL SDL_GetTrayMenuParentEntry(SDL_TrayMenu *menu);
  543. /**
  544. * Gets the tray for which this menu is the first-level menu, if the current
  545. * menu isn't a submenu.
  546. *
  547. * Either this function or SDL_GetTrayMenuParentEntry() will return non-NULL
  548. * for any given menu.
  549. *
  550. * \param menu the menu for which to get the parent enttrayry.
  551. * \returns the parent tray, or NULL if this menu is a submenu.
  552. *
  553. * \threadsafety This function should be called on the thread that created the
  554. * tray.
  555. *
  556. * \since This function is available since SDL 3.2.0.
  557. *
  558. * \sa SDL_CreateTrayMenu
  559. * \sa SDL_GetTrayMenuParentEntry
  560. */
  561. extern SDL_DECLSPEC SDL_Tray * SDLCALL SDL_GetTrayMenuParentTray(SDL_TrayMenu *menu);
  562. /**
  563. * Update the trays.
  564. *
  565. * This is called automatically by the event loop and is only needed if you're
  566. * using trays but aren't handling SDL events.
  567. *
  568. * \threadsafety This function should only be called on the main thread.
  569. *
  570. * \since This function is available since SDL 3.2.0.
  571. */
  572. extern SDL_DECLSPEC void SDLCALL SDL_UpdateTrays(void);
  573. /* Ends C function definitions when using C++ */
  574. #ifdef __cplusplus
  575. }
  576. #endif
  577. #include <SDL3/SDL_close_code.h>
  578. #endif /* SDL_tray_h_ */