зеркало из https://github.com/mozilla/pjs.git
suppress blur events to parent widget. bug 68454 r=bryner,jst,kmcclusk
This commit is contained in:
Родитель
5657505b12
Коммит
471e17c149
|
@ -23,8 +23,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
|
#include "nsGUIEvent.h"
|
||||||
#include "nsReadableUtils.h"
|
#include "nsReadableUtils.h"
|
||||||
#include "nsNetUtil.h"
|
#include "nsNetUtil.h"
|
||||||
|
#include "nsWindow.h"
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsIPlatformCharset.h"
|
#include "nsIPlatformCharset.h"
|
||||||
#include "nsFilePicker.h"
|
#include "nsFilePicker.h"
|
||||||
|
@ -64,7 +66,7 @@ char nsFilePicker::mLastUsedDirectory[MAX_PATH+1] = { 0 };
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
nsFilePicker::nsFilePicker()
|
nsFilePicker::nsFilePicker()
|
||||||
{
|
{
|
||||||
mWnd = NULL;
|
mParentWidget = nsnull;
|
||||||
mUnicodeEncoder = nsnull;
|
mUnicodeEncoder = nsnull;
|
||||||
mUnicodeDecoder = nsnull;
|
mUnicodeDecoder = nsnull;
|
||||||
mSelectedType = 1;
|
mSelectedType = 1;
|
||||||
|
@ -78,6 +80,7 @@ nsFilePicker::nsFilePicker()
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
nsFilePicker::~nsFilePicker()
|
nsFilePicker::~nsFilePicker()
|
||||||
{
|
{
|
||||||
|
NS_IF_RELEASE(mParentWidget);
|
||||||
NS_IF_RELEASE(mUnicodeEncoder);
|
NS_IF_RELEASE(mUnicodeEncoder);
|
||||||
NS_IF_RELEASE(mUnicodeDecoder);
|
NS_IF_RELEASE(mUnicodeDecoder);
|
||||||
}
|
}
|
||||||
|
@ -92,6 +95,12 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aReturnVal);
|
NS_ENSURE_ARG_POINTER(aReturnVal);
|
||||||
|
|
||||||
|
// suppress blur events
|
||||||
|
if (mParentWidget) {
|
||||||
|
nsWindow *parent = NS_STATIC_CAST(nsWindow *, mParentWidget);
|
||||||
|
parent->SuppressBlurEvents(PR_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
PRBool result = PR_FALSE;
|
PRBool result = PR_FALSE;
|
||||||
PRUnichar fileBuffer[MAX_PATH+1];
|
PRUnichar fileBuffer[MAX_PATH+1];
|
||||||
wcsncpy(fileBuffer, mDefault.get(), MAX_PATH);
|
wcsncpy(fileBuffer, mDefault.get(), MAX_PATH);
|
||||||
|
@ -114,7 +123,8 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal)
|
||||||
wcsncpy(dirBuffer, initialDir.get(), MAX_PATH);
|
wcsncpy(dirBuffer, initialDir.get(), MAX_PATH);
|
||||||
|
|
||||||
BROWSEINFOW browserInfo;
|
BROWSEINFOW browserInfo;
|
||||||
browserInfo.hwndOwner = mWnd;
|
browserInfo.hwndOwner = (HWND)
|
||||||
|
(mParentWidget ? mParentWidget->GetNativeData(NS_NATIVE_WINDOW) : 0);
|
||||||
browserInfo.pidlRoot = nsnull;
|
browserInfo.pidlRoot = nsnull;
|
||||||
browserInfo.pszDisplayName = (LPWSTR)dirBuffer;
|
browserInfo.pszDisplayName = (LPWSTR)dirBuffer;
|
||||||
browserInfo.lpszTitle = title;
|
browserInfo.lpszTitle = title;
|
||||||
|
@ -156,7 +166,8 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal)
|
||||||
ofn.lpstrTitle = (LPCWSTR)title;
|
ofn.lpstrTitle = (LPCWSTR)title;
|
||||||
ofn.lpstrFilter = (LPCWSTR)filterBuffer.get();
|
ofn.lpstrFilter = (LPCWSTR)filterBuffer.get();
|
||||||
ofn.nFilterIndex = mSelectedType;
|
ofn.nFilterIndex = mSelectedType;
|
||||||
ofn.hwndOwner = mWnd;
|
ofn.hwndOwner = (HWND)
|
||||||
|
(mParentWidget ? mParentWidget->GetNativeData(NS_NATIVE_WINDOW) : 0);
|
||||||
ofn.lpstrFile = fileBuffer;
|
ofn.lpstrFile = fileBuffer;
|
||||||
ofn.nMaxFile = MAX_PATH;
|
ofn.nMaxFile = MAX_PATH;
|
||||||
|
|
||||||
|
@ -315,6 +326,11 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal)
|
||||||
else {
|
else {
|
||||||
*aReturnVal = returnCancel;
|
*aReturnVal = returnCancel;
|
||||||
}
|
}
|
||||||
|
if (mParentWidget) {
|
||||||
|
nsWindow *parent = NS_STATIC_CAST(nsWindow *, mParentWidget);
|
||||||
|
parent->SuppressBlurEvents(PR_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -328,6 +344,12 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *aReturnVal)
|
||||||
{
|
{
|
||||||
NS_ENSURE_ARG_POINTER(aReturnVal);
|
NS_ENSURE_ARG_POINTER(aReturnVal);
|
||||||
|
|
||||||
|
// suppress blur event
|
||||||
|
if (mParentWidget) {
|
||||||
|
nsWindow *parent = NS_STATIC_CAST(nsWindow *, mParentWidget);
|
||||||
|
parent->SuppressBlurEvents(PR_TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
PRBool result = PR_FALSE;
|
PRBool result = PR_FALSE;
|
||||||
char fileBuffer[MAX_PATH+1] = "";
|
char fileBuffer[MAX_PATH+1] = "";
|
||||||
char *converted = ConvertToFileSystemCharset(mDefault.get());
|
char *converted = ConvertToFileSystemCharset(mDefault.get());
|
||||||
|
@ -359,7 +381,8 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *aReturnVal)
|
||||||
char dirBuffer[MAX_PATH+1];
|
char dirBuffer[MAX_PATH+1];
|
||||||
PL_strncpy(dirBuffer, initialDir.get(), MAX_PATH);
|
PL_strncpy(dirBuffer, initialDir.get(), MAX_PATH);
|
||||||
BROWSEINFO browserInfo;
|
BROWSEINFO browserInfo;
|
||||||
browserInfo.hwndOwner = mWnd;
|
browserInfo.hwndOwner = (HWND)
|
||||||
|
(mParentWidget ? mParentWidget->GetNativeData(NS_NATIVE_WINDOW) : 0);
|
||||||
browserInfo.pidlRoot = nsnull;
|
browserInfo.pidlRoot = nsnull;
|
||||||
browserInfo.pszDisplayName = (LPSTR)dirBuffer;
|
browserInfo.pszDisplayName = (LPSTR)dirBuffer;
|
||||||
browserInfo.lpszTitle = title;
|
browserInfo.lpszTitle = title;
|
||||||
|
@ -411,7 +434,8 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *aReturnVal)
|
||||||
ofn.lpstrTitle = title;
|
ofn.lpstrTitle = title;
|
||||||
ofn.lpstrFilter = filterBuffer;
|
ofn.lpstrFilter = filterBuffer;
|
||||||
ofn.nFilterIndex = mSelectedType;
|
ofn.nFilterIndex = mSelectedType;
|
||||||
ofn.hwndOwner = mWnd;
|
ofn.hwndOwner = (HWND)
|
||||||
|
(mParentWidget ? mParentWidget->GetNativeData(NS_NATIVE_WINDOW) : 0);
|
||||||
ofn.lpstrFile = fileBuffer;
|
ofn.lpstrFile = fileBuffer;
|
||||||
ofn.nMaxFile = MAX_PATH;
|
ofn.nMaxFile = MAX_PATH;
|
||||||
|
|
||||||
|
@ -581,6 +605,11 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *aReturnVal)
|
||||||
else {
|
else {
|
||||||
*aReturnVal = returnCancel;
|
*aReturnVal = returnCancel;
|
||||||
}
|
}
|
||||||
|
if (mParentWidget) {
|
||||||
|
nsWindow *parent = NS_STATIC_CAST(nsWindow *, mParentWidget);
|
||||||
|
parent->SuppressBlurEvents(PR_FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -749,7 +778,8 @@ NS_IMETHODIMP nsFilePicker::InitNative(nsIWidget *aParent,
|
||||||
const PRUnichar *aTitle,
|
const PRUnichar *aTitle,
|
||||||
PRInt16 aMode)
|
PRInt16 aMode)
|
||||||
{
|
{
|
||||||
mWnd = (HWND) ((aParent) ? aParent->GetNativeData(NS_NATIVE_WINDOW) : 0);
|
mParentWidget = aParent;
|
||||||
|
NS_IF_ADDREF(mParentWidget);
|
||||||
mTitle.SetLength(0);
|
mTitle.SetLength(0);
|
||||||
mTitle.Append(aTitle);
|
mTitle.Append(aTitle);
|
||||||
mMode = aMode;
|
mMode = aMode;
|
||||||
|
|
|
@ -76,7 +76,7 @@ protected:
|
||||||
char * ConvertToFileSystemCharset(const PRUnichar *inString);
|
char * ConvertToFileSystemCharset(const PRUnichar *inString);
|
||||||
PRUnichar * ConvertFromFileSystemCharset(const char *inString);
|
PRUnichar * ConvertFromFileSystemCharset(const char *inString);
|
||||||
|
|
||||||
HWND mWnd;
|
nsIWidget *mParentWidget;
|
||||||
nsString mTitle;
|
nsString mTitle;
|
||||||
PRInt16 mMode;
|
PRInt16 mMode;
|
||||||
nsCString mFile;
|
nsCString mFile;
|
||||||
|
|
|
@ -52,6 +52,9 @@ const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||||
const nsIInterfaceRequestor = Components.interfaces.nsIInterfaceRequestor
|
const nsIInterfaceRequestor = Components.interfaces.nsIInterfaceRequestor
|
||||||
const nsIDOMWindow = Components.interfaces.nsIDOMWindow;
|
const nsIDOMWindow = Components.interfaces.nsIDOMWindow;
|
||||||
const nsIStringBundleService = Components.interfaces.nsIStringBundleService;
|
const nsIStringBundleService = Components.interfaces.nsIStringBundleService;
|
||||||
|
const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
|
||||||
|
const nsIDocShellTreeItem = Components.interfaces.nsIDocShellTreeItem;
|
||||||
|
const nsIBaseWindow = Components.interfaces.nsIBaseWindow;
|
||||||
|
|
||||||
var bundle = null;
|
var bundle = null;
|
||||||
var lastDirectory = null;
|
var lastDirectory = null;
|
||||||
|
@ -195,11 +198,26 @@ nsFilePicker.prototype = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var parentWin = null;
|
||||||
try {
|
try {
|
||||||
|
parentWin = parent.QueryInterface(nsIInterfaceRequestor)
|
||||||
|
.getInterface(nsIWebNavigation)
|
||||||
|
.QueryInterface(nsIDocShellTreeItem)
|
||||||
|
.treeOwner
|
||||||
|
.QueryInterface(nsIInterfaceRequestor)
|
||||||
|
.getInterface(nsIBaseWindow);
|
||||||
|
} catch(ex) {
|
||||||
|
dump("file picker couldn't get base window\n"+ex+"\n");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (parentWin)
|
||||||
|
parentWin.blurSuppression = true;
|
||||||
parent.openDialog("chrome://global/content/filepicker.xul",
|
parent.openDialog("chrome://global/content/filepicker.xul",
|
||||||
"",
|
"",
|
||||||
"chrome,modal,titlebar,resizable=yes,dependent=yes",
|
"chrome,modal,titlebar,resizable=yes,dependent=yes",
|
||||||
o);
|
o);
|
||||||
|
if (parentWin)
|
||||||
|
parentWin.blurSuppression = false;
|
||||||
this.mFile = o.retvals.file;
|
this.mFile = o.retvals.file;
|
||||||
this.mFilterIndex = o.retvals.filterIndex;
|
this.mFilterIndex = o.retvals.filterIndex;
|
||||||
this.mFilesEnumerator = o.retvals.files;
|
this.mFilesEnumerator = o.retvals.files;
|
||||||
|
|
|
@ -52,6 +52,9 @@ const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||||
const nsIInterfaceRequestor = Components.interfaces.nsIInterfaceRequestor
|
const nsIInterfaceRequestor = Components.interfaces.nsIInterfaceRequestor
|
||||||
const nsIDOMWindow = Components.interfaces.nsIDOMWindow;
|
const nsIDOMWindow = Components.interfaces.nsIDOMWindow;
|
||||||
const nsIStringBundleService = Components.interfaces.nsIStringBundleService;
|
const nsIStringBundleService = Components.interfaces.nsIStringBundleService;
|
||||||
|
const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
|
||||||
|
const nsIDocShellTreeItem = Components.interfaces.nsIDocShellTreeItem;
|
||||||
|
const nsIBaseWindow = Components.interfaces.nsIBaseWindow;
|
||||||
|
|
||||||
var bundle = null;
|
var bundle = null;
|
||||||
var lastDirectory = null;
|
var lastDirectory = null;
|
||||||
|
@ -195,11 +198,26 @@ nsFilePicker.prototype = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var parentWin = null;
|
||||||
try {
|
try {
|
||||||
|
parentWin = parent.QueryInterface(nsIInterfaceRequestor)
|
||||||
|
.getInterface(nsIWebNavigation)
|
||||||
|
.QueryInterface(nsIDocShellTreeItem)
|
||||||
|
.treeOwner
|
||||||
|
.QueryInterface(nsIInterfaceRequestor)
|
||||||
|
.getInterface(nsIBaseWindow);
|
||||||
|
} catch(ex) {
|
||||||
|
dump("file picker couldn't get base window\n"+ex+"\n");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (parentWin)
|
||||||
|
parentWin.blurSuppression = true;
|
||||||
parent.openDialog("chrome://global/content/filepicker.xul",
|
parent.openDialog("chrome://global/content/filepicker.xul",
|
||||||
"",
|
"",
|
||||||
"chrome,modal,titlebar,resizable=yes,dependent=yes",
|
"chrome,modal,titlebar,resizable=yes,dependent=yes",
|
||||||
o);
|
o);
|
||||||
|
if (parentWin)
|
||||||
|
parentWin.blurSuppression = false;
|
||||||
this.mFile = o.retvals.file;
|
this.mFile = o.retvals.file;
|
||||||
this.mFilterIndex = o.retvals.filterIndex;
|
this.mFilterIndex = o.retvals.filterIndex;
|
||||||
this.mFilesEnumerator = o.retvals.files;
|
this.mFilesEnumerator = o.retvals.files;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче