fix mouse clicking

This commit is contained in:
pavlov%pavlov.net 1999-01-18 23:42:04 +00:00
parent cec0019a73
commit 723c42a967
7 changed files with 73 additions and 89 deletions

View File

@ -18,12 +18,30 @@
#include "nsAppShell.h"
#include "nsIAppShell.h"
#include "plevent.h"
#include <stdlib.h>
// XXX -- This is a HACK
extern void nsWebShell_SetUnixEventQueue(PLEventQueue* aEventQueue);
//PLEventQueue* gUnixMainEventQueue = nsnull;
//-------------------------------------------------------------------------
//
// nsAppShell constructor
//
//-------------------------------------------------------------------------
nsAppShell::nsAppShell()
{
mPLEventQueue = nsnull;
mRefCnt = 0;
mDispatchListener = 0;
}
//-------------------------------------------------------------------------
//
// nsAppShell destructor
//
//-------------------------------------------------------------------------
nsAppShell::~nsAppShell()
{
}
//-------------------------------------------------------------------------
//
@ -37,10 +55,17 @@ NS_IMPL_ISUPPORTS(nsAppShell,kIAppShellIID);
NS_METHOD nsAppShell::SetDispatchListener(nsDispatchListener* aDispatchListener)
{
mDispatchListener = aDispatchListener;
return NS_OK;
}
static void event_processor_callback(gpointer data,
gint source,
GdkInputCondition condition)
{
PLEventQueue *event = (PLEventQueue*)data;
PR_ProcessPendingEvents(event);
}
//-------------------------------------------------------------------------
//
// Create the application shell
@ -61,46 +86,18 @@ NS_METHOD nsAppShell::Create(int* argc, char ** argv)
return NS_OK;
}
//-------------------------------------------------------------------------
//
// PLEventQueue Processor
//
//-------------------------------------------------------------------------
/*
static void nsUnixEventProcessorCallback(gpointer data,
gint source,
GdkInputCondition condition)
{
NS_ASSERTION(source==PR_GetEventQueueSelectFD(gUnixMainEventQueue),
"Error in nsUnixMain.cpp:nsUnixEventProcessCallback");
PR_ProcessPendingEvents(gUnixMainEventQueue);
}
*/
//-------------------------------------------------------------------------
//
// Enter a message handler loop
//
//-------------------------------------------------------------------------
// XXX This comes from nsWebShell. If we don't link against nsWebShell
// this will break. FIX ME FIX ME Please!
extern void nsWebShell_SetUnixEventQueue(PLEventQueue* aEventQueue);
NS_METHOD nsAppShell::Run()
{
/*
gUnixMainEventQueue = PR_CreateEventQueue("viewer-event-queue", PR_GetCurrentThread());
if ( mPLEventQueue == NULL )
mPLEventQueue = PL_CreateEventQueue("toolkit", nsnull);
// XXX Setup webshell's event queue. This must be changed
nsWebShell_SetUnixEventQueue(gUnixMainEventQueue);
gdk_input_add(PR_GetEventQueueSelectFD(gUnixMainEventQueue),
gdk_input_add(PR_GetEventQueueSelectFD(mPLEventQueue),
GDK_INPUT_READ,
nsUnixEventProcessorCallback,
NULL);
*/
event_processor_callback,
mPLEventQueue);
nsWebShell_SetUnixEventQueue(mPLEventQueue);
gtk_main();
return NS_OK;
@ -120,26 +117,6 @@ NS_METHOD nsAppShell::Exit()
return NS_OK;
}
//-------------------------------------------------------------------------
//
// nsAppShell constructor
//
//-------------------------------------------------------------------------
nsAppShell::nsAppShell()
{
mRefCnt = 0;
mDispatchListener = 0;
}
//-------------------------------------------------------------------------
//
// nsAppShell destructor
//
//-------------------------------------------------------------------------
nsAppShell::~nsAppShell()
{
}
//-------------------------------------------------------------------------
//
// GetNativeData

View File

