feat: migrate custom macOS tray view to native one (#18981)

* restore stash

revert

some things work others dont

tracking area for rescue

manual popup

restore drag n drop

cleanup

* fix: make tray not block main process (#18880)

* fix: make tray not block main process

* make AtomMenuModel refcounted

* add support for ansi codes in title

add remove TODOs

* chore: use ScopedPumpMessagesInPrivateModes in tray (#18977)

* chore: use ScopedPumpMessagesInPrivateModes in tray

* revert refcounting of AtomMenuModel

* Prefer WeakPtr for posting tasks to handle unexpected destruction

* cleanup .h

* cleanup .mm

* add imports

add missing include

* fix: crash when tray popup called twice (#18999)

* remove highlightMode and TODOs

* remove unnecessary copy
This commit is contained in:
Micha Hanselmann 2019-07-31 10:52:50 -07:00 committed by Samuel Attard
parent cde79501e3
commit 47a38daee2
8 changed files with 51 additions and 358 deletions

View file

@ -17,7 +17,7 @@
namespace electron {
class TrayIconCocoa : public TrayIcon, public AtomMenuModel::Observer {
class TrayIconCocoa : public TrayIcon {
public:
TrayIconCocoa();
~TrayIconCocoa() override;
@ -27,7 +27,6 @@ class TrayIconCocoa : public TrayIcon, public AtomMenuModel::Observer {
void SetToolTip(const std::string& tool_tip) override;
void SetTitle(const std::string& title) override;
std::string GetTitle() override;
void SetHighlightMode(TrayIcon::HighlightMode mode) override;
void SetIgnoreDoubleClickEvents(bool ignore) override;
bool GetIgnoreDoubleClickEvents() override;
void PopUpOnUI(AtomMenuModel* menu_model);
@ -36,20 +35,13 @@ class TrayIconCocoa : public TrayIcon, public AtomMenuModel::Observer {
void SetContextMenu(AtomMenuModel* menu_model) override;
gfx::Rect GetBounds() override;
protected:
// AtomMenuModel::Observer:
void OnMenuWillClose() override;
private:
// Atom custom view for NSStatusItem.
// Electron custom view for NSStatusItem.
base::scoped_nsobject<StatusItemView> status_item_view_;
// Status menu shown when right-clicking the system icon.
base::scoped_nsobject<AtomMenuController> menu_;
// Used for unregistering observer.
AtomMenuModel* menu_model_ = nullptr; // weak ref.
base::WeakPtrFactory<TrayIconCocoa> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(TrayIconCocoa);