fix for 78514, r=pink, sr=hyatt. Windows only temporary (until focus gets totally overhauled) hack to support embedding applications better. This causes our app to relinquish focus to native chrome in the embeddor's app. To do this, we check if the window that is about to get focus is a mozilla window. If not, we obey wm_killfocus like a normal app, and don't wait for the following focus to send the blur event.
git-svn-id: svn://10.0.0.236/trunk@95393 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
e3706c4c82
commit
64b9ba3dd5
@ -460,7 +460,76 @@ nsEventStateManager::PreHandleEvent(nsIPresContext* aPresContext,
|
||||
// Hold the blur, wait for the focus so we can query the style of the focus
|
||||
// target as to what to do with the event. If appropriate we fire the blur
|
||||
// at that time.
|
||||
#ifdef XP_WIN
|
||||
if(! NS_STATIC_CAST(nsFocusEvent*, aEvent)->isMozWindowTakingFocus) {
|
||||
EnsureDocument(aPresContext);
|
||||
|
||||
// We can get a deactivate on an Ender widget. In this
|
||||
// case, we would like to obtain the DOM Window to start
|
||||
// with by looking at gLastFocusedContent.
|
||||
nsCOMPtr<nsIScriptGlobalObject> ourGlobal;
|
||||
if (gLastFocusedContent) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
gLastFocusedContent->GetDocument(*getter_AddRefs(doc));
|
||||
if(doc)
|
||||
doc->GetScriptGlobalObject(getter_AddRefs(ourGlobal));
|
||||
else {
|
||||
mDocument->GetScriptGlobalObject(getter_AddRefs(ourGlobal));
|
||||
NS_RELEASE(gLastFocusedContent);
|
||||
}
|
||||
}
|
||||
else mDocument->GetScriptGlobalObject(getter_AddRefs(ourGlobal));
|
||||
|
||||
// Now fire blurs. We have to fire a blur on the focused window
|
||||
// and on the focused element if there is one.
|
||||
if (gLastFocusedDocument && gLastFocusedPresContext) {
|
||||
// Blur the element.
|
||||
if (gLastFocusedContent) {
|
||||
// Retrieve this content node's pres context. it can be out of sync in
|
||||
// the Ender widget case.
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
gLastFocusedContent->GetDocument(*getter_AddRefs(doc));
|
||||
if (doc) {
|
||||
nsCOMPtr<nsIPresShell> shell = getter_AddRefs(doc->GetShellAt(0));
|
||||
if (shell) {
|
||||
nsCOMPtr<nsIPresContext> oldPresContext;
|
||||
shell->GetPresContext(getter_AddRefs(oldPresContext));
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
event.message = NS_BLUR_CONTENT;
|
||||
nsCOMPtr<nsIEventStateManager> esm;
|
||||
oldPresContext->GetEventStateManager(getter_AddRefs(esm));
|
||||
esm->SetFocusedContent(gLastFocusedContent);
|
||||
gLastFocusedContent->HandleDOMEvent(oldPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
|
||||
esm->SetFocusedContent(nsnull);
|
||||
NS_IF_RELEASE(gLastFocusedContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsEventStatus status = nsEventStatus_eIgnore;
|
||||
nsEvent event;
|
||||
event.eventStructType = NS_EVENT;
|
||||
event.message = NS_BLUR_CONTENT;
|
||||
|
||||
// fire blur on document and window
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalObject;
|
||||
if(gLastFocusedDocument) {
|
||||
gLastFocusedDocument->GetScriptGlobalObject(getter_AddRefs(globalObject));
|
||||
gLastFocusedDocument->HandleDOMEvent(gLastFocusedPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
|
||||
if(globalObject)
|
||||
globalObject->HandleDOMEvent(gLastFocusedPresContext, &event, nsnull, NS_EVENT_FLAG_INIT, &status);
|
||||
}
|
||||
// Now clear our our global variables
|
||||
mCurrentTarget = nsnull;
|
||||
NS_IF_RELEASE(gLastFocusedDocument);
|
||||
gLastFocusedPresContext = nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case NS_ACTIVATE:
|
||||
|
||||
@ -296,6 +296,13 @@ struct nsFormEvent : public nsEvent {
|
||||
nsIContent *originator;
|
||||
};
|
||||
|
||||
/**
|
||||
* Focus event
|
||||
*/
|
||||
struct nsFocusEvent : public nsGUIEvent {
|
||||
PRBool isMozWindowTakingFocus;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Event status for D&D Event
|
||||
@ -334,6 +341,7 @@ enum nsDragDropEventStatus {
|
||||
#define NS_RECONVERSION_QUERY 19
|
||||
#define NS_ACCESSIBLE_EVENT 20
|
||||
#define NS_FORM_EVENT 21
|
||||
#define NS_FOCUS_EVENT 22
|
||||
|
||||
/**
|
||||
* GUI MESSAGES
|
||||
|
||||
@ -2763,6 +2763,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
|
||||
static PRBool getWheelInfo = PR_TRUE;
|
||||
nsPaletteInfo palInfo;
|
||||
*aRetValue = 0;
|
||||
PRBool isMozWindowTakingFocus = PR_TRUE;
|
||||
|
||||
// Uncomment this to see all windows messages
|
||||
// first param showss all events
|
||||
@ -3142,7 +3143,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
|
||||
// notified when a child window that doesn't have this handler proc
|
||||
// (read as: windows created by plugins like Adobe Acrobat)
|
||||
// has been activated via clicking.
|
||||
DispatchFocus(NS_PLUGIN_ACTIVATE);
|
||||
DispatchFocus(NS_PLUGIN_ACTIVATE, isMozWindowTakingFocus);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -3154,18 +3155,23 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
|
||||
}
|
||||
|
||||
case WM_SETFOCUS:
|
||||
result = DispatchFocus(NS_GOTFOCUS);
|
||||
result = DispatchFocus(NS_GOTFOCUS, isMozWindowTakingFocus);
|
||||
if(gJustGotActivate) {
|
||||
gJustGotActivate = PR_FALSE;
|
||||
result = DispatchFocus(NS_ACTIVATE);
|
||||
result = DispatchFocus(NS_ACTIVATE, isMozWindowTakingFocus);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_KILLFOCUS:
|
||||
result = DispatchFocus(NS_LOSTFOCUS);
|
||||
char className[19];
|
||||
::GetClassName((HWND)wParam, className, 19);
|
||||
if(strcmp(className, WindowClass()))
|
||||
isMozWindowTakingFocus = PR_FALSE;
|
||||
|
||||
result = DispatchFocus(NS_LOSTFOCUS, isMozWindowTakingFocus);
|
||||
if(gJustGotDeactivate) {
|
||||
gJustGotDeactivate = PR_FALSE;
|
||||
result = DispatchFocus(NS_DEACTIVATE);
|
||||
result = DispatchFocus(NS_DEACTIVATE, isMozWindowTakingFocus);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -4195,18 +4201,20 @@ PRBool nsWindow::DispatchAccessibleEvent(PRUint32 aEventType, nsIAccessible** aA
|
||||
// Deal with focus messages
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsWindow::DispatchFocus(PRUint32 aEventType)
|
||||
PRBool nsWindow::DispatchFocus(PRUint32 aEventType, PRBool isMozWindowTakingFocus)
|
||||
{
|
||||
// call the event callback
|
||||
if (mEventCallback) {
|
||||
nsGUIEvent event;
|
||||
event.eventStructType = NS_GUI_EVENT;
|
||||
nsFocusEvent event;
|
||||
event.eventStructType = NS_FOCUS_EVENT;
|
||||
InitEvent(event, aEventType);
|
||||
|
||||
//focus and blur event should go to their base widget loc, not current mouse pos
|
||||
event.point.x = 0;
|
||||
event.point.y = 0;
|
||||
|
||||
event.isMozWindowTakingFocus = isMozWindowTakingFocus;
|
||||
|
||||
nsPluginEvent pluginEvent;
|
||||
|
||||
switch (aEventType)//~~~
|
||||
|
||||
@ -350,7 +350,7 @@ protected:
|
||||
ULONG IsSpecialChar(UINT aVirtualKeyCode, WORD *aAsciiKey);
|
||||
virtual PRBool DispatchKeyEvent(PRUint32 aEventType, WORD aCharCode, UINT aVirtualCharCode);
|
||||
|
||||
virtual PRBool DispatchFocus(PRUint32 aEventType);
|
||||
virtual PRBool DispatchFocus(PRUint32 aEventType, PRBool isMozWindowTakingFocus);
|
||||
virtual PRBool OnScroll(UINT scrollCode, int cPos);
|
||||
virtual HBRUSH OnControlColor();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user