Fl4m3Ph03n1x
Desktop App does not close and always reopens
Background
I have a basic Desktop app with the following config:
application.ex
defmodule WebInterface.Application do
use Application
alias Desktop
alias Manager
alias WebInterface.{Endpoint, PubSub, Telemetry}
@impl true
def start(_type, _args) do
children = [
Telemetry,
{Phoenix.PubSub, name: PubSub},
Endpoint,
Manager,
{Desktop.Window,
[
app: :web_interface,
id: WebInterface,
title: "Market Manager",
size: {900, 900},
icon: "static/images/resized_logo_5_32x32.png",
url: &WebInterface.Endpoint.url/0
]}
]
opts = [strategy: :one_for_one, name: WebInterface.Supervisor]
Supervisor.start_link(children, opts)
end
@impl true
def config_change(changed, _new, removed) do
WebInterface.Endpoint.config_change(changed, removed)
:ok
end
end
This is basically the default configuration. You will notice the desktop app does not have a MenuBar. This is on purpose, as I don’t want one.
Problem
The issue here is that no matter what, the application won’t close:

It always reopens.
After checking the code of Desktop, I believe the issue could be in Desktop.Window:
def init(options) do
window_title = options[:title] || Atom.to_string(options[:id])
size = options[:size] || {600, 500}
min_size = options[:min_size]
app = options[:app]
icon = options[:icon]
taskbar_icon = options[:taskbar_icon]
# not supported on mobile atm
menubar = unless OS.mobile?(), do: options[:menubar]
Namely, I am lead to believe there is a difference for Mobile apps and normal apps.
Funnily enough, if add a MenuBar, then the application does eventually close, even though it takes forever for the process behind it to terminate:
{Desktop.Window,
[
app: :web_interface,
id: WebInterface,
title: "Market Manager",
size: WindowUtils.calculate_window_size(0.4, 0.7),
menubar: MenuBar,
icon: "static/images/resized_logo_5_32x32.png",
url: &WebInterface.Endpoint.url/0
]}
Cliking on the Menubar Quit option also closes the application.
Questions
Am I forced to have a Menubar, if my I have a Desktop app?
How can this be fixed?
Most Liked
al2o3cr
The “close window” icon and the “Quit” menu item do quite different things:
-
the “Quit” menu item ends up calling
Window.quit/0, which ultimatelykill -9s the BEAM from outside (!!). -
the “close window” icon ends up calling
Window.close_window/2which returns{:stop, :normal, ui}- which will result in the parentSupervisorrestarting theWindowprocess.Setting the
Desktop.Windowprocess torestart: :transientwould be prevent this restart.
Not sure how the menu bar ties into this, tho… ![]()
Popular in Questions
Other popular topics
Latest Phoenix Threads
Latest in /Elixir Desktop
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








