Photon-only changes. These only affect QNX builds, which are not part of

Tinderbox. See QNX PR23898. The input group for clipboard copy/paste was
always hard coded to 1. To support other input groups, the real input group
being used by the user must be passed from the gui client (i.e. from voyager
via PtWeb to mozserver) or taken from the mouse/keyboard event. My QNX
email address is mfeil@qnx.com. r=amardare@qnx.com
This commit is contained in:
maxf%magma.ca 2005-04-12 16:03:14 +00:00
parent 74baeb2939
commit e905ae1273
8 changed files with 97 additions and 23 deletions

View File

@ -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 <nsIFocusController.h>
@ -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<nsClipboard> 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<nsIClipboardCommands> 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<nsIClipboardCommands> 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<nsIClipboardCommands> 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

View File

@ -52,6 +52,7 @@
#include <nsIAppShell.h>
#include <nsIDOMEventReceiver.h>
#include <nsVoidArray.h>
#include <nsClipboard.h>
// for profiles
#include <nsIPref.h>
@ -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;

View File

@ -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<nsIWebBrowserFind> 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;

View File

@ -106,3 +106,6 @@ CXXFLAGS += $(TK_CFLAGS)
ifdef PHOTON_DND
CXXFLAGS += -DPHOTON_DND
endif
export::
$(INSTALL) nsClipboard.h $(DIST)/include/widget

View File

@ -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<index; k++)
nsMemory::Free(NS_REINTERPRET_CAST(char*, cliphdr[k].data));
@ -358,7 +357,7 @@ nsClipboard::GetNativeClipboardData(nsITransferable * aTransferable,
char *data = nsnull, type[8];
PRUint32 dataLen;
clipPtr = PhClipboardPasteStart( 1 );
clipPtr = PhClipboardPasteStart( mInputGroup );
if(!clipPtr) return NS_ERROR_FAILURE;
/*
@ -389,7 +388,7 @@ nsClipboard::GetNativeClipboardData(nsITransferable * aTransferable,
if (err != NS_OK)
continue;
dont_use_flavour[i] = get_flavour_timestamp( type );
dont_use_flavour[i] = GetFlavourTimestamp( type );
if( dont_use_flavour[i] > 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;

View File

@ -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<nsIClipboardOwner> mSelectionOwner;
nsCOMPtr<nsIClipboardOwner> mGlobalOwner;
nsCOMPtr<nsITransferable> 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__

View File

@ -60,11 +60,13 @@
#include "nsReadableUtils.h"
#include "nsIPref.h"
#include "nsClipboard.h"
#include <errno.h>
#include <photon/PtServer.h>
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<nsClipboard> 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;

View File

@ -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;
};