From 4f032f53f0500fb8678d96049ea55fb633a274e1 Mon Sep 17 00:00:00 2001 From: "amardare%qnx.com" Date: Tue, 8 Jun 2004 18:54:05 +0000 Subject: [PATCH] Changes for qnx(photon) platform only. They should not affect building/runtime other platforms. Set PHOTON_DND in Makefile.in so that we include the Dnd service in the build. Firefox bookmarks check for the Dnd service, and are affected if it's missing. Focus related changes: when the window loses focus, the window must be deactivated ( cursor should stop blinking ). When the window is given focus again by the window manager, the window must be activated ( the same cursor should start blinking ). GetParent should check for mIsDestroying - this fixes a crash in 1.7 ( no crash before ) with http://java.sun.com/j2se/1.3/docs/api/. Click on java.awt and keep the cursor moving. In nsPhMozRemoteHelper.cpp, create the connector name based on the aProgram. Use mozilla-xremote-client to send commands. --- widget/src/photon/Makefile.in | 5 +++++ widget/src/photon/nsPhMozRemoteHelper.cpp | 14 ++++---------- widget/src/photon/nsWidget.cpp | 12 +++++------- widget/src/photon/nsWidget.h | 8 +------- widget/src/photon/nsWindow.cpp | 22 ++++++++++++++++++++++ widget/src/photon/nsWindow.h | 3 ++- 6 files changed, 39 insertions(+), 25 deletions(-) diff --git a/widget/src/photon/Makefile.in b/widget/src/photon/Makefile.in index d60a57e5d6fe..80a495e40c1d 100644 --- a/widget/src/photon/Makefile.in +++ b/widget/src/photon/Makefile.in @@ -83,6 +83,8 @@ REQUIRES += xremoteservice CPPSRCS += nsPhMozRemoteHelper.cpp endif +# always include the PHOTON_DND in the build - the bookmarks in firefox require it +PHOTON_DND=1 ifdef PHOTON_DND CPPSRCS += nsDragService.cpp endif @@ -99,3 +101,6 @@ include $(topsrcdir)/config/rules.mk DEFINES += -D_IMPL_NS_WIDGET -I$(srcdir)/../xpwidgets -I$(srcdir) CXXFLAGS += $(TK_CFLAGS) +ifdef PHOTON_DND +CXXFLAGS += -DPHOTON_DND +endif diff --git a/widget/src/photon/nsPhMozRemoteHelper.cpp b/widget/src/photon/nsPhMozRemoteHelper.cpp index c474a36fae8f..0a190f50e39a 100644 --- a/widget/src/photon/nsPhMozRemoteHelper.cpp +++ b/widget/src/photon/nsPhMozRemoteHelper.cpp @@ -52,16 +52,6 @@ // //------------------------------------------------------------------------- -/* the connector name that a client can use to remote control this instance of mozilla */ - -#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 static void const * RemoteMsgHandler( PtConnectionServer_t *connection, void *user_data, @@ -112,7 +102,11 @@ nsPhXRemoteWidgetHelper::EnableXRemoteCommands( nsIWidget *aWidget, const char * { static PRBool ConnectorCreated = PR_FALSE; +/* ATENTIE */ printf( "aProgram=%s aProfile=%s aWidget=%p\n", aProgram?aProgram:"NULL", aProfile?aProfile:"NULL", aWidget ); + if( !ConnectorCreated ) { + char RemoteServerName[128]; + sprintf( RemoteServerName, "%s_RemoteServer", aProgram ? aProgram : "mozilla" ); /* create a connector for the xremote control */ PtConnectorCreate( RemoteServerName, client_connect, NULL ); ConnectorCreated = PR_TRUE; diff --git a/widget/src/photon/nsWidget.cpp b/widget/src/photon/nsWidget.cpp index 2c087beb9cf2..08342678a55f 100644 --- a/widget/src/photon/nsWidget.cpp +++ b/widget/src/photon/nsWidget.cpp @@ -88,8 +88,7 @@ nsIDragService *nsWidget::sDragService = nsnull; #endif PRUint32 nsWidget::sWidgetCount = 0; PRBool nsWidget::sJustGotActivated = PR_FALSE; -PRBool nsWidget::sJustGotDeactivated = PR_FALSE; - +nsWidget* nsWidget::sFocusWidget = 0; nsWidget::nsWidget() { @@ -132,6 +131,9 @@ nsWidget::nsWidget() nsWidget::~nsWidget( ) { + + if( sFocusWidget == this ) sFocusWidget = 0; + // it's safe to always call Destroy() because it will only allow itself to be called once Destroy(); @@ -1145,7 +1147,7 @@ int nsWidget::GotFocusCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t { nsWidget *pWidget = (nsWidget *) data; - if( widget->class_rec->description && PtWidgetIsClass( widget, PtWindow ) ) { + if( PtWidgetIsClass( widget, PtWindow ) ) { if( pWidget->mEventCallback ) { /* the WM_ACTIVATE code */ @@ -1173,10 +1175,6 @@ int nsWidget::GotFocusCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t int nsWidget::LostFocusCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) { nsWidget *pWidget = (nsWidget *) data; - if( sJustGotDeactivated ) { - sJustGotDeactivated = PR_FALSE; - pWidget->DispatchStandardEvent(NS_DEACTIVATE); - } pWidget->DispatchStandardEvent(NS_LOSTFOCUS); return Pt_CONTINUE; } diff --git a/widget/src/photon/nsWidget.h b/widget/src/photon/nsWidget.h index 90413d9e79bc..1177356b1fe4 100644 --- a/widget/src/photon/nsWidget.h +++ b/widget/src/photon/nsWidget.h @@ -97,6 +97,7 @@ public: NS_IMETHOD Destroy(void); inline nsIWidget* GetParent(void) { + if( mIsDestroying ) return nsnull; nsIWidget* result = mParent; if( mParent ) NS_ADDREF( result ); return result; @@ -133,12 +134,6 @@ public: return NS_OK; } - inline NS_IMETHOD SetFocus(PRBool aRaise) - { - if( mWidget ) PtContainerGiveFocus( mWidget, NULL ); - return NS_OK; - } - PRBool OnResize(nsSizeEvent event); virtual PRBool OnResize(nsRect &aRect); virtual PRBool OnMove(PRInt32 aX, PRInt32 aY); @@ -361,7 +356,6 @@ protected: // Focus used global variable static nsWidget* sFocusWidget; //Current Focus Widget - static PRBool sJustGotDeactivated; static PRBool sJustGotActivated; //For getting rid of the ASSERT ERROR due to reducing suppressing of focus. static nsILookAndFeel *sLookAndFeel; diff --git a/widget/src/photon/nsWindow.cpp b/widget/src/photon/nsWindow.cpp index 5e17661bd203..fdf6050d2724 100644 --- a/widget/src/photon/nsWindow.cpp +++ b/widget/src/photon/nsWindow.cpp @@ -654,6 +654,8 @@ int nsWindow::WindowWMHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t if( we->event_state == Ph_WM_EVSTATE_FOCUSLOST ) { /* rollup the menus */ if( gRollupWidget && gRollupListener ) gRollupListener->Rollup(); + + if( sFocusWidget ) sFocusWidget->DispatchStandardEvent(NS_DEACTIVATE); } break; } @@ -951,3 +953,23 @@ int nsWindow::MenuRegionDestroyed( PtWidget_t *widget, void *data, PtCallbackInf } return Pt_CONTINUE; } + +NS_IMETHODIMP nsWindow::SetFocus(PRBool aRaise) +{ + sFocusWidget = this; + + if( PtIsFocused( mWidget ) == 2 ) return NS_OK; + + if( mWidget ) { + PtWidget_t *disjoint; + disjoint = PtFindDisjoint( mWidget ); + if( PtWidgetIsClass( disjoint, PtWindow ) ) { + if( !( PtWindowGetState( disjoint ) & Ph_WM_STATE_ISFOCUS ) ) { + nsWindow *pWin = (nsWindow *) GetInstance( disjoint ); + pWin->GetAttention( -1 ); + } + } + PtContainerGiveFocus( mWidget, NULL ); + } + return NS_OK; +} diff --git a/widget/src/photon/nsWindow.h b/widget/src/photon/nsWindow.h index c4ad95f40e79..68208225c056 100644 --- a/widget/src/photon/nsWindow.h +++ b/widget/src/photon/nsWindow.h @@ -92,11 +92,12 @@ public: return NS_OK; } - NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent); + NS_IMETHOD SetFocus(PRBool aRaise); + inline NS_IMETHOD GetAttention(PRInt32 aCycleCount) { if( mWidget ) PtWindowToFront( mWidget );