@ -20,6 +20,7 @@
#define nsAppShell_h__
#include "nsIAppShell.h"
#include "plevent.h"
#include <gtk/gtk.h>
/**
@ -28,10 +29,6 @@
class nsAppShell : public nsIAppShell
{
private:
GtkWidget *mTopLevel;
nsDispatchListener *mDispatchListener;
public:
nsAppShell();
virtual ~nsAppShell();
@ -39,13 +36,17 @@ class nsAppShell : public nsIAppShell
NS_DECL_ISUPPORTS
// nsIAppShellInterface
NS_IMETHOD Create(int* argc, char ** argv);
NS_IMETHOD Run();
NS_IMETHOD Exit();
NS_IMETHOD SetDispatchListener(nsDispatchListener* aDispatchListener);
virtual void* GetNativeData(PRUint32 aDataType);
NS_IMETHOD Create(int* argc, char ** argv);
NS_IMETHOD Run();
NS_IMETHOD Exit();
NS_IMETHOD SetDispatchListener(nsDispatchListener* aDispatchListener);
virtual void* GetNativeData(PRUint32 aDataType);
// Public global
private:
nsDispatchListener *mDispatchListener;
protected:
PLEventQueue *mPLEventQueue;
};
#endif // nsAppShell_h__

View File

@ -29,7 +29,6 @@
nsToolkit::nsToolkit()
{
NS_INIT_REFCNT();
mPLEventQueue = nsnull;
mSharedGC = nsnull;
}
@ -67,28 +66,12 @@ GdkGC *nsToolkit::GetSharedGC(void)
return mSharedGC;
}
static void event_processor_callback(gpointer data,
gint source,
GdkInputCondition condition)
{
PLEventQueue *event = (PLEventQueue*)data;
PR_ProcessPendingEvents(event);
}
//-------------------------------------------------------------------------
//
//
//-------------------------------------------------------------------------
NS_METHOD nsToolkit::Init(PRThread *aThread)
{
if ( mPLEventQueue == NULL )
mPLEventQueue = PL_CreateEventQueue("toolkit", aThread);
gdk_input_add(PR_GetEventQueueSelectFD(mPLEventQueue),
GDK_INPUT_READ,
event_processor_callback,
mPLEventQueue);
CreateSharedGC();
return NS_OK;

View File

@ -45,7 +45,6 @@ public:
GdkGC *GetSharedGC(void);
private:
PLEventQueue *mPLEventQueue;
GdkGC *mSharedGC;
};

View File

@ -172,7 +172,11 @@ NS_METHOD nsWidget::Move(PRUint32 aX, PRUint32 aY)
mBounds.x = aX;
mBounds.y = aY;
#ifdef USE_GTK_FIXED
::gtk_fixed_move(GTK_FIXED(mWidget->parent), mWidget, aX, aY);
#else
::gtk_layout_move(GTK_LAYOUT(mWidget->parent), mWidget, aX, aY);
#endif
return NS_OK;
}
@ -519,13 +523,17 @@ nsresult nsWidget::CreateWidget(nsIWidget *aParent,
}
CreateNative (parentWidget);
gtk_widget_show(mWidget);
Resize(mBounds.width, mBounds.height, PR_FALSE);
/* place the widget in its parent */
if (parentWidget)
#ifdef USE_GTK_FIXED
gtk_fixed_put(GTK_FIXED(parentWidget), mWidget, mBounds.x, mBounds.y);
#else
gtk_layout_put(GTK_LAYOUT(parentWidget), mWidget, mBounds.x, mBounds.y);
#endif
gtk_widget_pop_colormap();
gtk_widget_pop_visual();

View File

@ -31,6 +31,8 @@
#include <gtk/gtk.h>
// #define USE_GTK_FIXED 1
/**
* Base of all GTK+ native widgets.
*/

View File

@ -142,7 +142,11 @@ NS_METHOD nsWindow::PreCreateWidget(nsWidgetInitData *aInitData)
//-------------------------------------------------------------------------
NS_METHOD nsWindow::CreateNative(GtkWidget *parentWidget)
{
#ifdef USE_GTK_FIXED
mWidget = gtk_fixed_new();
#else
mWidget = gtk_layout_new(PR_FALSE, PR_FALSE);
#endif
GTK_WIDGET_SET_FLAGS(mWidget, GTK_CAN_FOCUS);
gtk_widget_set_events (mWidget,
@ -242,7 +246,11 @@ void *nsWindow::GetNativeData(PRUint32 aDataType)
{
switch(aDataType) {
case NS_NATIVE_WINDOW:
#ifndef USE_GTK_FIXED
return (void *)GTK_LAYOUT(mWidget)->bin_window;
#else
return (void *)mWidget->window;
#endif
case NS_NATIVE_DISPLAY:
return (void *)GDK_DISPLAY();
case NS_NATIVE_WIDGET:
@ -272,6 +280,7 @@ NS_METHOD nsWindow::SetColorMap(nsColorMap *aColorMap)
//-------------------------------------------------------------------------
NS_METHOD nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect)
{
#ifndef USE_GTK_FIXED
if (GTK_IS_LAYOUT(mWidget)) {
GtkAdjustment* horiz = gtk_layout_get_hadjustment(GTK_LAYOUT(mWidget));
GtkAdjustment* vert = gtk_layout_get_vadjustment(GTK_LAYOUT(mWidget));
@ -280,6 +289,7 @@ NS_METHOD nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect)
gtk_adjustment_value_changed(horiz);
gtk_adjustment_value_changed(vert);
}
#endif
return NS_OK;
}
@ -341,13 +351,17 @@ PRBool nsWindow::OnPaint(nsPaintEvent &event)
NS_METHOD nsWindow::BeginResizingChildren(void)
{
#ifndef USE_GTK_FIXED
gtk_layout_freeze(GTK_LAYOUT(mWidget));
#endif
return NS_OK;
}
NS_METHOD nsWindow::EndResizingChildren(void)
{
#ifndef USE_GTK_FIXED
gtk_layout_thaw(GTK_LAYOUT(mWidget));
#endif
return NS_OK;
}