Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ All commands that load the `:wx` application (compile, test, iex) need a display
| `Desktop.Backend.Json` | `:mobile_target` compile config or `OS.mobile?/0` — JSON bridge via `BRIDGE_PORT` |
| `Desktop.Backend.Browser` | `NO_WX=1` or `:wx` unavailable |

Override with `config :desktop, :backend, :wx | :json | :browser | :auto`.
Override with `config :desktop, :backend, :wx | :json | :browser | :auto` or a custom module.
Custom backends may set `config :desktop, :menu_adapter, Some.Menu.Adapter` (used by `desktop_webview`).

### Platform abstraction (do not regress)

Expand Down
8 changes: 8 additions & 0 deletions guides/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ For a custom implementation, set the backend to a module that implements the `De
config :desktop, :backend, MyApp.DesktopBackend
```

Third-party backends that ship their own menu adapter (for example [`desktop_webview`](https://github.com/elixir-desktop/webview)) should also set:

```elixir
config :desktop, :menu_adapter, DesktopWebview.Menu.Adapter
```

`Desktop.Platform.Menu.adapter/1` prefers `config :desktop, :menu_adapter` when present, then falls back to Wx / Json / DBus / Browser selection.

Restart the app after changing backend config — the router reads `Application.get_env(:desktop, :backend, :auto)` at runtime.

### Environment variables
Expand Down
5 changes: 1 addition & 4 deletions lib/desktop/menu.ex
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,11 @@ defmodule Desktop.Menu do

adapter_module =
case Keyword.get(init_opts, :adapter) do
mod when mod in [Adapter.Wx, Adapter.DBus, Adapter.Json, Adapter.Browser] ->
mod when is_atom(mod) and not is_nil(mod) ->
mod

nil ->
Desktop.Platform.Menu.adapter(init_opts)

_ ->
Desktop.Platform.Menu.adapter(init_opts)
end

adapter_opts =
Expand Down
5 changes: 4 additions & 1 deletion lib/desktop/platform/menu.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ defmodule Desktop.Platform.Menu do
caps = Desktop.Platform.capabilities()

cond do
Keyword.get(opts, :adapter) in [Adapter.Wx, Adapter.DBus, Adapter.Json, Adapter.Browser] ->
mod = Application.get_env(:desktop, :menu_adapter) ->
mod

Keyword.get(opts, :adapter) ->
Keyword.get(opts, :adapter)

Keyword.get(opts, :sni) != nil and Desktop.Platform.backend() == Desktop.Backend.Wx ->
Expand Down
Loading