mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 819888 - Check the result of nsBaseWidget::GetActiveRollupListener. r=enndeakin
This commit is contained in:
parent
18af471013
commit
5a00e1c7fb
@ -2673,9 +2673,9 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||
#endif /* MOZ_USE_NATIVE_POPUP_WINDOWS */
|
||||
|
||||
nsIRollupListener* rollupListener = nsBaseWidget::GetActiveRollupListener();
|
||||
NS_ENSURE_TRUE_VOID(rollupListener);
|
||||
nsCOMPtr<nsIWidget> widget = rollupListener->GetRollupWidget();
|
||||
if (!widget)
|
||||
return;
|
||||
NS_ENSURE_TRUE_VOID(widget);
|
||||
|
||||
NSWindow *popupWindow = (NSWindow*)widget->GetNativeData(NS_NATIVE_WINDOW);
|
||||
if (!popupWindow || ![popupWindow isKindOfClass:[PopupWindow class]])
|
||||
@ -2698,6 +2698,7 @@ NSEvent* gLastDragMouseDownEvent = nil;
|
||||
BOOL consumeEvent = NO;
|
||||
|
||||
nsIRollupListener* rollupListener = nsBaseWidget::GetActiveRollupListener();
|
||||
NS_ENSURE_TRUE(rollupListener, false);
|
||||
nsCOMPtr<nsIWidget> rollupWidget = rollupListener->GetRollupWidget();
|
||||
if (rollupWidget) {
|
||||
NSWindow* currentPopup = static_cast<NSWindow*>(rollupWidget->GetNativeData(NS_NATIVE_WINDOW));
|
||||
|
@ -89,9 +89,10 @@ NS_IMPL_ISUPPORTS_INHERITED1(nsCocoaWindow, Inherited, nsPIWidgetCocoa)
|
||||
static void RollUpPopups()
|
||||
{
|
||||
nsIRollupListener* rollupListener = nsBaseWidget::GetActiveRollupListener();
|
||||
NS_ENSURE_TRUE_VOID(rollupListener);
|
||||
nsCOMPtr<nsIWidget> rollupWidget = rollupListener->GetRollupWidget();
|
||||
if (rollupWidget)
|
||||
rollupListener->Rollup(0, nullptr);
|
||||
NS_ENSURE_TRUE_VOID(rollupWidget);
|
||||
rollupListener->Rollup(0, nullptr);
|
||||
}
|
||||
|
||||
nsCocoaWindow::nsCocoaWindow()
|
||||
|
@ -824,11 +824,13 @@ nsresult nsMenuX::SetupIcon()
|
||||
return;
|
||||
|
||||
nsIRollupListener* rollupListener = nsBaseWidget::GetActiveRollupListener();
|
||||
nsCOMPtr<nsIWidget> rollupWidget = rollupListener->GetRollupWidget();
|
||||
if (rollupWidget) {
|
||||
rollupListener->Rollup(0, nullptr);
|
||||
[menu cancelTracking];
|
||||
return;
|
||||
if (rollupListener) {
|
||||
nsCOMPtr<nsIWidget> rollupWidget = rollupListener->GetRollupWidget();
|
||||
if (rollupWidget) {
|
||||
rollupListener->Rollup(0, nullptr);
|
||||
[menu cancelTracking];
|
||||
return;
|
||||
}
|
||||
}
|
||||
mGeckoMenu->MenuOpened();
|
||||
}
|
||||
|
@ -165,9 +165,9 @@ static CGEventRef EventTapCallback(CGEventTapProxy proxy, CGEventType type, CGEv
|
||||
return event;
|
||||
|
||||
nsIRollupListener* rollupListener = nsBaseWidget::GetActiveRollupListener();
|
||||
NS_ENSURE_TRUE(rollupListener, event);
|
||||
nsCOMPtr<nsIWidget> rollupWidget = rollupListener->GetRollupWidget();
|
||||
if (!rollupWidget)
|
||||
return event;
|
||||
NS_ENSURE_TRUE(rollupWidget, event);
|
||||
|
||||
// Don't bother with rightMouseDown events here -- because of the delay,
|
||||
// we'll end up closing browser context menus that we just opened. Since
|
||||
|
@ -638,9 +638,11 @@ nsWindow::Destroy(void)
|
||||
this);
|
||||
|
||||
nsIRollupListener* rollupListener = nsBaseWidget::GetActiveRollupListener();
|
||||
nsCOMPtr<nsIWidget> rollupWidget = rollupListener->GetRollupWidget();
|
||||
if (static_cast<nsIWidget *>(this) == rollupWidget) {
|
||||
rollupListener->Rollup(0, nullptr);
|
||||
if (rollupListener) {
|
||||
nsCOMPtr<nsIWidget> rollupWidget = rollupListener->GetRollupWidget();
|
||||
if (static_cast<nsIWidget *>(this) == rollupWidget) {
|
||||
rollupListener->Rollup(0, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
// dragService will be null after shutdown of the service manager.
|
||||
@ -4782,55 +4784,58 @@ bool
|
||||
nsWindow::CheckForRollup(gdouble aMouseX, gdouble aMouseY,
|
||||
bool aIsWheel, bool aAlwaysRollup)
|
||||
{
|
||||
bool retVal = false;
|
||||
nsIRollupListener* rollupListener = GetActiveRollupListener();
|
||||
nsCOMPtr<nsIWidget> rollupWidget = rollupListener->GetRollupWidget();
|
||||
if (rollupWidget) {
|
||||
GdkWindow *currentPopup =
|
||||
(GdkWindow *)rollupWidget->GetNativeData(NS_NATIVE_WINDOW);
|
||||
if (aAlwaysRollup || !is_mouse_in_window(currentPopup, aMouseX, aMouseY)) {
|
||||
bool rollup = true;
|
||||
if (aIsWheel) {
|
||||
rollup = rollupListener->ShouldRollupOnMouseWheelEvent();
|
||||
retVal = true;
|
||||
}
|
||||
// if we're dealing with menus, we probably have submenus and
|
||||
// we don't want to rollup if the click is in a parent menu of
|
||||
// the current submenu
|
||||
uint32_t popupsToRollup = UINT32_MAX;
|
||||
if (!aAlwaysRollup) {
|
||||
nsAutoTArray<nsIWidget*, 5> widgetChain;
|
||||
uint32_t sameTypeCount = rollupListener->GetSubmenuWidgetChain(&widgetChain);
|
||||
for (uint32_t i=0; i<widgetChain.Length(); ++i) {
|
||||
nsIWidget* widget = widgetChain[i];
|
||||
GdkWindow* currWindow =
|
||||
(GdkWindow*) widget->GetNativeData(NS_NATIVE_WINDOW);
|
||||
if (is_mouse_in_window(currWindow, aMouseX, aMouseY)) {
|
||||
// don't roll up if the mouse event occurred within a
|
||||
// menu of the same type. If the mouse event occurred
|
||||
// in a menu higher than that, roll up, but pass the
|
||||
// number of popups to Rollup so that only those of the
|
||||
// same type close up.
|
||||
if (i < sameTypeCount) {
|
||||
rollup = false;
|
||||
}
|
||||
else {
|
||||
popupsToRollup = sameTypeCount;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} // foreach parent menu widget
|
||||
} // if rollup listener knows about menus
|
||||
|
||||
// if we've determined that we should still rollup, do it.
|
||||
if (rollup && rollupListener->Rollup(popupsToRollup, nullptr)) {
|
||||
retVal = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
nsCOMPtr<nsIWidget> rollupWidget;
|
||||
if (rollupListener) {
|
||||
rollupWidget = rollupListener->GetRollupWidget();
|
||||
}
|
||||
if (!rollupWidget) {
|
||||
nsBaseWidget::gRollupListener = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool retVal = false;
|
||||
GdkWindow *currentPopup =
|
||||
(GdkWindow *)rollupWidget->GetNativeData(NS_NATIVE_WINDOW);
|
||||
if (aAlwaysRollup || !is_mouse_in_window(currentPopup, aMouseX, aMouseY)) {
|
||||
bool rollup = true;
|
||||
if (aIsWheel) {
|
||||
rollup = rollupListener->ShouldRollupOnMouseWheelEvent();
|
||||
retVal = true;
|
||||
}
|
||||
// if we're dealing with menus, we probably have submenus and
|
||||
// we don't want to rollup if the click is in a parent menu of
|
||||
// the current submenu
|
||||
uint32_t popupsToRollup = UINT32_MAX;
|
||||
if (!aAlwaysRollup) {
|
||||
nsAutoTArray<nsIWidget*, 5> widgetChain;
|
||||
uint32_t sameTypeCount = rollupListener->GetSubmenuWidgetChain(&widgetChain);
|
||||
for (uint32_t i=0; i<widgetChain.Length(); ++i) {
|
||||
nsIWidget* widget = widgetChain[i];
|
||||
GdkWindow* currWindow =
|
||||
(GdkWindow*) widget->GetNativeData(NS_NATIVE_WINDOW);
|
||||
if (is_mouse_in_window(currWindow, aMouseX, aMouseY)) {
|
||||
// don't roll up if the mouse event occurred within a
|
||||
// menu of the same type. If the mouse event occurred
|
||||
// in a menu higher than that, roll up, but pass the
|
||||
// number of popups to Rollup so that only those of the
|
||||
// same type close up.
|
||||
if (i < sameTypeCount) {
|
||||
rollup = false;
|
||||
}
|
||||
else {
|
||||
popupsToRollup = sameTypeCount;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} // foreach parent menu widget
|
||||
} // if rollup listener knows about menus
|
||||
|
||||
// if we've determined that we should still rollup, do it.
|
||||
if (rollup && rollupListener->Rollup(popupsToRollup, nullptr)) {
|
||||
retVal = true;
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
@ -490,7 +490,10 @@ NS_METHOD nsWindow::Destroy()
|
||||
// just to be safe. If we're going away and for some reason we're still
|
||||
// the rollup widget, rollup and turn off capture.
|
||||
nsIRollupListener* rollupListener = GetActiveRollupListener();
|
||||
nsCOMPtr<nsIWidget> rollupWidget = rollupListener->GetRollupWidget();
|
||||
nsCOMPtr<nsIWidget> rollupWidget;
|
||||
if (rollupListener) {
|
||||
rollupWidget = rollupListener->GetRollupWidget();
|
||||
}
|
||||
if (this == rollupWidget) {
|
||||
rollupListener->Rollup(UINT32_MAX);
|
||||
CaptureRollupEvents(nullptr, false, true);
|
||||
@ -1543,7 +1546,7 @@ bool nsWindow::EventIsInsideWindow(nsWindow* aWindow)
|
||||
{
|
||||
RECTL rcl;
|
||||
POINTL ptl;
|
||||
|
||||
NS_ENSURE_TRUE(aWindow, false);
|
||||
if (WinQueryMsgPos(0, &ptl)) {
|
||||
WinMapWindowPoints(HWND_DESKTOP, aWindow->mWnd, &ptl, 1);
|
||||
WinQueryWindowRect(aWindow->mWnd, &rcl);
|
||||
@ -1565,7 +1568,10 @@ bool nsWindow::EventIsInsideWindow(nsWindow* aWindow)
|
||||
bool nsWindow::RollupOnButtonDown(ULONG aMsg)
|
||||
{
|
||||
nsIRollupListener* rollupListener = nsBaseWidget::GetActiveRollupListener();
|
||||
nsCOMPtr<nsIWidget> rollupWidget = rollupListener->GetRollupWidget();
|
||||
nsCOMPtr<nsIWidget> rollupWidget;
|
||||
if (rollupListener) {
|
||||
rollupWidget = rollupListener->GetRollupWidget();
|
||||
}
|
||||
|
||||
// Exit if the event is inside the most recent popup.
|
||||
if (EventIsInsideWindow((nsWindow*)rollupWidget)) {
|
||||
@ -1607,8 +1613,11 @@ bool nsWindow::RollupOnButtonDown(ULONG aMsg)
|
||||
void nsWindow::RollupOnFocusLost(HWND aFocus)
|
||||
{
|
||||
nsIRollupListener* rollupListener = nsBaseWidget::GetActiveRollupListener();
|
||||
nsCOMPtr<nsIWidget> rollupWidget = rollupListener->GetRollupWidget();
|
||||
HWND hRollup = ((nsWindow*)rollupWidget)->mWnd;
|
||||
nsCOMPtr<nsIWidget> rollupWidget;
|
||||
if (rollupListener) {
|
||||
rollupWidget = rollupListener->GetRollupWidget();
|
||||
}
|
||||
HWND hRollup = rollupWidget ? ((nsWindow*)rollupWidget)->mWnd : NULL;
|
||||
|
||||
// Exit if focus was lost to the most recent popup.
|
||||
if (hRollup == aFocus) {
|
||||
|
@ -589,8 +589,8 @@ MRESULT EXPENTRY fnwpFrame(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
|
||||
{
|
||||
// check to see if we have a rollup listener registered
|
||||
nsIRollupListener* rollupListener = nsBaseWidget::GetActiveRollupListener();
|
||||
nsCOMPtr<nsIWidget> rollupWidget = rollupListener->GetRollupWidget();
|
||||
if (rollupListener) {
|
||||
nsCOMPtr<nsIWidget> rollupWidget = rollupListener->GetRollupWidget();
|
||||
if (msg == WM_TRACKFRAME || msg == WM_MINMAXFRAME ||
|
||||
msg == WM_BUTTON1DOWN || msg == WM_BUTTON2DOWN ||
|
||||
msg == WM_BUTTON3DOWN) {
|
||||
|
@ -410,9 +410,12 @@ nsWindow::Destroy(void)
|
||||
ClearCachedResources();
|
||||
|
||||
nsIRollupListener* rollupListener = nsBaseWidget::GetActiveRollupListener();
|
||||
nsCOMPtr<nsIWidget> rollupWidget = rollupListener->GetRollupWidget();
|
||||
if (static_cast<nsIWidget *>(this) == rollupWidget)
|
||||
rollupListener->Rollup(0, nullptr);
|
||||
if (rollupListener) {
|
||||
nsCOMPtr<nsIWidget> rollupWidget = rollupListener->GetRollupWidget();
|
||||
if (static_cast<nsIWidget *>(this) == rollupWidget) {
|
||||
rollupListener->Rollup(0, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
Show(false);
|
||||
|
||||
@ -938,49 +941,52 @@ bool
|
||||
nsWindow::CheckForRollup(double aMouseX, double aMouseY,
|
||||
bool aIsWheel)
|
||||
{
|
||||
bool retVal = false;
|
||||
nsIRollupListener* rollupListener = GetActiveRollupListener();
|
||||
nsCOMPtr<nsIWidget> rollupWidget = rollupListener->GetRollupWidget();
|
||||
if (rollupWidget) {
|
||||
MozQWidget *currentPopup =
|
||||
(MozQWidget *)rollupWidget->GetNativeData(NS_NATIVE_WINDOW);
|
||||
|
||||
if (!is_mouse_in_window(currentPopup, aMouseX, aMouseY)) {
|
||||
bool rollup = true;
|
||||
if (aIsWheel) {
|
||||
rollup = rollupListener->ShouldRollupOnMouseWheelEvent();
|
||||
retVal = true;
|
||||
}
|
||||
// if we're dealing with menus, we probably have submenus and
|
||||
// we don't want to rollup if the clickis in a parent menu of
|
||||
// the current submenu
|
||||
uint32_t popupsToRollup = UINT32_MAX;
|
||||
if (rollupListener) {
|
||||
nsAutoTArray<nsIWidget*, 5> widgetChain;
|
||||
uint32_t sameTypeCount = rollupListener->GetSubmenuWidgetChain(&widgetChain);
|
||||
for (uint32_t i=0; i<widgetChain.Length(); ++i) {
|
||||
nsIWidget* widget = widgetChain[i];
|
||||
MozQWidget* currWindow =
|
||||
(MozQWidget*) widget->GetNativeData(NS_NATIVE_WINDOW);
|
||||
if (is_mouse_in_window(currWindow, aMouseX, aMouseY)) {
|
||||
if (i < sameTypeCount) {
|
||||
rollup = false;
|
||||
}
|
||||
else {
|
||||
popupsToRollup = sameTypeCount;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} // foreach parent menu widget
|
||||
} // if rollup listener knows about menus
|
||||
|
||||
// if we've determined that we should still rollup, do it.
|
||||
if (rollup) {
|
||||
retVal = rollupListener->Rollup(popupsToRollup, nullptr);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
nsCOMPtr<nsIWidget> rollupWidget;
|
||||
if (rollupListener) {
|
||||
rollupWidget = rollupListener->GetRollupWidget();
|
||||
}
|
||||
if (!rollupWidget) {
|
||||
nsBaseWidget::gRollupListener = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool retVal = false;
|
||||
MozQWidget *currentPopup =
|
||||
(MozQWidget *)rollupWidget->GetNativeData(NS_NATIVE_WINDOW);
|
||||
if (!is_mouse_in_window(currentPopup, aMouseX, aMouseY)) {
|
||||
bool rollup = true;
|
||||
if (aIsWheel) {
|
||||
rollup = rollupListener->ShouldRollupOnMouseWheelEvent();
|
||||
retVal = true;
|
||||
}
|
||||
// if we're dealing with menus, we probably have submenus and
|
||||
// we don't want to rollup if the clickis in a parent menu of
|
||||
// the current submenu
|
||||
uint32_t popupsToRollup = UINT32_MAX;
|
||||
if (rollupListener) {
|
||||
nsAutoTArray<nsIWidget*, 5> widgetChain;
|
||||
uint32_t sameTypeCount = rollupListener->GetSubmenuWidgetChain(&widgetChain);
|
||||
for (uint32_t i=0; i<widgetChain.Length(); ++i) {
|
||||
nsIWidget* widget = widgetChain[i];
|
||||
MozQWidget* currWindow =
|
||||
(MozQWidget*) widget->GetNativeData(NS_NATIVE_WINDOW);
|
||||
if (is_mouse_in_window(currWindow, aMouseX, aMouseY)) {
|
||||
if (i < sameTypeCount) {
|
||||
rollup = false;
|
||||
}
|
||||
else {
|
||||
popupsToRollup = sameTypeCount;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} // foreach parent menu widget
|
||||
} // if rollup listener knows about menus
|
||||
|
||||
// if we've determined that we should still rollup, do it.
|
||||
if (rollup) {
|
||||
retVal = rollupListener->Rollup(popupsToRollup, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
|
@ -7174,8 +7174,11 @@ void nsWindow::OnDestroy()
|
||||
// If we're going away and for some reason we're still the rollup widget, rollup and
|
||||
// turn off capture.
|
||||
nsIRollupListener* rollupListener = nsBaseWidget::GetActiveRollupListener();
|
||||
nsCOMPtr<nsIWidget> rollupWidget = rollupListener->GetRollupWidget();
|
||||
if ( this == rollupWidget ) {
|
||||
nsCOMPtr<nsIWidget> rollupWidget;
|
||||
if (rollupListener) {
|
||||
rollupWidget = rollupListener->GetRollupWidget();
|
||||
}
|
||||
if (this == rollupWidget) {
|
||||
if ( rollupListener )
|
||||
rollupListener->Rollup(0, nullptr);
|
||||
CaptureRollupEvents(nullptr, false);
|
||||
@ -8017,129 +8020,126 @@ nsWindow::EventIsInsideWindow(UINT Msg, nsWindow* aWindow)
|
||||
}
|
||||
|
||||
// Handle events that may cause a popup (combobox, XPMenu, etc) to need to rollup.
|
||||
BOOL
|
||||
bool
|
||||
nsWindow::DealWithPopups(HWND inWnd, UINT inMsg, WPARAM inWParam, LPARAM inLParam, LRESULT* outResult)
|
||||
{
|
||||
NS_ASSERTION(outResult, "Bad outResult");
|
||||
|
||||
*outResult = MA_NOACTIVATE;
|
||||
|
||||
if (!::IsWindowVisible(inWnd))
|
||||
return false;
|
||||
nsIRollupListener* rollupListener = nsBaseWidget::GetActiveRollupListener();
|
||||
NS_ENSURE_TRUE(rollupListener, false);
|
||||
nsCOMPtr<nsIWidget> rollupWidget = rollupListener->GetRollupWidget();
|
||||
if (rollupWidget && ::IsWindowVisible(inWnd)) {
|
||||
NS_ENSURE_TRUE(rollupWidget, false);
|
||||
|
||||
inMsg = WinUtils::GetNativeMessage(inMsg);
|
||||
if (inMsg == WM_LBUTTONDOWN || inMsg == WM_RBUTTONDOWN || inMsg == WM_MBUTTONDOWN ||
|
||||
inMsg == WM_MOUSEWHEEL || inMsg == WM_MOUSEHWHEEL || inMsg == WM_ACTIVATE ||
|
||||
(inMsg == WM_KILLFOCUS && IsDifferentThreadWindow((HWND)inWParam)) ||
|
||||
inMsg == WM_NCRBUTTONDOWN ||
|
||||
inMsg == WM_MOVING ||
|
||||
inMsg == WM_SIZING ||
|
||||
inMsg == WM_NCLBUTTONDOWN ||
|
||||
inMsg == WM_NCMBUTTONDOWN ||
|
||||
inMsg == WM_MOUSEACTIVATE ||
|
||||
inMsg == WM_ACTIVATEAPP ||
|
||||
inMsg == WM_MENUSELECT)
|
||||
{
|
||||
// Rollup if the event is outside the popup.
|
||||
bool rollup = !nsWindow::EventIsInsideWindow(inMsg, (nsWindow*)(rollupWidget.get()));
|
||||
inMsg = WinUtils::GetNativeMessage(inMsg);
|
||||
if (inMsg == WM_LBUTTONDOWN || inMsg == WM_RBUTTONDOWN || inMsg == WM_MBUTTONDOWN ||
|
||||
inMsg == WM_MOUSEWHEEL || inMsg == WM_MOUSEHWHEEL || inMsg == WM_ACTIVATE ||
|
||||
(inMsg == WM_KILLFOCUS && IsDifferentThreadWindow((HWND)inWParam)) ||
|
||||
inMsg == WM_NCRBUTTONDOWN ||
|
||||
inMsg == WM_MOVING ||
|
||||
inMsg == WM_SIZING ||
|
||||
inMsg == WM_NCLBUTTONDOWN ||
|
||||
inMsg == WM_NCMBUTTONDOWN ||
|
||||
inMsg == WM_MOUSEACTIVATE ||
|
||||
inMsg == WM_ACTIVATEAPP ||
|
||||
inMsg == WM_MENUSELECT) {
|
||||
// Rollup if the event is outside the popup.
|
||||
bool rollup = !nsWindow::EventIsInsideWindow(inMsg, (nsWindow*)(rollupWidget.get()));
|
||||
|
||||
if (rollup && (inMsg == WM_MOUSEWHEEL || inMsg == WM_MOUSEHWHEEL))
|
||||
{
|
||||
rollup = rollupListener->ShouldRollupOnMouseWheelEvent();
|
||||
*outResult = true;
|
||||
}
|
||||
if (rollup && (inMsg == WM_MOUSEWHEEL || inMsg == WM_MOUSEHWHEEL)) {
|
||||
rollup = rollupListener->ShouldRollupOnMouseWheelEvent();
|
||||
*outResult = MA_ACTIVATE;
|
||||
}
|
||||
|
||||
// If we're dealing with menus, we probably have submenus and we don't
|
||||
// want to rollup if the click is in a parent menu of the current submenu.
|
||||
uint32_t popupsToRollup = UINT32_MAX;
|
||||
if (rollup) {
|
||||
nsAutoTArray<nsIWidget*, 5> widgetChain;
|
||||
uint32_t sameTypeCount = rollupListener->GetSubmenuWidgetChain(&widgetChain);
|
||||
for ( uint32_t i = 0; i < widgetChain.Length(); ++i ) {
|
||||
nsIWidget* widget = widgetChain[i];
|
||||
if ( nsWindow::EventIsInsideWindow(inMsg, (nsWindow*)widget) ) {
|
||||
// don't roll up if the mouse event occurred within a menu of the
|
||||
// same type. If the mouse event occurred in a menu higher than
|
||||
// that, roll up, but pass the number of popups to Rollup so
|
||||
// that only those of the same type close up.
|
||||
if (i < sameTypeCount) {
|
||||
rollup = false;
|
||||
}
|
||||
else {
|
||||
popupsToRollup = sameTypeCount;
|
||||
}
|
||||
break;
|
||||
// If we're dealing with menus, we probably have submenus and we don't
|
||||
// want to rollup if the click is in a parent menu of the current submenu.
|
||||
uint32_t popupsToRollup = UINT32_MAX;
|
||||
if (rollup) {
|
||||
nsAutoTArray<nsIWidget*, 5> widgetChain;
|
||||
uint32_t sameTypeCount = rollupListener->GetSubmenuWidgetChain(&widgetChain);
|
||||
for ( uint32_t i = 0; i < widgetChain.Length(); ++i ) {
|
||||
nsIWidget* widget = widgetChain[i];
|
||||
if ( nsWindow::EventIsInsideWindow(inMsg, (nsWindow*)widget) ) {
|
||||
// don't roll up if the mouse event occurred within a menu of the
|
||||
// same type. If the mouse event occurred in a menu higher than
|
||||
// that, roll up, but pass the number of popups to Rollup so
|
||||
// that only those of the same type close up.
|
||||
if (i < sameTypeCount) {
|
||||
rollup = false;
|
||||
} else {
|
||||
popupsToRollup = sameTypeCount;
|
||||
}
|
||||
} // foreach parent menu widget
|
||||
}
|
||||
|
||||
if (inMsg == WM_MOUSEACTIVATE) {
|
||||
// Prevent the click inside the popup from causing a change in window
|
||||
// activation. Since the popup is shown non-activated, we need to eat
|
||||
// any requests to activate the window while it is displayed. Windows
|
||||
// will automatically activate the popup on the mousedown otherwise.
|
||||
if (!rollup) {
|
||||
*outResult = MA_NOACTIVATE;
|
||||
return TRUE;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
UINT uMsg = HIWORD(inLParam);
|
||||
if (uMsg == WM_MOUSEMOVE)
|
||||
{
|
||||
// WM_MOUSEACTIVATE cause by moving the mouse - X-mouse (eg. TweakUI)
|
||||
// must be enabled in Windows.
|
||||
rollup = rollupListener->ShouldRollupOnMouseActivate();
|
||||
if (!rollup)
|
||||
{
|
||||
*outResult = MA_NOACTIVATE;
|
||||
return true;
|
||||
}
|
||||
} // foreach parent menu widget
|
||||
}
|
||||
|
||||
if (inMsg == WM_MOUSEACTIVATE) {
|
||||
// Prevent the click inside the popup from causing a change in window
|
||||
// activation. Since the popup is shown non-activated, we need to eat
|
||||
// any requests to activate the window while it is displayed. Windows
|
||||
// will automatically activate the popup on the mousedown otherwise.
|
||||
if (!rollup) {
|
||||
return true;
|
||||
} else {
|
||||
UINT uMsg = HIWORD(inLParam);
|
||||
if (uMsg == WM_MOUSEMOVE) {
|
||||
// WM_MOUSEACTIVATE cause by moving the mouse - X-mouse (eg. TweakUI)
|
||||
// must be enabled in Windows.
|
||||
rollup = rollupListener->ShouldRollupOnMouseActivate();
|
||||
if (!rollup) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// if we've still determined that we should still rollup everything, do it.
|
||||
else if (rollup) {
|
||||
// only need to deal with the last rollup for left mouse down events.
|
||||
NS_ASSERTION(!mLastRollup, "mLastRollup is null");
|
||||
bool consumeRollupEvent =
|
||||
rollupListener->Rollup(popupsToRollup, inMsg == WM_LBUTTONDOWN ? &mLastRollup : nullptr);
|
||||
NS_IF_ADDREF(mLastRollup);
|
||||
}
|
||||
// if we've still determined that we should still rollup everything, do it.
|
||||
else if (rollup) {
|
||||
// only need to deal with the last rollup for left mouse down events.
|
||||
NS_ASSERTION(!mLastRollup, "mLastRollup is null");
|
||||
bool consumeRollupEvent =
|
||||
rollupListener->Rollup(popupsToRollup, inMsg == WM_LBUTTONDOWN ? &mLastRollup : nullptr);
|
||||
NS_IF_ADDREF(mLastRollup);
|
||||
|
||||
// Tell hook to stop processing messages
|
||||
sProcessHook = false;
|
||||
sRollupMsgId = 0;
|
||||
sRollupMsgWnd = NULL;
|
||||
// Tell hook to stop processing messages
|
||||
sProcessHook = false;
|
||||
sRollupMsgId = 0;
|
||||
sRollupMsgWnd = NULL;
|
||||
|
||||
// return TRUE tells Windows that the event is consumed,
|
||||
// false allows the event to be dispatched
|
||||
//
|
||||
// So if we are NOT supposed to be consuming events, let it go through
|
||||
if (consumeRollupEvent && inMsg != WM_RBUTTONDOWN) {
|
||||
*outResult = MA_ACTIVATE;
|
||||
// return TRUE tells Windows that the event is consumed,
|
||||
// false allows the event to be dispatched
|
||||
//
|
||||
// So if we are NOT supposed to be consuming events, let it go through
|
||||
if (consumeRollupEvent && inMsg != WM_RBUTTONDOWN) {
|
||||
*outResult = MA_ACTIVATE;
|
||||
|
||||
// However, don't activate panels
|
||||
if (inMsg == WM_MOUSEACTIVATE) {
|
||||
nsWindow* activateWindow = WinUtils::GetNSWindowPtr(inWnd);
|
||||
if (activateWindow) {
|
||||
nsWindowType wintype;
|
||||
activateWindow->GetWindowType(wintype);
|
||||
if (wintype == eWindowType_popup && activateWindow->PopupType() == ePopupTypePanel) {
|
||||
*outResult = popupsToRollup != UINT32_MAX ? MA_NOACTIVATEANDEAT : MA_NOACTIVATE;
|
||||
}
|
||||
// However, don't activate panels
|
||||
if (inMsg == WM_MOUSEACTIVATE) {
|
||||
nsWindow* activateWindow = WinUtils::GetNSWindowPtr(inWnd);
|
||||
if (activateWindow) {
|
||||
nsWindowType wintype;
|
||||
activateWindow->GetWindowType(wintype);
|
||||
if (wintype == eWindowType_popup && activateWindow->PopupType() == ePopupTypePanel) {
|
||||
*outResult = popupsToRollup != UINT32_MAX ? MA_NOACTIVATEANDEAT : MA_NOACTIVATE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
// if we are only rolling up some popups, don't activate and don't let
|
||||
// the event go through. This prevents clicks menus higher in the
|
||||
// chain from opening when a context menu is open
|
||||
if (popupsToRollup != UINT32_MAX && inMsg == WM_MOUSEACTIVATE) {
|
||||
*outResult = MA_NOACTIVATEANDEAT;
|
||||
return TRUE;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // if event that might trigger a popup to rollup
|
||||
} // if rollup listeners registered
|
||||
// if we are only rolling up some popups, don't activate and don't let
|
||||
// the event go through. This prevents clicks menus higher in the
|
||||
// chain from opening when a context menu is open
|
||||
if (popupsToRollup != UINT32_MAX && inMsg == WM_MOUSEACTIVATE) {
|
||||
*outResult = MA_NOACTIVATEANDEAT;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} // if event that might trigger a popup to rollup
|
||||
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
|
@ -421,7 +421,7 @@ protected:
|
||||
static void ScheduleHookTimer(HWND aWnd, UINT aMsgId);
|
||||
static void RegisterSpecialDropdownHooks();
|
||||
static void UnregisterSpecialDropdownHooks();
|
||||
static BOOL DealWithPopups(HWND inWnd, UINT inMsg, WPARAM inWParam, LPARAM inLParam, LRESULT* outResult);
|
||||
static bool DealWithPopups(HWND inWnd, UINT inMsg, WPARAM inWParam, LPARAM inLParam, LRESULT* outResult);
|
||||
|
||||
/**
|
||||
* Window transparency helpers
|
||||
|
Loading…
Reference in New Issue
Block a user