зеркало из https://github.com/mozilla/gecko-dev.git
Родитель
c7dcf80ce0
Коммит
ae5904ae09
|
@ -1,5 +1,39 @@
|
|||
/* PtRawDrawContainer.c - widget source file */
|
||||
|
||||
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
|
||||
/* ***** 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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 ***** */
|
||||
#include "PtRawDrawContainer.h"
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
|
@ -55,7 +55,6 @@
|
|||
/* Global Definitions */
|
||||
PRBool nsAppShell::gExitMainLoop = PR_FALSE;
|
||||
|
||||
static PRBool sInitialized = PR_FALSE;
|
||||
static PLHashTable *sQueueHashTable = nsnull;
|
||||
static PLHashTable *sCountHashTable = nsnull;
|
||||
|
||||
|
@ -73,7 +72,7 @@ our_photon_input_add (int fd,
|
|||
PtFdProc_t event_processor_callback,
|
||||
void *data)
|
||||
{
|
||||
int err = PtAppAddFdPri( NULL, fd, (Pt_FD_READ | Pt_FD_NOPOLL | Pt_FD_DRAIN ), event_processor_callback, data, getprio( 0 ) + 1 );
|
||||
int err = PtAppAddFd( NULL, fd, (Pt_FD_READ | Pt_FD_NOPOLL | Pt_FD_DRAIN ), event_processor_callback, data );
|
||||
if (err != 0)
|
||||
{
|
||||
NS_ASSERTION(0,"nsAppShell::our_photon_input_add Error calling PtAppAddFD\n");
|
||||
|
@ -136,9 +135,10 @@ NS_IMETHODIMP nsAppShell::SetDispatchListener(nsDispatchListener* aDispatchListe
|
|||
static int event_processor_callback(int fd, void *data, unsigned mode)
|
||||
{
|
||||
nsIEventQueue *eventQueue = (nsIEventQueue*)data;
|
||||
PtHold();
|
||||
if (eventQueue)
|
||||
eventQueue->ProcessPendingEvents();
|
||||
|
||||
PtRelease();
|
||||
return Pt_CONTINUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,24 +1,39 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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 IBM code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is IBM.
|
||||
* Portions created by IBM are
|
||||
* Copyright (C) International Business Machines
|
||||
* Corporation, 2000. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Simon Montagu
|
||||
*/
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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 ***** */
|
||||
|
||||
#include "nsBidiKeyboard.h"
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsDragService.h"
|
||||
|
||||
#include "nsITransferable.h"
|
||||
#include "nsString.h"
|
||||
#include "nsClipboard.h"
|
||||
|
@ -64,8 +63,11 @@ NS_IMPL_QUERY_INTERFACE2(nsDragService, nsIDragService, nsIDragSession)
|
|||
nsDragService::nsDragService()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mWidget = nsnull;
|
||||
mNumFlavors = 0;
|
||||
mDndWidget = nsnull;
|
||||
mDndEvent = nsnull;
|
||||
mNativeCtrl = nsnull;
|
||||
mflavorStr = nsnull;
|
||||
mData = nsnull;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -75,238 +77,144 @@ nsDragService::nsDragService()
|
|||
//-------------------------------------------------------------------------
|
||||
nsDragService::~nsDragService()
|
||||
{
|
||||
if (mWidget)
|
||||
{
|
||||
PtDestroyWidget(mWidget);
|
||||
mWidget=nsnull;
|
||||
if( mNativeCtrl ) PtReleaseTransportCtrl( mNativeCtrl );
|
||||
if( mflavorStr ) free( mflavorStr );
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDragService::SetNativeDndData( PtWidget_t *widget, PhEvent_t *event ) {
|
||||
mDndWidget = widget;
|
||||
mDndEvent = event;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDragService::SetDropData( char *data, PRUint32 tmpDataLen, char *aflavorStr ) {
|
||||
|
||||
mtmpDataLen = tmpDataLen;
|
||||
|
||||
if( mData ) free( mData );
|
||||
mData = ( char * ) malloc( tmpDataLen );
|
||||
memcpy( mData, data, tmpDataLen );
|
||||
|
||||
if( mflavorStr ) free( mflavorStr );
|
||||
mflavorStr = strdup( aflavorStr );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* free the target list */
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDragService::StartDragSession()
|
||||
{
|
||||
NS_WARNING("nsDragService::StartDragSession() - Not Supported Yet");
|
||||
nsBaseDragService::StartDragSession();
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDragService::EndDragSession()
|
||||
{
|
||||
NS_WARNING("nsDragService::EndDragSession()\n");
|
||||
nsBaseDragService::EndDragSession();
|
||||
|
||||
//gtk_drag_source_unset(mWidget);
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsDragService::InvokeDragSession (nsIDOMNode *aDOMNode,
|
||||
nsISupportsArray *aTransferableArray,
|
||||
nsIScriptableRegion *aRegion,
|
||||
PRUint32 aActionType)
|
||||
NS_IMETHODIMP
|
||||
nsDragService::InvokeDragSession (nsIDOMNode *aDOMNode,
|
||||
nsISupportsArray * aArrayTransferables,
|
||||
nsIScriptableRegion * aRegion,
|
||||
PRUint32 aActionType)
|
||||
{
|
||||
nsBaseDragService::InvokeDragSession ( aDOMNode, aTransferableArray, aRegion, aActionType );
|
||||
|
||||
//mWidget = gtk_invisible_new();
|
||||
//gtk_widget_show(mWidget);
|
||||
/* ATENTIE */ printf( "nsDragService::InvokeDragSession\n" );
|
||||
nsBaseDragService::InvokeDragSession (aDOMNode, aArrayTransferables, aRegion, aActionType);
|
||||
|
||||
// add the flavors from the transferables. Cache this array for the send data proc
|
||||
//GtkTargetList *targetlist = RegisterDragItemsAndFlavors(aTransferableArray);
|
||||
// make sure that we have an array of transferables to use
|
||||
if(!aArrayTransferables) return NS_ERROR_INVALID_ARG;
|
||||
|
||||
switch (aActionType)
|
||||
{
|
||||
case DRAGDROP_ACTION_NONE:
|
||||
//mActionType = GDK_ACTION_DEFAULT;
|
||||
break;
|
||||
case DRAGDROP_ACTION_COPY:
|
||||
//mActionType = GDK_ACTION_COPY;
|
||||
break;
|
||||
case DRAGDROP_ACTION_MOVE:
|
||||
//mActionType = GDK_ACTION_MOVE;
|
||||
break;
|
||||
case DRAGDROP_ACTION_LINK:
|
||||
//mActionType = GDK_ACTION_LINK;
|
||||
break;
|
||||
}
|
||||
nsresult rv;
|
||||
PRUint32 numItemsToDrag = 0;
|
||||
rv = aArrayTransferables->Count(&numItemsToDrag);
|
||||
if ( !numItemsToDrag )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
StartDragSession();
|
||||
PRUint32 tmpDataLen = 0;
|
||||
nsCOMPtr<nsISupports> genericDataWrapper;
|
||||
char aflavorStr[100];
|
||||
GetRawData( aArrayTransferables, getter_AddRefs( genericDataWrapper ), &tmpDataLen, aflavorStr );
|
||||
|
||||
// XXX 3rd param ??? & last param should be a real event...
|
||||
//gtk_drag_begin(mWidget, targetlist, mActionType, 1, gdk_event_get());
|
||||
void *data;
|
||||
nsPrimitiveHelpers::CreateDataFromPrimitive ( aflavorStr, genericDataWrapper, &data, tmpDataLen );
|
||||
|
||||
mNativeCtrl = PtCreateTransportCtrl( );
|
||||
static char * dupdata;
|
||||
if( dupdata ) free( dupdata );
|
||||
dupdata = (char*) calloc( 1, tmpDataLen + 4 + 100 );
|
||||
if( dupdata ) {
|
||||
*(int*)dupdata = tmpDataLen;
|
||||
strcpy( dupdata+4, aflavorStr );
|
||||
memcpy( dupdata+4+100, data, tmpDataLen );
|
||||
PtTransportType( mNativeCtrl, "Mozilla", "dnddata", 0, Ph_TRANSPORT_INLINE, "raw", dupdata, tmpDataLen+4+100, 0 );
|
||||
PtInitDnd( mNativeCtrl, mDndWidget, mDndEvent, NULL, 0 );
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
GtkTargetList *nsDragService::RegisterDragItemsAndFlavors(nsISupportsArray *inArray)
|
||||
{
|
||||
unsigned int numDragItems = 0;
|
||||
inArray->Count(&numDragItems);
|
||||
|
||||
GtkTargetList *targetlist;
|
||||
targetlist = gtk_target_list_new(nsnull, numDragItems);
|
||||
|
||||
printf("nsDragService::RegisterDragItemsAndFlavors\n");
|
||||
|
||||
for (unsigned int i = 0; i < numDragItems; ++i)
|
||||
{
|
||||
nsCOMPtr<nsISupports> genericItem;
|
||||
inArray->GetElementAt (i, getter_AddRefs(genericItem));
|
||||
nsCOMPtr<nsITransferable> currItem (do_QueryInterface(genericItem));
|
||||
if (currItem)
|
||||
{
|
||||
nsCOMPtr<nsISupportsArray> flavorList;
|
||||
if (NS_SUCCEEDED(currItem->FlavorsTransferableCanExport(getter_AddRefs(flavorList))))
|
||||
{
|
||||
flavorList->Count (&mNumFlavors);
|
||||
for (PRUint32 flavorIndex = 0; flavorIndex < mNumFlavors; ++flavorIndex)
|
||||
{
|
||||
nsCOMPtr<nsISupports> genericWrapper;
|
||||
flavorList->GetElementAt ( flavorIndex, getter_AddRefs(genericWrapper) );
|
||||
nsCOMPtr<nsISupportsString> currentFlavor ( do_QueryInterface(genericWrapper) );
|
||||
if ( currentFlavor )
|
||||
{
|
||||
nsXPIDLCString flavorStr;
|
||||
currentFlavor->ToString ( getter_Copies(flavorStr) );
|
||||
|
||||
// register native flavors
|
||||
GdkAtom atom = gdk_atom_intern(flavorStr, PR_TRUE);
|
||||
gtk_target_list_add(targetlist, atom, 1, atom);
|
||||
}
|
||||
|
||||
} // foreach flavor in item
|
||||
} // if valid flavor list
|
||||
} // if item is a transferable
|
||||
} // foreach drag item
|
||||
|
||||
return targetlist;
|
||||
}
|
||||
|
||||
|
||||
/* return PR_TRUE if we have converted or PR_FALSE if we havn't and need to keep being called */
|
||||
PRBool nsDragService::DoConvert(GdkAtom type)
|
||||
{
|
||||
|
||||
printf("nsDragService::DoRealConvert(%li)\n {\n", type);
|
||||
int e = 0;
|
||||
// Set a flag saying that we're blocking waiting for the callback:
|
||||
mBlocking = PR_TRUE;
|
||||
|
||||
//
|
||||
// ask X what kind of data we can get
|
||||
//
|
||||
#ifdef DEBUG_DRAG
|
||||
printf(" Doing real conversion of atom type '%s'\n", gdk_atom_name(type));
|
||||
#endif
|
||||
gtk_selection_convert(mWidget,
|
||||
GDK_SELECTION_PRIMARY,
|
||||
type,
|
||||
GDK_CURRENT_TIME);
|
||||
|
||||
// Now we need to wait until the callback comes in ...
|
||||
// i is in case we get a runaway (yuck).
|
||||
#ifdef DEBUG_DRAG
|
||||
printf(" Waiting for the callback... mBlocking = %d\n", mBlocking);
|
||||
#endif /* DEBUG_CLIPBOARD */
|
||||
for (e=0; mBlocking == PR_TRUE && e < 1000; ++e)
|
||||
{
|
||||
gtk_main_iteration_do(PR_TRUE);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_DRAG
|
||||
printf(" }\n");
|
||||
#endif
|
||||
|
||||
if (mSelectionData.length > 0)
|
||||
return PR_TRUE;
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsDragService::GetNumDropItems (PRUint32 * aNumItems)
|
||||
{
|
||||
*aNumItems = 0;
|
||||
*aNumItems = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsDragService::GetData (nsITransferable * aTransferable, PRUint32 anItem)
|
||||
{
|
||||
#if 0
|
||||
NS_IMETHODIMP nsDragService::GetData (nsITransferable * aTransferable, PRUint32 aItemIndex ) {
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISupports> genericDataWrapper;
|
||||
nsPrimitiveHelpers::CreatePrimitiveForData( mflavorStr, mData, mtmpDataLen, getter_AddRefs( genericDataWrapper ) );
|
||||
rv = aTransferable->SetTransferData( mflavorStr, genericDataWrapper, mtmpDataLen );
|
||||
return rv;
|
||||
}
|
||||
|
||||
// make sure we have a good transferable
|
||||
if (!aTransferable) {
|
||||
printf(" GetData: Transferable is null!\n");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsDragService::GetRawData( nsISupportsArray* aArrayTransferables, nsISupports **data, PRUint32 *tmpDataLen, char *aflavorStr ) {
|
||||
|
||||
// get flavor list that includes all acceptable flavors (including ones obtained through
|
||||
// conversion)
|
||||
int aItemIndex = 0;
|
||||
|
||||
// get the item with the right index
|
||||
nsCOMPtr<nsISupports> genericItem;
|
||||
aArrayTransferables->GetElementAt(aItemIndex, getter_AddRefs(genericItem));
|
||||
nsCOMPtr<nsITransferable> aTransferable (do_QueryInterface(genericItem));
|
||||
|
||||
// get flavor list that includes all acceptable flavors (including
|
||||
// ones obtained through conversion). Flavors are nsISupportsStrings
|
||||
// so that they can be seen from JS.
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsCOMPtr<nsISupportsArray> flavorList;
|
||||
nsresult errCode = aTransferable->FlavorsTransferableCanImport ( getter_AddRefs(flavorList) );
|
||||
if ( NS_FAILED(errCode) )
|
||||
return NS_ERROR_FAILURE;
|
||||
rv = aTransferable->FlavorsTransferableCanImport(getter_AddRefs(flavorList));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Walk through flavors and see which flavor matches the one being pasted:
|
||||
// count the number of flavors
|
||||
PRUint32 cnt;
|
||||
flavorList->Count(&cnt);
|
||||
nsCAutoString foundFlavor;
|
||||
for ( PRUint32 i = 0; i < cnt; ++i ) {
|
||||
nsCOMPtr<nsISupports> genericFlavor;
|
||||
flavorList->GetElementAt ( i, getter_AddRefs(genericFlavor) );
|
||||
nsCOMPtr<nsISupportsString> currentFlavor (do_QueryInterface(genericFlavor));
|
||||
if ( currentFlavor ) {
|
||||
flavorList->Count (&cnt);
|
||||
unsigned int i;
|
||||
|
||||
// Now walk down the list of flavors. When we find one that is
|
||||
// actually present, copy out the data into the transferable in that
|
||||
// format. SetTransferData() implicitly handles conversions.
|
||||
for ( i = 0; i < cnt; ++i ) {
|
||||
nsCOMPtr<nsISupports> genericWrapper;
|
||||
flavorList->GetElementAt(i,getter_AddRefs(genericWrapper));
|
||||
nsCOMPtr<nsISupportsString> currentFlavor;
|
||||
currentFlavor = do_QueryInterface(genericWrapper);
|
||||
if (currentFlavor) {
|
||||
// find our gtk flavor
|
||||
nsXPIDLCString flavorStr;
|
||||
currentFlavor->ToString(getter_Copies(flavorStr));
|
||||
if (DoConvert(gdk_atom_intern(flavorStr, 1))) {
|
||||
foundFlavor = flavorStr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
currentFlavor->ToString ( getter_Copies(flavorStr) );
|
||||
|
||||
// We're back from the callback, no longer blocking:
|
||||
mBlocking = PR_FALSE;
|
||||
// get the item with the right index
|
||||
nsCOMPtr<nsISupports> genericItem;
|
||||
aArrayTransferables->GetElementAt( aItemIndex, getter_AddRefs(genericItem));
|
||||
nsCOMPtr<nsITransferable> item (do_QueryInterface(genericItem));
|
||||
if (item) {
|
||||
rv = item->GetTransferData(flavorStr, data, tmpDataLen);
|
||||
if( NS_SUCCEEDED( rv ) ) {
|
||||
strcpy( aflavorStr, flavorStr );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // foreach flavor
|
||||
|
||||
//
|
||||
// Now we have data in mSelectionData.data.
|
||||
// We just have to copy it to the transferable.
|
||||
//
|
||||
|
||||
#if 0
|
||||
// pinkerton - we have the flavor already from above, so we don't need
|
||||
// to re-derrive it.
|
||||
nsString *name = new nsString((const char*)gdk_atom_name(mSelectionData.type));
|
||||
int format = GetFormat(*name);
|
||||
df->SetString((const char*)gdk_atom_name(sSelTypes[format]));
|
||||
#endif
|
||||
|
||||
nsCOMPtr<nsISupports> genericDataWrapper;
|
||||
nsPrimitiveHelpers::CreatePrimitiveForData ( foundFlavor, mSelectionData.data, mSelectionData.length, getter_AddRefs(genericDataWrapper) );
|
||||
aTransferable->SetTransferData(foundFlavor,
|
||||
genericDataWrapper,
|
||||
mSelectionData.length);
|
||||
|
||||
//delete name;
|
||||
|
||||
// transferable is now copying the data, so we can free it.
|
||||
// g_free(mSelectionData.data);
|
||||
mSelectionData.data = nsnull;
|
||||
mSelectionData.length = 0;
|
||||
|
||||
gtk_drag_source_unset(mWidget);
|
||||
|
||||
#endif
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -314,122 +222,6 @@ NS_IMETHODIMP nsDragService::IsDataFlavorSupported(const char *aDataFlavor, PRBo
|
|||
{
|
||||
if (!aDataFlavor || !_retval)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*_retval = PR_TRUE;
|
||||
*_retval = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsDragService::GetCurrentSession (nsIDragSession **aSession)
|
||||
{
|
||||
if (!aSession)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
*aSession = (nsIDragSession *)this;
|
||||
NS_ADDREF(*aSession);
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
//-------------------------------------------------------------------------
|
||||
void
|
||||
nsDragService::DragLeave (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
guint time)
|
||||
{
|
||||
printf("leave\n");
|
||||
//gHaveDrag = PR_FALSE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool
|
||||
nsDragService::DragMotion(GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gint x,
|
||||
gint y,
|
||||
guint time)
|
||||
{
|
||||
printf("drag motion\n");
|
||||
GtkWidget *source_widget;
|
||||
|
||||
#if 0
|
||||
if (!gHaveDrag) {
|
||||
gHaveDrag = PR_TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
source_widget = gtk_drag_get_source_widget (context);
|
||||
printf("motion, source %s\n", source_widget ?
|
||||
gtk_type_name (GTK_OBJECT (source_widget)->klass->type) :
|
||||
"unknown");
|
||||
|
||||
gdk_drag_status (context, context->suggested_action, time);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool
|
||||
nsDragService::DragDrop(GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gint x,
|
||||
gint y,
|
||||
guint time)
|
||||
{
|
||||
printf("drop\n");
|
||||
//gHaveDrag = PR_FALSE;
|
||||
|
||||
if (context->targets){
|
||||
gtk_drag_get_data (widget, context,
|
||||
GPOINTER_TO_INT (context->targets->data),
|
||||
time);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void
|
||||
nsDragService::DragDataReceived (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gint x,
|
||||
gint y,
|
||||
GtkSelectionData *data,
|
||||
guint info,
|
||||
guint time)
|
||||
{
|
||||
if ((data->length >= 0) && (data->format == 8)) {
|
||||
printf ("Received \"%s\"\n", (gchar *)data->data);
|
||||
gtk_drag_finish (context, PR_TRUE, PR_FALSE, time);
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_drag_finish (context, PR_FALSE, PR_FALSE, time);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void
|
||||
nsDragService::DragDataGet(GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time,
|
||||
gpointer data)
|
||||
{
|
||||
gtk_selection_data_set (selection_data,
|
||||
selection_data->target,
|
||||
8, (guchar *)"I'm Data!", 9);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
void
|
||||
nsDragService::DragDataDelete(GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gpointer data)
|
||||
{
|
||||
printf ("Delete the data!\n");
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -38,9 +38,11 @@
|
|||
#ifndef nsDragService_h__
|
||||
#define nsDragService_h__
|
||||
|
||||
#include "nsBaseDragService.h"
|
||||
#include <Pt.h>
|
||||
|
||||
#include "nsBaseDragService.h"
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Native Photon DragService wrapper
|
||||
|
@ -55,6 +57,10 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
/* photon dependent stuff */
|
||||
NS_IMETHOD SetNativeDndData( PtWidget_t * widget, PhEvent_t *event );
|
||||
|
||||
|
||||
// nsIDragService
|
||||
NS_IMETHOD InvokeDragSession (nsIDOMNode *aDOMNode, nsISupportsArray * anArrayTransferables,
|
||||
nsIScriptableRegion * aRegion, PRUint32 aActionType);
|
||||
|
@ -63,61 +69,17 @@ public:
|
|||
NS_IMETHOD GetData (nsITransferable * aTransferable, PRUint32 anItem);
|
||||
NS_IMETHOD GetNumDropItems (PRUint32 * aNumItems);
|
||||
NS_IMETHOD IsDataFlavorSupported(const char *aDataFlavor, PRBool *_retval);
|
||||
|
||||
NS_IMETHOD StartDragSession();
|
||||
NS_IMETHOD EndDragSession();
|
||||
|
||||
|
||||
//GtkTargetList *RegisterDragItemsAndFlavors(nsISupportsArray *inArray);
|
||||
|
||||
protected:
|
||||
|
||||
//PRBool DoConvert(GdkAtom type);
|
||||
|
||||
static PRBool gHaveDrag;
|
||||
|
||||
//static void DragLeave(PtWidget_t *widget,
|
||||
// GdkDragContext *context,
|
||||
// guint time);
|
||||
|
||||
//static PRBool DragMotion(PtWidget_t *widget,
|
||||
// GdkDragContext *context,
|
||||
// gint x,
|
||||
// gint y,
|
||||
// guint time);
|
||||
|
||||
//static PRBool DragDrop(PtWidget_t *widget,
|
||||
// GdkDragContext *context,
|
||||
// gint x,
|
||||
// gint y,
|
||||
// guint time);
|
||||
|
||||
//static void DragDataReceived(PtWidget_t *widget,
|
||||
// GdkDragContext *context,
|
||||
// gint x,
|
||||
// gint y,
|
||||
// GtkSelectionData *data,
|
||||
// guint info,
|
||||
// guint time);
|
||||
|
||||
//static void DragDataGet(PtWidget_t *widget,
|
||||
// GdkDragContext *context,
|
||||
// GtkSelectionData *selection_data,
|
||||
// guint info,
|
||||
// guint time,
|
||||
// gpointer data);
|
||||
|
||||
// static void DragDataDelete(PtWidget_t *widget,
|
||||
// GdkDragContext *context,
|
||||
// gpointer data);
|
||||
NS_IMETHOD SetDropData( char *data, PRUint32 tmpDataLen, char *flavorStr );
|
||||
NS_IMETHOD GetRawData( nsISupportsArray* aArrayTransferables, nsISupports **data, PRUint32 *tmpDataLen, char *aflavorStr );
|
||||
|
||||
private:
|
||||
// GdkDragAction mActionType;
|
||||
PRUint32 mNumFlavors;
|
||||
PtWidget_t *mWidget;
|
||||
// GdkDragContext *mDragContext;
|
||||
// GtkSelectionData mSelectionData;
|
||||
PRBool mBlocking;
|
||||
PtWidget_t *mDndWidget;
|
||||
PhEvent_t *mDndEvent;
|
||||
|
||||
PtTransportCtrl_t *mNativeCtrl;
|
||||
char *mData;
|
||||
PRUint32 mtmpDataLen;
|
||||
char *mflavorStr;
|
||||
};
|
||||
|
||||
#endif // nsDragService_h__
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "nsPhWidgetLog.h"
|
||||
|
||||
#include "nsXPLookAndFeel.h"
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsLookAndFeel, nsILookAndFeel)
|
||||
|
||||
#define PH_TO_NS_RGB(ns) (ns & 0xff) << 16 | (ns & 0xff00) | ((ns >> 16) & 0xff)
|
||||
|
@ -321,9 +321,9 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
|
|||
case eMetric_SubmenuDelay:
|
||||
aMetric = 200;
|
||||
break;
|
||||
case eMetric_DragFullWindow:
|
||||
aMetric = 0;
|
||||
break;
|
||||
case eMetric_DragFullWindow:
|
||||
aMetric = 1;
|
||||
break;
|
||||
default:
|
||||
aMetric = -1;
|
||||
res = NS_ERROR_FAILURE;
|
||||
|
@ -378,6 +378,8 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricFloatID aID, float & aMetri
|
|||
}
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
#include "nsSize.h"
|
||||
|
||||
NS_IMETHODIMP nsLookAndFeel::GetNavSize(const nsMetricNavWidgetID aWidgetID,
|
||||
const nsMetricNavFontID aFontID,
|
||||
const PRInt32 aFontSize,
|
||||
|
|
|
@ -54,12 +54,14 @@
|
|||
#include "nsIRollupListener.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsWindow.h"
|
||||
#include "nsDragService.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
#include "nsIPref.h"
|
||||
#include "nsPhWidgetLog.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <photon/PtServer.h>
|
||||
|
||||
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
|
||||
|
@ -82,6 +84,7 @@ nsIWidget *nsWidget::gRollupWidget = nsnull;
|
|||
/* These are used to keep Popup Menus from drawing twice when they are put away */
|
||||
/* because of extra EXPOSE events from Photon */
|
||||
|
||||
|
||||
//
|
||||
// Keep track of the last widget being "dragged"
|
||||
//
|
||||
|
@ -91,10 +94,10 @@ PtWorkProcId_t *nsWidget::mWorkProcID = nsnull;
|
|||
PRBool nsWidget::mDmgQueueInited = PR_FALSE;
|
||||
#endif
|
||||
nsILookAndFeel *nsWidget::sLookAndFeel = nsnull;
|
||||
nsIDragService *nsWidget::sDragService = nsnull;
|
||||
PRUint32 nsWidget::sWidgetCount = 0;
|
||||
nsWidget *nsWidget::sFocusWidget = nsnull;
|
||||
PRBool nsWidget::sJustGotActivated = PR_FALSE;
|
||||
PRBool nsWidget::sJustGotDeactivated = PR_TRUE;
|
||||
PRBool nsWidget::sJustGotDeactivated = PR_FALSE;
|
||||
|
||||
/* Enable this to queue widget damage, this should be ON by default */
|
||||
#define ENABLE_DAMAGE_QUEUE
|
||||
|
@ -119,6 +122,14 @@ nsWidget::nsWidget()
|
|||
if( sLookAndFeel )
|
||||
sLookAndFeel->GetColor( nsILookAndFeel::eColor_WindowBackground, mBackground );
|
||||
|
||||
if( !sDragService ) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIDragService> s;
|
||||
s = do_GetService( "@mozilla.org/widget/dragservice;1", &rv );
|
||||
sDragService = ( nsIDragService * ) s;
|
||||
if( NS_FAILED( rv ) ) sDragService = 0;
|
||||
}
|
||||
|
||||
mWidget = nsnull;
|
||||
mParent = nsnull;
|
||||
mPreferredWidth = 0;
|
||||
|
@ -130,10 +141,8 @@ nsWidget::nsWidget()
|
|||
mBounds.height = 0;
|
||||
mIsDestroying = PR_FALSE;
|
||||
mOnDestroyCalled = PR_FALSE;
|
||||
mIsDragDest = PR_FALSE;
|
||||
mIsToplevel = PR_FALSE;
|
||||
mListenForResizes = PR_FALSE;
|
||||
mHasFocus = PR_FALSE;
|
||||
#if 0
|
||||
if (NS_OK == nsComponentManager::CreateInstance(kRegionCID,
|
||||
nsnull,
|
||||
|
@ -209,8 +218,6 @@ NS_IMETHODIMP nsWidget::Destroy( void ) {
|
|||
// make sure no callbacks happen
|
||||
mEventCallback = nsnull;
|
||||
|
||||
if( sFocusWidget == this ) sFocusWidget = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -503,38 +510,9 @@ NS_METHOD nsWidget::Enable( PRBool bState ) {
|
|||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsWidget::SetFocus( PRBool aRaise ) {
|
||||
|
||||
if(sFocusWidget == this)
|
||||
return NS_OK;
|
||||
|
||||
// call this so that any cleanup will happen that needs to...
|
||||
if(sFocusWidget && mWidget->parent)
|
||||
sFocusWidget->LoseFocus();
|
||||
|
||||
if(!mWidget->parent)
|
||||
return NS_OK;
|
||||
|
||||
sFocusWidget = this;
|
||||
|
||||
if( mWidget && mWidget->parent) {
|
||||
PtContainerGiveFocus( mWidget, NULL );
|
||||
}
|
||||
|
||||
DispatchStandardEvent(NS_GOTFOCUS);
|
||||
mHasFocus = PR_TRUE;
|
||||
if( mWidget ) PtContainerGiveFocus( mWidget, NULL );
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
void nsWidget::LoseFocus( void )
|
||||
{
|
||||
|
||||
// doesn't do anything. needed for nsWindow housekeeping, really.
|
||||
if( mHasFocus == PR_FALSE ) return;
|
||||
|
||||
mHasFocus = PR_FALSE;
|
||||
sFocusWidget = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -739,7 +717,7 @@ NS_METHOD nsWidget::Invalidate( const nsRect & aRect, PRBool aIsSynchronous ) {
|
|||
|
||||
if( !mWidget ) return NS_OK; // mWidget will be null during printing
|
||||
if( !PtWidgetIsRealized( mWidget ) ) return NS_OK;
|
||||
|
||||
|
||||
PhRect_t prect;
|
||||
prect.ul.x = aRect.x;
|
||||
prect.ul.y = aRect.y;
|
||||
|
@ -942,8 +920,6 @@ nsresult nsWidget::CreateWidget(nsIWidget *aParent,
|
|||
|
||||
PtWidget_t *parentWidget = nsnull;
|
||||
|
||||
sJustGotActivated = PR_TRUE;
|
||||
|
||||
nsIWidget *baseParent = aInitData && (aInitData->mWindowType == eWindowType_dialog ||
|
||||
aInitData->mWindowType == eWindowType_toplevel ) ? nsnull : aParent;
|
||||
|
||||
|
@ -971,6 +947,7 @@ nsresult nsWidget::CreateWidget(nsIWidget *aParent,
|
|||
PtAddCallback( mWidget, Pt_CB_GOT_FOCUS, GotFocusCallback, this );
|
||||
PtAddCallback( mWidget, Pt_CB_LOST_FOCUS, LostFocusCallback, this );
|
||||
PtAddCallback( mWidget, Pt_CB_IS_DESTROYED, DestroyedCallback, this );
|
||||
// PtAddCallback( mWidget, Pt_CB_DND, DndCallback, this );
|
||||
}
|
||||
|
||||
DispatchStandardEvent(NS_CREATE);
|
||||
|
@ -1377,17 +1354,12 @@ void nsWidget::InitKeyEvent(PhKeyEvent_t *aPhKeyEvent,
|
|||
anEvent.point.x = 0;
|
||||
anEvent.point.y = 0;
|
||||
|
||||
|
||||
PRBool IsChar;
|
||||
unsigned long keysym;
|
||||
|
||||
if (Pk_KF_Sym_Valid & aPhKeyEvent->key_flags)
|
||||
keysym = nsConvertKey(aPhKeyEvent->key_sym, &IsChar);
|
||||
else
|
||||
/* Need this to support key release events on numeric key pad */
|
||||
if (Pk_KF_Cap_Valid & aPhKeyEvent->key_flags)
|
||||
keysym = nsConvertKey(aPhKeyEvent->key_cap, &IsChar);
|
||||
|
||||
|
||||
else
|
||||
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;
|
||||
|
@ -1397,7 +1369,6 @@ void nsWidget::InitKeyEvent(PhKeyEvent_t *aPhKeyEvent,
|
|||
if ((aEventType == NS_KEY_PRESS) && (IsChar == PR_TRUE)) {
|
||||
anEvent.charCode = aPhKeyEvent->key_sym;
|
||||
anEvent.keyCode = 0; /* I think the spec says this should be 0 */
|
||||
//printf("nsWidget::InitKeyEvent charCode=<%d>\n", anEvent.charCode);
|
||||
|
||||
if ((anEvent.isControl) || (anEvent.isAlt))
|
||||
anEvent.charCode = aPhKeyEvent->key_cap;
|
||||
|
@ -1409,6 +1380,7 @@ void nsWidget::InitKeyEvent(PhKeyEvent_t *aPhKeyEvent,
|
|||
anEvent.keyCode = (keysym & 0x00FF);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1421,7 +1393,7 @@ PRBool nsWidget::DispatchKeyEvent( PhKeyEvent_t *aPhKeyEvent ) {
|
|||
if ( (aPhKeyEvent->key_flags & Pk_KF_Cap_Valid) == 0) {
|
||||
//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_TRUE;
|
||||
return PR_FALSE; //PR_TRUE;
|
||||
}
|
||||
|
||||
if ( PtIsFocused(mWidget) != 2) {
|
||||
|
@ -1436,12 +1408,12 @@ PRBool nsWidget::DispatchKeyEvent( PhKeyEvent_t *aPhKeyEvent ) {
|
|||
|| ( aPhKeyEvent->key_cap == Pk_Num_Lock )
|
||||
|| ( aPhKeyEvent->key_cap == Pk_Scroll_Lock )
|
||||
)
|
||||
return PR_TRUE;
|
||||
return PR_FALSE; //PR_TRUE;
|
||||
|
||||
nsWindow *w = (nsWindow *) this;
|
||||
|
||||
w->AddRef();
|
||||
|
||||
|
||||
if (aPhKeyEvent->key_flags & Pk_KF_Key_Down) {
|
||||
InitKeyEvent(aPhKeyEvent, this, keyEvent, NS_KEY_DOWN);
|
||||
result = w->OnKey(keyEvent);
|
||||
|
@ -1480,7 +1452,7 @@ int nsWidget::RawEventHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t
|
|||
// kedl, shouldn't handle events if the window is being destroyed
|
||||
if ( (someWidget) &&
|
||||
(someWidget->mIsDestroying == PR_FALSE) &&
|
||||
(someWidget->nsWidget::HandleEvent( cbinfo ))
|
||||
(someWidget->nsWidget::HandleEvent( widget, cbinfo ))
|
||||
/* because nsWindow::HandleEvent() is simply calling nsWidget::HandleEvent(), try to save a call - it was (someWidget->HandleEvent( cbinfo )) */
|
||||
)
|
||||
return( Pt_END ); // Event was consumed
|
||||
|
@ -1488,8 +1460,11 @@ int nsWidget::RawEventHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t
|
|||
return( Pt_CONTINUE );
|
||||
}
|
||||
|
||||
#ifndef Ph_PTR_FLAG_Z_ONLY
|
||||
#define Ph_PTR_FLAG_Z_ONLY 0x08
|
||||
#endif
|
||||
|
||||
PRBool nsWidget::HandleEvent( PtCallbackInfo_t* aCbInfo ) {
|
||||
PRBool nsWidget::HandleEvent( PtWidget_t *widget, PtCallbackInfo_t* aCbInfo ) {
|
||||
PRBool result = PR_TRUE; // call the default nsWindow proc
|
||||
PhEvent_t* event = aCbInfo->event;
|
||||
|
||||
|
@ -1506,6 +1481,8 @@ PRBool nsWidget::HandleEvent( PtCallbackInfo_t* aCbInfo ) {
|
|||
|
||||
if( ptrev ) {
|
||||
|
||||
if( ptrev->flags & Ph_PTR_FLAG_Z_ONLY ) break; // sometimes z presses come out of nowhere */
|
||||
|
||||
///* ATENTIE */ printf( "Ph_EV_PTR_MOTION_NOBUTTON (%d %d)\n", ptrev->pos.x, ptrev->pos.y );
|
||||
|
||||
ScreenToWidget( ptrev->pos );
|
||||
|
@ -1517,21 +1494,37 @@ PRBool nsWidget::HandleEvent( PtCallbackInfo_t* aCbInfo ) {
|
|||
|
||||
case Ph_EV_BUT_PRESS:
|
||||
{
|
||||
|
||||
PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( event );
|
||||
nsMouseEvent theMouseEvent;
|
||||
|
||||
/* 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 */
|
||||
PtWidget_t *disjoint = PtFindDisjoint( widget );
|
||||
if( PtWidgetIsClassMember( disjoint, PtServer ) )
|
||||
PtContainerGiveFocus( widget, aCbInfo->event );
|
||||
else {
|
||||
if( sJustGotActivated ) {
|
||||
sJustGotActivated = PR_FALSE;
|
||||
DispatchStandardEvent(NS_ACTIVATE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* 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();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( ptrev ) {
|
||||
ScreenToWidget( ptrev->pos );
|
||||
|
||||
///* ATENTIE */ printf( "Ph_EV_PTR_PRESS (%d %d)\n", ptrev->pos.x, ptrev->pos.y );
|
||||
|
||||
if( ptrev->buttons & Ph_BUTTON_SELECT ) // Normally the left mouse button
|
||||
InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_LEFT_BUTTON_DOWN );
|
||||
else if( ptrev->buttons & Ph_BUTTON_MENU ) // the right button
|
||||
|
@ -1565,6 +1558,8 @@ PRBool nsWidget::HandleEvent( 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);
|
||||
}
|
||||
}
|
||||
|
@ -1572,6 +1567,7 @@ PRBool nsWidget::HandleEvent( PtCallbackInfo_t* aCbInfo ) {
|
|||
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" );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1581,8 +1577,17 @@ PRBool nsWidget::HandleEvent( PtCallbackInfo_t* aCbInfo ) {
|
|||
PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( event );
|
||||
nsMouseEvent theMouseEvent;
|
||||
|
||||
|
||||
if( ptrev ) {
|
||||
|
||||
if( ptrev->flags & Ph_PTR_FLAG_Z_ONLY ) break; // sometimes z presses come out of nowhere */
|
||||
|
||||
if( sDragService ) {
|
||||
nsDragService *d;
|
||||
nsIDragService *s = sDragService;
|
||||
d = ( nsDragService * )s;
|
||||
d->SetNativeDndData( widget, event );
|
||||
}
|
||||
|
||||
ScreenToWidget( ptrev->pos );
|
||||
InitMouseEvent(ptrev, this, theMouseEvent, NS_MOUSE_MOVE );
|
||||
result = DispatchMouseEvent(theMouseEvent);
|
||||
|
@ -1592,8 +1597,29 @@ PRBool nsWidget::HandleEvent( PtCallbackInfo_t* aCbInfo ) {
|
|||
|
||||
case Ph_EV_KEY:
|
||||
{
|
||||
PhKeyEvent_t* keyev = (PhKeyEvent_t*) PhGetData( event );
|
||||
PhKeyEvent_t* keyev = (PhKeyEvent_t*) PhGetData( event );
|
||||
nsWidget *parent = (nsWidget*)mParent;
|
||||
int old_menu = 0;
|
||||
|
||||
if (!parent || (parent->mWindowType != eWindowType_popup))
|
||||
{
|
||||
if (gRollupWidget && gRollupListener)
|
||||
old_menu = 1;
|
||||
}
|
||||
|
||||
result = DispatchKeyEvent(keyev);
|
||||
#if 1
|
||||
if ((result == PR_TRUE) && (keyev->key_cap != Pk_Up) && (keyev->key_cap != Pk_Down) &&
|
||||
(keyev->key_cap != Pk_Left) && (keyev->key_cap != Pk_Right) && old_menu && (keyev->key_flags & Pk_KF_Key_Down))
|
||||
{
|
||||
/* 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 */
|
||||
if (!parent || (parent->mWindowType != eWindowType_popup))
|
||||
{
|
||||
if (gRollupWidget && gRollupListener)
|
||||
gRollupListener->Rollup();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1615,6 +1641,14 @@ PRBool nsWidget::HandleEvent( PtCallbackInfo_t* aCbInfo ) {
|
|||
case Ph_EV_DRAG_MOTION_EVENT: {
|
||||
PhPointerEvent_t* ptrev2 = (PhPointerEvent_t*) PhGetData( event );
|
||||
ScreenToWidget( ptrev2->pos );
|
||||
|
||||
if( sDragService ) {
|
||||
nsDragService *d;
|
||||
nsIDragService *s = sDragService;
|
||||
d = ( nsDragService * )s;
|
||||
d->SetNativeDndData( widget, event );
|
||||
}
|
||||
|
||||
InitMouseEvent(ptrev2, this, theMouseEvent, NS_MOUSE_MOVE );
|
||||
result = DispatchMouseEvent(theMouseEvent);
|
||||
}
|
||||
|
@ -1884,51 +1918,61 @@ int nsWidget::WorkProc( void *data )
|
|||
return Pt_END;
|
||||
}
|
||||
#endif
|
||||
|
||||
int nsWidget::GotFocusCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo )
|
||||
{
|
||||
nsWidget *pWidget = (nsWidget *) data;
|
||||
|
||||
if(!widget->parent)
|
||||
{
|
||||
pWidget->DispatchStandardEvent(NS_GOTFOCUS);
|
||||
}
|
||||
if( widget->class_rec->description && PtWidgetIsClass( widget, PtWindow ) ) {
|
||||
if( pWidget->mEventCallback ) {
|
||||
|
||||
if( !widget->parent || PtIsFocused(widget) != 2 ) return Pt_CONTINUE;
|
||||
/* the WM_ACTIVATE code */
|
||||
|
||||
pWidget->DispatchStandardEvent(NS_GOTFOCUS);
|
||||
sJustGotActivated = PR_TRUE;
|
||||
|
||||
nsMouseEvent event;
|
||||
event.eventStructType = NS_GUI_EVENT;
|
||||
pWidget->InitEvent(event, NS_MOUSE_ACTIVATE);
|
||||
event.acceptActivation = PR_TRUE;
|
||||
|
||||
if( !sJustGotActivated )
|
||||
{
|
||||
sJustGotActivated = PR_TRUE;
|
||||
sJustGotDeactivated = PR_FALSE;
|
||||
pWidget->DispatchStandardEvent(NS_ACTIVATE);
|
||||
}
|
||||
else sJustGotActivated = PR_FALSE;
|
||||
pWidget->DispatchWindowEvent(&event);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
|
||||
if( sJustGotActivated ) {
|
||||
sJustGotActivated = PR_FALSE;
|
||||
pWidget->DispatchStandardEvent(NS_ACTIVATE);
|
||||
}
|
||||
}
|
||||
|
||||
pWidget->DispatchStandardEvent(NS_GOTFOCUS);
|
||||
|
||||
return Pt_CONTINUE;
|
||||
}
|
||||
|
||||
int nsWidget::LostFocusCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo )
|
||||
{
|
||||
// nsWidget *pWidget = (nsWidget *) data;
|
||||
nsWidget *pWidget = (nsWidget *) data;
|
||||
|
||||
if(!widget->parent)
|
||||
{
|
||||
if(sFocusWidget)
|
||||
{
|
||||
if(!sJustGotDeactivated)
|
||||
{
|
||||
sFocusWidget->DispatchStandardEvent(NS_DEACTIVATE);
|
||||
sJustGotDeactivated = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
if( widget->class_rec->description && PtWidgetIsClass( widget, PtWindow ) ) {
|
||||
if( pWidget->mEventCallback ) {
|
||||
|
||||
if (!widget->parent || PtIsFocused(widget) != 2) return Pt_CONTINUE;
|
||||
|
||||
// pWidget->DispatchStandardEvent(NS_LOSTFOCUS);
|
||||
|
||||
sJustGotActivated = PR_FALSE;
|
||||
/* the WM_ACTIVATE code */
|
||||
sJustGotDeactivated = PR_TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if( sJustGotDeactivated ) {
|
||||
sJustGotDeactivated = PR_FALSE;
|
||||
pWidget->DispatchStandardEvent(NS_DEACTIVATE);
|
||||
}
|
||||
pWidget->DispatchStandardEvent(NS_LOSTFOCUS);
|
||||
}
|
||||
|
||||
return Pt_CONTINUE;
|
||||
}
|
||||
|
@ -1957,6 +2001,104 @@ void nsWidget::EnableDamage( PtWidget_t *widget, PRBool enable ) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void nsWidget::ProcessDrag( PhEvent_t *event, PRUint32 aEventType, PhPoint_t *pos ) {
|
||||
nsCOMPtr<nsIDragSession> currSession;
|
||||
sDragService->GetCurrentSession ( getter_AddRefs(currSession) );
|
||||
if( !currSession ) return;
|
||||
|
||||
currSession->SetDragAction( 2 );
|
||||
|
||||
DispatchDragDropEvent( aEventType, pos );
|
||||
|
||||
event->subtype = Ph_EV_DND_ENTER;
|
||||
|
||||
PRBool canDrop;
|
||||
currSession->GetCanDrop(&canDrop);
|
||||
if(!canDrop) {
|
||||
static PhCharacterCursorDescription_t nodrop_cursor = { { Ph_CURSOR_NOINPUT, sizeof(PhCharacterCursorDescription_t) }, PgRGB( 255, 255, 224 ) };
|
||||
PhAckDnd( event, Ph_EV_DND_MOTION, ( PhCursorDescription_t * ) &nodrop_cursor );
|
||||
}
|
||||
else {
|
||||
static PhCharacterCursorDescription_t drop_cursor = { { Ph_CURSOR_PASTE, sizeof(PhCharacterCursorDescription_t) }, PgRGB( 255, 255, 224 ) };
|
||||
PhAckDnd( event, Ph_EV_DND_MOTION, ( PhCursorDescription_t * ) &drop_cursor );
|
||||
}
|
||||
|
||||
// Clear the cached value
|
||||
currSession->SetCanDrop(PR_FALSE);
|
||||
}
|
||||
|
||||
void nsWidget::DispatchDragDropEvent( PRUint32 aEventType, PhPoint_t *pos ) {
|
||||
nsEventStatus status;
|
||||
nsMouseEvent event;
|
||||
|
||||
InitEvent( event, aEventType );
|
||||
|
||||
event.point.x = pos->x;
|
||||
event.point.y = pos->y;
|
||||
|
||||
event.isShift = 0;
|
||||
event.isControl = 0;
|
||||
event.isMeta = PR_FALSE;
|
||||
event.isAlt = 0;
|
||||
|
||||
event.widget = this;
|
||||
|
||||
///* ATENTIE */ printf("DispatchDragDropEvent pos=%d %d widget=%p\n", event.point.x, event.point.y, this );
|
||||
|
||||
DispatchEvent( &event, status );
|
||||
}
|
||||
|
||||
|
||||
int nsWidget::DndCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) {
|
||||
nsWidget *pWidget = (nsWidget *) data;
|
||||
PtDndCallbackInfo_t *cbdnd = ( PtDndCallbackInfo_t * ) cbinfo->cbdata;
|
||||
|
||||
static PtDndFetch_t dnd_data_template = { "Mozilla", "dnddata", Ph_TRANSPORT_INLINE, Pt_DND_SELECT_MOTION,
|
||||
NULL, NULL, NULL, NULL, NULL };
|
||||
|
||||
///* ATENTIE */ printf( "In nsWidget::DndCallback subtype=%d\n", cbinfo->reason_subtype );
|
||||
|
||||
PhPointerEvent_t* ptrev = (PhPointerEvent_t*) PhGetData( cbinfo->event );
|
||||
//printf("Enter pos=%d %d\n", ptrev->pos.x, ptrev->pos.y );
|
||||
pWidget->ScreenToWidget( ptrev->pos );
|
||||
//printf("After trans pos=%d %d pWidget=%p\n", ptrev->pos.x, ptrev->pos.y, pWidget );
|
||||
|
||||
|
||||
switch( cbinfo->reason_subtype ) {
|
||||
case Ph_EV_DND_ENTER: {
|
||||
sDragService->StartDragSession();
|
||||
pWidget->ProcessDrag( cbinfo->event, NS_DRAGDROP_ENTER, &ptrev->pos );
|
||||
|
||||
PtDndSelect( widget, &dnd_data_template, 1, NULL, NULL, cbinfo );
|
||||
}
|
||||
break;
|
||||
|
||||
case Ph_EV_DND_MOTION: {
|
||||
pWidget->ProcessDrag( cbinfo->event, NS_DRAGDROP_OVER, &ptrev->pos );
|
||||
}
|
||||
break;
|
||||
case Ph_EV_DND_DROP:
|
||||
nsDragService *d;
|
||||
d = ( nsDragService * )sDragService;
|
||||
d->SetDropData( (char*)cbdnd->data+4+100, (PRUint32) *(int*)cbdnd->data, (char*) cbdnd->data + 4 );
|
||||
/* ATENTIE */ printf("SetDropData with data=%s\n", (char*) cbdnd->data );
|
||||
|
||||
pWidget->ProcessDrag( cbinfo->event, NS_DRAGDROP_DROP, &ptrev->pos );
|
||||
sDragService->EndDragSession();
|
||||
break;
|
||||
case Ph_EV_DND_LEAVE:
|
||||
case Ph_EV_DND_CANCEL:
|
||||
pWidget->ProcessDrag( cbinfo->event, NS_DRAGDROP_EXIT, &ptrev->pos );
|
||||
sDragService->EndDragSession();
|
||||
break;
|
||||
}
|
||||
|
||||
return Pt_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//#if defined(DEBUG)
|
||||
/**************************************************************/
|
||||
/* This was stolen from widget/src/xpwidgets/nsBaseWidget.cpp */
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "nsBaseWidget.h"
|
||||
#include "nsIKBStateControl.h"
|
||||
#include "nsIRegion.h"
|
||||
#include "nsIDragService.h"
|
||||
|
||||
class nsILookAndFeel;
|
||||
class nsIAppShell;
|
||||
|
@ -107,8 +108,6 @@ public:
|
|||
NS_IMETHOD Enable(PRBool aState);
|
||||
NS_IMETHOD SetFocus(PRBool aRaise);
|
||||
|
||||
virtual void LoseFocus(void);
|
||||
|
||||
PRBool OnResize(nsSizeEvent event);
|
||||
virtual PRBool OnResize(nsRect &aRect);
|
||||
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
|
||||
|
@ -197,6 +196,8 @@ protected:
|
|||
//#endif
|
||||
|
||||
PRBool DispatchWindowEvent(nsGUIEvent* event);
|
||||
void DispatchDragDropEvent( PRUint32 aEventType, PhPoint_t *pos );
|
||||
void ProcessDrag( PhEvent_t *event, PRUint32 aEventType, PhPoint_t *pos );
|
||||
|
||||
// this is the "native" destroy code that will destroy any
|
||||
// native windows / widgets for this logical widget
|
||||
|
@ -213,7 +214,7 @@ protected:
|
|||
//
|
||||
//////////////////////////////////////////////////////////////////
|
||||
static int RawEventHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo );
|
||||
virtual PRBool HandleEvent( PtCallbackInfo_t* aCbInfo );
|
||||
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 );
|
||||
|
@ -260,6 +261,7 @@ protected:
|
|||
static int GotFocusCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo );
|
||||
static int LostFocusCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo );
|
||||
static int DestroyedCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo );
|
||||
static int DndCallback( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo );
|
||||
|
||||
PtWidget_t *mWidget;
|
||||
nsIWidget *mParent;
|
||||
|
@ -283,6 +285,8 @@ protected:
|
|||
static nsIWidget *gRollupWidget;
|
||||
|
||||
static nsILookAndFeel *sLookAndFeel;
|
||||
// static nsCOMPtr<nsIDragService> sDragService;
|
||||
static nsIDragService *sDragService;
|
||||
static PRUint32 sWidgetCount;
|
||||
};
|
||||
|
||||
|
|
|
@ -184,12 +184,12 @@ static nsModuleComponentInfo components[] =
|
|||
{ "Ph Sound",
|
||||
NS_SOUND_CID,
|
||||
"@mozilla.org/sound;1",
|
||||
nsSoundConstructor }
|
||||
nsSoundConstructor },
|
||||
#ifdef IBMBIDI
|
||||
, { "Gtk Bidi Keyboard",
|
||||
{ "Gtk Bidi Keyboard",
|
||||
NS_BIDIKEYBOARD_CID,
|
||||
"@mozilla.org/widget/bidikeyboard;1",
|
||||
nsBidiKeyboardConstructor }
|
||||
nsBidiKeyboardConstructor },
|
||||
#endif // IBMBIDI
|
||||
};
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
#include "nsGfxCIID.h"
|
||||
#include "nsIMenuBar.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
#include "nsClipboard.h"
|
||||
#include "nsIRollupListener.h"
|
||||
|
@ -70,7 +71,6 @@
|
|||
#include "nsIPresShell.h"
|
||||
#include "nsReadableUtils.h"
|
||||
|
||||
|
||||
PRBool nsWindow::mResizeQueueInited = PR_FALSE;
|
||||
DamageQueueEntry *nsWindow::mResizeQueue = nsnull;
|
||||
PtWorkProcId_t *nsWindow::mResizeProcID = nsnull;
|
||||
|
@ -117,9 +117,6 @@ nsWindow::~nsWindow()
|
|||
Destroy();
|
||||
|
||||
RemoveResizeWidget();
|
||||
#if 0
|
||||
RemoveDamagedWidget( mWidget );
|
||||
#endif
|
||||
}
|
||||
|
||||
PRBool nsWindow::IsChild() const
|
||||
|
@ -146,15 +143,11 @@ NS_IMETHODIMP nsWindow::WidgetToScreen( const nsRect& aOldRect, nsRect& aNewRect
|
|||
void nsWindow::DestroyNative(void)
|
||||
{
|
||||
RemoveResizeWidget();
|
||||
#if 0
|
||||
RemoveDamagedWidget( mWidget );
|
||||
#endif
|
||||
if ( mClientWidget )
|
||||
{
|
||||
PtDestroyWidget(mClientWidget );
|
||||
mClientWidget = nsnull;
|
||||
}
|
||||
|
||||
// destroy all of the children that are nsWindow() classes
|
||||
// preempting the gdk destroy system.
|
||||
DestroyNativeChildren();
|
||||
|
@ -208,71 +201,32 @@ NS_IMETHODIMP nsWindow::CaptureRollupEvents( nsIRollupListener * aListener, PRBo
|
|||
|
||||
NS_IMETHODIMP nsWindow::Invalidate(PRBool aIsSynchronous)
|
||||
{
|
||||
if (!mWidget) return NS_OK; // mWidget will be null during printing.
|
||||
if (!PtWidgetIsRealized(mWidget)) return NS_OK;
|
||||
#if 0
|
||||
/* Damage has to be relative Widget coords */
|
||||
mUpdateArea->SetTo( 0,0, mBounds.width, mBounds.height );
|
||||
|
||||
if (aIsSynchronous) UpdateWidgetDamage();
|
||||
else QueueWidgetDamage();
|
||||
#else
|
||||
if (!mWidget) return NS_OK; // mWidget will be null during printing.
|
||||
if (!PtWidgetIsRealized(mWidget)) return NS_OK;
|
||||
nsWidget::Invalidate(aIsSynchronous);
|
||||
#endif
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindow::Invalidate(const nsRect &aRect, PRBool aIsSynchronous)
|
||||
{
|
||||
if (!mWidget) return NS_OK; // mWidget will be null during printing.
|
||||
if (!PtWidgetIsRealized(mWidget)) return NS_OK;
|
||||
#if 0
|
||||
/* Offset the rect by the mBounds X,Y to fix damaging inside widget in test14 */
|
||||
if (mWindowType == eWindowType_popup) mUpdateArea->Union(aRect.x, aRect.y, aRect.width, aRect.height);
|
||||
else mUpdateArea->Union((aRect.x+mBounds.x), (aRect.y+mBounds.y), aRect.width, aRect.height);
|
||||
|
||||
if (aIsSynchronous)
|
||||
{
|
||||
UpdateWidgetDamage();
|
||||
}
|
||||
else
|
||||
{
|
||||
QueueWidgetDamage();
|
||||
}
|
||||
#else
|
||||
if (!mWidget) return NS_OK; // mWidget will be null during printing.
|
||||
if (!PtWidgetIsRealized(mWidget)) return NS_OK;
|
||||
nsWidget::Invalidate(aRect, aIsSynchronous);
|
||||
#endif
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindow::InvalidateRegion(const nsIRegion* aRegion, PRBool aIsSynchronous)
|
||||
{
|
||||
|
||||
if (!mWidget) return NS_OK; // mWidget will be null during printing.
|
||||
if (!PtWidgetIsRealized(mWidget)) return NS_OK;
|
||||
#if 0
|
||||
nsIRegion *newRegion;
|
||||
|
||||
newRegion = GetRegion( );
|
||||
newRegion->SetTo( *aRegion );
|
||||
|
||||
if (mWindowType != eWindowType_popup)
|
||||
newRegion->Offset(mBounds.x, mBounds.y);
|
||||
mUpdateArea->Union(*newRegion);
|
||||
|
||||
NS_RELEASE( newRegion );
|
||||
|
||||
if (aIsSynchronous) UpdateWidgetDamage();
|
||||
else QueueWidgetDamage();
|
||||
#else
|
||||
if (!mWidget) return NS_OK; // mWidget will be null during printing.
|
||||
if (!PtWidgetIsRealized(mWidget)) return NS_OK;
|
||||
nsWidget::InvalidateRegion(aRegion,aIsSynchronous);
|
||||
#endif
|
||||
return NS_OK;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWindow::SetBackgroundColor( const nscolor &aColor ) {
|
||||
return nsWidget::SetBackgroundColor(aColor);
|
||||
}
|
||||
NS_IMETHODIMP nsWindow::SetBackgroundColor( const nscolor &aColor )
|
||||
{
|
||||
return nsWidget::SetBackgroundColor(aColor);
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsWindow::SetFocus( PRBool aRaise ) {
|
||||
|
@ -398,7 +352,6 @@ NS_METHOD nsWindow::CreateNative( PtWidget_t *parentWidget ) {
|
|||
|
||||
PtSetArg( &arg[arg_count++], Pt_ARG_REGION_FIELDS, fields, fields );
|
||||
PtSetArg( &arg[arg_count++], Pt_ARG_REGION_PARENT, Ph_ROOT_RID, 0 );
|
||||
PtSetArg( &arg[arg_count++], Pt_ARG_REGION_FLAGS, Ph_FORCE_FRONT, Ph_FORCE_FRONT );
|
||||
PtSetArg( &arg[arg_count++], Pt_ARG_REGION_SENSE, sense | Ph_EV_DRAG|Ph_EV_EXPOSE, sense | Ph_EV_DRAG|Ph_EV_EXPOSE);
|
||||
PtSetArg( &arg[arg_count++], Pt_ARG_REGION_OPAQUE, sense | Ph_EV_DRAG|Ph_EV_EXPOSE|Ph_EV_DRAW, sense |Ph_EV_DRAG|Ph_EV_EXPOSE|Ph_EV_DRAW);
|
||||
PtSetArg( &arg[arg_count++], Pt_ARG_FLAGS, Pt_DELAY_REALIZE, Pt_GETS_FOCUS | Pt_DELAY_REALIZE);
|
||||
|
@ -419,7 +372,7 @@ NS_METHOD nsWindow::CreateNative( PtWidget_t *parentWidget ) {
|
|||
mClientWidget = PtCreateWidget( PtRawDrawContainer, mWidget, arg_count, arg );
|
||||
}
|
||||
else {
|
||||
PtSetParentWidget( nsnull );
|
||||
PtSetParentWidget( NULL );
|
||||
|
||||
/* Dialog and TopLevel Windows */
|
||||
PtSetArg( &arg[arg_count++], Pt_ARG_FLAGS, Pt_DELAY_REALIZE, Pt_DELAY_REALIZE);
|
||||
|
@ -430,16 +383,25 @@ NS_METHOD nsWindow::CreateNative( PtWidget_t *parentWidget ) {
|
|||
PtCallback_t cb_resize = { ResizeHandler, NULL };
|
||||
PtSetArg( &arg[arg_count++], Pt_CB_RESIZE, &cb_resize, NULL );
|
||||
PtSetArg( &arg[arg_count++], Pt_CB_RAW, &cb_raw, NULL );
|
||||
|
||||
mWidget = PtCreateWidget( PtWindow, NULL, arg_count, arg );
|
||||
}
|
||||
#if 0
|
||||
PhRect_t rect;
|
||||
memset(&rect, 0, sizeof(rect));
|
||||
PtSetArg( &arg[0], Pt_ARG_ANCHOR_OFFSETS, &rect, 0 );
|
||||
PtSetArg( &arg[1], Pt_ARG_ANCHOR_FLAGS, -1,
|
||||
Pt_LEFT_ANCHORED_LEFT |
|
||||
Pt_RIGHT_ANCHORED_RIGHT |
|
||||
Pt_TOP_ANCHORED_TOP |
|
||||
Pt_BOTTOM_ANCHORED_BOTTOM );
|
||||
mClientWidget = PtCreateWidget( PtOSContainer, mWidget, 2, arg );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if( mWidget ) {
|
||||
SetInstance( mWidget, this );
|
||||
if( mClientWidget ) SetInstance( mClientWidget, this );
|
||||
|
||||
if( mWindowType == eWindowType_child ) {
|
||||
SetInstance( mWidget, this );
|
||||
if( mClientWidget ) SetInstance( mClientWidget, this );
|
||||
if( mWindowType == eWindowType_child ) {
|
||||
PtAddCallback(mWidget, Pt_CB_RESIZE, ResizeHandler, nsnull );
|
||||
PtAddEventHandler( mWidget,
|
||||
Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON |
|
||||
|
@ -570,9 +532,26 @@ NS_METHOD nsWindow::Scroll( PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect ) {
|
|||
|
||||
PtEndFlux( widget);
|
||||
|
||||
PhRect_t source = {{widget->area.pos.x, widget->area.pos.y},{widget->area.pos.x+ widget->area.size.w, widget->area.pos.y + widget->area.size.h}};
|
||||
PhRect_t source = {{widget->area.pos.x, widget->area.pos.y},{widget->area.pos.x+ widget->area.size.w-1, widget->area.pos.y + widget->area.size.h-1}};
|
||||
PhPoint_t point = { aDx, aDy };
|
||||
PtBlit( widget, &source, &point );
|
||||
|
||||
if( !widget->damage_list )
|
||||
PtBlit( widget, &source, &point );
|
||||
else {
|
||||
/* first noticed as a scrolling problem in netscape email */
|
||||
/* the scrolling should be clipped out by the rectangles given by Invalidate(). These are accumulated in widget->damage_list */
|
||||
PhTile_t original = { source, NULL }, *clip;
|
||||
|
||||
clip = PhGetTile();
|
||||
clip->rect = source;
|
||||
clip->next = NULL;
|
||||
clip = PhClipTilings( clip, widget->damage_list, NULL );
|
||||
|
||||
if( clip ) {
|
||||
PtClippedBlit( widget, &original, &point, clip );
|
||||
PhFreeTiles( clip );
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -706,12 +685,12 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
|
|||
}
|
||||
}
|
||||
|
||||
PtArg_t arg;
|
||||
PhDim_t dim = { aWidth, aHeight };
|
||||
|
||||
PtArg_t arg;
|
||||
PhDim_t dim = { aWidth, aHeight };
|
||||
|
||||
if( mWidget ) {
|
||||
// EnableDamage( mWidget, PR_FALSE );
|
||||
|
||||
// EnableDamage( mWidget, PR_FALSE );
|
||||
|
||||
// center the dialog
|
||||
if( mWindowType == eWindowType_dialog ) {
|
||||
PhPoint_t p, pos = nsToolkit::GetConsoleOffset( );
|
||||
|
@ -719,10 +698,11 @@ NS_IMETHODIMP nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
|
|||
p.x -= pos.x;
|
||||
p.y -= pos.y;
|
||||
Move(p.x, p.y); // the move should be in coordinates assuming the console is 0, 0
|
||||
}
|
||||
|
||||
PtSetArg( &arg, Pt_ARG_DIM, &dim, 0 );
|
||||
PtSetResources( mWidget, 1, &arg );
|
||||
}
|
||||
|
||||
PtSetArg( &arg, Pt_ARG_DIM, &dim, 0 );
|
||||
PtSetResources( mWidget, 1, &arg );
|
||||
|
||||
/* This fixes XUL dialogs */
|
||||
if (mClientWidget) {
|
||||
PtWidget_t *theClientChild = PtWidgetChildBack(mClientWidget);
|
||||
|
@ -798,42 +778,24 @@ int nsWindow::WindowWMHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t
|
|||
break;
|
||||
|
||||
default:
|
||||
/* destroy any pop up widgets ( menus ) */
|
||||
if (we->event_f == Ph_WM_FOCUS && we->state_f == Ph_WM_EVSTATE_FOCUS)
|
||||
if( we->event_f == Ph_WM_TOFRONT || ( we->event_f == Ph_WM_FOCUS && we->state_f == Ph_WM_EVSTATE_FOCUS ) )
|
||||
return Pt_CONTINUE;
|
||||
|
||||
/* destroy any pop up widgets ( menus ) */
|
||||
if( gRollupWidget && gRollupListener ) gRollupListener->Rollup();
|
||||
}
|
||||
|
||||
return Pt_CONTINUE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
NS_METHOD nsWindow::Show( PRBool bState ) {
|
||||
|
||||
if( !mWidget ) return NS_OK; // Will be null durring printing
|
||||
if( ( mShown && bState ) || ( !mShown && !bState ) ) return NS_OK;
|
||||
|
||||
if( mWindowType == eWindowType_popup ) {
|
||||
|
||||
//EnableDamage( mWidget, PR_FALSE );
|
||||
|
||||
if( bState ) PtRealizeWidget( mWidget );
|
||||
else PtUnrealizeWidget( mWidget );
|
||||
|
||||
// EnableDamage( mWidget, PR_TRUE );
|
||||
}
|
||||
|
||||
return nsWidget::Show(bState);
|
||||
}
|
||||
#endif
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Process all nsWindows messages
|
||||
//
|
||||
//-------------------------------------------------------------------------
|
||||
PRBool nsWindow::HandleEvent( PtCallbackInfo_t* aCbInfo ) {
|
||||
PRBool nsWindow::HandleEvent( PtWidget_t *widget, PtCallbackInfo_t* aCbInfo ) {
|
||||
/* if in the future you add code here, modify nsWidget::HandleEvent() to allow you this call */
|
||||
return nsWidget::HandleEvent(aCbInfo);
|
||||
return nsWidget::HandleEvent( widget, aCbInfo);
|
||||
}
|
||||
|
||||
void nsWindow::RawDrawFunc( PtWidget_t * pWidget, PhTile_t * damage )
|
||||
|
@ -873,8 +835,8 @@ void nsWindow::RawDrawFunc( PtWidget_t * pWidget, PhTile_t * damage )
|
|||
// new_damage = PhRectsToTiles( &pWidget->extent, 1 );
|
||||
// }
|
||||
// else {
|
||||
// new_damage = PhRectsToTiles(&damage->rect, 1);
|
||||
new_damage = PhCopyTiles(damage->next);
|
||||
new_damage = PhRectsToTiles(&damage->rect, 1);
|
||||
// new_damage = PhCopyTiles(damage->next);
|
||||
/* new_damage is the same as tiles... I need to release it later */
|
||||
new_damage = PhClipTilings( new_damage, clip_tiles, NULL);
|
||||
// }
|
||||
|
@ -984,7 +946,7 @@ int nsWindow::ResizeHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t *c
|
|||
|
||||
/* This enables the resize holdoff */
|
||||
if (PtWidgetIsRealized(widget)) {
|
||||
someWindow->ResizeHoldOff();
|
||||
// someWindow->ResizeHoldOff();
|
||||
someWindow->OnResize( rect );
|
||||
}
|
||||
}
|
||||
|
@ -998,7 +960,14 @@ static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
|
|||
int nsWindow::EvInfo( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo ) {
|
||||
|
||||
if( cbinfo->event && cbinfo->event->type == Ph_EV_INFO && cbinfo->event->subtype == Ph_OFFSCREEN_INVALID ) {
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIPref> pPrefs = do_GetService(NS_PREF_CONTRACTID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PRBool displayInternalChange = PR_FALSE;
|
||||
pPrefs->GetBoolPref("browser.display.internaluse.graphics_changed", &displayInternalChange);
|
||||
pPrefs->SetBoolPref("browser.display.internaluse.graphics_changed", !displayInternalChange);
|
||||
}
|
||||
nsCOMPtr<nsIWindowMediator> windowMediator(do_GetService(kWindowMediatorCID));
|
||||
NS_ENSURE_TRUE(windowMediator, NS_ERROR_FAILURE);
|
||||
|
||||
|
|
|
@ -131,9 +131,10 @@ protected:
|
|||
NS_IMETHOD CreateNative(PtWidget_t *parentWidget);
|
||||
|
||||
static int ResizeHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo );
|
||||
static int OpeningHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo );
|
||||
static int EvInfo( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo );
|
||||
static int WindowWMHandler( PtWidget_t *widget, void *data, PtCallbackInfo_t *cbinfo );
|
||||
PRBool HandleEvent( PtCallbackInfo_t* aCbInfo );
|
||||
PRBool HandleEvent( PtWidget_t *widget, PtCallbackInfo_t* aCbInfo );
|
||||
PhTile_t *GetWindowClipping( );
|
||||
|
||||
void ResizeHoldOff();
|
||||
|
|
|
@ -44,107 +44,121 @@
|
|||
#include <errno.h>
|
||||
struct PRLogModuleInfo *PhTimLog = nsnull;
|
||||
|
||||
|
||||
PRBool nsTimerPh::FireTimeout()
|
||||
{
|
||||
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::FireTimeout this=<%p>\n", this));
|
||||
struct itimerspec tv;
|
||||
int err;
|
||||
|
||||
if (mFunc != NULL) {
|
||||
(*mFunc)(this, mClosure);
|
||||
}
|
||||
else if (mCallback != NULL) {
|
||||
mCallback->Notify(this); // Fire the timer
|
||||
}
|
||||
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::FireTimeout this=<%p>\n", this));
|
||||
|
||||
/* FIXME: the use of REPEATING_SLACK is not know, more testing should be done. */
|
||||
return (mType == NS_TYPE_REPEATING_SLACK || (mType == NS_TYPE_REPEATING_PRECISE));
|
||||
nsCOMPtr<nsITimer> kungFuDeathGrip = this;
|
||||
|
||||
if (mFunc != NULL)
|
||||
{
|
||||
(*mFunc)(this, mClosure);
|
||||
}
|
||||
else if (mCallback != NULL)
|
||||
{
|
||||
mCallback->Notify(this); // Fire the timer
|
||||
}
|
||||
if ( mType == NS_TYPE_REPEATING_SLACK) {
|
||||
tv.it_value.tv_sec = ( mDelay / 1000 );
|
||||
tv.it_value.tv_nsec = ( mDelay % 1000 ) * 1000000L;
|
||||
|
||||
/* If delay is set to 0 seconds then change it to 1 nsec. */
|
||||
if ( (tv.it_value.tv_sec == 0) && (tv.it_value.tv_nsec == 0))
|
||||
tv.it_value.tv_nsec = 1;
|
||||
|
||||
err = timer_settime( mTimerId, 0, &tv, NULL );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void nsTimerPh::SetDelay(PRUint32 aDelay)
|
||||
{
|
||||
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::SetDelay this=<%p> aDelay=<%d>\n", this, aDelay));
|
||||
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::SetDelay this=<%p> aDelay=<%d>\n", this, aDelay));
|
||||
|
||||
if (aDelay!=mDelay)
|
||||
{
|
||||
int err;
|
||||
Cancel();
|
||||
mDelay=aDelay;
|
||||
err=SetupTimer();
|
||||
}
|
||||
if (aDelay!=mDelay)
|
||||
{
|
||||
int err;
|
||||
Cancel();
|
||||
mDelay=aDelay;
|
||||
err=SetupTimer();
|
||||
}
|
||||
};
|
||||
|
||||
void nsTimerPh::SetPriority(PRUint32 aPriority)
|
||||
{
|
||||
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::SetPriority this=<%p> aPriority=<%d>\n", this, aPriority));
|
||||
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::SetPriority this=<%p> aPriority=<%d>\n", this, aPriority));
|
||||
|
||||
if (aPriority!=mPriority)
|
||||
{
|
||||
int err;
|
||||
Cancel();
|
||||
mPriority = aPriority;
|
||||
err=SetupTimer();
|
||||
}
|
||||
if (aPriority!=mPriority)
|
||||
{
|
||||
int err;
|
||||
Cancel();
|
||||
mPriority = aPriority;
|
||||
err=SetupTimer();
|
||||
}
|
||||
}
|
||||
|
||||
void nsTimerPh::SetType(PRUint32 aType)
|
||||
{
|
||||
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::SetType this=<%p> aType=<%d>\n", this, aType));
|
||||
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::SetType this=<%p> aType=<%d>\n", this, aType));
|
||||
|
||||
if (aType!=mType)
|
||||
{
|
||||
int err;
|
||||
Cancel();
|
||||
mType = aType;
|
||||
err=SetupTimer();
|
||||
}
|
||||
if (aType!=mType)
|
||||
{
|
||||
int err;
|
||||
Cancel();
|
||||
mType = aType;
|
||||
err=SetupTimer();
|
||||
}
|
||||
}
|
||||
|
||||
nsTimerPh::nsTimerPh()
|
||||
{
|
||||
|
||||
#ifdef DEBUG
|
||||
if (!PhTimLog)
|
||||
{
|
||||
PhTimLog = PR_NewLogModule("PhTimLog");
|
||||
}
|
||||
if (!PhTimLog)
|
||||
{
|
||||
PhTimLog = PR_NewLogModule("PhTimLog");
|
||||
}
|
||||
#endif
|
||||
|
||||
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::nsTimerPh this=<%p>\n", this));
|
||||
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::nsTimerPh this=<%p>\n", this));
|
||||
|
||||
NS_INIT_REFCNT();
|
||||
mFunc = NULL;
|
||||
mCallback = NULL;
|
||||
mNext = NULL;
|
||||
mTimerId = -1;
|
||||
mDelay = 0;
|
||||
mClosure = NULL;
|
||||
mPriority = 0;
|
||||
mType = NS_TYPE_ONE_SHOT;
|
||||
mPulsePid = 0;
|
||||
mPulseMsgId = NULL;
|
||||
mInputId = NULL;
|
||||
NS_INIT_REFCNT();
|
||||
mFunc = NULL;
|
||||
mCallback = NULL;
|
||||
mNext = NULL;
|
||||
mTimerId = -1;
|
||||
mDelay = 0;
|
||||
mClosure = NULL;
|
||||
mPriority = 0;
|
||||
mType = NS_TYPE_ONE_SHOT;
|
||||
mPulsePid = 0;
|
||||
mPulseMsgId = NULL;
|
||||
mInputId = NULL;
|
||||
}
|
||||
|
||||
nsTimerPh::~nsTimerPh()
|
||||
{
|
||||
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::~nsTimerPh this=<%p>\n", this));
|
||||
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::~nsTimerPh this=<%p>\n", this));
|
||||
|
||||
Cancel();
|
||||
NS_IF_RELEASE(mCallback);
|
||||
Cancel();
|
||||
NS_IF_RELEASE(mCallback);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTimerPh::Init(nsTimerCallbackFunc aFunc,
|
||||
void *aClosure,
|
||||
PRUint32 aDelay,
|
||||
PRUint32 aPriority,
|
||||
PRUint32 aType
|
||||
)
|
||||
nsresult
|
||||
nsTimerPh::Init(nsTimerCallbackFunc aFunc,
|
||||
void *aClosure,
|
||||
PRUint32 aDelay,
|
||||
PRUint32 aPriority,
|
||||
PRUint32 aType
|
||||
)
|
||||
{
|
||||
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::Init this=<%p> aClosure=<%p> aDelay=<%d> aPriority=<%d> aType=<%d>\n", this, aClosure,
|
||||
aDelay, aPriority, aType));
|
||||
int err;
|
||||
|
||||
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::Init this=<%p> aClosure=<%p> aDelay=<%d> aPriority=<%d> aType=<%d>\n", this, aClosure,
|
||||
aDelay, aPriority, aType));
|
||||
int err;
|
||||
|
||||
mFunc = aFunc;
|
||||
mClosure = aClosure;
|
||||
mPriority = aPriority;
|
||||
|
@ -152,22 +166,20 @@ nsTimerPh::Init(nsTimerCallbackFunc aFunc,
|
|||
mDelay = aDelay;
|
||||
|
||||
err = SetupTimer();
|
||||
//mTimerId = g_timeout_add_full(calc_priority(mPriority),mDelay, nsTimerExpired, this, NULL);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsTimerPh::Init(nsITimerCallback *aCallback,
|
||||
PRUint32 aDelay,
|
||||
PRUint32 aPriority,
|
||||
PRUint32 aType
|
||||
)
|
||||
nsresult
|
||||
nsTimerPh::Init(nsITimerCallback *aCallback,
|
||||
PRUint32 aDelay,
|
||||
PRUint32 aPriority,
|
||||
PRUint32 aType
|
||||
)
|
||||
{
|
||||
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::Init this=<%p> aDelay=<%d> aPriority=<%d> aType=<%d>\n", this,
|
||||
aDelay, aPriority, aType));
|
||||
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::Init this=<%p> aDelay=<%d> aPriority=<%d> aType=<%d>\n", this,
|
||||
aDelay, aPriority, aType));
|
||||
|
||||
int err;
|
||||
int err;
|
||||
mCallback = aCallback;
|
||||
NS_ADDREF(mCallback);
|
||||
mPriority = aPriority;
|
||||
|
@ -175,83 +187,66 @@ nsTimerPh::Init(nsITimerCallback *aCallback,
|
|||
mDelay = aDelay;
|
||||
|
||||
err = SetupTimer();
|
||||
//mTimerId = g_timeout_add_full(calc_priority(mPriority), mDelay, nsTimerExpired, this, NULL);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsTimerPh, nsITimer)
|
||||
|
||||
void
|
||||
nsTimerPh::Cancel()
|
||||
void
|
||||
nsTimerPh::Cancel()
|
||||
{
|
||||
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::Cancel this=<%p>\n", this));
|
||||
int err;
|
||||
|
||||
if( mTimerId >= 0)
|
||||
{
|
||||
err = timer_delete( mTimerId );
|
||||
if (err < 0)
|
||||
{
|
||||
char buf[256];
|
||||
sprintf(buf, "TimerImpl::Cancel Failed in timer_delete mTimerId=<%d> err=<%d> errno=<%d>", mTimerId, err, errno);
|
||||
//NS_ASSERTION(0,"TimerImpl::Cancel Failed in timer_delete");
|
||||
NS_ASSERTION(0,buf);
|
||||
return;
|
||||
}
|
||||
|
||||
mTimerId = -1;
|
||||
}
|
||||
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::Cancel this=<%p>\n", this));
|
||||
int err;
|
||||
|
||||
if( mInputId )
|
||||
{
|
||||
PtAppRemoveInput( NULL, mInputId );
|
||||
mInputId = NULL;
|
||||
}
|
||||
if( mTimerId >= 0)
|
||||
{
|
||||
err = timer_delete( mTimerId );
|
||||
if (err < 0)
|
||||
{
|
||||
char buf[256];
|
||||
sprintf(buf, "TimerImpl::Cancel Failed in timer_delete mTimerId=<%d> err=<%d> errno=<%d>", mTimerId, err, errno);
|
||||
//NS_ASSERTION(0,"TimerImpl::Cancel Failed in timer_delete");
|
||||
NS_ASSERTION(0,buf);
|
||||
return;
|
||||
}
|
||||
|
||||
if( mPulseMsgId )
|
||||
{
|
||||
PtPulseDisarm( mPulseMsgId );
|
||||
mPulseMsgId = NULL;
|
||||
}
|
||||
mTimerId = -1;
|
||||
}
|
||||
|
||||
if( mPulsePid )
|
||||
{
|
||||
PtAppDeletePulse( NULL, mPulsePid );
|
||||
mPulsePid = 0;
|
||||
}
|
||||
if( mInputId )
|
||||
{
|
||||
PtAppRemoveInput( NULL, mInputId );
|
||||
mInputId = NULL;
|
||||
}
|
||||
|
||||
if( mPulseMsgId )
|
||||
{
|
||||
PtPulseDisarm( mPulseMsgId );
|
||||
mPulseMsgId = NULL;
|
||||
}
|
||||
|
||||
if( mPulsePid )
|
||||
{
|
||||
PtAppDeletePulse( NULL, mPulsePid );
|
||||
mPulsePid = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// This is the timer handler that gets called by the Photon
|
||||
// input proc
|
||||
|
||||
//
|
||||
int nsTimerPh::TimerEventHandler( void *aData, pid_t aRcvId, void *aMsg, size_t aMsgLen )
|
||||
{
|
||||
int localTimerId;
|
||||
nsTimerPh* timer = (nsTimerPh *)aData;
|
||||
|
||||
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::TimerEventHandler this=<%p>\n", aData));
|
||||
NS_ASSERTION(timer, "nsTimerPh::TimerEventHandler is NULL!");
|
||||
|
||||
// because Notify can cause 'timer' to get destroyed, we need to hold a ref
|
||||
nsCOMPtr<nsITimer> kungFuDeathGrip = timer;
|
||||
|
||||
localTimerId = timer->mTimerId;
|
||||
nsTimerPh* timer = (nsTimerPh *)aData;
|
||||
|
||||
if( timer->mFunc != NULL )
|
||||
{
|
||||
(*timer->mFunc)( timer, timer->mClosure );
|
||||
}
|
||||
else if ( timer->mCallback != NULL )
|
||||
{
|
||||
timer->mCallback->Notify( timer );
|
||||
}
|
||||
|
||||
return Pt_CONTINUE;
|
||||
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::TimerEventHandler this=<%p>\n", aData));
|
||||
NS_ASSERTION(timer, "nsTimerPh::TimerEventHandler is NULL!");
|
||||
PtHold();
|
||||
timer->FireTimeout();
|
||||
PtRelease();
|
||||
return Pt_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_METHOD nsTimerPh::SetupTimer()
|
||||
{
|
||||
PR_LOG(PhTimLog, PR_LOG_DEBUG, ("nsTimerPh::SetupTimer this=<%p>\n", this));
|
||||
|
@ -259,73 +254,69 @@ NS_METHOD nsTimerPh::SetupTimer()
|
|||
struct itimerspec tv;
|
||||
int err;
|
||||
|
||||
if( mPulsePid )
|
||||
{
|
||||
NS_ASSERTION(0,"TimerImpl::SetupTimer - reuse of timer not allowed!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
//int CurrentPriority = 10; /* How Do I get this?? */
|
||||
/* We get the current priority of the thread, by calling getprio(0) which is Neutrino specific. */
|
||||
int CurrentPriority = getprio (0);
|
||||
int NewPriority = CurrentPriority;
|
||||
|
||||
|
||||
switch(mPriority)
|
||||
{
|
||||
case NS_PRIORITY_LOWEST:
|
||||
NewPriority = CurrentPriority - 2;
|
||||
break;
|
||||
break;
|
||||
|
||||
case NS_PRIORITY_LOW:
|
||||
NewPriority = CurrentPriority - 1;
|
||||
break;
|
||||
break;
|
||||
|
||||
case NS_PRIORITY_NORMAL:
|
||||
NewPriority = CurrentPriority;
|
||||
break;
|
||||
break;
|
||||
|
||||
case NS_PRIORITY_HIGH:
|
||||
NewPriority = CurrentPriority +1;
|
||||
break;
|
||||
break;
|
||||
|
||||
case NS_PRIORITY_HIGHEST:
|
||||
NewPriority = CurrentPriority + 2;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
if(( mPulsePid = PtAppCreatePulse( NULL, NewPriority )) == 0 )
|
||||
if( mPulsePid == 0 && ( mPulsePid = PtAppCreatePulse( NULL, NewPriority )) == 0 )
|
||||
{
|
||||
NS_ASSERTION(0,"TimerImpl::SetupTimer - failed to create pulse");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if(( mPulseMsgId = PtPulseArmPid( NULL, mPulsePid, getpid(), &mPulseMsg )) == NULL )
|
||||
if( mPulseMsgId == NULL && ( mPulseMsgId = PtPulseArmPid( NULL, mPulsePid, getpid(), &mPulseMsg )) == NULL )
|
||||
{
|
||||
NS_ASSERTION(0,"TimerImpl::SetupTimer - failed to arm pulse!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if(( mInputId = PtAppAddInput( NULL, mPulsePid, TimerEventHandler, this )) == NULL )
|
||||
if( mInputId == 0 && ( mInputId = PtAppAddInput( NULL, mPulsePid, TimerEventHandler, this )) == NULL )
|
||||
{
|
||||
NS_ASSERTION(0,"TimerImpl::SetupTimer - failed to add input handler!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mTimerId = -1;
|
||||
err = timer_create( CLOCK_MONOTONIC, &mPulseMsg, &mTimerId );
|
||||
if( err != 0 )
|
||||
{
|
||||
NS_ASSERTION(0,"TimerImpl::SetupTimer - timer_create error");
|
||||
return NS_ERROR_FAILURE;
|
||||
if ( mTimerId == -1 ) {
|
||||
mTimerId = -1;
|
||||
err = timer_create( CLOCK_MONOTONIC, &mPulseMsg, &mTimerId );
|
||||
if( err != 0 )
|
||||
{
|
||||
NS_ASSERTION(0,"TimerImpl::SetupTimer - timer_create error");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
switch(mType)
|
||||
{
|
||||
case NS_TYPE_REPEATING_SLACK:
|
||||
case NS_TYPE_ONE_SHOT:
|
||||
tv.it_interval.tv_sec = 0;
|
||||
tv.it_interval.tv_nsec = 0;
|
||||
break;
|
||||
case NS_TYPE_REPEATING_SLACK: /* HACK WRONG! */
|
||||
case NS_TYPE_REPEATING_PRECISE:
|
||||
tv.it_interval.tv_sec = ( mDelay / 1000 );
|
||||
tv.it_interval.tv_nsec = ( mDelay % 1000 ) * 1000000L;
|
||||
tv.it_interval.tv_nsec = ( mDelay % 1000 ) * 1000000L;
|
||||
break;
|
||||
}
|
||||
tv.it_value.tv_sec = ( mDelay / 1000 );
|
||||
|
@ -333,9 +324,7 @@ NS_METHOD nsTimerPh::SetupTimer()
|
|||
|
||||
/* If delay is set to 0 seconds then change it to 1 nsec. */
|
||||
if ( (tv.it_value.tv_sec == 0) && (tv.it_value.tv_nsec == 0))
|
||||
{
|
||||
tv.it_value.tv_nsec = 1;
|
||||
}
|
||||
|
||||
err = timer_settime( mTimerId, 0, &tv, NULL );
|
||||
if( err != 0 )
|
||||
|
@ -343,33 +332,34 @@ NS_METHOD nsTimerPh::SetupTimer()
|
|||
NS_ASSERTION(0,"TimerImpl::SetupTimer timer_settime");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
#ifdef MOZ_MONOLITHIC_TOOLKIT
|
||||
nsresult NS_NewTimer(nsITimer** aInstancePtrResult)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (nsnull == aInstancePtrResult)
|
||||
{
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsTimerPh *timer = new nsTimerPh();
|
||||
if (nsnull == timer) {
|
||||
if (nsnull == timer)
|
||||
{
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
return CallQueryInterface(timer, aInstancePtrResult);
|
||||
}
|
||||
|
||||
int NS_TimeToNextTimeout(struct timeval *aTimer)
|
||||
int NS_TimeToNextTimeout(struct timeval *aTimer)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void NS_ProcessTimeouts(void)
|
||||
void NS_ProcessTimeouts(void)
|
||||
{
|
||||
}
|
||||
#endif /* MOZ_MONOLITHIC_TOOLKIT */
|
||||
|
|
Загрузка…
Ссылка в новой задаче