diff --git a/mozilla/embedding/browser/photon/src/EmbedPrivate.cpp b/mozilla/embedding/browser/photon/src/EmbedPrivate.cpp index b72539e7c97..c85386727a6 100644 --- a/mozilla/embedding/browser/photon/src/EmbedPrivate.cpp +++ b/mozilla/embedding/browser/photon/src/EmbedPrivate.cpp @@ -74,6 +74,10 @@ #include "nsIWebBrowserPrint.h" #include "nsIClipboardCommands.h" +// for the clipboard input group setting +#include "nsClipboard.h" +#include "nsWidgetsCID.h" + // for the focus hacking we need to do #include @@ -96,10 +100,12 @@ extern char *g_Print_Left_Header_String, *g_Print_Right_Header_String, *g_Print_Left_Footer_String, *g_Print_Right_Footer_String; static const char sWatcherContractID[] = "@mozilla.org/embedcomp/window-watcher;1"; +static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID); nsIAppShell *EmbedPrivate::sAppShell = nsnull; nsIPref *EmbedPrivate::sPrefs = nsnull; nsVoidArray *EmbedPrivate::sWindowList = nsnull; +nsClipboard *EmbedPrivate::sClipboard = nsnull; EmbedPrivate::EmbedPrivate(void) { @@ -119,6 +125,13 @@ EmbedPrivate::EmbedPrivate(void) sWindowList = new nsVoidArray(); } sWindowList->AppendElement(this); + if( !sClipboard ) { + nsresult rv; + nsCOMPtr s; + s = do_GetService( kCClipboardCID, &rv ); + sClipboard = ( nsClipboard * ) s; + if( NS_FAILED( rv ) ) sClipboard = 0; + } } EmbedPrivate::~EmbedPrivate() @@ -499,27 +512,48 @@ EmbedPrivate::CanGoForward() } void -EmbedPrivate::Cut() +EmbedPrivate::Cut(int ig) { nsCOMPtr clipboard(do_GetInterface(mWindow->mWebBrowser)); - if (clipboard) + if (clipboard) { + // + // Pass Voyager input group to clipboard functions. + // Using Ctrl-C/V does not do this, only Edit->Copy/Paste. + // + if (sClipboard) + sClipboard->SetInputGroup(ig); clipboard->CutSelection(); + } } void -EmbedPrivate::Copy() +EmbedPrivate::Copy(int ig) { nsCOMPtr clipboard(do_GetInterface(mWindow->mWebBrowser)); - if (clipboard) + if (clipboard) { + // + // Pass Voyager input group to clipboard functions. + // Using Ctrl-C/V does not do this, only Edit->Copy/Paste. + // + if (sClipboard) + sClipboard->SetInputGroup(ig); clipboard->CopySelection(); + } } void -EmbedPrivate::Paste() +EmbedPrivate::Paste(int ig) { nsCOMPtr clipboard(do_GetInterface(mWindow->mWebBrowser)); - if (clipboard) + if (clipboard) { + // + // Pass Voyager input group to clipboard functions. + // Using Ctrl-C/V does not do this, only Edit->Copy/Paste. + // + if (sClipboard) + sClipboard->SetInputGroup(ig); clipboard->Paste(); + } } void diff --git a/mozilla/embedding/browser/photon/src/EmbedPrivate.h b/mozilla/embedding/browser/photon/src/EmbedPrivate.h index 2148f259dca..0eef50e4ad4 100644 --- a/mozilla/embedding/browser/photon/src/EmbedPrivate.h +++ b/mozilla/embedding/browser/photon/src/EmbedPrivate.h @@ -52,6 +52,7 @@ #include #include #include +#include // for profiles #include @@ -91,9 +92,9 @@ class EmbedPrivate { void ScrollDown(int amount); void ScrollLeft(int amount); void ScrollRight(int amount); - void Cut (void); - void Copy (void); - void Paste (void); + void Cut (int ig); + void Copy (int ig); + void Paste (int ig); void SelectAll (void); void Clear (void); int SaveAs(char *fname,char *dirname); @@ -177,6 +178,8 @@ class EmbedPrivate { // for profiles static nsIPref *sPrefs; static nsVoidArray *sWindowList; + // for clipboard input group setting + static nsClipboard *sClipboard; // chrome mask PRUint32 mChromeMask; diff --git a/mozilla/embedding/browser/photon/src/PtMozilla.cpp b/mozilla/embedding/browser/photon/src/PtMozilla.cpp index 0e03ee6bab8..ffe520866f0 100644 --- a/mozilla/embedding/browser/photon/src/PtMozilla.cpp +++ b/mozilla/embedding/browser/photon/src/PtMozilla.cpp @@ -81,6 +81,7 @@ #include "nsIEventQueueService.h" #include "nsIServiceManager.h" +#include "nsIComponentRegistrar.h" #include "nsUnknownContentTypeHandler.h" #include "EmbedPrivate.h" @@ -355,19 +356,20 @@ mozilla_modify( PtWidget_t *widget, PtArg_t const *argt, PtResourceRec_t const * } break; - case Pt_ARG_MOZ_COMMAND: + case Pt_ARG_MOZ_COMMAND: { + PtWebClient2Command_t *wdata = ( PtWebClient2Command_t * ) argt->len; switch ((int)(argt->value)) { case Pt_MOZ_COMMAND_CUT: { - moz->EmbedRef->Cut(); + moz->EmbedRef->Cut(wdata?wdata->ClipboardInfo.input_group:1); } break; case Pt_MOZ_COMMAND_COPY: { - moz->EmbedRef->Copy(); + moz->EmbedRef->Copy(wdata?wdata->ClipboardInfo.input_group:1); } break; case Pt_MOZ_COMMAND_PASTE: { - moz->EmbedRef->Paste(); + moz->EmbedRef->Paste(wdata?wdata->ClipboardInfo.input_group:1); } break; case Pt_MOZ_COMMAND_SELECTALL: { @@ -380,7 +382,6 @@ mozilla_modify( PtWidget_t *widget, PtArg_t const *argt, PtResourceRec_t const * break; case Pt_MOZ_COMMAND_FIND: { - PtWebClient2Command_t *wdata = ( PtWebClient2Command_t * ) argt->len; nsCOMPtr finder( do_GetInterface( moz->EmbedRef->mWindow->mWebBrowser ) ); finder->SetSearchString( NS_ConvertASCIItoUCS2(wdata->FindInfo.string).get() ); finder->SetMatchCase( wdata->FindInfo.flags & Pt_WEB_FIND_MATCH_CASE ); @@ -394,7 +395,6 @@ mozilla_modify( PtWidget_t *widget, PtArg_t const *argt, PtResourceRec_t const * } case Pt_MOZ_COMMAND_SAVEAS: { - PtWebClient2Command_t *wdata = ( PtWebClient2Command_t * ) argt->len; char *dirname = ( char * ) calloc( 1, strlen( wdata->SaveasInfo.filename + 7 ) ); if( dirname ) { sprintf( dirname, "%s_files", wdata->SaveasInfo.filename ); @@ -403,6 +403,7 @@ mozilla_modify( PtWidget_t *widget, PtArg_t const *argt, PtResourceRec_t const * } break; } + } } break; diff --git a/mozilla/widget/src/photon/Makefile.in b/mozilla/widget/src/photon/Makefile.in index d8d7eff53fe..5035f4f827a 100644 --- a/mozilla/widget/src/photon/Makefile.in +++ b/mozilla/widget/src/photon/Makefile.in @@ -106,3 +106,6 @@ CXXFLAGS += $(TK_CFLAGS) ifdef PHOTON_DND CXXFLAGS += -DPHOTON_DND endif + +export:: + $(INSTALL) nsClipboard.h $(DIST)/include/widget diff --git a/mozilla/widget/src/photon/nsClipboard.cpp b/mozilla/widget/src/photon/nsClipboard.cpp index ad7931090fd..1351eaa3636 100644 --- a/mozilla/widget/src/photon/nsClipboard.cpp +++ b/mozilla/widget/src/photon/nsClipboard.cpp @@ -82,8 +82,6 @@ NS_IMPL_ISUPPORTS1(nsClipboard, nsIClipboard) #define Ph_CLIPBOARD_TYPE_IMAGE "IMAG" #define Ph_CLIPBOARD_TYPE_HTML "HTML" -static unsigned long get_flavour_timestamp( char *type ); - //------------------------------------------------------------------------- // // nsClipboard constructor @@ -100,6 +98,7 @@ nsClipboard::nsClipboard() mSelectionTransferable = nsnull; mGlobalOwner = nsnull; mSelectionOwner = nsnull; + mInputGroup = 1; } //------------------------------------------------------------------------- @@ -302,7 +301,7 @@ NS_IMETHODIMP nsClipboard::SetNativeClipboardData(PRInt32 aWhichClipboard) } } - PhClipboardCopy( 1, index, cliphdr ); + PhClipboardCopy( mInputGroup, index, cliphdr ); for( PRUint32 k=0; k max_time ) max_time = dont_use_flavour[i]; } } @@ -580,9 +579,8 @@ nsITransferable *nsClipboard::GetTransferable(PRInt32 aWhichClipboard) return transferable; } -static unsigned long get_flavour_timestamp( char *type ) +unsigned long nsClipboard::GetFlavourTimestamp( char *type) { - int ig = 1; /* we always use input group 1 in mozilla */ char fname[512]; extern struct _Ph_ctrl *_Ph_; @@ -597,7 +595,7 @@ static unsigned long get_flavour_timestamp( char *type ) if(gethostname(&fname[strlen(fname)],PATH_MAX-40)!=0) strcpy(&fname[strlen(fname)],"localhost"); - sprintf( &fname[strlen(fname)], "/%08x/%d.%s",buf.st_uid, ig, type ); + sprintf( &fname[strlen(fname)], "/%08x/%d.%s",buf.st_uid, mInputGroup, type ); struct stat st; if( stat( fname, &st ) != 0 ) return 0; diff --git a/mozilla/widget/src/photon/nsClipboard.h b/mozilla/widget/src/photon/nsClipboard.h index fb37ab6fae8..11436ba689f 100644 --- a/mozilla/widget/src/photon/nsClipboard.h +++ b/mozilla/widget/src/photon/nsClipboard.h @@ -69,6 +69,13 @@ public: // nsIClipboard NS_DECL_NSICLIPBOARD + NS_IMETHOD SetInputGroup(PRInt32 aInputGroup) + { + mInputGroup = aInputGroup; + return NS_OK; + } + + protected: NS_IMETHOD SetNativeClipboardData(PRInt32 aWhichClipboard); NS_IMETHOD GetNativeClipboardData(nsITransferable * aTransferable, @@ -79,6 +86,7 @@ nsresult GetFormat(const char* aMimeStr, char *format ); inline nsITransferable *GetTransferable(PRInt32 aWhichClipboard); private: + unsigned long GetFlavourTimestamp( char *type ); nsCOMPtr mSelectionOwner; nsCOMPtr mGlobalOwner; nsCOMPtr mSelectionTransferable; @@ -87,6 +95,8 @@ private: // Used for communicating pasted data // from the asynchronous X routines back to a blocking paste: PRBool mBlocking; + // Used for keeping track of the current input group + PRInt32 mInputGroup; }; #endif // nsClipboard_h__ diff --git a/mozilla/widget/src/photon/nsWidget.cpp b/mozilla/widget/src/photon/nsWidget.cpp index f642bfa06c2..50356944987 100644 --- a/mozilla/widget/src/photon/nsWidget.cpp +++ b/mozilla/widget/src/photon/nsWidget.cpp @@ -60,11 +60,13 @@ #include "nsReadableUtils.h" #include "nsIPref.h" +#include "nsClipboard.h" #include #include static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID); +static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID); // BGR, not RGB - REVISIT #define NSCOLOR_TO_PHCOLOR(g,n) \ @@ -86,6 +88,7 @@ nsILookAndFeel *nsWidget::sLookAndFeel = nsnull; #ifdef PHOTON_DND nsIDragService *nsWidget::sDragService = nsnull; #endif +nsClipboard *nsWidget::sClipboard = nsnull; PRUint32 nsWidget::sWidgetCount = 0; nsWidget* nsWidget::sFocusWidget = 0; @@ -108,6 +111,14 @@ nsWidget::nsWidget() } #endif + if( !sClipboard ) { + nsresult rv; + nsCOMPtr s; + s = do_GetService( kCClipboardCID, &rv ); + sClipboard = ( nsClipboard * ) s; + if( NS_FAILED( rv ) ) sClipboard = 0; + } + mWidget = nsnull; mParent = nsnull; mPreferredWidth = 0; @@ -1031,6 +1042,14 @@ inline PRBool nsWidget::HandleEvent( PtWidget_t *widget, PtCallbackInfo_t* aCbIn PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( event ); nsMouseEvent theMouseEvent; + // Update the current input group for clipboard mouse events + // (mozilla only). Note that for mozserver the mouse based + // (eg. Edit->Copy/Paste menu) events don't come through here. + // They are sent by the voyager client app via libPtWeb.so to + // do_command() in mozserver.cpp. + if (sClipboard) + sClipboard->SetInputGroup(event->input_group); + if (event->subtype==Ph_EV_RELEASE_REAL || event->subtype==Ph_EV_RELEASE_PHANTOM) { if (ptrev) { ScreenToWidgetPos( ptrev->pos ); @@ -1078,6 +1097,10 @@ inline PRBool nsWidget::HandleEvent( PtWidget_t *widget, PtCallbackInfo_t* aCbIn break; case Ph_EV_KEY: + // Update the current input group for clipboard key events. This + // covers both mozserver and mozilla. + if (sClipboard) + sClipboard->SetInputGroup(event->input_group); result = DispatchKeyEvent( (PhKeyEvent_t*) PhGetData( event ) ); break; diff --git a/mozilla/widget/src/photon/nsWidget.h b/mozilla/widget/src/photon/nsWidget.h index 81cf71b47b7..2620cb3f355 100644 --- a/mozilla/widget/src/photon/nsWidget.h +++ b/mozilla/widget/src/photon/nsWidget.h @@ -44,6 +44,7 @@ #ifdef PHOTON_DND #include "nsIDragService.h" #endif +#include "nsClipboard.h" class nsILookAndFeel; class nsIAppShell; @@ -363,6 +364,7 @@ protected: #ifdef PHOTON_DND static nsIDragService *sDragService; #endif + static nsClipboard *sClipboard; static PRUint32 sWidgetCount; };