suppress blur events to parent widget. bug 68454 r=bryner,jst,kmcclusk

This commit is contained in:
danm%netscape.com 2003-02-24 20:15:48 +00:00
Родитель 5657505b12
Коммит 471e17c149
4 изменённых файлов: 73 добавлений и 7 удалений

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

@ -23,8 +23,10 @@
*/
#include "nsCOMPtr.h"
#include "nsGUIEvent.h"
#include "nsReadableUtils.h"
#include "nsNetUtil.h"
#include "nsWindow.h"
#include "nsIServiceManager.h"
#include "nsIPlatformCharset.h"
#include "nsFilePicker.h"
@ -64,7 +66,7 @@ char nsFilePicker::mLastUsedDirectory[MAX_PATH+1] = { 0 };
//-------------------------------------------------------------------------
nsFilePicker::nsFilePicker()
{
mWnd = NULL;
mParentWidget = nsnull;
mUnicodeEncoder = nsnull;
mUnicodeDecoder = nsnull;
mSelectedType = 1;
@ -78,6 +80,7 @@ nsFilePicker::nsFilePicker()
//-------------------------------------------------------------------------
nsFilePicker::~nsFilePicker()
{
NS_IF_RELEASE(mParentWidget);
NS_IF_RELEASE(mUnicodeEncoder);
NS_IF_RELEASE(mUnicodeDecoder);
}
@ -92,6 +95,12 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *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;
PRUnichar fileBuffer[MAX_PATH+1];
wcsncpy(fileBuffer, mDefault.get(), MAX_PATH);
@ -114,7 +123,8 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal)
wcsncpy(dirBuffer, initialDir.get(), MAX_PATH);
BROWSEINFOW browserInfo;
browserInfo.hwndOwner = mWnd;
browserInfo.hwndOwner = (HWND)
(mParentWidget ? mParentWidget->GetNativeData(NS_NATIVE_WINDOW) : 0);
browserInfo.pidlRoot = nsnull;
browserInfo.pszDisplayName = (LPWSTR)dirBuffer;
browserInfo.lpszTitle = title;
@ -156,7 +166,8 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal)
ofn.lpstrTitle = (LPCWSTR)title;
ofn.lpstrFilter = (LPCWSTR)filterBuffer.get();
ofn.nFilterIndex = mSelectedType;
ofn.hwndOwner = mWnd;
ofn.hwndOwner = (HWND)
(mParentWidget ? mParentWidget->GetNativeData(NS_NATIVE_WINDOW) : 0);
ofn.lpstrFile = fileBuffer;
ofn.nMaxFile = MAX_PATH;
@ -315,6 +326,11 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal)
else {
*aReturnVal = returnCancel;
}
if (mParentWidget) {
nsWindow *parent = NS_STATIC_CAST(nsWindow *, mParentWidget);
parent->SuppressBlurEvents(PR_FALSE);
}
return NS_OK;
}
#endif
@ -328,6 +344,12 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *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;
char fileBuffer[MAX_PATH+1] = "";
char *converted = ConvertToFileSystemCharset(mDefault.get());
@ -359,7 +381,8 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *aReturnVal)
char dirBuffer[MAX_PATH+1];
PL_strncpy(dirBuffer, initialDir.get(), MAX_PATH);
BROWSEINFO browserInfo;
browserInfo.hwndOwner = mWnd;
browserInfo.hwndOwner = (HWND)
(mParentWidget ? mParentWidget->GetNativeData(NS_NATIVE_WINDOW) : 0);
browserInfo.pidlRoot = nsnull;
browserInfo.pszDisplayName = (LPSTR)dirBuffer;
browserInfo.lpszTitle = title;
@ -411,7 +434,8 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *aReturnVal)
ofn.lpstrTitle = title;
ofn.lpstrFilter = filterBuffer;
ofn.nFilterIndex = mSelectedType;
ofn.hwndOwner = mWnd;
ofn.hwndOwner = (HWND)
(mParentWidget ? mParentWidget->GetNativeData(NS_NATIVE_WINDOW) : 0);
ofn.lpstrFile = fileBuffer;
ofn.nMaxFile = MAX_PATH;
@ -581,6 +605,11 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *aReturnVal)
else {
*aReturnVal = returnCancel;
}
if (mParentWidget) {
nsWindow *parent = NS_STATIC_CAST(nsWindow *, mParentWidget);
parent->SuppressBlurEvents(PR_FALSE);
}
return NS_OK;
}
#endif
@ -749,7 +778,8 @@ NS_IMETHODIMP nsFilePicker::InitNative(nsIWidget *aParent,
const PRUnichar *aTitle,
PRInt16 aMode)
{
mWnd = (HWND) ((aParent) ? aParent->GetNativeData(NS_NATIVE_WINDOW) : 0);
mParentWidget = aParent;
NS_IF_ADDREF(mParentWidget);
mTitle.SetLength(0);
mTitle.Append(aTitle);
mMode = aMode;

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

@ -76,7 +76,7 @@ protected:
char * ConvertToFileSystemCharset(const PRUnichar *inString);
PRUnichar * ConvertFromFileSystemCharset(const char *inString);
HWND mWnd;
nsIWidget *mParentWidget;
nsString mTitle;
PRInt16 mMode;
nsCString mFile;

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

@ -52,6 +52,9 @@ const nsIFilePicker = Components.interfaces.nsIFilePicker;
const nsIInterfaceRequestor = Components.interfaces.nsIInterfaceRequestor
const nsIDOMWindow = Components.interfaces.nsIDOMWindow;
const nsIStringBundleService = Components.interfaces.nsIStringBundleService;
const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
const nsIDocShellTreeItem = Components.interfaces.nsIDocShellTreeItem;
const nsIBaseWindow = Components.interfaces.nsIBaseWindow;
var bundle = null;
var lastDirectory = null;
@ -195,11 +198,26 @@ nsFilePicker.prototype = {
}
}
var parentWin = null;
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",
"",
"chrome,modal,titlebar,resizable=yes,dependent=yes",
o);
if (parentWin)
parentWin.blurSuppression = false;
this.mFile = o.retvals.file;
this.mFilterIndex = o.retvals.filterIndex;
this.mFilesEnumerator = o.retvals.files;

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

@ -52,6 +52,9 @@ const nsIFilePicker = Components.interfaces.nsIFilePicker;
const nsIInterfaceRequestor = Components.interfaces.nsIInterfaceRequestor
const nsIDOMWindow = Components.interfaces.nsIDOMWindow;
const nsIStringBundleService = Components.interfaces.nsIStringBundleService;
const nsIWebNavigation = Components.interfaces.nsIWebNavigation;
const nsIDocShellTreeItem = Components.interfaces.nsIDocShellTreeItem;
const nsIBaseWindow = Components.interfaces.nsIBaseWindow;
var bundle = null;
var lastDirectory = null;
@ -195,11 +198,26 @@ nsFilePicker.prototype = {
}
}
var parentWin = null;
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",
"",
"chrome,modal,titlebar,resizable=yes,dependent=yes",
o);
if (parentWin)
parentWin.blurSuppression = false;
this.mFile = o.retvals.file;
this.mFilterIndex = o.retvals.filterIndex;
this.mFilesEnumerator = o.retvals.files;