r=mkaply, sr=blizzard, a=mkaply
OS/2 only - better checking for the message window so firebird/thunderbird/mozilla can coexist
This commit is contained in:
mkaply%us.ibm.com 2003-08-13 20:40:53 +00:00
Родитель 7fd1fa309e
Коммит 1a880b764d
2 изменённых файлов: 47 добавлений и 17 удалений

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

@ -75,9 +75,6 @@
extern char ** __argv; extern char ** __argv;
extern int __argc; extern int __argc;
// Adding to support DDE
#define ID_MESSAGEWINDOW 0xDEAF
/* trying to keep this like Window's COPYDATASTRUCT, but a compiler error is /* trying to keep this like Window's COPYDATASTRUCT, but a compiler error is
* forcing me to add chBuff so that we can append the data to the end of the * forcing me to add chBuff so that we can append the data to the end of the
* structure * structure
@ -957,12 +954,41 @@ struct MessageWindow {
// ctor/dtor are simplistic // ctor/dtor are simplistic
MessageWindow() { MessageWindow() {
// Try to find window. // Try to find window.
// XXX need to improve this to use check the class HATOMTBL hatomtbl;
mHandle = WinWindowFromID( HWND_OBJECT, ID_MESSAGEWINDOW ); HENUM henum;
HWND hwndNext;
char classname[CCHMAXPATH];
mHandle = NULLHANDLE;
hatomtbl = WinQuerySystemAtomTable();
mMsgWindowAtom = WinFindAtom(hatomtbl, className());
if (mMsgWindowAtom == 0)
{
// If there is not atom in the system table for this class name, then
// we can assume that the app is not currently running.
mMsgWindowAtom = WinAddAtom(hatomtbl, className());
} else {
// Found an existing atom for this class name. Cycle through existing
// windows and see if one with our window id and class name already
// exists
henum = WinBeginEnumWindows(HWND_OBJECT);
while ((hwndNext = WinGetNextWindow(henum)) != NULLHANDLE)
{
if (WinQueryWindowUShort(hwndNext, QWS_ID) == (USHORT)mMsgWindowAtom)
{
WinQueryClassName(hwndNext, CCHMAXPATH, classname);
if (strcmp(classname, className()) == 0)
{
mHandle = hwndNext;
break;
}
}
}
}
} }
// Act like an HWND. HWND getHWND() {
operator HWND() {
return mHandle; return mHandle;
} }
@ -1002,7 +1028,7 @@ struct MessageWindow {
0,0, // cx,cy 0,0, // cx,cy
HWND_DESKTOP,// owner HWND_DESKTOP,// owner
HWND_BOTTOM, // hwndbehind HWND_BOTTOM, // hwndbehind
ID_MESSAGEWINDOW, // id (USHORT)mMsgWindowAtom, // id
NULL, // pCtlData NULL, // pCtlData
NULL ); // pres params NULL ); // pres params
@ -1018,6 +1044,9 @@ struct MessageWindow {
nsresult retval = NS_OK; nsresult retval = NS_OK;
if ( mHandle ) { if ( mHandle ) {
HATOMTBL hatomtbl = WinQuerySystemAtomTable();
WinDeleteAtom(hatomtbl, mMsgWindowAtom);
// DestroyWindow can only destroy windows created from // DestroyWindow can only destroy windows created from
// the same thread. // the same thread.
BOOL desRes = WinDestroyWindow( mHandle ); BOOL desRes = WinDestroyWindow( mHandle );
@ -1101,7 +1130,8 @@ struct MessageWindow {
} }
private: private:
HWND mHandle; HWND mHandle;
USHORT mMsgWindowAtom;
}; // struct MessageWindow }; // struct MessageWindow
static char nameBuffer[128] = { 0 }; static char nameBuffer[128] = { 0 };
@ -1174,7 +1204,7 @@ nsNativeAppSupportOS2::Start( PRBool *aResult ) {
// Search for existing message window. // Search for existing message window.
MessageWindow msgWindow; MessageWindow msgWindow;
if ( (HWND)msgWindow ) { if ( msgWindow.getHWND() ) {
// We are a client process. Pass request to message window. // We are a client process. Pass request to message window.
char *cmd = GetCommandLine(); char *cmd = GetCommandLine();
rv = msgWindow.SendRequest( cmd ); rv = msgWindow.SendRequest( cmd );
@ -2355,7 +2385,7 @@ nsNativeAppSupportOS2::StartServerMode() {
mInitialWindowActive = PR_TRUE; mInitialWindowActive = PR_TRUE;
// Hide this window by re-parenting it (to ensure it doesn't appear). // Hide this window by re-parenting it (to ensure it doesn't appear).
ReParent( newWindow, (HWND)MessageWindow() ); ReParent( newWindow, MessageWindow().getHWND() );
return NS_OK; return NS_OK;
} }

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

@ -933,9 +933,9 @@ struct MessageWindow {
} }
} }
nsCOMPtr<nsIWindowsHooks> winHooksService ( do_GetService( NS_IWINDOWSHOOKS_CONTRACTID, &rv ) ); nsCOMPtr<nsIOSHooks> osHooksService ( do_GetService( NS_IOSHOOKS_CONTRACTID, &rv ) );
if ( NS_SUCCEEDED( rv ) ) if ( NS_SUCCEEDED( rv ) )
winHooksService->StartupRemoveOption("-turbo"); osHooksService->StartupRemoveOption("-turbo");
nsCOMPtr<nsIAppShellService> appShell = do_GetService( "@mozilla.org/appshell/appShellService;1", &rv ); nsCOMPtr<nsIAppShellService> appShell = do_GetService( "@mozilla.org/appshell/appShellService;1", &rv );
if ( NS_SUCCEEDED( rv ) ) { if ( NS_SUCCEEDED( rv ) ) {
@ -1083,10 +1083,10 @@ nsNativeAppSupportWin::FindTopic( HSZ topic ) {
static PRBool handlingHTTP() { static PRBool handlingHTTP() {
PRBool result = PR_FALSE; // Answer no if an error occurs. PRBool result = PR_FALSE; // Answer no if an error occurs.
// See if we're the "default browser" (i.e., handling http Internet shortcuts) // See if we're the "default browser" (i.e., handling http Internet shortcuts)
nsCOMPtr<nsIWindowsHooks> winhooks( do_GetService( NS_IWINDOWSHOOKS_CONTRACTID ) ); nsCOMPtr<nsIOSHooks> oshooks( do_GetService( NS_IOSHOOKS_CONTRACTID ) );
if ( winhooks ) { if ( oshooks ) {
nsCOMPtr<nsIWindowsHooksSettings> settings; nsCOMPtr<nsIOSHooksSettings> settings;
nsresult rv = winhooks->GetSettings( getter_AddRefs( settings ) ); nsresult rv = oshooks->GetSettings( getter_AddRefs( settings ) );
if ( NS_SUCCEEDED( rv ) ) { if ( NS_SUCCEEDED( rv ) ) {
settings->GetIsHandlingHTTP( &result ); settings->GetIsHandlingHTTP( &result );
if ( result ) { if ( result ) {