PHOTON BUILD only

Removal of some printfs and fixes for rendering issues and the Clipboard implementation.
Also fixes a problem with scrolling lists sometimes causing a crash.


git-svn-id: svn://10.0.0.236/trunk@118253 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
briane%qnx.com 2002-04-05 15:15:59 +00:00
parent c5491b3460
commit 6c09555279
9 changed files with 523 additions and 292 deletions

View File

@ -64,7 +64,9 @@ static void raw_draw_container_draw( PtWidget_t *widget, PhTile_t *damage )
if (widget == NULL)
{
#ifdef DEBUG
printf("raw_draw_container_draw NULL widget!\n");
#endif
return;
}
if( rdc->draw_f )

View File

@ -106,7 +106,10 @@ nsAppShell::~nsAppShell()
if (err==-1)
{
NS_WARNING("nsAppShell::~EventQueueTokenQueue Run Error calling PtAppRemoveFd");
#ifdef DEBUG
printf("nsAppShell::~EventQueueTokenQueue Run Error calling PtAppRemoveFd mFD=<%d> errno=<%d>\n", mFD, errno);
#endif
}
mFD = -1;
}
@ -246,7 +249,9 @@ void MyMainLoop( void )
PtProcessEvent();
}
NS_WARNING("MyMainLoop exiting!\n");
#ifdef DEBUG
printf("nsAppShell: MyMainLoop exiting!\n");
#endif
}
//-------------------------------------------------------------------------

View File

