Skip to content

Commit 6fada47

Browse files
committed
WM menu: move wMenuItemWithTitle to menu.c
1 parent 0502885 commit 6fada47

4 files changed

Lines changed: 29 additions & 20 deletions

File tree

Applications/Workspace/WM/appmenu.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -785,18 +785,6 @@ void wApplicationMenuShow(WMenu *menu)
785785
}
786786
}
787787

788-
WMenuItem *wMenuItemWithTitle(WMenu *menu, char *title)
789-
{
790-
WMenuItem **items = menu->items;
791-
792-
for (int i = 0; i < menu->items_count; i++) {
793-
if (!strcmp(items[i]->text, title)) {
794-
return items[i];
795-
}
796-
}
797-
return NULL;
798-
}
799-
800788
// Menu state
801789
//--------------------------------------------------------------------------------------------------
802790

Applications/Workspace/WM/appmenu.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,5 @@ void wApplicationMenuShow(WMenu *menu);
3535
void wApplicationMenuSaveState(WMenu *main_menu, CFMutableArrayRef menus_state);
3636
void wApplicationMenuRestoreFromState(WMenu *menu, CFArrayRef state);
3737

38-
WMenuItem *wMenuItemWithTitle(WMenu *menu, char *title);
39-
4038
void wApplicationMenuSetKeyGrabs(WWindow *wwin);
4139
Bool wApplicationMenuHandleKeyPress(struct WWindow *focused_window, XEvent *event);

Applications/Workspace/WM/menu.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,3 +2198,24 @@ void wMenuRestoreState(WScreen *scr)
21982198

21992199
restoreMenu(scr, menu);
22002200
}
2201+
2202+
WMenuItem *wMenuItemWithTitle(WMenu *menu, char *title)
2203+
{
2204+
WMenuItem *item = NULL;
2205+
2206+
for (short i = 0; i < menu->items_count; i++) {
2207+
item = menu->items[i];
2208+
if (strcmp(item->text, title) == 0) {
2209+
break;
2210+
}
2211+
if (item->submenu_index >= 0) {
2212+
item = wMenuItemWithTitle(menu->submenus[item->submenu_index], title);
2213+
if (item) {
2214+
break;
2215+
}
2216+
}
2217+
item = NULL;
2218+
}
2219+
2220+
return item;
2221+
}

Applications/Workspace/WM/menu.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@ typedef struct WMenu {
8383
void (*on_destroy)(struct WMenu *menu);
8484

8585
struct {
86-
unsigned int titled : 1;
86+
unsigned int titled : 1;
8787
unsigned int realized : 1; /* whether the window was configured */
8888
unsigned int restored : 1; /* whether the menu was restored from saved state */
8989
unsigned int app_menu : 1; /* this is a application or root menu */
90-
unsigned int mapped : 1; /* if menu is already mapped on screen*/
91-
unsigned int hidden : 1; /* if menu was hidden on app deactivation */
92-
unsigned int tornoff : 1; /* if the close button is visible (menu was torn off) */
93-
unsigned int lowered : 1;
94-
unsigned int brother : 1; /* if this is a copy of the menu */
90+
unsigned int mapped : 1; /* if menu is already mapped on screen*/
91+
unsigned int hidden : 1; /* if menu was hidden on app deactivation */
92+
unsigned int tornoff : 1; /* if the close button is visible (menu was torn off) */
93+
unsigned int lowered : 1;
94+
unsigned int brother : 1; /* if this is a copy of the menu */
9595
} flags;
9696
} WMenu;
9797

@@ -128,4 +128,6 @@ WMenu *wMenuUnderPointer(WScreen *screen);
128128
void wMenuSaveState(WScreen *scr);
129129
void wMenuRestoreState(WScreen *scr);
130130

131+
WMenuItem *wMenuItemWithTitle(WMenu *menu, char *title);
132+
131133
#endif /* __WORKSPACE_WM_MENU__ */

0 commit comments

Comments
 (0)