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:
parent
14c8e000cb
commit
36af8022ca
2 changed files with 33 additions and 9 deletions
|
@ -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);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue