fix: delay emitting NotifyIcon events on Windows (#26668)

* wip?

* attempt to use weakptr

* apply posttask change to other balloon events

* chore: add clarifying comment on weakptr

* refactor: move weakptr include to implementation

(it's not needed in the header file)

* refactor: use default initializer for weak factory

* refactor: move weakptr usage outside of loop

* fix: convert mouse events as well

* refactor: use member function for balloon events

* fix: check if wicon is truthy in callback

* refactor: bind mouse events with member function

* refactor: inline lparams

* refactor: inline getkeyboardmodifiers()

* chore: correct GetKeyboardModifiers typo
This commit is contained in:
Erick Zhao 2020-11-29 23:49:30 -08:00 committed by GitHub
parent 14c8e000cb
commit 36af8022ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 9 deletions

View file

@ -71,6 +71,8 @@ class NotifyIcon : public TrayIcon {
void SetContextMenu(ElectronMenuModel* menu_model) override;
gfx::Rect GetBounds() override;
base::WeakPtr<NotifyIcon> GetWeakPtr() { return weak_factory_.GetWeakPtr(); }
private:
void InitIconData(NOTIFYICONDATA* icon_data);
@ -101,6 +103,8 @@ class NotifyIcon : public TrayIcon {
// Context menu associated with this icon (if any).
std::unique_ptr<views::MenuRunner> menu_runner_;
base::WeakPtrFactory<NotifyIcon> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(NotifyIcon);
};