@ -1,245 +1,436 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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.
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999-2000 Netscape Communications Corporation.
* All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
* Stuart Parmenter <pavlov@netscape.com>
* Mike Pinkerton <pinkerton@netscape.com>
* Dan Rosen <dr@netscape.com>
*/
#include "nsClipboard.h"
#include <Pt.h>
#include "nsCOMPtr.h"
#include "nsFileSpec.h"
#include "nsCRT.h"
#include "nsISupportsArray.h"
#include "nsIClipboardOwner.h"
#include "nsITransferable.h" // kTextMime
#include "nsISupportsPrimitives.h"
#include "nsReadableUtils.h"
#include "nsIWidget.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsWidgetsCID.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsPrimitiveHelpers.h"
#include "nsTextFormatter.h"
#include "nsVoidArray.h"
#include "nsPhWidgetLog.h"
// Initialize the class statics:
#include "nsIServiceManager.h"
#include "nsICharsetConverterManager.h"
#include "prtime.h"
#include "prthread.h"
// unicode conversion
#include "nsIPlatformCharset.h"
// Define this to enable the obsolete X cut buffer mechanism
// In general, a bad idea (see http://www.jwz.org/doc/x-cut-and-paste.html)
// but it might have its uses for backwards compatibility.
NS_IMPL_ISUPPORTS1(nsClipboard, nsIClipboard);
#define Ph_CLIPBOARD_TYPE_MOZ_BOOKMARK "BOOK"
#define Ph_CLIPBOARD_TYPE_IMAGE "IMAG"
#define Ph_CLIPBOARD_TYPE_HTML "HTML"
//-------------------------------------------------------------------------
//
// nsClipboard constructor
//
//-------------------------------------------------------------------------
nsClipboard::nsClipboard() : nsBaseClipboard()
nsClipboard::nsClipboard()
{
#ifdef DEBUG_CLIPBOARD
printf("nsClipboard::nsClipboard()\n");
#endif /* DEBUG_CLIPBOARD */
NS_INIT_REFCNT();
mIgnoreEmptyNotification = PR_FALSE;
mGlobalTransferable = nsnull;
mSelectionTransferable = nsnull;
mGlobalOwner = nsnull;
mSelectionOwner = nsnull;
}
//-------------------------------------------------------------------------
//
// nsClipboard destructor
//
//-------------------------------------------------------------------------
nsClipboard::~nsClipboard()
{
#ifdef DEBUG_CLIPBOARD
printf("nsClipboard::~nsClipboard()\n");
#endif /* DEBUG_CLIPBOARD */
}
/**
* Sets the transferable object
*
*/
NS_IMETHODIMP nsClipboard::SetData(nsITransferable * aTransferable,
nsIClipboardOwner * anOwner,
PRInt32 aWhichClipboard)
{
if ((aTransferable == mGlobalTransferable.get() && anOwner == mGlobalOwner.get() &&
aWhichClipboard == kGlobalClipboard ) || (aTransferable == mSelectionTransferable.get() &&
anOwner == mSelectionOwner.get() && aWhichClipboard == kSelectionClipboard))
{
return NS_OK;
}
EmptyClipboard(aWhichClipboard);
switch (aWhichClipboard)
{
case kSelectionClipboard:
mSelectionOwner = anOwner;
mSelectionTransferable = aTransferable;
break;
case kGlobalClipboard:
mGlobalOwner = anOwner;
mGlobalTransferable = aTransferable;
break;
}
return SetNativeClipboardData(aWhichClipboard);
}
/**
* Gets the transferable object
*
*/
NS_IMETHODIMP nsClipboard::GetData(nsITransferable * aTransferable, PRInt32 aWhichClipboard)
{
if (nsnull != aTransferable)
return GetNativeClipboardData(aTransferable, aWhichClipboard);
else
{
#ifdef DEBUG_CLIPBOARD
printf(" nsClipboard::GetData(), aTransferable is NULL.\n");
#endif
}
return NS_ERROR_FAILURE;
}
//-------------------------------------------------------------------------
NS_IMETHODIMP nsClipboard::ForceDataToClipboard(PRInt32 aWhichClipboard)
/**
*
*
*/
NS_IMETHODIMP nsClipboard::EmptyClipboard(PRInt32 aWhichClipboard)
{
// make sure we have a good transferable
if (nsnull == mTransferable) {
return NS_ERROR_FAILURE;
}
if (mIgnoreEmptyNotification)
return NS_OK;
switch(aWhichClipboard)
{
case kSelectionClipboard:
if (mSelectionOwner)
{
mSelectionOwner->LosingOwnership(mSelectionTransferable);
mSelectionOwner = nsnull;
}
mSelectionTransferable = nsnull;
break;
case kGlobalClipboard:
if (mGlobalOwner)
{
mGlobalOwner->LosingOwnership(mGlobalTransferable);
mGlobalOwner = nsnull;
}
mGlobalTransferable = nsnull;
break;
}
return NS_OK;
}
NS_IMETHODIMP nsClipboard::SupportsSelectionClipboard(PRBool *_retval)
{
NS_ENSURE_ARG_POINTER(_retval);
*_retval = PR_TRUE; // we support the selection clipboard on unix.
return NS_OK;
}
//-------------------------------------------------------------------------
NS_IMETHODIMP nsClipboard::SetNativeClipboardData(PRInt32 aWhichClipboard)
{
nsresult res = NS_ERROR_FAILURE;
mIgnoreEmptyNotification = PR_TRUE;
// make sure we have a good transferable
if( nsnull == mTransferable ) return NS_ERROR_FAILURE;
#ifdef DEBUG_CLIPBOARD
printf(" nsClipboard::SetNativeClipboardData(%i)\n", aWhichClipboard);
#endif /* DEBUG_CLIPBOARD */
// get flavor list that includes all flavors that can be written (including ones
// obtained through conversion)
nsCOMPtr<nsISupportsArray> flavorList;
nsresult errCode = mTransferable->FlavorsTransferableCanExport ( getter_AddRefs(flavorList) );
if ( NS_FAILED(errCode) ) return NS_ERROR_FAILURE;
PRUint32 cnt;
flavorList->Count(&cnt);
if (cnt) {
PhClipHeader *cliphdr = (PhClipHeader *) calloc( cnt, sizeof( PhClipHeader ));
nsCOMPtr<nsITransferable> transferable(getter_AddRefs(GetTransferable(aWhichClipboard)));
if( cliphdr ) {
PRUint32 i=0, index=0;
void *data = nsnull;
PRUint32 dataLen;
mIgnoreEmptyNotification = PR_TRUE;
for ( PRUint32 i=0; i<cnt; ++i ) {
nsCOMPtr<nsISupports> genericFlavor;
flavorList->GetElementAt ( i, getter_AddRefs(genericFlavor) );
nsCOMPtr<nsISupportsString> currentFlavor ( do_QueryInterface(genericFlavor) );
if ( currentFlavor )
{
nsXPIDLCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr));
nsresult err = GetFormat( flavorStr, &cliphdr[index] );
if( err != NS_OK ) continue;
// Get data out of transferable.
nsCOMPtr<nsISupports> genericDataWrapper;
mTransferable->GetTransferData( flavorStr, getter_AddRefs(genericDataWrapper), &dataLen );
nsPrimitiveHelpers::CreateDataFromPrimitive ( flavorStr, genericDataWrapper, &data, dataLen );
int len = 0;
char *plain;
nsPrimitiveHelpers::ConvertUnicodeToPlatformPlainText( (PRUnichar*)data, dataLen/2, &plain, &len );
cliphdr[index].length = len+1;
cliphdr[index].data = plain;
index++;
}
}
PhClipboardCopy( 1, index, cliphdr );
for(i=0; i<index; i++)
nsCRT::free ( NS_REINTERPRET_CAST(char*, cliphdr[i].data) );
res = NS_OK;
mIgnoreEmptyNotification = PR_FALSE;
free( cliphdr );
}
}
return res;
// make sure we have a good transferable
if (nsnull == transferable)
{
#ifdef DEBUG_CLIPBOARD
printf("nsClipboard::SetNativeClipboardData(): no transferable!\n");
#endif
return NS_ERROR_FAILURE;
}
// get flavor list that includes all flavors that can be written (including ones
// obtained through conversion)
nsCOMPtr<nsISupportsArray> flavorList;
nsresult errCode = transferable->FlavorsTransferableCanExport ( getter_AddRefs(flavorList) );
if ( NS_FAILED(errCode) )
return NS_ERROR_FAILURE;
PRUint32 cnt;
flavorList->Count(&cnt);
for ( PRUint32 i=0; i<cnt; ++i )
{
PhClipHeader *cliphdr = (PhClipHeader *) calloc( cnt, sizeof( PhClipHeader ));
if( cliphdr )
{
PRUint32 i=0, index=0;
void *data = nsnull;
PRUint32 dataLen;
nsCOMPtr<nsISupports> genericFlavor;
flavorList->GetElementAt ( i, getter_AddRefs(genericFlavor) );
nsCOMPtr<nsISupportsString> currentFlavor ( do_QueryInterface(genericFlavor) );
if ( currentFlavor )
{
nsXPIDLCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr));
nsresult err = GetFormat( flavorStr, &cliphdr[index] );
if( err != NS_OK )
continue;
// Get data out of transferable.
nsCOMPtr<nsISupports> genericDataWrapper;
transferable->GetTransferData( flavorStr, getter_AddRefs(genericDataWrapper), &dataLen );
nsPrimitiveHelpers::CreateDataFromPrimitive ( flavorStr, genericDataWrapper, &data, dataLen );
if (strcmp(cliphdr[index].type, Ph_CLIPBOARD_TYPE_MOZ_BOOKMARK) == 0)
{
cliphdr[index].length = dataLen;
cliphdr[index].data = data;
}
else if (strcmp(cliphdr[index].type, Ph_CLIPBOARD_TYPE_TEXT) == 0)
{
int len = 0;
char *plain;
nsPrimitiveHelpers::ConvertUnicodeToPlatformPlainText( (PRUnichar*)data, dataLen/2, &plain, &len );
cliphdr[index].length = len+1;
cliphdr[index].data = plain;
printf("Set TEXT: %s\n", plain);
}
index++;
}
PhClipboardCopy( 1, index, cliphdr );
for(i=0; i<index; i++)
nsCRT::free ( NS_REINTERPRET_CAST(char*, cliphdr[i].data) );
free( cliphdr );
}
}
mIgnoreEmptyNotification = PR_FALSE;
return NS_OK;
}
//-------------------------------------------------------------------------
//
// The blocking Paste routine
//
//-------------------------------------------------------------------------
NS_IMETHODIMP
nsClipboard::GetNativeClipboardData( nsITransferable * aTransferable, PRInt32 aWhichClipboard ) {
nsClipboard::GetNativeClipboardData(nsITransferable * aTransferable,
PRInt32 aWhichClipboard)
{
#ifdef DEBUG_CLIPBOARD
printf("nsClipboard::GetNativeClipboardData(%i)\n", aWhichClipboard);
#endif /* DEBUG_CLIPBOARD */
nsresult res = NS_ERROR_FAILURE;
// make sure we have a good transferable
if (nsnull == aTransferable)
{
#ifdef DEBUG_CLIPBOARD
printf(" GetNativeClipboardData: Transferable is null!\n");
#endif
return NS_ERROR_FAILURE;
}
// make sure we have a good transferable
if( nsnull == aTransferable ) return NS_ERROR_FAILURE;
// get flavor list that includes all acceptable flavors (including ones obtained through
// conversion)
nsCOMPtr<nsISupportsArray> flavorList;
nsresult errCode = aTransferable->FlavorsTransferableCanImport ( getter_AddRefs(flavorList) );
if ( NS_FAILED(errCode) )
return NS_ERROR_FAILURE;
// get flavor list that includes all acceptable flavors (including ones obtained through
// conversion)
nsCOMPtr<nsISupportsArray> flavorList;
nsresult errCode = aTransferable->FlavorsTransferableCanImport ( getter_AddRefs(flavorList) );
if ( NS_FAILED(errCode) ) return NS_ERROR_FAILURE;
// Walk through flavors and see which flavor matches the one being pasted:
PRUint32 cnt;
flavorList->Count(&cnt);
nsCAutoString foundFlavor;
PRBool foundData = PR_FALSE;
// Walk through flavors and see which flavor matches the one being pasted:
PRUint32 cnt;
if (cnt > 0)
{
void *clipPtr;
PhClipHeader cliptype;
PhClipHeader *cliphdr;
void *data = nsnull;
PRUint32 dataLen;
flavorList->Count(&cnt);
nsCAutoString foundFlavor;
if (cnt > 0) {
void *clipPtr;
PhClipHeader cliptype;
PhClipHeader *cliphdr;
void *data = nsnull;
PRUint32 dataLen;
clipPtr = PhClipboardPasteStart( 1 );
if(!clipPtr)
return NS_ERROR_FAILURE;
clipPtr = PhClipboardPasteStart( 1 );
if(!clipPtr)
return NS_ERROR_FAILURE;
for ( PRUint32 i = 0; i < cnt; ++i ) {
nsCOMPtr<nsISupports> genericFlavor;
flavorList->GetElementAt ( i, getter_AddRefs(genericFlavor) );
nsCOMPtr<nsISupportsString> currentFlavor ( do_QueryInterface(genericFlavor) );
if ( currentFlavor ) {
nsXPIDLCString flavorStr;
currentFlavor->ToString ( getter_Copies(flavorStr) );
nsresult err = GetFormat( flavorStr, &cliptype);
if (err != NS_OK) continue;
cliphdr = PhClipboardPasteType( clipPtr, cliptype.type );
if (cliphdr) {
data = cliphdr->data;
dataLen = cliphdr->length;
for ( PRUint32 i = 0; i < cnt; ++i )
{
nsCOMPtr<nsISupports> genericFlavor;
flavorList->GetElementAt ( i, getter_AddRefs(genericFlavor) );
nsCOMPtr<nsISupportsString> currentFlavor ( do_QueryInterface(genericFlavor) );
if ( currentFlavor )
{
nsXPIDLCString flavorStr;
currentFlavor->ToString ( getter_Copies(flavorStr) );
nsresult err = GetFormat( flavorStr, &cliptype);
if (err != NS_OK)
continue;
cliphdr = PhClipboardPasteType( clipPtr, cliptype.type );
if (cliphdr)
{
int len_unicode;
PRUnichar *unicode;
nsPrimitiveHelpers::ConvertPlatformPlainTextToUnicode( (char*) data, dataLen, &unicode, &len_unicode );
len_unicode--;
len_unicode *= 2;
data = cliphdr->data;
dataLen = cliphdr->length;
nsCOMPtr<nsISupports> genericDataWrapper;
if (strcmp(cliptype.type, Ph_CLIPBOARD_TYPE_MOZ_BOOKMARK) == 0)
{
len_unicode = cliphdr->length;
nsPrimitiveHelpers::CreatePrimitiveForData ( flavorStr, cliphdr->data, len_unicode, getter_AddRefs(genericDataWrapper) );
}
else if (strcmp(cliptype.type, Ph_CLIPBOARD_TYPE_TEXT) == 0)
{
printf("Get TEXT: %s\n", (char*) data);
nsPrimitiveHelpers::ConvertPlatformPlainTextToUnicode( (char*) data, dataLen, &unicode, &len_unicode );
len_unicode--;
len_unicode *= 2;
nsPrimitiveHelpers::CreatePrimitiveForData ( flavorStr, unicode, len_unicode, getter_AddRefs(genericDataWrapper) );
}
aTransferable->SetTransferData(flavorStr, genericDataWrapper, len_unicode );
break;
}
}
}
PhClipboardPasteFinish( clipPtr );
}
#if 0
/* Kirk - 2/25/99 Disable this for unicode text */
/* If this is a TEXT, and is NULL teminated then strip it off */
if ( (strcmp(cliptype.type, Ph_CLIPBOARD_TYPE_TEXT) == 0)
&& (*(dataStr+(dataLen-1)) == NULL)
)
{
dataLen--;
}
// We're back from the callback, no longer blocking:
mBlocking = PR_FALSE;
//
// Now we have data in mSelectionData.data.
// We just have to copy it to the transferable.
//
if ( foundData ) {
nsCOMPtr<nsISupports> genericDataWrapper;
nsPrimitiveHelpers::CreatePrimitiveForData(foundFlavor.get(), mSelectionData.data,
mSelectionData.length, getter_AddRefs(genericDataWrapper));
aTransferable->SetTransferData(foundFlavor.get(),
genericDataWrapper,
mSelectionData.length);
}
// transferable is now owning the data, so we can free it.
nsMemory::Free(mSelectionData.data);
mSelectionData.data = nsnull;
mSelectionData.length = 0;
#endif
nsCOMPtr<nsISupports> genericDataWrapper;
nsPrimitiveHelpers::CreatePrimitiveForData ( flavorStr, unicode, len_unicode, getter_AddRefs(genericDataWrapper) );
aTransferable->SetTransferData(flavorStr, genericDataWrapper, len_unicode );
return NS_OK;
}
res = NS_OK;
break;
}
}
}
/**
* Some platforms support deferred notification for putting data on the clipboard
* This method forces the data onto the clipboard in its various formats
* This may be used if the application going away.
*
* @result NS_OK if successful.
*/
NS_IMETHODIMP nsClipboard::ForceDataToClipboard(PRInt32 aWhichClipboard)
{
#ifdef DEBUG_CLIPBOARD
printf(" nsClipboard::ForceDataToClipboard()\n");
#endif /* DEBUG_CLIPBOARD */
PhClipboardPasteFinish( clipPtr );
}
return res;
}
// make sure we have a good transferable
nsCOMPtr<nsITransferable> transferable(getter_AddRefs(GetTransferable(aWhichClipboard)));
if (nsnull == transferable)
return NS_ERROR_FAILURE;
return NS_OK;
}
NS_IMETHODIMP
nsClipboard::HasDataMatchingFlavors(nsISupportsArray* aFlavorList,
PRInt32 aWhichClipboard,
PRBool * outResult) {
PRBool * outResult)
{
// XXX this doesn't work right. need to fix it.
// Note to implementor...(from pink the clipboard bitch).
//
// If a client asks for unicode, first check if unicode is present. If not, then
// check for plain text. If it's there, say "yes" as we will do the conversion
// in GetNativeClipboardData(). From this point on, no client will
// ever ask for text/plain explicitly. If they do, you must ASSERT!
#ifdef DEBUG_CLIPBOARD
printf(" nsClipboard::HasDataMatchingFlavors()\n {\n");
#endif
nsresult res = NS_OK;
* outResult = PR_FALSE;
@ -255,8 +446,8 @@ nsClipboard::HasDataMatchingFlavors(nsISupportsArray* aFlavorList,
PhClipHeader *cliphdr;
clipPtr = PhClipboardPasteStart( 1 );
if(nsnull == clipPtr)
return res;
if(nsnull == clipPtr)
return res;
for ( PRUint32 i = 0; i < cnt; ++i ) {
nsCOMPtr<nsISupports> genericFlavor;
@ -272,36 +463,59 @@ nsClipboard::HasDataMatchingFlavors(nsISupportsArray* aFlavorList,
if (err != NS_OK) continue;
cliphdr = PhClipboardPasteType( clipPtr, cliptype.type );
if (cliphdr)
{
if (cliphdr)
{
res = NS_OK;
*outResult = PR_TRUE;
break;
}
}
}
res = NS_OK;
*outResult = PR_TRUE;
break;
}
}
}
PhClipboardPasteFinish( clipPtr );
PhClipboardPasteFinish( clipPtr );
}
return res;
}
//=========================================================================
//-------------------------------------------------------------------------
nsresult nsClipboard::GetFormat(const char* aMimeStr, PhClipHeader *cliphdr ) {
nsresult nsClipboard::GetFormat(const char* aMimeStr, PhClipHeader *cliphdr )
{
nsCAutoString mimeStr ( CBufDescriptor(NS_CONST_CAST(char*,aMimeStr), PR_TRUE, PL_strlen(aMimeStr)+1) );
nsCAutoString mimeStr ( CBufDescriptor(NS_CONST_CAST(char*,aMimeStr), PR_TRUE, PL_strlen(aMimeStr)+1) );
cliphdr->type[0]=0;
cliphdr->type[0]=0;
if (mimeStr.Equals(kUnicodeMime) || mimeStr.Equals(kHTMLMime) || mimeStr.Equals(kTextMime))
strcpy( cliphdr->type, Ph_CLIPBOARD_TYPE_TEXT );
else if (mimeStr.Equals(kHTMLMime))
strcpy( cliphdr->type, Ph_CLIPBOARD_TYPE_HTML );
else if (mimeStr.Equals("moz/bookmarkclipboarditem"))
strcpy( cliphdr->type, Ph_CLIPBOARD_TYPE_MOZ_BOOKMARK );
// else if (mimeStr.Equals(kPNGImageMime) || mimeStr.Equals(kJPEGImageMime) || mimeStr.Equals(kGIFImageMime))
// strcpy( cliphdr->type, Ph_CLIPBOARD_TYPE_IMAGE);
if (cliphdr->type[0] == 0)
return NS_ERROR_FAILURE;
else
return NS_OK;
}
/* inline */
nsITransferable *nsClipboard::GetTransferable(PRInt32 aWhichClipboard)
{
nsITransferable *transferable = nsnull;
switch (aWhichClipboard)
{
case kGlobalClipboard:
transferable = mGlobalTransferable;
break;
case kSelectionClipboard:
transferable = mSelectionTransferable;
break;
}
NS_IF_ADDREF(transferable);
return transferable;
}
if (mimeStr.Equals(kUnicodeMime))
strcpy( cliphdr->type, Ph_CLIPBOARD_TYPE_TEXT );
if (cliphdr->type[0] == 0)
return NS_ERROR_FAILURE;
else
return NS_OK;
}

