Skip to content

Commit

Permalink
Add window menu also to X11 windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
phkaeser committed Jan 7, 2025
1 parent 3e74fdd commit 9ab0d2f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion doc/ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Support for visual effects to improve usability, but not for pure show.
* [done] Menu shown on right-button-down, items trigger on right-button-up.
* [done] When invoked on unclaimed button, exits menu on button release.
* [done] Available as window menu in windows.
* Available also for X11 windows.
* [done] Available also for X11 windows.
* Available as (hardcoded) application menu.
* Menu with submenus.
* Window menu adapting to window state.
Expand Down
1 change: 0 additions & 1 deletion src/tl_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ wlmaker_tl_menu_t *wlmaker_tl_menu_create(
wlmaker_action_item_menu_item(action_item_ptr));
}


return tl_menu_ptr;
}

Expand Down
8 changes: 6 additions & 2 deletions src/toolkit/content.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ bool wlmtk_content_init(
&content_ptr->super_container.super_element,
&_wlmtk_content_element_vmt);

wlmtk_content_set_element(content_ptr, element_ptr);

if (!wlmtk_container_init(&content_ptr->popup_container, env_ptr)) {
wlmtk_content_fini(content_ptr);
return false;
Expand All @@ -73,6 +71,8 @@ bool wlmtk_content_init(
&content_ptr->popup_container.super_element,
true);

wlmtk_content_set_element(content_ptr, element_ptr);

return true;
}

Expand Down Expand Up @@ -123,6 +123,10 @@ void wlmtk_content_set_element(
content_ptr->element_ptr = element_ptr;
wlmtk_element_set_visible(element_ptr, true);

// FIXME
wlmtk_container_raise_element_to_top(
&content_ptr->super_container,
&content_ptr->popup_container.super_element);
}
}

Expand Down
8 changes: 3 additions & 5 deletions src/xdg_toplevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,17 @@ wlmtk_window_t *wlmtk_window_create_from_xdg_toplevel(
xdg_toplevel_surface_destroy(surface_ptr);
return NULL;
}
wl_signal_emit(&server_ptr->window_created_event, wlmtk_window_ptr);

bs_log(BS_INFO, "Created window %p for wlmtk XDG toplevel surface %p",
wlmtk_window_ptr, surface_ptr);

// FIXME:
surface_ptr->tl_menu_ptr = wlmaker_tl_menu_create(
wlmtk_window_ptr, server_ptr);
if (NULL == surface_ptr->tl_menu_ptr) {
xdg_toplevel_surface_destroy(surface_ptr);
return NULL;
}

wl_signal_emit(&server_ptr->window_created_event, wlmtk_window_ptr);
bs_log(BS_INFO, "Created window %p for wlmtk XDG toplevel surface %p",
wlmtk_window_ptr, surface_ptr);
return wlmtk_window_ptr;
}

Expand Down
19 changes: 19 additions & 0 deletions src/xwl_toplevel.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include "xwl_toplevel.h"

#include "tl_menu.h"

/* == Declarations ========================================================= */

/** State of a XWayland toplevel window. */
Expand All @@ -31,6 +33,9 @@ struct _wlmaker_xwl_toplevel_t {
/** Back-link to server. */
wlmaker_server_t *server_ptr;

/** The toplevel's window menu. */
wlmaker_tl_menu_t *tl_menu_ptr;

/** Listener for `map` event of the surface. */
struct wl_listener surface_map_listener;
/** Listener for `unmap` event of the surface. */
Expand Down Expand Up @@ -66,6 +71,15 @@ wlmaker_xwl_toplevel_t *wlmaker_xwl_toplevel_create(
wlmaker_xwl_toplevel_destroy(xwl_toplevel_ptr);
return NULL;
}

xwl_toplevel_ptr->tl_menu_ptr = wlmaker_tl_menu_create(
xwl_toplevel_ptr->window_ptr,
server_ptr);
if (NULL == xwl_toplevel_ptr->tl_menu_ptr) {
wlmaker_xwl_toplevel_destroy(xwl_toplevel_ptr);
return NULL;
}

wl_signal_emit(&server_ptr->window_created_event,
xwl_toplevel_ptr->window_ptr);

Expand Down Expand Up @@ -98,6 +112,11 @@ void wlmaker_xwl_toplevel_destroy(
wl_list_remove(&xwl_toplevel_ptr->surface_unmap_listener.link);
wl_list_remove(&xwl_toplevel_ptr->surface_map_listener.link);

if (NULL != xwl_toplevel_ptr->tl_menu_ptr) {
wlmaker_tl_menu_destroy(xwl_toplevel_ptr->tl_menu_ptr);
xwl_toplevel_ptr->tl_menu_ptr = NULL;
}

free(xwl_toplevel_ptr);
}

Expand Down

0 comments on commit 9ab0d2f

Please sign in to comment.