File 0205-observer-Call-original-event-handlers-for-menu-comma.patch of Package erlang

From bd4e2801658045967e3994a0ef0dfa538630c005 Mon Sep 17 00:00:00 2001
From: Wojtek Mach <wojtek@wojtekmach.pl>
Date: Thu, 17 Mar 2022 13:58:40 +0100
Subject: [PATCH 2/3] observer: Call original event handlers for menu commands

This is important for macOS where by default we get the "App menu" with:

- Services
- Hide <app>
- Hide Others
- Show All
- Quit <app>

Before this patch, "Hide <app>", "Hide Others", and "Show All" are not
doing anything. This is what we get when clicking "Hide <app>":

    observer_sys_wx:238: Unhandled event {wx,5250,
                                          {wx_ref,35,wxFrame,[]},
                                          [],
                                          {wxCommand,command_menu_selected,[],-1,
                                           0}}

After this patch, the original (system-level) event handlers are fired
and on the Erlang side we can simply ignore these events.
---
 lib/observer/src/observer_wx.erl | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/observer/src/observer_wx.erl b/lib/observer/src/observer_wx.erl
index 07e2fb1b29..bd59229c01 100644
--- a/lib/observer/src/observer_wx.erl
+++ b/lib/observer/src/observer_wx.erl
@@ -157,7 +157,7 @@ setup(#state{frame = Frame} = State) ->
     wxNotebook:connect(Notebook, command_notebook_page_changed,
                        [{skip, true}, {id, ?ID_NOTEBOOK}]),
     wxFrame:connect(Frame, close_window, []),
-    wxMenu:connect(Frame, command_menu_selected),
+    wxMenu:connect(Frame, command_menu_selected, [{skip, true}]),
     wxFrame:show(Frame),
 
     %% Freeze and thaw is buggy currently
@@ -390,6 +390,10 @@ handle_event(#wx{id = Id, event = #wxCommand{type = command_menu_selected}},
              end,
     {noreply, change_node_view(Node, LState)};
 
+handle_event(#wx{id = Id, event = #wxCommand{type = command_menu_selected}}, State)
+  when Id >= ?wxID_OSX_MENU_FIRST, Id =< ?wxID_OSX_MENU_LAST ->
+    {noreply, State};
+
 handle_event(Event, #state{active_tab=Pid} = State) ->
     Pid ! Event,
     {noreply, State}.
-- 
2.34.1

openSUSE Build Service is sponsored by