From d42fd6fc7ee307d6a463c4f52e7acf9e78f54a3d Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 29 Jul 2015 13:10:51 +0800 Subject: [PATCH] win: Pass modifers in 'clicked' events --- atom/browser/ui/win/notify_icon.cc | 7 ++++--- atom/browser/ui/win/notify_icon.h | 1 + atom/browser/ui/win/notify_icon_host.cc | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/atom/browser/ui/win/notify_icon.cc b/atom/browser/ui/win/notify_icon.cc index b58b5931276..fd9a90ae1d5 100644 --- a/atom/browser/ui/win/notify_icon.cc +++ b/atom/browser/ui/win/notify_icon.cc @@ -63,6 +63,7 @@ NotifyIcon::~NotifyIcon() { } void NotifyIcon::HandleClickEvent(const gfx::Point& cursor_pos, + int modifiers, bool left_mouse_click, bool double_button_click) { NOTIFYICONIDENTIFIER icon_id; @@ -80,12 +81,12 @@ void NotifyIcon::HandleClickEvent(const gfx::Point& cursor_pos, if (left_mouse_click) { if (double_button_click) // double left click - NotifyDoubleClicked(gfx::Rect(rect)); + NotifyDoubleClicked(gfx::Rect(rect), modifiers); else // single left click - NotifyClicked(gfx::Rect(rect)); + NotifyClicked(gfx::Rect(rect), modifiers); return; } else if (!double_button_click) { // single right click - NotifyRightClicked(gfx::Rect(rect)); + NotifyRightClicked(gfx::Rect(rect), modifiers); PopContextMenu(cursor_pos); } } diff --git a/atom/browser/ui/win/notify_icon.h b/atom/browser/ui/win/notify_icon.h index c004d5f3940..a28a00ff0d6 100644 --- a/atom/browser/ui/win/notify_icon.h +++ b/atom/browser/ui/win/notify_icon.h @@ -34,6 +34,7 @@ class NotifyIcon : public TrayIcon { // there is a registered observer, passes the click event to the observer, // otherwise displays the context menu if there is one. void HandleClickEvent(const gfx::Point& cursor_pos, + int modifiers, bool left_button_click, bool double_button_click); diff --git a/atom/browser/ui/win/notify_icon_host.cc b/atom/browser/ui/win/notify_icon_host.cc index 33ac722a537..c34e14375e7 100644 --- a/atom/browser/ui/win/notify_icon_host.cc +++ b/atom/browser/ui/win/notify_icon_host.cc @@ -11,7 +11,9 @@ #include "base/stl_util.h" #include "base/threading/non_thread_safe.h" #include "base/threading/thread.h" +#include "base/win/win_util.h" #include "base/win/wrapped_window_proc.h" +#include "ui/events/event_constants.h" #include "ui/gfx/screen.h" #include "ui/gfx/win/hwnd_util.h" @@ -26,6 +28,17 @@ const UINT kBaseIconId = 2; const wchar_t kNotifyIconHostWindowClass[] = L"Electron_NotifyIconHostWindow"; +int GetKeyboardModifers() { + int modifiers = ui::EF_NONE; + if (base::win::IsShiftPressed()) + modifiers |= ui::EF_SHIFT_DOWN; + if (base::win::IsCtrlPressed()) + modifiers |= ui::EF_CONTROL_DOWN; + if (base::win::IsAltPressed()) + modifiers |= ui::EF_ALT_DOWN; + return modifiers; +} + } // namespace NotifyIconHost::NotifyIconHost() @@ -155,6 +168,7 @@ LRESULT CALLBACK NotifyIconHost::WndProc(HWND hwnd, gfx::Screen::GetNativeScreen()->GetCursorScreenPoint()); win_icon->HandleClickEvent( cursor_pos, + GetKeyboardModifers(), (lparam == WM_LBUTTONDOWN || lparam == WM_LBUTTONDBLCLK), (lparam == WM_LBUTTONDBLCLK || lparam == WM_RBUTTONDBLCLK)); return TRUE;