void NotifyIcon::HandleClickEvent(int modifiers,
bool left_mouse_click,
bool double_button_click) {
- 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);
+ gfx::Rect bounds = GetBounds();
if (left_mouse_click) {
if (double_button_click) // double left click
- NotifyDoubleClicked(gfx::Rect(rect), modifiers);
+ NotifyDoubleClicked(bounds, modifiers);
else // single left click
- NotifyClicked(gfx::Rect(rect), modifiers);
+ NotifyClicked(bounds, modifiers);
return;
} else if (!double_button_click) { // single right click
if (menu_model_)
PopUpContextMenu(gfx::Point(), menu_model_);
else
- NotifyRightClicked(gfx::Rect(rect), modifiers);
+ NotifyRightClicked(bounds, modifiers);
}
}
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) {
memset(icon_data, 0, sizeof(NOTIFYICONDATA));
icon_data->cbSize = sizeof(NOTIFYICONDATA);