|
@@ -42,7 +42,7 @@
|
|
|
struct SDL_TrayMenu {
|
|
|
HMENU hMenu;
|
|
|
|
|
|
- size_t nEntries;
|
|
|
+ int nEntries;
|
|
|
SDL_TrayEntry **entries;
|
|
|
|
|
|
SDL_Tray *parent_tray;
|
|
@@ -75,7 +75,7 @@ static UINT_PTR get_next_id(void)
|
|
|
|
|
|
static SDL_TrayEntry *find_entry_in_menu(SDL_TrayMenu *menu, UINT_PTR id)
|
|
|
{
|
|
|
- for (size_t i = 0; i < menu->nEntries; i++) {
|
|
|
+ for (int i = 0; i < menu->nEntries; i++) {
|
|
|
SDL_TrayEntry *entry = menu->entries[i];
|
|
|
|
|
|
if (entry->id == id) {
|
|
@@ -145,7 +145,7 @@ LRESULT CALLBACK TrayWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar
|
|
|
|
|
|
static void DestroySDLMenu(SDL_TrayMenu *menu)
|
|
|
{
|
|
|
- for (size_t i = 0; i < menu->nEntries; i++) {
|
|
|
+ for (int i = 0; i < menu->nEntries; i++) {
|
|
|
if (menu->entries[i] && menu->entries[i]->submenu) {
|
|
|
DestroySDLMenu(menu->entries[i]->submenu);
|
|
|
}
|
|
@@ -166,8 +166,7 @@ static wchar_t *escape_label(const char *in)
|
|
|
len += (*c == '&') ? 2 : 1;
|
|
|
}
|
|
|
|
|
|
- char *escaped = SDL_malloc(SDL_strlen(in) + len + 1);
|
|
|
-
|
|
|
+ char *escaped = (char *)SDL_malloc(SDL_strlen(in) + len + 1);
|
|
|
if (!escaped) {
|
|
|
return NULL;
|
|
|
}
|
|
@@ -190,7 +189,7 @@ static wchar_t *escape_label(const char *in)
|
|
|
|
|
|
SDL_Tray *SDL_CreateTray(SDL_Surface *icon, const char *tooltip)
|
|
|
{
|
|
|
- SDL_Tray *tray = SDL_malloc(sizeof(SDL_Tray));
|
|
|
+ SDL_Tray *tray = (SDL_Tray *)SDL_malloc(sizeof(*tray));
|
|
|
|
|
|
if (!tray) {
|
|
|
return NULL;
|
|
@@ -273,7 +272,7 @@ void SDL_SetTrayTooltip(SDL_Tray *tray, const char *tooltip)
|
|
|
|
|
|
SDL_TrayMenu *SDL_CreateTrayMenu(SDL_Tray *tray)
|
|
|
{
|
|
|
- tray->menu = SDL_malloc(sizeof(SDL_TrayMenu));
|
|
|
+ tray->menu = (SDL_TrayMenu *)SDL_malloc(sizeof(*tray->menu));
|
|
|
|
|
|
if (!tray->menu) {
|
|
|
return NULL;
|
|
@@ -309,10 +308,9 @@ SDL_TrayMenu *SDL_GetTraySubmenu(SDL_TrayEntry *entry)
|
|
|
const SDL_TrayEntry **SDL_GetTrayEntries(SDL_TrayMenu *menu, int *size)
|
|
|
{
|
|
|
if (size) {
|
|
|
- *size = (int) menu->nEntries;
|
|
|
+ *size = menu->nEntries;
|
|
|
}
|
|
|
-
|
|
|
- return (const SDL_TrayEntry **) menu->entries;
|
|
|
+ return menu->entries;
|
|
|
}
|
|
|
|
|
|
void SDL_RemoveTrayEntry(SDL_TrayEntry *entry)
|
|
@@ -324,7 +322,7 @@ void SDL_RemoveTrayEntry(SDL_TrayEntry *entry)
|
|
|
SDL_TrayMenu *menu = entry->parent;
|
|
|
|
|
|
bool found = false;
|
|
|
- for (size_t i = 0; i < menu->nEntries - 1; i++) {
|
|
|
+ for (int i = 0; i < menu->nEntries - 1; i++) {
|
|
|
if (menu->entries[i] == entry) {
|
|
|
found = true;
|
|
|
}
|
|
@@ -339,7 +337,7 @@ void SDL_RemoveTrayEntry(SDL_TrayEntry *entry)
|
|
|
}
|
|
|
|
|
|
menu->nEntries--;
|
|
|
- SDL_TrayEntry ** new_entries = SDL_realloc(menu->entries, (menu->nEntries + 1) * sizeof(SDL_TrayEntry *));
|
|
|
+ SDL_TrayEntry **new_entries = (SDL_TrayEntry **)SDL_realloc(menu->entries, (menu->nEntries + 1) * sizeof(*new_entries));
|
|
|
|
|
|
/* Not sure why shrinking would fail, but even if it does, we can live with a "too big" array */
|
|
|
if (new_entries) {
|
|
@@ -357,7 +355,7 @@ void SDL_RemoveTrayEntry(SDL_TrayEntry *entry)
|
|
|
|
|
|
SDL_TrayEntry *SDL_InsertTrayEntryAt(SDL_TrayMenu *menu, int pos, const char *label, SDL_TrayEntryFlags flags)
|
|
|
{
|
|
|
- if (pos < -1 || pos > (int) menu->nEntries) {
|
|
|
+ if (pos < -1 || pos > menu->nEntries) {
|
|
|
SDL_InvalidParamError("pos");
|
|
|
return NULL;
|
|
|
}
|
|
@@ -365,13 +363,12 @@ SDL_TrayEntry *SDL_InsertTrayEntryAt(SDL_TrayMenu *menu, int pos, const char *la
|
|
|
int windows_compatible_pos = pos;
|
|
|
|
|
|
if (pos == -1) {
|
|
|
- pos = (int) menu->nEntries;
|
|
|
+ pos = menu->nEntries;
|
|
|
} else if (pos == menu->nEntries) {
|
|
|
windows_compatible_pos = -1;
|
|
|
}
|
|
|
|
|
|
- SDL_TrayEntry *entry = SDL_malloc(sizeof(SDL_TrayEntry));
|
|
|
-
|
|
|
+ SDL_TrayEntry *entry = (SDL_TrayEntry *)SDL_malloc(sizeof(*entry));
|
|
|
if (!entry) {
|
|
|
return NULL;
|
|
|
}
|
|
@@ -391,8 +388,7 @@ SDL_TrayEntry *SDL_InsertTrayEntryAt(SDL_TrayMenu *menu, int pos, const char *la
|
|
|
SDL_snprintf(entry->label_cache, sizeof(entry->label_cache), "%s", label ? label : "");
|
|
|
|
|
|
if (label != NULL && flags & SDL_TRAYENTRY_SUBMENU) {
|
|
|
- entry->submenu = SDL_malloc(sizeof(SDL_TrayMenu));
|
|
|
-
|
|
|
+ entry->submenu = (SDL_TrayMenu *)SDL_malloc(sizeof(*entry->submenu));
|
|
|
if (!entry->submenu) {
|
|
|
SDL_free(entry);
|
|
|
SDL_free(label_w);
|
|
@@ -408,8 +404,7 @@ SDL_TrayEntry *SDL_InsertTrayEntryAt(SDL_TrayMenu *menu, int pos, const char *la
|
|
|
entry->id = get_next_id();
|
|
|
}
|
|
|
|
|
|
- SDL_TrayEntry **new_entries = (SDL_TrayEntry **) SDL_realloc(menu->entries, (menu->nEntries + 2) * sizeof(SDL_TrayEntry **));
|
|
|
-
|
|
|
+ SDL_TrayEntry **new_entries = (SDL_TrayEntry **)SDL_realloc(menu->entries, (menu->nEntries + 2) * sizeof(*new_entries));
|
|
|
if (!new_entries) {
|
|
|
SDL_free(entry);
|
|
|
SDL_free(label_w);
|
|
@@ -423,7 +418,7 @@ SDL_TrayEntry *SDL_InsertTrayEntryAt(SDL_TrayMenu *menu, int pos, const char *la
|
|
|
menu->entries = new_entries;
|
|
|
menu->nEntries++;
|
|
|
|
|
|
- for (int i = (int) menu->nEntries - 1; i > pos; i--) {
|
|
|
+ for (int i = menu->nEntries - 1; i > pos; i--) {
|
|
|
menu->entries[i] = menu->entries[i - 1];
|
|
|
}
|
|
|
|