win: Implement tray.getBounds() API
This commit is contained in:
parent
db98e256f2
commit
886ef1717c
2 changed files with 17 additions and 11 deletions
|
@ -48,26 +48,19 @@ NotifyIcon::~NotifyIcon() {
|
||||||
void NotifyIcon::HandleClickEvent(int modifiers,
|
void NotifyIcon::HandleClickEvent(int modifiers,
|
||||||
bool left_mouse_click,
|
bool left_mouse_click,
|
||||||
bool double_button_click) {
|
bool double_button_click) {
|
||||||
NOTIFYICONIDENTIFIER icon_id;
|
gfx::Rect bounds = GetBounds();
|
||||||
memset(&icon_id, 0, sizeof(NOTIFYICONIDENTIFIER));
|
|
||||||
icon_id.uID = icon_id_;
|
|
||||||
icon_id.hWnd = window_;
|
|
||||||
icon_id.cbSize = sizeof(NOTIFYICONIDENTIFIER);
|
|
||||||
|
|
||||||
RECT rect = { 0 };
|
|
||||||
Shell_NotifyIconGetRect(&icon_id, &rect);
|
|
||||||
|
|
||||||
if (left_mouse_click) {
|
if (left_mouse_click) {
|
||||||
if (double_button_click) // double left click
|
if (double_button_click) // double left click
|
||||||
NotifyDoubleClicked(gfx::Rect(rect), modifiers);
|
NotifyDoubleClicked(bounds, modifiers);
|
||||||
else // single left click
|
else // single left click
|
||||||
NotifyClicked(gfx::Rect(rect), modifiers);
|
NotifyClicked(bounds, modifiers);
|
||||||
return;
|
return;
|
||||||
} else if (!double_button_click) { // single right click
|
} else if (!double_button_click) { // single right click
|
||||||
if (menu_model_)
|
if (menu_model_)
|
||||||
PopUpContextMenu(gfx::Point(), menu_model_);
|
PopUpContextMenu(gfx::Point(), menu_model_);
|
||||||
else
|
else
|
||||||
NotifyRightClicked(gfx::Rect(rect), modifiers);
|
NotifyRightClicked(bounds, modifiers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,6 +156,18 @@ void NotifyIcon::SetContextMenu(ui::SimpleMenuModel* menu_model) {
|
||||||
menu_model_ = menu_model;
|
menu_model_ = menu_model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gfx::Rect NotifyIcon::GetBounds() {
|
||||||
|
NOTIFYICONIDENTIFIER icon_id;
|
||||||
|
memset(&icon_id, 0, sizeof(NOTIFYICONIDENTIFIER));
|
||||||
|
icon_id.uID = icon_id_;
|
||||||
|
icon_id.hWnd = window_;
|
||||||
|
icon_id.cbSize = sizeof(NOTIFYICONIDENTIFIER);
|
||||||
|
|
||||||
|
RECT rect = { 0 };
|
||||||
|
Shell_NotifyIconGetRect(&icon_id, &rect);
|
||||||
|
return gfx::Rect(rect);
|
||||||
|
}
|
||||||
|
|
||||||
void NotifyIcon::InitIconData(NOTIFYICONDATA* icon_data) {
|
void NotifyIcon::InitIconData(NOTIFYICONDATA* icon_data) {
|
||||||
memset(icon_data, 0, sizeof(NOTIFYICONDATA));
|
memset(icon_data, 0, sizeof(NOTIFYICONDATA));
|
||||||
icon_data->cbSize = sizeof(NOTIFYICONDATA);
|
icon_data->cbSize = sizeof(NOTIFYICONDATA);
|
||||||
|
|
|
@ -54,6 +54,7 @@ class NotifyIcon : public TrayIcon {
|
||||||
void PopUpContextMenu(const gfx::Point& pos,
|
void PopUpContextMenu(const gfx::Point& pos,
|
||||||
ui::SimpleMenuModel* menu_model) override;
|
ui::SimpleMenuModel* menu_model) override;
|
||||||
void SetContextMenu(ui::SimpleMenuModel* menu_model) override;
|
void SetContextMenu(ui::SimpleMenuModel* menu_model) override;
|
||||||
|
gfx::Rect GetBounds() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitIconData(NOTIFYICONDATA* icon_data);
|
void InitIconData(NOTIFYICONDATA* icon_data);
|
||||||
|
|
Loading…
Reference in a new issue