diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 7085abf7c483..b621420af904 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -101,3 +101,4 @@ fix_swap_global_proxies_before_initializing_the_windows_proxies.patch fix_default_to_ntlm_v2_in_network_service.patch feat_add_streaming-protocol_registry_to_multibuffer_data_source.patch fix_handling_non_client_pointer_events_from_pen_on_windows_10.patch +remove_menu_window_task_item.patch diff --git a/patches/chromium/remove_menu_window_task_item.patch b/patches/chromium/remove_menu_window_task_item.patch new file mode 100644 index 000000000000..c63ec4be7a81 --- /dev/null +++ b/patches/chromium/remove_menu_window_task_item.patch @@ -0,0 +1,20 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Cheng Zhao +Date: Thu, 4 Oct 2018 14:57:02 -0700 +Subject: fix: remove menu window from taskbar + +Refs https://chromium-review.googlesource.com/c/chromium/src/+/2245941 + +diff --git a/ui/views/widget/widget_hwnd_utils.cc b/ui/views/widget/widget_hwnd_utils.cc +index 40e66a212e3ea158b61f11d804a3c1644023b2d7..89f5b62f95dfec59bacf79f33895438039fac1c5 100644 +--- a/ui/views/widget/widget_hwnd_utils.cc ++++ b/ui/views/widget/widget_hwnd_utils.cc +@@ -118,6 +118,8 @@ void CalculateWindowStylesFromInitParams( + else + *style |= WS_BORDER; + } ++ if (!params.force_show_in_taskbar) ++ *ex_style |= WS_EX_TOOLWINDOW; + break; + case Widget::InitParams::TYPE_TOOLTIP: + *style |= WS_POPUP; diff --git a/shell/browser/ui/win/notify_icon.cc b/shell/browser/ui/win/notify_icon.cc index 15f3e252c6be..3c3c17cf3563 100644 --- a/shell/browser/ui/win/notify_icon.cc +++ b/shell/browser/ui/win/notify_icon.cc @@ -18,7 +18,6 @@ #include "ui/gfx/geometry/rect.h" #include "ui/gfx/image/image.h" #include "ui/views/controls/menu/menu_runner.h" -#include "ui/views/widget/widget.h" namespace { @@ -49,11 +48,7 @@ NotifyIcon::NotifyIcon(NotifyIconHost* host, HWND window, UINT message, GUID guid) - : host_(host), - icon_id_(id), - window_(window), - message_id_(message), - weak_factory_(this) { + : host_(host), icon_id_(id), window_(window), message_id_(message) { guid_ = guid; is_using_guid_ = guid != GUID_DEFAULT; NOTIFYICONDATA icon_data; @@ -213,26 +208,10 @@ void NotifyIcon::PopUpContextMenu(const gfx::Point& pos, if (pos.IsOrigin()) rect.set_origin(display::Screen::GetScreen()->GetCursorScreenPoint()); - // Create a widget for the menu, otherwise we get no keyboard events, which - // is required for accessibility. - widget_.reset(new views::Widget()); - views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); - params.ownership = - views::Widget::InitParams::Ownership::WIDGET_OWNS_NATIVE_WIDGET; - params.bounds = gfx::Rect(0, 0, 0, 0); - params.force_software_compositing = true; - params.z_order = ui::ZOrderLevel::kFloatingUIElement; - - widget_->Init(std::move(params)); - - widget_->Show(); - widget_->Activate(); - menu_runner_.reset(new views::MenuRunner( - menu_model != nullptr ? menu_model : menu_model_, - views::MenuRunner::CONTEXT_MENU | views::MenuRunner::HAS_MNEMONICS, - base::BindRepeating(&NotifyIcon::OnContextMenuClosed, - weak_factory_.GetWeakPtr()))); - menu_runner_->RunMenuAt(widget_.get(), NULL, rect, + menu_runner_.reset( + new views::MenuRunner(menu_model != nullptr ? menu_model : menu_model_, + views::MenuRunner::HAS_MNEMONICS)); + menu_runner_->RunMenuAt(nullptr, nullptr, rect, views::MenuAnchorPosition::kTopLeft, ui::MENU_SOURCE_MOUSE); } @@ -273,8 +252,4 @@ void NotifyIcon::InitIconData(NOTIFYICONDATA* icon_data) { } } -void NotifyIcon::OnContextMenuClosed() { - widget_->Close(); -} - } // namespace electron diff --git a/shell/browser/ui/win/notify_icon.h b/shell/browser/ui/win/notify_icon.h index 3589a86ca419..37b4b4c81b7e 100644 --- a/shell/browser/ui/win/notify_icon.h +++ b/shell/browser/ui/win/notify_icon.h @@ -14,7 +14,6 @@ #include "base/compiler_specific.h" #include "base/macros.h" -#include "base/memory/weak_ptr.h" #include "base/win/scoped_gdi_object.h" #include "shell/browser/ui/tray_icon.h" #include "shell/browser/ui/win/notify_icon_host.h" @@ -25,8 +24,7 @@ class Point; namespace views { class MenuRunner; -class Widget; -} // namespace views +} namespace electron { @@ -75,7 +73,6 @@ class NotifyIcon : public TrayIcon { private: void InitIconData(NOTIFYICONDATA* icon_data); - void OnContextMenuClosed(); // The tray that owns us. Weak. NotifyIconHost* host_; @@ -104,12 +101,6 @@ class NotifyIcon : public TrayIcon { // Context menu associated with this icon (if any). std::unique_ptr menu_runner_; - // Temporary widget for the context menu, needed for keyboard event capture. - std::unique_ptr widget_; - - // WeakPtrFactory for CloseClosure safety. - base::WeakPtrFactory weak_factory_; - DISALLOW_COPY_AND_ASSIGN(NotifyIcon); };