clean up uses of QI and friends to use the macros correctly

clean up resizing and moving code.
wrote initial unix drag and drop code
more good things to come soon.
This commit is contained in:
pavlov%netscape.com 1999-09-02 21:30:31 +00:00
Родитель b0fc39b600
Коммит 93145abc11
16 изменённых файлов: 678 добавлений и 309 удалений

Просмотреть файл

@ -132,10 +132,10 @@ nsAppShell::~nsAppShell()
// nsISupports implementation macro
//
//-------------------------------------------------------------------------
NS_IMPL_ISUPPORTS(nsAppShell, nsIAppShell::GetIID());
NS_IMPL_ISUPPORTS1(nsAppShell, nsIAppShell)
//-------------------------------------------------------------------------
NS_METHOD nsAppShell::SetDispatchListener(nsDispatchListener* aDispatchListener)
NS_IMETHODIMP nsAppShell::SetDispatchListener(nsDispatchListener* aDispatchListener)
{
mDispatchListener = aDispatchListener;
return NS_OK;
@ -192,7 +192,7 @@ HandleColormapPrefs( void )
//
//-------------------------------------------------------------------------
NS_METHOD nsAppShell::Create(int *bac, char **bav)
NS_IMETHODIMP nsAppShell::Create(int *bac, char **bav)
{
gchar *home=nsnull;
gchar *path=nsnull;
@ -241,7 +241,7 @@ NS_METHOD nsAppShell::Create(int *bac, char **bav)
// Spinup - do any preparation necessary for running a message loop
//
//-------------------------------------------------------------------------
NS_METHOD nsAppShell::Spinup()
NS_IMETHODIMP nsAppShell::Spinup()
{
return NS_OK;
}
@ -251,7 +251,7 @@ NS_METHOD nsAppShell::Spinup()
// Spindown - do any cleanup necessary for finishing a message loop
//
//-------------------------------------------------------------------------
NS_METHOD nsAppShell::Spindown()
NS_IMETHODIMP nsAppShell::Spindown()
{
return NS_OK;
}
@ -261,7 +261,7 @@ NS_METHOD nsAppShell::Spindown()
// PushThreadEventQueue
//
//-------------------------------------------------------------------------
NS_METHOD
NS_IMETHODIMP
nsAppShell::PushThreadEventQueue()
{
nsresult rv;
@ -293,7 +293,7 @@ nsAppShell::PushThreadEventQueue()
// PopThreadEventQueue
//
//-------------------------------------------------------------------------
NS_METHOD
NS_IMETHODIMP
nsAppShell::PopThreadEventQueue()
{
nsresult rv;
@ -319,7 +319,7 @@ nsAppShell::PopThreadEventQueue()
// Run
//
//-------------------------------------------------------------------------
NS_METHOD nsAppShell::Run()
NS_IMETHODIMP nsAppShell::Run()
{
NS_ADDREF_THIS();
nsresult rv = NS_OK;
@ -381,7 +381,7 @@ done:
//
//-------------------------------------------------------------------------
NS_METHOD nsAppShell::Exit()
NS_IMETHODIMP nsAppShell::Exit()
{
gtk_main_quit ();
@ -403,7 +403,7 @@ void* nsAppShell::GetNativeData(PRUint32 aDataType)
return nsnull;
}
NS_METHOD nsAppShell::GetNativeEvent(PRBool &aRealEvent, void *& aEvent)
NS_IMETHODIMP nsAppShell::GetNativeEvent(PRBool &aRealEvent, void *& aEvent)
{
GdkEvent *event;
@ -420,17 +420,17 @@ NS_METHOD nsAppShell::GetNativeEvent(PRBool &aRealEvent, void *& aEvent)
return NS_OK;
}
NS_METHOD nsAppShell::DispatchNativeEvent(PRBool aRealEvent, void *aEvent)
NS_IMETHODIMP nsAppShell::DispatchNativeEvent(PRBool aRealEvent, void *aEvent)
{
if ( aRealEvent == PR_TRUE )
g_main_iteration (PR_TRUE);
return NS_OK;
}
NS_METHOD nsAppShell::EventIsForModalWindow(PRBool aRealEvent,
void *aEvent,
nsIWidget *aWidget,
PRBool *aForWindow)
NS_IMETHODIMP nsAppShell::EventIsForModalWindow(PRBool aRealEvent,
void *aEvent,
nsIWidget *aWidget,
PRBool *aForWindow)
{
PRBool isInWindow, isMouseEvent;
GdkEventAny *msg = (GdkEventAny *) aEvent;

Просмотреть файл

@ -32,31 +32,31 @@ struct PRLock;
class nsAppShell : public nsIAppShell
{
public:
nsAppShell();
virtual ~nsAppShell();
public:
nsAppShell();
virtual ~nsAppShell();
NS_DECL_ISUPPORTS
NS_DECL_ISUPPORTS
// nsIAppShellInterface
NS_IMETHOD Create(int* argc, char ** argv);
NS_IMETHOD Run();
NS_IMETHOD Spinup();
NS_IMETHOD Spindown();
NS_IMETHOD PushThreadEventQueue();
NS_IMETHOD PopThreadEventQueue();
NS_IMETHOD GetNativeEvent(PRBool &aRealEvent, void *&aEvent);
NS_IMETHOD DispatchNativeEvent(PRBool aRealEvent, void * aEvent);
NS_IMETHOD EventIsForModalWindow(PRBool aRealEvent, void *aEvent,
nsIWidget *aWidget, PRBool *aForWindow);
NS_IMETHOD Exit();
NS_IMETHOD SetDispatchListener(nsDispatchListener* aDispatchListener);
virtual void* GetNativeData(PRUint32 aDataType);
// nsIAppShellInterface
NS_IMETHOD Create(int* argc, char ** argv);
NS_IMETHOD Run();
NS_IMETHOD Spinup();
NS_IMETHOD Spindown();
NS_IMETHOD PushThreadEventQueue();
NS_IMETHOD PopThreadEventQueue();
NS_IMETHOD GetNativeEvent(PRBool &aRealEvent, void *&aEvent);
NS_IMETHOD DispatchNativeEvent(PRBool aRealEvent, void * aEvent);
NS_IMETHOD EventIsForModalWindow(PRBool aRealEvent, void *aEvent,
nsIWidget *aWidget, PRBool *aForWindow);
NS_IMETHOD Exit();
NS_IMETHOD SetDispatchListener(nsDispatchListener* aDispatchListener);
virtual void* GetNativeData(PRUint32 aDataType);
private:
nsDispatchListener *mDispatchListener;
PRLock *mLock;
EventQueueTokenQueue *mEventQueueTokens;
private:
nsDispatchListener *mDispatchListener;
PRLock *mLock;
EventQueueTokenQueue *mEventQueueTokens;
};
#endif // nsAppShell_h__

Просмотреть файл

@ -553,7 +553,7 @@ nsClipboard::GetNativeClipboardData(nsITransferable * aTransferable)
#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));
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

Просмотреть файл

@ -42,11 +42,14 @@ public:
NS_IMETHOD ForceDataToClipboard();
// invisible widget. also used by dragndrop
static GtkWidget *sWidget;
protected:
NS_IMETHOD SetNativeClipboardData();
NS_IMETHOD GetNativeClipboardData(nsITransferable * aTransferable);
PRBool mIgnoreEmptyNotification;
PRBool mIgnoreEmptyNotification;
void AddTarget(GdkAtom aAtom);
@ -59,8 +62,6 @@ protected:
void Init(void);
static GtkWidget *sWidget;
// Used for communicating pasted data
// from the asynchronous X routines back to a blocking paste:
GtkSelectionData mSelectionData;

Просмотреть файл

@ -17,8 +17,15 @@
*/
#include "nsDragService.h"
#include "nsITransferable.h"
#include "nsIServiceManager.h"
#include "nsString.h"
#include "nsClipboard.h"
#include "nsIRegion.h"
#include "nsVoidArray.h"
#include "nsISupportsPrimitives.h"
#include "nsCOMPtr.h"
#include "nsXPIDLString.h"
#include "nsWidgetsCID.h"
@ -26,6 +33,8 @@ 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
@ -34,6 +43,8 @@ NS_IMPL_QUERY_INTERFACE2(nsDragService, nsIDragService, nsIDragSession)
nsDragService::nsDragService()
{
NS_INIT_REFCNT();
mWidget = nsnull;
mNumFlavors = 0;
}
//-------------------------------------------------------------------------
@ -45,15 +56,320 @@ nsDragService::~nsDragService()
{
}
enum {
TARGET_STRING,
TARGET_ROOTWIN
};
static GtkTargetEntry target_table[] = {
{ "STRING", 0, TARGET_STRING },
{ "text/plain", 0, TARGET_STRING },
{ "application/x-rootwin-drop", 0, TARGET_ROOTWIN }
};
static guint n_targets = sizeof(target_table) / sizeof(target_table[0]);
NS_IMETHODIMP nsDragService::StartDragSession()
{
printf("nsDragService::StartDragSession()\n");
nsBaseDragService::StartDragSession();
/*
gtk_drag_source_set(mWidget,
GDK_MODIFIER_MASK,
targetlist,
mNumFlavors,
action);
*/
gtk_drag_source_set(mWidget,
GDK_MODIFIER_MASK,
target_table,
n_targets,
mActionType);
return NS_OK;
}
NS_IMETHODIMP nsDragService::EndDragSession()
{
printf("nsDragService::EndDragSession()\n");
nsBaseDragService::EndDragSession();
gtk_drag_source_unset(mWidget);
return NS_OK;
}
//-------------------------------------------------------------------------
NS_IMETHODIMP nsDragService::InvokeDragSession (nsISupportsArray *anArrayTransferables,
NS_IMETHODIMP nsDragService::InvokeDragSession (nsISupportsArray *aTransferableArray,
nsIScriptableRegion *aRegion,
PRUint32 aActionType)
{
mWidget = gtk_get_event_widget(gtk_get_current_event());
// add the flavors from the transferables. Cache this array for the send data proc
GtkTargetList *targetlist = RegisterDragItemsAndFlavors(aTransferableArray);
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;
}
StartDragSession();
// XXX 3rd param ??? & last param should be a real event...
gtk_drag_begin(mWidget, targetlist, mActionType, 1, gtk_get_current_event());
#if 0
// we have to synthesize the native event because we may be called from JavaScript
// through XPConnect. In that case, we only have a DOM event and no way to
// get to the native event. As a consequence, we just always fake it.
Point globalMouseLoc;
::GetMouse(&globalMouseLoc);
::LocalToGlobal(&globalMouseLoc);
WindowPtr theWindow = nsnull;
if ( ::FindWindow(globalMouseLoc, &theWindow) != inContent ) {
// debugging sanity check
#ifdef NS_DEBUG
DebugStr("\pAbout to start drag, but FindWindow() != inContent; g");
#endif
}
EventRecord theEvent;
theEvent.what = mouseDown;
theEvent.message = reinterpret_cast<UInt32>(theWindow);
theEvent.when = 0;
theEvent.where = globalMouseLoc;
theEvent.modifiers = 0;
RgnHandle theDragRgn = ::NewRgn();
BuildDragRegion ( aDragRgn, globalMouseLoc, theDragRgn );
// register drag send proc which will call us back when asked for the actual
// flavor data (instead of placing it all into the drag manager)
::SetDragSendProc ( theDragRef, sDragSendDataUPP, this );
// start the drag. Be careful, mDragRef will be invalid AFTER this call (it is
// reset by the dragTrackingHandler).
::TrackDrag ( theDragRef, &theEvent, theDragRgn );
// clean up after ourselves
::DisposeRgn ( theDragRgn );
result = ::DisposeDrag ( theDragRef );
NS_ASSERTION ( result == noErr, "Error disposing drag" );
mDragRef = 0L;
mDataItems = nsnull;
return NS_OK;
#endif
return NS_OK;
}
GtkTargetList *
nsDragService::RegisterDragItemsAndFlavors(nsISupportsArray *inArray)
{
unsigned int numDragItems = 0;
inArray->Count(&numDragItems);
GtkTargetList *targetlist;
targetlist = gtk_target_list_new(nsnull, numDragItems);
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)
{
#ifdef DEBUG_DRAG
g_print(" nsDragService::DoRealConvert(%li)\n {\n", type);
#endif
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
g_print(" 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
g_print(" }\n");
#endif
if (mSelectionData.length > 0)
return PR_TRUE;
return PR_FALSE;
}
#if 0
/**
* Called when the data from a drag comes in (recieved from gdk_selection_convert)
*
* @param aWidget the widget
* @param aSelectionData gtk selection stuff
* @param aTime time the selection was requested
*/
void
nsDragService::SelectionReceivedCB (GtkWidget *aWidget,
GdkDragContext *aContext,
gint aX,
gint aY,
GtkSelectionData *aSelectionData,
guint aInfo,
guint aTime)
{
#ifdef DEBUG_DRAG
printf(" nsDragService::SelectionReceivedCB\n {\n");
#endif
nsDragService *ds =(nsDragSession *)gtk_object_get_data(GTK_OBJECT(aWidget),
"ds");
if (!cb)
{
g_print("no dragservice found.. this is bad.\n");
return;
}
ds->SelectionReceiver(aWidget, aSelectionData);
#ifdef DEBUG_DRAG
g_print(" }\n");
#endif
}
/**
* local method (called from nsClipboard::SelectionReceivedCB)
*
* @param aWidget the widget
* @param aSelectionData gtk selection stuff
*/
void
nsDragService::SelectionReceiver (GtkWidget *aWidget,
GtkSelectionData *aSD)
{
gint type;
mBlocking = PR_FALSE;
if (aSD->length < 0)
{
printf(" Error retrieving selection: length was %d\n",
aSD->length);
return;
}
switch (type)
{
case GDK_TARGET_STRING:
case TARGET_COMPOUND_TEXT:
case TARGET_TEXT_PLAIN:
case TARGET_TEXT_XIF:
case TARGET_TEXT_UNICODE:
case TARGET_TEXT_HTML:
#ifdef DEBUG_CLIPBOARD
g_print(" Copying mSelectionData pointer -- ");
#endif
mSelectionData = *aSD;
mSelectionData.data = g_new(guchar, aSD->length + 1);
#ifdef DEBUG_CLIPBOARD
g_print(" Data = %s\n Length = %i\n", aSD->data, aSD->length);
#endif
memcpy(mSelectionData.data,
aSD->data,
aSD->length);
// Null terminate in case anyone cares,
// and so we can print the string for debugging:
mSelectionData.data[aSD->length] = '\0';
mSelectionData.length = aSD->length;
return;
default:
mSelectionData = *aSD;
mSelectionData.data = g_new(guchar, aSD->length + 1);
memcpy(mSelectionData.data,
aSD->data,
aSD->length);
mSelectionData.length = aSD->length;
return;
}
}
#endif
//-------------------------------------------------------------------------
NS_IMETHODIMP nsDragService::GetNumDropItems (PRUint32 * aNumItems)
{
@ -64,7 +380,79 @@ NS_IMETHODIMP nsDragService::GetNumDropItems (PRUint32 * aNumItems)
//-------------------------------------------------------------------------
NS_IMETHODIMP nsDragService::GetData (nsITransferable * aTransferable, PRUint32 anItem)
{
return NS_ERROR_FAILURE;
#ifdef DEBUG_DRAG
printf("nsClipboard::GetNativeClipboardData()\n");
#endif /* DEBUG_CLIPBOARD */
// make sure we have a good transferable
if (!aTransferable) {
printf(" GetData: Transferable is null!\n");
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;
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));
if (DoConvert(gdk_atom_intern(flavorStr, 1))) {
foundFlavor = flavorStr;
break;
}
}
}
#ifdef DEBUG_CLIPBOARD
printf(" Got the callback: '%s', %d\n",
mSelectionData.data, mSelectionData.length);
#endif /* DEBUG_CLIPBOARD */
// 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 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;
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);
return NS_OK;
}
//-------------------------------------------------------------------------

Просмотреть файл

@ -46,7 +46,16 @@ public:
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(GtkWidget *widget,
@ -83,6 +92,14 @@ protected:
static void DragDataDelete(GtkWidget *widget,
GdkDragContext *context,
gpointer data);
private:
GdkDragAction mActionType;
PRUint32 mNumFlavors;
GtkWidget *mWidget;
GdkDragContext *mDragContext;
GtkSelectionData mSelectionData;
PRBool mBlocking;
};
#endif // nsDragService_h__

Просмотреть файл

@ -30,6 +30,7 @@ nsFileWidget::nsFileWidget() : nsIFileWidget()
{
NS_INIT_REFCNT();
mWidget = nsnull;
mDisplayDirectory = nsnull;
mFilterMenu = nsnull;
mOptionMenu = nsnull;
mNumberOfFilters = 0;
@ -101,6 +102,11 @@ PRBool nsFileWidget::Show()
else
gtk_widget_hide(mOptionMenu);
#if 0
if (mDisplayDirectory)
gtk_file_selection_complete(fs, "/");
#endif
// gtk_window_set_modal(GTK_WINDOW(mWidget), PR_TRUE);
gtk_widget_show(mWidget);

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
@ -28,9 +28,7 @@
#include "nsVoidArray.h"
#include "nsFontSizeIterator.h"
NS_IMPL_ADDREF(nsFontRetrieverService)
NS_IMPL_RELEASE(nsFontRetrieverService)
NS_IMPL_ISUPPORTS2(nsFontRetrieverService, nsIFontRetrieverService, nsIFontNameIterator)
//----------------------------------------------------------
nsFontRetrieverService::nsFontRetrieverService()
@ -59,35 +57,6 @@ nsFontRetrieverService::~nsFontRetrieverService()
NS_IF_RELEASE(mSizeIter);
}
/**
* @param aIID The name of the class implementing the method
* @param _classiiddef The name of the #define symbol that defines the IID
* for the class (e.g. NS_ISUPPORTS_IID)
*
*/
nsresult nsFontRetrieverService::QueryInterface(const nsIID& aIID, void** aInstancePtr)
{
if (NULL == aInstancePtr) {
return NS_ERROR_NULL_POINTER;
}
nsresult rv = NS_NOINTERFACE;
if (aIID.Equals(nsIFontRetrieverService::GetIID())) {
*aInstancePtr = (void*) ((nsIFontRetrieverService*)this);
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(nsIFontNameIterator::GetIID())) {
*aInstancePtr = (void*) ((nsIFontNameIterator*)this);
NS_ADDREF_THIS();
return NS_OK;
}
return rv;
}
//----------------------------------------------------------

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
@ -26,7 +26,8 @@ class nsVoidArray;
class nsFontSizeIterator;
class nsFontRetrieverService: public nsIFontRetrieverService,
public nsIFontNameIterator {
public nsIFontNameIterator
{
public:
nsFontRetrieverService();
virtual ~nsFontRetrieverService();
@ -34,16 +35,16 @@ public:
NS_DECL_ISUPPORTS
// nsIFontRetrieverService
NS_IMETHOD CreateFontNameIterator( nsIFontNameIterator** aIterator );
NS_IMETHOD CreateFontNameIterator( nsIFontNameIterator** aIterator );
NS_IMETHOD CreateFontSizeIterator( const nsString & aFontName, nsIFontSizeIterator** aIterator );
NS_IMETHOD IsFontScalable( const nsString & aFontName, PRBool* aResult );
NS_IMETHOD CreateFontSizeIterator( const nsString & aFontName, nsIFontSizeIterator** aIterator );
NS_IMETHOD IsFontScalable( const nsString & aFontName, PRBool* aResult );
// nsIFontNameIterator
NS_IMETHOD Reset();
NS_IMETHOD Get( nsString* aFontName );
NS_IMETHOD Advance();
NS_IMETHOD Reset();
NS_IMETHOD Get( nsString* aFontName );
NS_IMETHOD Advance();

Просмотреть файл

@ -43,12 +43,12 @@ static NS_DEFINE_CID(kCharsetConverterManagerCID,
#include "stdio.h"
#include "ctype.h"
#define DBG 0
#include <gdk/gdkkeysyms.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#define DEBUG_EVENTS 1
struct EventInfo {
nsWidget *widget; // the widget
nsRect *rect; // the rect

Просмотреть файл

@ -39,7 +39,7 @@ static PRLibrary *lib = nsnull;
/* used to play the sounds from the find symbol call */
typedef int (PR_CALLBACK *EsdPlayFileType)(const char *, const char *, int);
NS_IMPL_ISUPPORTS(nsSound, nsCOMTypeInfo<nsISound>::GetIID());
NS_IMPL_ISUPPORTS1(nsSound, nsISound);
////////////////////////////////////////////////////////////////////////
nsSound::nsSound()

Просмотреть файл

@ -45,8 +45,8 @@ nsToolkit::~nsToolkit()
// nsISupports implementation macro
//
//-------------------------------------------------------------------------
NS_DEFINE_IID(kIToolkitIID, NS_ITOOLKIT_IID);
NS_IMPL_ISUPPORTS(nsToolkit,kIToolkitIID);
NS_IMPL_ISUPPORTS1(nsToolkit, nsIToolkit)
void nsToolkit::CreateSharedGC(void)
{
@ -70,7 +70,7 @@ GdkGC *nsToolkit::GetSharedGC(void)
//
//
//-------------------------------------------------------------------------
NS_METHOD nsToolkit::Init(PRThread *aThread)
NS_IMETHODIMP nsToolkit::Init(PRThread *aThread)
{
CreateSharedGC();

Просмотреть файл

@ -33,16 +33,17 @@ class nsToolkit : public nsIToolkit
public:
nsToolkit();
virtual ~nsToolkit();
virtual ~nsToolkit();
NS_DECL_ISUPPORTS
NS_IMETHOD Init(PRThread *aThread);
void CreateSharedGC(void);
GdkGC *GetSharedGC(void);
NS_IMETHOD Init(PRThread *aThread);
void CreateSharedGC(void);
GdkGC *GetSharedGC(void);
private:
GdkGC *mSharedGC;
GdkGC *mSharedGC;
};

Просмотреть файл

@ -38,14 +38,28 @@ PRUint32 nsWidget::sWidgetCount = 0;
//
// Keep track of the last widget being "dragged"
//
nsWidget * nsWidget::sButtonMotionTarget = NULL;
nsWidget *nsWidget::sButtonMotionTarget = NULL;
gint nsWidget::sButtonMotionRootX = -1;
gint nsWidget::sButtonMotionRootY = -1;
gint nsWidget::sButtonMotionWidgetX = -1;
gint nsWidget::sButtonMotionWidgetY = -1;
//#define DBG 1
#undef DEBUG_pavlov
// Drag & Drop stuff.
enum {
TARGET_STRING,
TARGET_ROOTWIN
};
static GtkTargetEntry target_table[] = {
{ "STRING", 0, TARGET_STRING },
{ "text/plain", 0, TARGET_STRING },
{ "application/x-rootwin-drop", 0, TARGET_ROOTWIN }
};
static guint n_targets = sizeof(target_table) / sizeof(target_table[0]);
//#undef DEBUG_pavlov
nsWidget::nsWidget()
{
@ -55,7 +69,7 @@ nsWidget::nsWidget()
if (!sLookAndFeel) {
if (NS_OK != nsComponentManager::CreateInstance(kLookAndFeelCID,
nsnull,
nsILookAndFeel::GetIID(),
NS_GET_IID(nsILookAndFeel),
(void**)&sLookAndFeel))
sLookAndFeel = nsnull;
}
@ -267,15 +281,9 @@ NS_IMETHODIMP nsWidget::Show(PRBool bState)
return NS_OK; // Will be null durring printing
if (bState)
::gtk_widget_show(mWidget);
gtk_widget_show(mWidget);
else
{
::gtk_widget_hide(mWidget);
// For some strange reason, gtk_widget_hide() does not seem to
// unmap the window.
::gtk_widget_unmap(mWidget);
}
gtk_widget_hide(mWidget);
mShown = bState;
@ -288,10 +296,14 @@ NS_IMETHODIMP nsWidget::SetModal(void)
if (!mWidget)
return NS_ERROR_FAILURE;
toplevel = (GtkWindow *) ::gtk_widget_get_toplevel( mWidget );
if ( !toplevel )
toplevel = GTK_WINDOW(gtk_widget_get_toplevel(mWidget));
if (!toplevel)
return NS_ERROR_FAILURE;
::gtk_window_set_modal(toplevel, PR_TRUE);
gtk_window_set_modal(toplevel, PR_TRUE);
return NS_OK;
}
@ -326,9 +338,8 @@ NS_IMETHODIMP nsWidget::CaptureMouse(PRBool aCapture)
NS_IMETHODIMP nsWidget::IsVisible(PRBool &aState)
{
if (mWidget) {
if (mWidget)
aState = GTK_WIDGET_VISIBLE(mWidget);
}
else
aState = PR_FALSE;
@ -378,10 +389,10 @@ NS_IMETHODIMP nsWidget::Move(PRInt32 aX, PRInt32 aY)
PRInt32 x_correction = (PRInt32) ha->value;
PRInt32 y_correction = (PRInt32) va->value;
::gtk_layout_move(GTK_LAYOUT(layout),
mWidget,
aX + x_correction,
aY + y_correction);
gtk_layout_move(GTK_LAYOUT(layout),
mWidget,
aX + x_correction,
aY + y_correction);
}
return NS_OK;
@ -396,14 +407,9 @@ NS_IMETHODIMP nsWidget::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
#endif
mBounds.width = aWidth;
mBounds.height = aHeight;
if (mWidget) {
::gtk_widget_set_usize(mWidget, aWidth, aHeight);
if (aRepaint) {
if (GTK_WIDGET_VISIBLE (mWidget)) {
::gtk_widget_queue_draw (mWidget);
}
}
}
if (mWidget)
gtk_widget_set_usize(mWidget, aWidth, aHeight);
return NS_OK;
}
@ -411,8 +417,8 @@ NS_IMETHODIMP nsWidget::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
NS_IMETHODIMP nsWidget::Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth,
PRInt32 aHeight, PRBool aRepaint)
{
Move(aX, aY);
Resize(aWidth,aHeight,aRepaint);
Move(aX,aY);
return NS_OK;
}
@ -476,9 +482,9 @@ PRBool nsWidget::OnMove(PRInt32 aX, PRInt32 aY)
//-------------------------------------------------------------------------
NS_IMETHODIMP nsWidget::Enable(PRBool bState)
{
if (mWidget) {
::gtk_widget_set_sensitive(mWidget, bState);
}
if (mWidget)
gtk_widget_set_sensitive(mWidget, bState);
return NS_OK;
}
@ -489,9 +495,9 @@ NS_IMETHODIMP nsWidget::Enable(PRBool bState)
//-------------------------------------------------------------------------
NS_IMETHODIMP nsWidget::SetFocus(void)
{
if (mWidget) {
::gtk_widget_grab_focus(mWidget);
}
if (mWidget)
gtk_widget_grab_focus(mWidget);
return NS_OK;
}
@ -651,17 +657,14 @@ NS_IMETHODIMP nsWidget::SetCursor(nsCursor aCursor)
NS_IMETHODIMP nsWidget::Invalidate(PRBool aIsSynchronous)
{
if (mWidget == nsnull) {
if (mWidget == nsnull)
return NS_OK; // mWidget will be null during printing.
}
if (!GTK_IS_WIDGET (mWidget)) {
if (!GTK_IS_WIDGET (mWidget))
return NS_ERROR_FAILURE;
}
if (!GTK_WIDGET_REALIZED (GTK_WIDGET(mWidget))) {
if (!GTK_WIDGET_REALIZED (GTK_WIDGET(mWidget)))
return NS_ERROR_FAILURE;
}
if (aIsSynchronous) {
::gtk_widget_draw(mWidget, NULL);
@ -676,28 +679,28 @@ NS_IMETHODIMP nsWidget::Invalidate(PRBool aIsSynchronous)
NS_IMETHODIMP nsWidget::Invalidate(const nsRect & aRect, PRBool aIsSynchronous)
{
if (mWidget == nsnull) {
if (mWidget)
return NS_OK; // mWidget is null during printing
}
if (!GTK_IS_WIDGET (mWidget)) {
if (!GTK_IS_WIDGET (mWidget))
return NS_ERROR_FAILURE;
}
if (!GTK_WIDGET_REALIZED (GTK_WIDGET(mWidget))) {
if (!GTK_WIDGET_REALIZED (GTK_WIDGET(mWidget)))
return NS_ERROR_FAILURE;
if (aIsSynchronous)
{
GdkRectangle nRect;
NSRECT_TO_GDKRECT(aRect, nRect);
gtk_widget_draw(mWidget, &nRect);
}
if ( aIsSynchronous) {
GdkRectangle nRect;
NSRECT_TO_GDKRECT(aRect, nRect);
::gtk_widget_draw(mWidget, &nRect);
} else {
mUpdateArea.UnionRect(mUpdateArea, aRect);
::gtk_widget_queue_draw_area(mWidget,
aRect.x, aRect.y,
aRect.width, aRect.height);
else
{
mUpdateArea.UnionRect(mUpdateArea, aRect);
gtk_widget_queue_draw_area(mWidget,
aRect.x, aRect.y,
aRect.width, aRect.height);
}
return NS_OK;
@ -829,9 +832,9 @@ NS_IMETHODIMP nsWidget::GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight)
NS_IMETHODIMP nsWidget::SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight)
{
mPreferredWidth = aWidth;
mPreferredHeight = aHeight;
return NS_OK;
mPreferredWidth = aWidth;
mPreferredHeight = aHeight;
return NS_OK;
}
NS_IMETHODIMP nsWidget::SetMenuBar(nsIMenuBar * aMenuBar)
@ -875,9 +878,9 @@ nsresult nsWidget::CreateWidget(nsIWidget *aParent,
gtk_widget_push_visual(gdk_rgb_get_visual());
nsIWidget *baseParent = aInitData &&
(aInitData->mWindowType == eWindowType_dialog ||
aInitData->mWindowType == eWindowType_toplevel) ?
nsnull : aParent;
(aInitData->mWindowType == eWindowType_dialog ||
aInitData->mWindowType == eWindowType_toplevel) ?
nsnull : aParent;
BaseCreate(baseParent, aRect, aHandleEventFunction, aContext,
aAppShell, aToolkit, aInitData);
mParent = aParent;
@ -927,6 +930,12 @@ nsresult nsWidget::CreateWidget(nsIWidget *aParent,
InstallEnterNotifySignal(mWidget);
InstallLeaveNotifySignal(mWidget);
// Initialize this window instance as a drag target.
gtk_drag_dest_set (mWidget,
GTK_DEST_DEFAULT_ALL,
target_table, n_targets - 1, /* no rootwin */
GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE));
// Drag & Drop events.
InstallDragBeginSignal(mWidget);
@ -1014,49 +1023,49 @@ void nsWidget::ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY)
void nsWidget::InitEvent(nsGUIEvent& event, PRUint32 aEventType, nsPoint* aPoint)
{
event.widget = this;
event.widget = this;
GdkEventConfigure *ge;
ge = (GdkEventConfigure*)gtk_get_current_event();
GdkEventConfigure *ge;
ge = (GdkEventConfigure*)gtk_get_current_event();
if (aPoint == nsnull) { // use the point from the event
// get the message position in client coordinates and in twips
if (aPoint == nsnull) { // use the point from the event
// get the message position in client coordinates and in twips
if (ge != nsnull) {
// ::ScreenToClient(mWnd, &cpos);
event.point.x = PRInt32(ge->x);
event.point.y = PRInt32(ge->y);
} else {
event.point.x = 0;
event.point.y = 0;
}
}
else { // use the point override if provided
event.point.x = aPoint->x;
event.point.y = aPoint->y;
}
if (ge != nsnull) {
// ::ScreenToClient(mWnd, &cpos);
event.point.x = PRInt32(ge->x);
event.point.y = PRInt32(ge->y);
} else {
event.point.x = 0;
event.point.y = 0;
}
}
else { // use the point override if provided
event.point.x = aPoint->x;
event.point.y = aPoint->y;
}
event.time = gdk_event_get_time((GdkEvent*)ge);
event.message = aEventType;
event.time = gdk_event_get_time((GdkEvent*)ge);
event.message = aEventType;
// mLastPoint.x = event.point.x;
// mLastPoint.y = event.point.y;
// mLastPoint.x = event.point.x;
// mLastPoint.y = event.point.y;
}
PRBool nsWidget::ConvertStatus(nsEventStatus aStatus)
{
switch(aStatus) {
case nsEventStatus_eIgnore:
return(PR_FALSE);
case nsEventStatus_eConsumeNoDefault:
return(PR_TRUE);
case nsEventStatus_eConsumeDoDefault:
return(PR_FALSE);
default:
NS_ASSERTION(0, "Illegal nsEventStatus enumeration value");
break;
case nsEventStatus_eIgnore:
return(PR_FALSE);
case nsEventStatus_eConsumeNoDefault:
return(PR_TRUE);
case nsEventStatus_eConsumeDoDefault:
return(PR_FALSE);
default:
NS_ASSERTION(0, "Illegal nsEventStatus enumeration value");
break;
}
return(PR_FALSE);
return PR_FALSE;
}
PRBool nsWidget::DispatchWindowEvent(nsGUIEvent* event)
@ -1083,9 +1092,9 @@ PRBool nsWidget::DispatchStandardEvent(PRUint32 aMsg)
PRBool nsWidget::DispatchFocus(nsGUIEvent &aEvent)
{
if (mEventCallback) {
if (mEventCallback)
return DispatchWindowEvent(&aEvent);
}
return PR_FALSE;
}
@ -1509,6 +1518,17 @@ nsWidget::OnDragMotionSignal(GdkDragContext *aGdkDragContext,
OnDragEnterSignal(aGdkDragContext, x, y, time);
}
GtkWidget *source_widget;
source_widget = gtk_drag_get_source_widget (aGdkDragContext);
g_print("motion, source %s\n", source_widget ?
gtk_type_name (GTK_OBJECT (source_widget)->klass->type) :
"unknown");
gdk_drag_status (aGdkDragContext, aGdkDragContext->suggested_action, time);
nsMouseEvent event;
event.message = NS_DRAGDROP_OVER;
@ -1703,55 +1723,55 @@ nsWidget::OnButtonPressSignal(GdkEventButton * aGdkButtonEvent)
// Switch on single, double, triple click.
switch (aGdkButtonEvent->type)
{
// Single click.
case GDK_BUTTON_PRESS:
// Single click.
case GDK_BUTTON_PRESS:
switch (aGdkButtonEvent->button) // Which button?
{
case 1:
eventType = NS_MOUSE_LEFT_BUTTON_DOWN;
break;
case 2:
eventType = NS_MOUSE_MIDDLE_BUTTON_DOWN;
break;
{
case 1:
eventType = NS_MOUSE_LEFT_BUTTON_DOWN;
break;
case 3:
eventType = NS_MOUSE_RIGHT_BUTTON_DOWN;
break;
case 2:
eventType = NS_MOUSE_MIDDLE_BUTTON_DOWN;
break;
// Single-click default.
default:
eventType = NS_MOUSE_LEFT_BUTTON_DOWN;
break;
}
case 3:
eventType = NS_MOUSE_RIGHT_BUTTON_DOWN;
break;
// Single-click default.
default:
eventType = NS_MOUSE_LEFT_BUTTON_DOWN;
break;
}
break;
// Double click.
// Double click.
case GDK_2BUTTON_PRESS:
switch (aGdkButtonEvent->button) // Which button?
{
case 1:
eventType = NS_MOUSE_LEFT_DOUBLECLICK;
break;
{
case 1:
eventType = NS_MOUSE_LEFT_DOUBLECLICK;
break;
case 2:
eventType = NS_MOUSE_MIDDLE_DOUBLECLICK;
break;
case 2:
eventType = NS_MOUSE_MIDDLE_DOUBLECLICK;
break;
case 3:
eventType = NS_MOUSE_RIGHT_DOUBLECLICK;
break;
case 3:
eventType = NS_MOUSE_RIGHT_DOUBLECLICK;
break;
default:
// Double-click default.
eventType = NS_MOUSE_LEFT_DOUBLECLICK;
break;
}
default:
// Double-click default.
eventType = NS_MOUSE_LEFT_DOUBLECLICK;
break;
}
break;
// Triple click.
// Triple click.
case GDK_3BUTTON_PRESS:
// Unhandled triple click.
break;
@ -1786,27 +1806,27 @@ nsWidget::OnButtonReleaseSignal(GdkEventButton * aGdkButtonEvent)
PRUint32 eventType = 0;
switch (aGdkButtonEvent->button)
{
case 1:
eventType = NS_MOUSE_LEFT_BUTTON_UP;
break;
{
case 1:
eventType = NS_MOUSE_LEFT_BUTTON_UP;
break;
case 2:
eventType = NS_MOUSE_MIDDLE_BUTTON_UP;
break;
case 2:
eventType = NS_MOUSE_MIDDLE_BUTTON_UP;
break;
case 3:
eventType = NS_MOUSE_RIGHT_BUTTON_UP;
break;
case 3:
eventType = NS_MOUSE_RIGHT_BUTTON_UP;
break;
default:
eventType = NS_MOUSE_LEFT_BUTTON_UP;
break;
default:
eventType = NS_MOUSE_LEFT_BUTTON_UP;
break;
}
InitMouseEvent(aGdkButtonEvent, event, eventType);
if (nsnull != sButtonMotionTarget)
if (sButtonMotionTarget)
{
sButtonMotionTarget = nsnull;
@ -1940,7 +1960,7 @@ nsWidget::InitMouseEvent(GdkEventButton * aGdkButtonEvent,
//////////////////////////////////////////////////////////////////
PRBool
nsWidget::DropEvent(GtkWidget * aWidget,
GdkWindow * aEventWindow)
GdkWindow * aEventWindow)
{
NS_ASSERTION( nsnull != aWidget, "widget is null");
NS_ASSERTION( nsnull != aEventWindow, "event window is null");
@ -1950,24 +1970,24 @@ nsWidget::DropEvent(GtkWidget * aWidget,
if (GTK_IS_LAYOUT(aWidget))
{
GtkLayout * layout = GTK_LAYOUT(aWidget);
GtkLayout * layout = GTK_LAYOUT(aWidget);
printf("%4d DropEvent(this=%p,widget=%p,event_win=%p,wid_win=%p,bin_win=%p)\n",
count++,
this,
aWidget,
aEventWindow,
aWidget->window,
layout->bin_window);
printf("%4d DropEvent(this=%p,widget=%p,event_win=%p,wid_win=%p,bin_win=%p)\n",
count++,
this,
aWidget,
aEventWindow,
aWidget->window,
layout->bin_window);
}
else
{
printf("%4d DropEvent(this=%p,widget=%p,event_win=%p,wid_win=%p)\n",
count++,
this,
aWidget,
aEventWindow,
aWidget->window);
printf("%4d DropEvent(this=%p,widget=%p,event_win=%p,wid_win=%p)\n",
count++,
this,
aWidget,
aEventWindow,
aWidget->window);
}
#endif
@ -1978,12 +1998,12 @@ nsWidget::DropEvent(GtkWidget * aWidget,
// drop the event.
if (GTK_IS_LAYOUT(aWidget))
{
GtkLayout * layout = GTK_LAYOUT(aWidget);
GtkLayout * layout = GTK_LAYOUT(aWidget);
if (aEventWindow != layout->bin_window)
{
return PR_TRUE;
}
if (aEventWindow != layout->bin_window)
{
return PR_TRUE;
}
}
return PR_FALSE;
@ -2125,7 +2145,7 @@ nsWidget::LeaveNotifySignal(GtkWidget * aWidget,
if (widget->DropEvent(aWidget, aGdkCrossingEvent->window))
{
return PR_TRUE;
return PR_TRUE;
}
widget->OnLeaveNotifySignal(aGdkCrossingEvent);
@ -2149,7 +2169,7 @@ nsWidget::ButtonPressSignal(GtkWidget * aWidget,
if (widget->DropEvent(aWidget, aGdkButtonEvent->window))
{
return PR_TRUE;
return PR_TRUE;
}
widget->OnButtonPressSignal(aGdkButtonEvent);
@ -2173,7 +2193,7 @@ nsWidget::ButtonReleaseSignal(GtkWidget * aWidget,
if (widget->DropEvent(aWidget, aGdkButtonEvent->window))
{
return PR_TRUE;
return PR_TRUE;
}
widget->OnButtonReleaseSignal(aGdkButtonEvent);

Просмотреть файл

@ -363,7 +363,7 @@ private:
//
// Keep track of the last widget being "dragged"
//
static nsWidget * sButtonMotionTarget;
static nsWidget *sButtonMotionTarget;
static gint sButtonMotionRootX;
static gint sButtonMotionRootY;
static gint sButtonMotionWidgetX;

Просмотреть файл

@ -136,9 +136,9 @@ NS_METHOD nsWindow::WidgetToScreen(const nsRect& aOldRect, nsRect& aNewRect)
NS_METHOD nsWindow::ScreenToWidget(const nsRect& aOldRect, nsRect& aNewRect)
{
g_print("nsWidget::ScreenToWidget\n");
NS_NOTYETIMPLEMENTED("nsWidget::ScreenToWidget");
return NS_OK;
g_print("nsWidget::ScreenToWidget\n");
NS_NOTYETIMPLEMENTED("nsWidget::ScreenToWidget");
return NS_OK;
}
@ -264,21 +264,6 @@ NS_METHOD nsWindow::PreCreateWidget(nsWidgetInitData *aInitData)
}
// Drag & Drop stuff.
enum {
TARGET_STRING,
TARGET_ROOTWIN
};
static GtkTargetEntry target_table[] = {
{ "STRING", 0, TARGET_STRING },
{ "text/plain", 0, TARGET_STRING },
{ "application/x-rootwin-drop", 0, TARGET_ROOTWIN }
};
static guint n_targets = sizeof(target_table) / sizeof(target_table[0]);
gint nsWindow::ConvertBorderStyles(nsBorderStyle bs)
{
gint w = 0;
@ -331,7 +316,6 @@ NS_METHOD nsWindow::CreateNative(GtkWidget *parentWidget)
GDK_POINTER_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK);
switch(mWindowType)
{
case eWindowType_dialog:
@ -379,12 +363,6 @@ NS_METHOD nsWindow::CreateNative(GtkWidget *parentWidget)
break;
}
// Initialize this window instance as a drag target.
gtk_drag_dest_set (mWidget,
GTK_DEST_DEFAULT_ALL,
target_table, n_targets - 1, /* no rootwin */
GdkDragAction(GDK_ACTION_COPY | GDK_ACTION_MOVE));
if (mIsToplevel)
{
@ -558,7 +536,7 @@ PRBool nsWindow::OnPaint(nsPaintEvent &event)
static NS_DEFINE_CID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID);
if (NS_OK == nsComponentManager::CreateInstance(kRenderingContextCID,
nsnull,
nsCOMTypeInfo<nsIRenderingContext>::GetIID(),
NS_GET_IID(nsIRenderingContext),
(void **)&event.renderingContext))
{
event.renderingContext->Init(mContext, this);
@ -685,7 +663,7 @@ NS_METHOD nsWindow::Show(PRBool bState)
// For some strange reason, gtk_widget_hide() does not seem to
// unmap the window.
gtk_widget_unmap(mWidget);
// gtk_widget_unmap(mWidget);
}
mShown = bState;
@ -812,24 +790,12 @@ NS_METHOD nsWindow::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
// toplevel window? if so, we should resize it as well.
if (mIsToplevel && mShell)
{
// XXX HACK FIXME
// gtk does not want to resize windows using set_default_size on a window after is is shown
// work around this behavior as we should always resize before we show.
if (GTK_WIDGET_VISIBLE(mShell))
{
gtk_widget_hide(mShell);
gtk_window_set_default_size(GTK_WINDOW(mShell), aWidth, aHeight);
gtk_widget_show(mShell);
}
else
gtk_window_set_default_size(GTK_WINDOW(mShell), aWidth, aHeight);
// gtk_widget_set_usize(mShell, aWidth, aHeight);
gtk_window_set_default_size(GTK_WINDOW(mShell), aWidth, aHeight);
}
gtk_widget_set_usize(mWidget, aWidth, aHeight);
}
// XXX pav
// call the size allocation handler directly to avoid code duplication
// note, this could be a problem as this will make layout think that it