View File

@ -1,72 +1,76 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Netscape 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/NPL/
*
* 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.
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1999-2000 Netscape Communications Corporation.
* All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the NPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
* Stuart Parmenter <pavlov@netscape.com>
* Mike Pinkerton <pinkerton@netscape.com>
*/
#ifndef nsClipboard_h__
#define nsClipboard_h__
#include "nsBaseClipboard.h"
#include <Pt.h>
#include "nsIClipboard.h"
#include "nsITransferable.h"
#include "nsIClipboardOwner.h"
#include <nsCOMPtr.h>
class nsITransferable;
class nsIClipboardOwner;
class nsIWidget;
/**
* Native Photon Clipboard wrapper
* Native Clipboard wrapper
*/
class nsClipboard : public nsBaseClipboard
class nsClipboard : public nsIClipboard
{
public:
nsClipboard();
virtual ~nsClipboard();
// nsIClipboard
NS_IMETHOD ForceDataToClipboard ( PRInt32 aWhichClipboard );
NS_IMETHOD HasDataMatchingFlavors(nsISupportsArray* aFlavorList,
PRInt32 aWhichClipboard,
PRBool * outResult);
//nsISupports
NS_DECL_ISUPPORTS
// nsIClipboard
NS_DECL_NSICLIPBOARD
protected:
NS_IMETHOD SetNativeClipboardData(PRInt32 aWhichClipboard);
NS_IMETHOD SetNativeClipboardData(PRInt32 aWhichClipboard);
NS_IMETHOD GetNativeClipboardData(nsITransferable * aTransferable,
PRInt32 aWhichClipboard );
nsresult GetFormat(const char* aMimeStr, PhClipHeader *cliphdr );
nsresult GetFormat(const char* aMimeStr, PhClipHeader *cliphdr );
PRBool mIgnoreEmptyNotification;
inline nsITransferable *GetTransferable(PRInt32 aWhichClipboard);
private:
nsCOMPtr<nsIClipboardOwner> mSelectionOwner;
nsCOMPtr<nsIClipboardOwner> mGlobalOwner;
nsCOMPtr<nsITransferable> mSelectionTransferable;
nsCOMPtr<nsITransferable> mGlobalTransferable;
// Used for communicating pasted data
// from the asynchronous X routines back to a blocking paste:
PRBool mBlocking;
};
#endif // nsClipboard_h__

