Bug 1737501 - Allow contextmenu option on Windows SystemStatusBar r=mconley

We want to be able to have a different behavior for interactions with an entry
in the Windows system tray - specifically, we want to be able to open a window
on left click, and show a menu on right click. This patch allows us to control
this with a "contextmenu" attribute on the menu passed in to `AddItem`, and
receive a "systemstatusbarclick" event in the case of a left click.

Regarding tests, I don't know that we have a good way of testing this?
Suggestions are of course welcome here.

Differential Revision: https://phabricator.services.mozilla.com/D129413
This commit is contained in:
Doug Thayer 2021-10-28 16:07:31 +00:00
Родитель 1f882ebd64
Коммит 90b2905a58
4 изменённых файлов: 15 добавлений и 0 удалений

Просмотреть файл

@ -422,6 +422,8 @@ NON_IDL_EVENT(overflow, eScrollPortOverflow, EventNameType_XUL,
eBasicEventClass)
NON_IDL_EVENT(underflow, eScrollPortUnderflow, EventNameType_XUL,
eBasicEventClass)
NON_IDL_EVENT(systemstatusbarclick, eXULSystemStatusBarClick, EventNameType_XUL,
eBasicEventClass)
// Various SVG events
NON_IDL_EVENT(SVGLoad, eSVGLoad, EventNameType_None, eBasicEventClass)

Просмотреть файл

@ -156,6 +156,7 @@ NS_EVENT_MESSAGE(eXULPopupHiding)
NS_EVENT_MESSAGE(eXULPopupHidden)
NS_EVENT_MESSAGE(eXULBroadcast)
NS_EVENT_MESSAGE(eXULCommandUpdate)
NS_EVENT_MESSAGE(eXULSystemStatusBarClick)
// Legacy mouse scroll (wheel) events
NS_EVENT_MESSAGE(eLegacyMouseLineOrPageScroll)

Просмотреть файл

@ -10,6 +10,7 @@
#include "mozilla/dom/Document.h"
#include "mozilla/dom/Element.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/LinkedList.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/widget/IconLoader.h"
@ -212,6 +213,16 @@ LRESULT StatusBarEntry::OnMessage(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
return TRUE;
}
if (LOWORD(lp) == WM_LBUTTONUP &&
mMenu->HasAttr(kNameSpaceID_None, nsGkAtoms::contextmenu)) {
nsEventStatus status = nsEventStatus_eIgnore;
WidgetMouseEvent event(true, eXULSystemStatusBarClick, nullptr,
WidgetMouseEvent::eReal);
EventDispatcher::Dispatch(mMenu, menu->PresContext(), &event, nullptr,
&status);
return DefWindowProc(hWnd, msg, wp, lp);
}
nsMenuPopupFrame* popupFrame = menu->GetPopup();
if (!popupFrame) {
return TRUE;

Просмотреть файл

@ -907,6 +907,7 @@ STATIC_ATOMS = [
Atom("onstorage", "onstorage"),
Atom("onsubmit", "onsubmit"),
Atom("onsuccess", "onsuccess"),
Atom("onsystemstatusbarclick", "onsystemstatusbarclick"),
Atom("ontypechange", "ontypechange"),
Atom("onterminate", "onterminate"),
Atom("ontext", "ontext"),