From 8352dc70d6ab9d3a4fec86eacf54064663e739cf Mon Sep 17 00:00:00 2001 From: "amardare%qnx.com" Date: Fri, 20 Feb 2004 22:48:17 +0000 Subject: [PATCH] Changes for the qnx platform only. These changes should not affect runtime/building other platforms. --- widget/src/photon/nsAppShell.cpp | 27 +++----- widget/src/photon/nsClipboard.cpp | 2 +- widget/src/photon/nsPhMozRemoteHelper.cpp | 45 ++++++++++++++ widget/src/photon/nsPhMozRemoteHelper.h | 43 +++++++++++++ widget/src/photon/nsWidget.cpp | 37 +++++------ widget/src/photon/nsWindow.cpp | 2 +- widget/src/xremoteclient/PhRemoteClient.cpp | 20 ++++-- xpfe/bootstrap/nsNativeAppSupportPh.cpp | 69 ++------------------- 8 files changed, 137 insertions(+), 108 deletions(-) create mode 100644 widget/src/photon/nsPhMozRemoteHelper.cpp create mode 100644 widget/src/photon/nsPhMozRemoteHelper.h diff --git a/widget/src/photon/nsAppShell.cpp b/widget/src/photon/nsAppShell.cpp index c1800afa2a9d..6f53fc99f43d 100644 --- a/widget/src/photon/nsAppShell.cpp +++ b/widget/src/photon/nsAppShell.cpp @@ -142,8 +142,14 @@ static int event_processor_callback(int fd, void *data, unsigned mode) #ifdef MOZ_ENABLE_XREMOTE /* the connector name that a client can use to remote control this instance of mozilla */ -#define BrowserRemoteServerName "MozillaBrowserRemoteServer" -#define MailRemoteServerName "MozillaMailRemoteServer" + +#if defined(MOZ_PHOENIX) +#define RemoteServerName "FirebirdRemoteServer" +#elif defined(MOZ_THUNDERBIRD) +#define RemoteServerName "ThunderbirdRemoteServer" +#else +#define RemoteServerName "MozillaRemoteServer" +#endif #define MOZ_REMOTE_MSG_TYPE 100 @@ -174,7 +180,7 @@ static void const * RemoteMsgHandler( PtConnectionServer_t *connection, void *us static void client_connect( PtConnector_t *cntr, PtConnectionServer_t *csrvr, void *data ) { - PtConnectionMsgHandler_t handlers[] = { { 0, RemoteMsgHandler } }; + static PtConnectionMsgHandler_t handlers[] = { { 0, RemoteMsgHandler } }; PtConnectionAddMsgHandlers( csrvr, handlers, sizeof(handlers)/sizeof(handlers[0]) ); } @@ -222,23 +228,8 @@ NS_IMETHODIMP nsAppShell::Create(int *bac, char **bav) mPtInited = PR_TRUE; #ifdef MOZ_ENABLE_XREMOTE - - char *RemoteServerName = BrowserRemoteServerName; - char *RemoteServerNameExtra = nsnull; - - if( argc > 0 && argv && argv[0] ) { - if( PL_strstr( argv[0], "Firebird" ) ) RemoteServerName = BrowserRemoteServerName; - else if( PL_strstr( argv[0], "thunderbird" ) ) RemoteServerName = MailRemoteServerName; - else { - /* full mozilla creates 2 connectors one for the browser side and another one for the mail side */ - RemoteServerName = BrowserRemoteServerName; - RemoteServerNameExtra = MailRemoteServerName; - } - } - /* create a connector for the xremote control */ PtConnectorCreate( RemoteServerName, client_connect, NULL ); - if( RemoteServerNameExtra ) PtConnectorCreate( RemoteServerNameExtra, client_connect, NULL ); #endif } diff --git a/widget/src/photon/nsClipboard.cpp b/widget/src/photon/nsClipboard.cpp index 489846414d26..dc23d6c2af9f 100644 --- a/widget/src/photon/nsClipboard.cpp +++ b/widget/src/photon/nsClipboard.cpp @@ -350,7 +350,7 @@ nsClipboard::GetNativeClipboardData(nsITransferable * aTransferable, We can have a HTML flavour from a previous copy and a TEXT flavour from a more recent copy from another application ( from instance from ped or pterm ). The HTML flavour and TEXT flavour are desynchronized and we have to use only the most recent one */ - unsigned long *dont_use_flavour = ( unsigned long * ) calloc( 1, cnt ); + unsigned long *dont_use_flavour = ( unsigned long * ) calloc( cnt, sizeof( unsigned long ) ); if( !dont_use_flavour ) { PhClipboardPasteFinish( clipPtr ); return NS_ERROR_FAILURE; diff --git a/widget/src/photon/nsPhMozRemoteHelper.cpp b/widget/src/photon/nsPhMozRemoteHelper.cpp new file mode 100644 index 000000000000..ce4ecc8f2265 --- /dev/null +++ b/widget/src/photon/nsPhMozRemoteHelper.cpp @@ -0,0 +1,45 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Christopher Blizzard. + * Portions created by Christopher Blizzard are Copyright (C) + * Christopher Blizzard. All Rights Reserved. + * + * Contributor(s): + * Adrian Mardare + */ + +/* the XRemoteService.cpp insists on getting the "widget helper service" */ + +#include +#include +#include +#include +#include "nsPhMozRemoteHelper.h" + +nsPhXRemoteWidgetHelper::nsPhXRemoteWidgetHelper() +{ +} + +nsPhXRemoteWidgetHelper::~nsPhXRemoteWidgetHelper() +{ +} + +NS_IMPL_ISUPPORTS1(nsPhXRemoteWidgetHelper, nsIXRemoteWidgetHelper) + +NS_IMETHODIMP +nsPhXRemoteWidgetHelper::EnableXRemoteCommands(nsIWidget *aWidget) +{ + return NS_OK; +} + diff --git a/widget/src/photon/nsPhMozRemoteHelper.h b/widget/src/photon/nsPhMozRemoteHelper.h new file mode 100644 index 000000000000..89cba45d2101 --- /dev/null +++ b/widget/src/photon/nsPhMozRemoteHelper.h @@ -0,0 +1,43 @@ +/* + * The contents of this file are subject to the Mozilla Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Christopher Blizzard. + * Portions created by Christopher Blizzard are Copyright (C) + * Christopher Blizzard. All Rights Reserved. + * + * Contributor(s): + * Adrian Mardare + */ + +#ifndef __nsPhMozRemoteHelper_h__ +#define __nsPhMozRemoteHelper_h__ + +#include + +// {84f94aac-1dd2-11b2-a05f-9b338fea662c} + +#define NS_PHXREMOTEWIDGETHELPER_CID \ + { 0x84f94aac, 0x1dd2, 0x11b2, \ + { 0xa0, 0x5f, 0x9b, 0x33, 0x8f, 0xea, 0x66, 0x2c } } + +class nsPhXRemoteWidgetHelper : public nsIXRemoteWidgetHelper { + public: + nsPhXRemoteWidgetHelper(); + virtual ~nsPhXRemoteWidgetHelper(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD EnableXRemoteCommands(nsIWidget *aWidget); +}; + +#endif /* __nsPhMozRemoteHelper_h__ */ diff --git a/widget/src/photon/nsWidget.cpp b/widget/src/photon/nsWidget.cpp index aa411a1cd41c..635cd44cc3df 100644 --- a/widget/src/photon/nsWidget.cpp +++ b/widget/src/photon/nsWidget.cpp @@ -787,35 +787,32 @@ struct nsKeyConverter { }; static struct nsKeyConverter nsKeycodes[] = { + { NS_VK_PAGE_UP, Pk_Pg_Up, PR_FALSE }, + { NS_VK_PAGE_DOWN, Pk_Pg_Down, PR_FALSE }, + { NS_VK_UP, Pk_Up, PR_FALSE }, + { NS_VK_DOWN, Pk_Down, PR_FALSE }, + { NS_VK_TAB, Pk_Tab, PR_FALSE }, + { NS_VK_HOME, Pk_Home, PR_FALSE }, + { NS_VK_END, Pk_End, PR_FALSE }, + { NS_VK_LEFT, Pk_Left, PR_FALSE }, + { NS_VK_RIGHT, Pk_Right, PR_FALSE }, + { NS_VK_DELETE, Pk_Delete, PR_FALSE }, + { NS_VK_SPACE, Pk_space, PR_TRUE }, { NS_VK_CANCEL, Pk_Cancel, PR_FALSE }, { NS_VK_BACK, Pk_BackSpace, PR_FALSE }, - { NS_VK_TAB, Pk_Tab, PR_FALSE }, - { NS_VK_TAB, Pk_KP_Tab, PR_FALSE }, { NS_VK_CLEAR, Pk_Clear, PR_FALSE }, { NS_VK_RETURN, Pk_Return, PR_FALSE }, { NS_VK_SHIFT, Pk_Shift_L, PR_FALSE }, { NS_VK_SHIFT, Pk_Shift_R, PR_FALSE }, - { NS_VK_SHIFT, Pk_Shift_L, PR_FALSE }, - { NS_VK_SHIFT, Pk_Shift_R, PR_FALSE }, { NS_VK_CONTROL, Pk_Control_L, PR_FALSE }, { NS_VK_CONTROL, Pk_Control_R, PR_FALSE }, { NS_VK_ALT, Pk_Alt_L, PR_FALSE }, { NS_VK_ALT, Pk_Alt_R, PR_FALSE }, + { NS_VK_INSERT, Pk_Insert, PR_FALSE }, { NS_VK_PAUSE, Pk_Pause, PR_FALSE }, { NS_VK_CAPS_LOCK, Pk_Caps_Lock, PR_FALSE }, { NS_VK_ESCAPE, Pk_Escape, PR_FALSE }, - { NS_VK_SPACE, Pk_space, PR_TRUE }, - { NS_VK_PAGE_UP, Pk_Pg_Up, PR_FALSE }, - { NS_VK_PAGE_DOWN, Pk_Pg_Down, PR_FALSE }, - { NS_VK_END, Pk_End, PR_FALSE }, - { NS_VK_HOME, Pk_Home, PR_FALSE }, - { NS_VK_LEFT, Pk_Left, PR_FALSE }, - { NS_VK_UP, Pk_Up, PR_FALSE }, - { NS_VK_RIGHT, Pk_Right, PR_FALSE }, - { NS_VK_DOWN, Pk_Down, PR_FALSE }, { NS_VK_PRINTSCREEN, Pk_Print, PR_FALSE }, - { NS_VK_INSERT, Pk_Insert, PR_FALSE }, - { NS_VK_DELETE, Pk_Delete, PR_FALSE }, { NS_VK_COMMA, Pk_comma, PR_TRUE }, { NS_VK_PERIOD, Pk_period, PR_TRUE }, { NS_VK_SLASH, Pk_slash, PR_TRUE }, @@ -892,9 +889,9 @@ inline void nsWidget::InitKeyEvent(PhKeyEvent_t *aPhKeyEvent, PRBool IsChar; unsigned long vkey; - if (Pk_KF_Cap_Valid & aPhKeyEvent->key_flags) - vkey = nsConvertKey(aPhKeyEvent->key_cap, &IsChar); - else vkey = nsConvertKey(aPhKeyEvent->key_sym, &IsChar); + if( aPhKeyEvent->key_flags & Pk_KF_Sym_Valid ) + vkey = nsConvertKey( aPhKeyEvent->key_sym, &IsChar ); + else vkey = nsConvertKey( aPhKeyEvent->key_cap, &IsChar ); anEvent.isShift = ( aPhKeyEvent->key_mods & Pk_KM_Shift ) ? PR_TRUE : PR_FALSE; anEvent.isControl = ( aPhKeyEvent->key_mods & Pk_KM_Ctrl ) ? PR_TRUE : PR_FALSE; @@ -924,10 +921,10 @@ PRBool nsWidget::DispatchKeyEvent( PhKeyEvent_t *aPhKeyEvent ) { nsKeyEvent keyEvent; PRBool result = PR_FALSE; - if ( (aPhKeyEvent->key_flags & Pk_KF_Cap_Valid) == 0) { + if( !(aPhKeyEvent->key_flags & (Pk_KF_Cap_Valid|Pk_KF_Sym_Valid) ) ) { //printf("nsWidget::DispatchKeyEvent throwing away invalid key: Modifiers Valid=<%d,%d,%d> this=<%p>\n", //(aPhKeyEvent->key_flags & Pk_KF_Scan_Valid), (aPhKeyEvent->key_flags & Pk_KF_Sym_Valid), (aPhKeyEvent->key_flags & Pk_KF_Cap_Valid), this ); - return PR_FALSE; //PR_TRUE; + return PR_FALSE; } if ( PtIsFocused(mWidget) != 2) { diff --git a/widget/src/photon/nsWindow.cpp b/widget/src/photon/nsWindow.cpp index cd8580bffd41..ee4afafc1584 100644 --- a/widget/src/photon/nsWindow.cpp +++ b/widget/src/photon/nsWindow.cpp @@ -40,7 +40,7 @@ #include "nsPhWidgetLog.h" #include -#include +#include #include "PtRawDrawContainer.h" #include "nsCRT.h" /* JPB - Added to get around nsCRT undeclared issues... */ diff --git a/widget/src/xremoteclient/PhRemoteClient.cpp b/widget/src/xremoteclient/PhRemoteClient.cpp index 9682b7fb537b..e3a79a8a5fdb 100644 --- a/widget/src/xremoteclient/PhRemoteClient.cpp +++ b/widget/src/xremoteclient/PhRemoteClient.cpp @@ -35,8 +35,14 @@ #include #include -#define BrowserRemoteServerName "MozillaBrowserRemoteServer" -#define MailRemoteServerName "MozillaMailRemoteServer" +#if defined(MOZ_PHOENIX) || defined(MOZ_THUNDERBIRD) +#define BrowserRemoteServerName "FirebirdRemoteServer" +#define MailRemoteServerName "ThunderbirdRemoteServer" +#else +#define BrowserRemoteServerName "MozillaRemoteServer" +#define MailRemoteServerName "MozillaRemoteServer" +#endif + #define MOZ_REMOTE_MSG_TYPE 100 XRemoteClient::XRemoteClient() @@ -74,9 +80,15 @@ XRemoteClient::SendCommand (const char *aCommand, PRBool *aWindowFound) char *RemoteServerName; - if( PL_strstr( aCommand, "mailto" ) ) + if( !strncmp( aCommand, "mping", 5 ) ) { RemoteServerName = MailRemoteServerName; - else RemoteServerName = BrowserRemoteServerName; + aCommand++; + } + else { + if( PL_strstr( aCommand, "mailto" ) ) + RemoteServerName = MailRemoteServerName; + else RemoteServerName = BrowserRemoteServerName; + } PtConnectionClient_t *cnt = PtConnectionFindName( RemoteServerName, 0, 0 ); if( !cnt ) { diff --git a/xpfe/bootstrap/nsNativeAppSupportPh.cpp b/xpfe/bootstrap/nsNativeAppSupportPh.cpp index 3fbf8e4c4f79..86192ce47f96 100644 --- a/xpfe/bootstrap/nsNativeAppSupportPh.cpp +++ b/xpfe/bootstrap/nsNativeAppSupportPh.cpp @@ -35,7 +35,6 @@ * * ***** END LICENSE BLOCK ***** */ -#include //For random splash screen. #include "nsNativeAppSupport.h" #define PX_IMAGE_MODULES @@ -102,53 +101,6 @@ public: nsrefcnt mRefCnt; }; // class nsSplashScreenPh -char *RandomSplash( char *gob ) -{ - int i=0; - int value=0; - int foundIT=0; - char duper[80]; - - DIR* dirp; - struct dirent* direntp; - - dirp = opendir( gob ); - if( dirp != NULL ) - { - for(;;) - { - direntp = readdir( dirp ); - if( direntp == NULL ) break; - i++;// number of available splash screens - } - - closedir( dirp ); - - // generate random number based on currnet time - srand(time(NULL)); - for(value = 0; value < 9999; value = rand()); - - dirp = opendir( gob ); - if( dirp != NULL ) { - for(foundIT=1;foundIT<=i;foundIT++) { - direntp = readdir( dirp ); - if( direntp == NULL ) break; - if( foundIT == value%i ) break; - } - - closedir( dirp ); - - // return the original splash.bmp if the directory entries are "." or ".." - if (((value%i) == 1) || ((value%i) == 2)) - return "../splash.bmp"; - - return direntp->d_name; - } - - - } - return (char *)EXIT_FAILURE; -} NS_IMETHODIMP nsSplashScreenPh::Show() @@ -156,8 +108,7 @@ nsSplashScreenPh::Show() PhImage_t *img = nsnull; char *p = NULL; char *splash = NULL; - //char splash[80]; - char splashdir[80]; + char splash_path[256]; int inp_grp,n=0; PhRid_t rid; PhRegion_t region; @@ -184,20 +135,10 @@ nsSplashScreenPh::Show() mDialog = nsnull; /* Setup proper path to the splash.bmp so it loads the splash screen at start up. */ - /* Only try and open the splash screen bitmap if running exec'ing from mozilla shellscript*/ - splash = getenv ("ADDON_PATH"); - if ( splash ) { - // if ADDON_PATH/splash/ exists -- randomly choose a splash screen from here... - strcpy (splashdir,"/opt/Mozilla/mozilla/splash/"); - if( lstat( splashdir, &sbuf ) == 0) - { - strcpy (splash,splashdir); - strcat (splash,(char *)RandomSplash(splashdir)); - } - else - strcat (splash,"/splash.bmp"); - - if ((img = PxLoadImage(splash, NULL)) !=NULL ) + splash = getenv( "MOZILLA_FIVE_HOME" ); + if( splash ) { + sprintf( splash_path, "%s/splash.bmp", splash ); + if( ( img = PxLoadImage( splash_path, NULL ) ) != NULL ) { PtArg_t arg[6]; PhPoint_t pos;