View File

@ -53,8 +53,6 @@ NS_IMPL_ADDREF_INHERITED(nsDragService, nsBaseDragService)
NS_IMPL_RELEASE_INHERITED(nsDragService, nsBaseDragService)
NS_IMPL_QUERY_INTERFACE2(nsDragService, nsIDragService, nsIDragSession)
#define DEBUG_DRAG 1
//-------------------------------------------------------------------------
//
// DragService constructor
@ -108,7 +106,9 @@ nsDragService::InvokeDragSession (nsIDOMNode *aDOMNode,
nsIScriptableRegion * aRegion,
PRUint32 aActionType)
{
/* ATENTIE */ printf( "nsDragService::InvokeDragSession\n" );
#ifdef DEBUG
printf( "nsDragService::InvokeDragSession\n" );
#endif
nsBaseDragService::InvokeDragSession (aDOMNode, aArrayTransferables, aRegion, aActionType);
// make sure that we have an array of transferables to use

View File

@ -371,7 +371,7 @@ NS_METHOD nsWidget::IsVisible( PRBool &aState ) {
// Constrain a potential move to see if it fits onscreen
//
//-------------------------------------------------------------------------
NS_METHOD nsWidget::ConstrainPosition(PRBool aAllowSlop, PRInt32 *aX, PRInt32 *aY ) {
NS_METHOD nsWidget::ConstrainPosition(int b, PRInt32 *aX, PRInt32 *aY ) {
return NS_OK;
}
@ -499,10 +499,10 @@ PRBool nsWidget::OnMove( PRInt32 aX, PRInt32 aY ) {
// Enable/disable this component
//
//-------------------------------------------------------------------------
NS_METHOD nsWidget::Enable( PRBool aState ) {
NS_METHOD nsWidget::Enable( PRBool bState ) {
if( mWidget ) {
PtArg_t arg;
if( aState )
if( bState )
PtSetArg( &arg, Pt_ARG_FLAGS, 0, Pt_BLOCKED );
else
PtSetArg( &arg, Pt_ARG_FLAGS, Pt_BLOCKED, Pt_BLOCKED );
@ -511,11 +511,16 @@ NS_METHOD nsWidget::Enable( PRBool aState ) {
return NS_OK;
}
NS_IMETHODIMP nsWidget::IsEnabled(PRBool *aState)
{
NS_ENSURE_ARG_POINTER(aState);
NS_METHOD nsWidget::IsEnabled( PRBool *aState ) {
NS_ENSURE_ARG_POINTER(aState);
*aState = PR_TRUE;
return NS_ERROR_NOT_IMPLEMENTED;
if (PtWidgetFlags(mWidget) & Pt_BLOCKED)
*aState = PR_FALSE;
else
*aState = PR_TRUE;
return NS_OK;
}
@ -1371,12 +1376,10 @@ void nsWidget::InitKeyEvent(PhKeyEvent_t *aPhKeyEvent,
PRBool IsChar;
unsigned long keysym;
if (Pk_KF_Sym_Valid & aPhKeyEvent->key_flags)
keysym = nsConvertKey(aPhKeyEvent->key_sym, &IsChar);
if (Pk_KF_Cap_Valid & aPhKeyEvent->key_flags)
keysym = nsConvertKey(aPhKeyEvent->key_cap, &IsChar);
else
/* Need this to support key release events on numeric key pad */
keysym = nsConvertKey(aPhKeyEvent->key_cap, &IsChar);
keysym = nsConvertKey(aPhKeyEvent->key_sym, &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;
@ -1502,7 +1505,7 @@ PRBool nsWidget::HandleEvent( PtWidget_t *widget, PtCallbackInfo_t* aCbInfo ) {
///* ATENTIE */ printf( "Ph_EV_PTR_MOTION_NOBUTTON (%d %d)\n", ptrev->pos.x, ptrev->pos.y );
ScreenToWidget( ptrev->pos );
ScreenToWidgetPos( ptrev->pos );
InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_MOVE );
result = DispatchMouseEvent(theMouseEvent);
}
@ -1513,7 +1516,17 @@ PRBool nsWidget::HandleEvent( PtWidget_t *widget, PtCallbackInfo_t* aCbInfo ) {
{
PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( event );
nsMouseEvent theMouseEvent;
nsMouseEvent theMouseEvent;
/* there is no big region to capture the button press events outside the menu's area - this will be checked here, and if the click was not on a menu item, close the menu, if any */
nsWidget *parent = (nsWidget*)mParent;
if ((parent && (parent->mWindowType != eWindowType_popup) && (mWindowType != eWindowType_popup)) || (!parent && (mWindowType != eWindowType_popup)))
{
// if( !parent || ( parent->mWindowType != eWindowType_popup ) ) {
if( gRollupWidget && gRollupListener ) {
gRollupListener->Rollup();
}
}
/* there should be no reason to do this - mozilla should figure out how to call SetFocus */
/* this though fixes the problem with the plugins capturing the focus */
@ -1527,20 +1540,8 @@ PRBool nsWidget::HandleEvent( PtWidget_t *widget, PtCallbackInfo_t* aCbInfo ) {
}
}
/* there is no big region to capture the button press events outside the menu's area - this will be checked here, and if the click was not on a menu item, close the menu, if any */
nsWidget *parent = (nsWidget*)mParent;
if( !parent || ( parent->mWindowType != eWindowType_popup ) ) {
if( gRollupWidget && gRollupListener ) {
gRollupListener->Rollup();
}
}
if( ptrev ) {
ScreenToWidget( ptrev->pos );
///* ATENTIE */ printf( "Ph_EV_PTR_PRESS (%d %d)\n", ptrev->pos.x, ptrev->pos.y );
ScreenToWidgetPos( ptrev->pos );
if( ptrev->buttons & Ph_BUTTON_SELECT ) // Normally the left mouse button
InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_LEFT_BUTTON_DOWN );
@ -1557,6 +1558,7 @@ PRBool nsWidget::HandleEvent( PtWidget_t *widget, PtCallbackInfo_t* aCbInfo ) {
result = DispatchMouseEvent( theMouseEvent );
}
}
}
break;
@ -1567,7 +1569,7 @@ PRBool nsWidget::HandleEvent( PtWidget_t *widget, PtCallbackInfo_t* aCbInfo ) {
if (event->subtype==Ph_EV_RELEASE_REAL || event->subtype==Ph_EV_RELEASE_PHANTOM) {
if (ptrev) {
ScreenToWidget( ptrev->pos );
ScreenToWidgetPos( ptrev->pos );
if ( ptrev->buttons & Ph_BUTTON_SELECT ) // Normally the left mouse button
InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_LEFT_BUTTON_UP );
else if( ptrev->buttons & Ph_BUTTON_MENU ) // the right button
@ -1575,16 +1577,13 @@ PRBool nsWidget::HandleEvent( PtWidget_t *widget, PtCallbackInfo_t* aCbInfo ) {
else // middle button
InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_MIDDLE_BUTTON_UP );
///* ATENTIE */ printf( "Ph_EV_PTR_RELEASE (%d %d)\n", ptrev->pos.x, ptrev->pos.y );
result = DispatchMouseEvent(theMouseEvent);
}
}
else if (event->subtype==Ph_EV_RELEASE_OUTBOUND) {
PhRect_t rect = {{0,0},{0,0}};
PhRect_t boundary = {{-10000,-10000},{10000,10000}};
PhInitDrag( PtWidgetRid(mWidget), ( Ph_DRAG_KEY_MOTION | Ph_DRAG_TRACK ),&rect, &boundary, aCbInfo->event->input_group , NULL, NULL, NULL, NULL, NULL);
///* ATENTIE */ printf( "PhInitDrag\n" );
PhInitDrag( PtWidgetRid(mWidget), ( Ph_DRAG_KEY_MOTION | Ph_DRAG_TRACK | Ph_TRACK_DRAG),&rect, &boundary, aCbInfo->event->input_group , NULL, NULL, NULL, NULL, NULL);
}
}
break;
@ -1605,7 +1604,7 @@ PRBool nsWidget::HandleEvent( PtWidget_t *widget, PtCallbackInfo_t* aCbInfo ) {
d->SetNativeDndData( widget, event );
}
ScreenToWidget( ptrev->pos );
ScreenToWidgetPos( ptrev->pos );
InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_MOVE );
result = DispatchMouseEvent(theMouseEvent);
}
@ -1650,14 +1649,14 @@ PRBool nsWidget::HandleEvent( PtWidget_t *widget, PtCallbackInfo_t* aCbInfo ) {
{
nsMouseEvent theMouseEvent;
PhPointerEvent_t* ptrev2 = (PhPointerEvent_t*) PhGetData( event );
ScreenToWidget( ptrev2->pos );
ScreenToWidgetPos( ptrev2->pos );
InitMouseEvent(ptrev2, this, theMouseEvent, NS_MOUSE_LEFT_BUTTON_UP );
result = DispatchMouseEvent(theMouseEvent);
}
break;
case Ph_EV_DRAG_MOTION_EVENT: {
PhPointerEvent_t* ptrev2 = (PhPointerEvent_t*) PhGetData( event );
ScreenToWidget( ptrev2->pos );
ScreenToWidgetPos( ptrev2->pos );
if( sDragService ) {
nsDragService *d;
@ -1693,7 +1692,7 @@ PRBool nsWidget::HandleEvent( PtWidget_t *widget, PtCallbackInfo_t* aCbInfo ) {
}
void nsWidget::ScreenToWidget( PhPoint_t &pt ) {
void nsWidget::ScreenToWidgetPos( PhPoint_t &pt ) {
// pt is in screen coordinates
// convert it to be relative to ~this~ widgets origin
short x=0,y=0;
@ -2078,7 +2077,7 @@ int nsWidget::DndCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbi
PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( cbinfo->event );
//printf("Enter pos=%d %d\n", ptrev->pos.x, ptrev->pos.y );
pWidget->ScreenToWidget( ptrev->pos );
pWidget->ScreenToWidgetPos( ptrev->pos );
//printf("After trans pos=%d %d pWidget=%p\n", ptrev->pos.x, ptrev->pos.y, pWidget );
@ -2123,7 +2122,7 @@ nsAutoString nsWidget::GuiEventToString(nsGUIEvent * aGuiEvent)
{
NS_ASSERTION(nsnull != aGuiEvent,"cmon, null gui event.");
nsAutoString eventName(NS_LITERAL_STRING("UNKNOWN"));
nsAutoString eventName; eventName.AssignWithConversion("UNKNOWN");
#define _ASSIGN_eventName(_value,_name)\
case _value: eventName = (const PRUnichar *) _name ; break
@ -2209,7 +2208,7 @@ nsAutoString nsWidget::PhotonEventToString(PhEvent_t * aPhEvent)
{
NS_ASSERTION(nsnull != aPhEvent,"cmon, null photon gui event.");
nsAutoString eventName(NS_LITERAL_STRING("UNKNOWN"));
nsAutoString eventName; eventName.AssignWithConversion("UNKNOWN");
#define _ASSIGN_eventName(_value,_name)\
case _value: eventName = (const PRUnichar *) _name ; break

View File

@ -213,7 +213,7 @@ protected:
virtual PRBool HandleEvent( PtWidget_t *, PtCallbackInfo_t* aCbInfo );
PRBool DispatchMouseEvent(PhPoint_t &aPos, PRUint32 aEvent);
PRBool DispatchKeyEvent(PhKeyEvent_t *aPhKeyEvent);
virtual void ScreenToWidget( PhPoint_t &pt );
void ScreenToWidgetPos( PhPoint_t &pt );
void InitKeyEvent(PhKeyEvent_t *aPhKeyEvent, nsWidget *aWidget,
nsKeyEvent &aKeyEvent, PRUint32 aEventType);

View File

@ -132,7 +132,7 @@ static nsresult nsVertScrollbarConstructor (nsISupports *aOuter, REFNSIID aIID,
return rv;
}
static const nsModuleComponentInfo components[] =
static nsModuleComponentInfo components[] =
{
{ "Ph nsWindow",
NS_WINDOW_CID,
@ -164,12 +164,10 @@ static const nsModuleComponentInfo components[] =
nsLookAndFeelConstructor },
{ "Transferrable",
NS_TRANSFERABLE_CID,
// "@mozilla.org/widget/transferrable/ph;1",
"@mozilla.org/widget/transferable;1",
nsTransferableConstructor },
{ "Ph Clipboard",
NS_CLIPBOARD_CID,
// "@mozilla.org/widget/clipboard/ph;1",
"@mozilla.org/widget/clipboard;1",
nsClipboardConstructor },
{ "HTML Format Converter",
@ -178,13 +176,12 @@ static const nsModuleComponentInfo components[] =
nsHTMLFormatConverterConstructor },
{ "Ph Drag Service",
NS_DRAGSERVICE_CID,
// "@mozilla.org/widget/dragservice/ph;1",
"@mozilla.org/widget/dragservice;1",
nsDragServiceConstructor },
{ "Ph Sound",
NS_SOUND_CID,
"@mozilla.org/sound;1",
nsSoundConstructor },
{ "Ph Sound",
NS_SOUND_CID,
"@mozilla.org/sound;1",
nsSoundConstructor },
#ifdef IBMBIDI
{ "Gtk Bidi Keyboard",
NS_BIDIKEYBOARD_CID,
@ -193,4 +190,12 @@ static const nsModuleComponentInfo components[] =
#endif // IBMBIDI
};
NS_IMPL_NSGETMODULE(nsWidgetPhModule, components)
PR_STATIC_CALLBACK(void)
nsWidgetPhModuleDtor(nsIModule *self)
{
// nsPhIMEHelper::Shutdown();
}
NS_IMPL_NSGETMODULE_WITH_DTOR(nsWidgetPhModule,
components,
nsWidgetPhModuleDtor)

View File

@ -294,7 +294,7 @@ NS_METHOD nsWindow::CreateNative( PtWidget_t *parentWidget ) {
else
{
// No border or decorations is the default
render_flags = Ph_WM_RENDER_INLINE;
render_flags = Ph_WM_RENDER_INLINE | Ph_WM_RENDER_RESIZE;
if( mWindowType != eWindowType_popup ) {
@ -412,6 +412,8 @@ NS_METHOD nsWindow::CreateNative( PtWidget_t *parentWidget ) {
Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE |Ph_EV_BOUNDARY | Ph_EV_WM /*| Ph_EV_EXPOSE*/,
RawEventHandler, this );
PtAddEventHandler( mWidget, Ph_EV_DRAG /*| Ph_EV_EXPOSE*/, RawEventHandler, this );
PtArg_t arg;
PtRawCallback_t callback;