Skip to content

Commit

Permalink
Handle workspace changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
phkaeser committed Feb 14, 2025
1 parent 3e1e503 commit ac55086
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion doc/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Support for visual effects to improve usability, but not for pure show.
* [done] Available also for X11 windows.
* Available as (hardcoded) application menu.
* Menu with submenus.
* Window menu adapting to window state.
* [done] Window menu adapting to window state.
(Eg. "Maximize" shown when not maximized, otherwise: "restore".)
* When positioning the root menu, keep it entirely within the desktop area.

Expand Down
11 changes: 11 additions & 0 deletions src/tl_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,17 @@ void _wlmaker_tl_menu_handle_window_state_changed(
wlmtk_menu_item_set_enabled(
wlmaker_action_item_menu_item(tl_menu_ptr->unmaximize_ai_ptr),
wlmtk_window_is_maximized(window_ptr));

if (NULL != wlmtk_window_get_workspace(window_ptr)) {
bs_dllist_node_t *ws_dlnode_ptr = wlmtk_dlnode_from_workspace(
wlmtk_window_get_workspace(window_ptr));
wlmtk_menu_item_set_enabled(
wlmaker_action_item_menu_item(tl_menu_ptr->prev_ws_ai_ptr),
NULL != ws_dlnode_ptr->prev_ptr);
wlmtk_menu_item_set_enabled(
wlmaker_action_item_menu_item(tl_menu_ptr->next_ws_ai_ptr),
NULL != ws_dlnode_ptr->next_ptr);
}
}

/* == End of tl_menu.c ===================================================== */
2 changes: 2 additions & 0 deletions src/toolkit/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,8 @@ void wlmtk_window_set_workspace(
wlmtk_workspace_t *workspace_ptr)
{
window_ptr->workspace_ptr = workspace_ptr;

wl_signal_emit(&window_ptr->events.state_changed, window_ptr);
}

/* ------------------------------------------------------------------------- */
Expand Down
3 changes: 3 additions & 0 deletions src/toolkit/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ typedef struct {
* - @ref wlmtk_window_is_fullscreen
* - @ref wlmtk_window_is_shaded
*
* The signal is also raised when the window's workspace is changed.
* Retrieve through @ref wlmtk_window_get_workspace.
*
* data_ptr points to the window state (@ref wlmtk_window_t).
*/
struct wl_signal state_changed;
Expand Down

0 comments on commit ac55086

Please sign in to comment.