Rewrote the resize handler. This fixes the crashes at startup. There are

still conditions to make this go into infinite loop.
All callbacks/event handlers now return proper values.
This commit is contained in:
msw%gimp.org 1998-11-30 05:53:17 +00:00
Родитель 91798f3747
Коммит ada6ca7ced
4 изменённых файлов: 187 добавлений и 149 удалений

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

@ -221,7 +221,7 @@ static Bool checkForExpose(Display *dpy, XEvent *evt, XtPointer client_data)
#endif
//==============================================================
void nsGtkWidget_ExposureMask_EventHandler(GtkWidget *w, GdkEventExpose *event, gpointer p)
gint nsGtkWidget_ExposureMask_EventHandler(GtkWidget *w, GdkEventExpose *event, gpointer p)
{
nsWindow *widgetWindow = (nsWindow *)p;
@ -235,12 +235,8 @@ void nsGtkWidget_ExposureMask_EventHandler(GtkWidget *w, GdkEventExpose *event,
rect.width = event->area.width;
rect.height = event->area.height;
if (widgetWindow->GetResized())
return;
if (event->type == GDK_NO_EXPOSE) {
return;
return FALSE;
}
/* FIXME
Display* display = XtDisplay(w);
@ -257,66 +253,80 @@ void nsGtkWidget_ExposureMask_EventHandler(GtkWidget *w, GdkEventExpose *event,
}
*/
widgetWindow->OnPaint(pevent);
return FALSE;
}
//==============================================================
void nsGtkWidget_ButtonPressMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
gint nsGtkWidget_ButtonPressMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
{
nsWindow *widgetWindow = (nsWindow *)p;
nsMouseEvent mevent;
nsGtkWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_LEFT_BUTTON_DOWN);
widgetWindow->DispatchMouseEvent(mevent);
return FALSE;
}
//==============================================================
void nsGtkWidget_ButtonReleaseMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
gint nsGtkWidget_ButtonReleaseMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
{
nsWindow *widgetWindow = (nsWindow *)p;
nsMouseEvent mevent;
nsGtkWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_LEFT_BUTTON_UP);
widgetWindow->DispatchMouseEvent(mevent);
return FALSE;
}
//==============================================================
void nsGtkWidget_ButtonMotionMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
gint nsGtkWidget_ButtonMotionMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
{
nsPaintEvent pevent;
nsWindow *widgetWindow = (nsWindow *)p;
nsMouseEvent mevent;
nsGtkWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_MOVE);
widgetWindow->DispatchMouseEvent(mevent);
return FALSE;
}
//==============================================================
void nsGtkWidget_MotionMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
gint nsGtkWidget_MotionMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
{
nsWindow *widgetWindow = (nsWindow *)p;
nsMouseEvent mevent;
nsGtkWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_MOVE);
widgetWindow->DispatchMouseEvent(mevent);
return FALSE;
}
//==============================================================
void nsGtkWidget_EnterMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
gint nsGtkWidget_EnterMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
{
nsWindow *widgetWindow = (nsWindow *)p;
nsMouseEvent mevent;
nsGtkWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_ENTER);
widgetWindow->DispatchMouseEvent(mevent);
return FALSE;
}
//==============================================================
void nsGtkWidget_LeaveMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
gint nsGtkWidget_LeaveMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
{
if (DBG) fprintf(stderr, "***************** nsGtkWidget_LeaveMask_EventHandler\n");
nsWindow * widgetWindow = (nsWindow *)p;
nsMouseEvent mevent;
nsGtkWidget_InitNSMouseEvent(event, p, mevent, NS_MOUSE_EXIT);
widgetWindow->DispatchMouseEvent(mevent);
return FALSE;
}
//==============================================================
void nsGtkWidget_Focus_Callback(GtkWidget *w, gpointer p)
gint nsGtkWidget_Focus_Callback(GtkWidget *w, gpointer p)
{
nsWindow *widgetWindow = (nsWindow*)gtk_object_get_user_data(GTK_OBJECT(w));
#if 0
@ -328,10 +338,12 @@ void nsGtkWidget_Focus_Callback(GtkWidget *w, gpointer p)
cbs->reason == XmCR_FOCUS?NS_GOTFOCUS:NS_LOSTFOCUS);
widgetWindow->DispatchFocus(event);
#endif
return FALSE;
}
//==============================================================
void nsGtkWidget_Toggle_Callback(GtkWidget *w, gpointer p)
gint nsGtkWidget_Toggle_Callback(GtkWidget *w, gpointer p)
{
nsWindow *widgetWindow = (nsWindow*)gtk_object_get_user_data(GTK_OBJECT(w));
#if 0
@ -341,20 +353,24 @@ void nsGtkWidget_Toggle_Callback(GtkWidget *w, gpointer p)
nsScrollbarEvent sevent;
XmToggleButtonCallbackStruct * cbs = (XmToggleButtonCallbackStruct*)call_data;
#endif
return FALSE;
}
//==============================================================
void CheckButton_Toggle_Callback(GtkWidget *w, gpointer p)
gint nsGtkWidget_CheckButton_Toggle_Callback(GtkWidget *w, gpointer p)
{
nsCheckButton *checkBtn = (nsCheckButton*)gtk_object_get_user_data(GTK_OBJECT(w));
if (GTK_TOGGLE_BUTTON(w)->active)
checkBtn->Armed();
else
checkBtn->DisArmed();
return FALSE;
}
//==============================================================
void nsGtkWidget_RadioButton_ArmCallback(GtkWidget *w, gpointer p)
gint nsGtkWidget_RadioButton_ArmCallback(GtkWidget *w, gpointer p)
{
nsWindow *widgetWindow = (nsWindow*)gtk_object_get_user_data(GTK_OBJECT(w));
#if 0
@ -365,10 +381,12 @@ void nsGtkWidget_RadioButton_ArmCallback(GtkWidget *w, gpointer p)
nsGtkWidget_InitNSMouseEvent(cbs->event, p, mevent, NS_MOUSE_LEFT_BUTTON_DOWN);
radioBtn->DispatchMouseEvent(mevent);
#endif
return FALSE;
}
//==============================================================
void nsGtkWidget_RadioButton_DisArmCallback(GtkWidget *w, gpointer p)
gint nsGtkWidget_RadioButton_DisArmCallback(GtkWidget *w, gpointer p)
{
nsWindow *widgetWindow = (nsWindow*)gtk_object_get_user_data(GTK_OBJECT(w));
#if 0
@ -380,11 +398,13 @@ void nsGtkWidget_RadioButton_DisArmCallback(GtkWidget *w, gpointer p)
nsGtkWidget_InitNSMouseEvent(cbs->event, p, mevent, NS_MOUSE_LEFT_BUTTON_UP);
radioBtn->DispatchMouseEvent(mevent);
#endif
return FALSE;
}
//==============================================================
void nsGtkWidget_Scrollbar_Callback(GtkWidget *w, gpointer p)
gint nsGtkWidget_Scrollbar_Callback(GtkWidget *w, gpointer p)
{
// nsScrollbar *widget = (nsScrollbar*)gtk_object_get_user_data(GTK_OBJECT(w));
nsScrollbar *widget = (nsScrollbar*) p;
@ -441,7 +461,7 @@ void nsGtkWidget_Scrollbar_Callback(GtkWidget *w, gpointer p)
//==============================================================
void nsGtkWidget_Expose_Callback(GtkWidget *w, gpointer p)
gint nsGtkWidget_Expose_Callback(GtkWidget *w, gpointer p)
{
nsWindow *widgetWindow = (nsWindow*)gtk_object_get_user_data(GTK_OBJECT(w));
#if 0
@ -461,12 +481,7 @@ void nsGtkWidget_Expose_Callback(GtkWidget *w, gpointer p)
}
//==============================================================
void nsGtkWidget_Resize_Callback(GtkWidget *w, gpointer p)
{
}
//==============================================================
void nsGtkWidget_Text_Callback(GtkWidget *w, GdkEvent* event, gpointer p)
gint nsGtkWidget_Text_Callback(GtkWidget *w, GdkEvent* event, gpointer p)
{
nsKeyEvent kevent;
nsGtkWidget_InitNSKeyEvent(NS_KEY_UP, kevent, w, p, event);
@ -510,7 +525,7 @@ void nsGtkWidget_Text_Callback(GtkWidget *w, GdkEvent* event, gpointer p)
}
//==============================================================
void nsGtkWidget_FSBCancel_Callback(GtkWidget *w, gpointer p)
gint nsGtkWidget_FSBCancel_Callback(GtkWidget *w, gpointer p)
{
nsWindow *widgetWindow = (nsWindow*)gtk_object_get_user_data(GTK_OBJECT(w));
#if 0
@ -519,10 +534,12 @@ void nsGtkWidget_FSBCancel_Callback(GtkWidget *w, gpointer p)
widgetWindow->OnCancel();
}
#endif
return FALSE;
}
//==============================================================
void nsGtkWidget_FSBOk_Callback(GtkWidget *w, gpointer p)
gint nsGtkWidget_FSBOk_Callback(GtkWidget *w, gpointer p)
{
nsWindow *widgetWindow = (nsWindow*)gtk_object_get_user_data(GTK_OBJECT(w));
#if 0
@ -531,6 +548,8 @@ void nsGtkWidget_FSBOk_Callback(GtkWidget *w, gpointer p)
widgetWindow->OnOk();
}
#endif
return FALSE;
}
//==============================================================
@ -551,25 +570,29 @@ void nsGtkWidget_InitNSKeyEvent(int aEventType, nsKeyEvent& aKeyEvent,
}
//==============================================================
void nsGtkWidget_KeyPressMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
gint nsGtkWidget_KeyPressMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
{
nsKeyEvent kevent;
nsGtkWidget_InitNSKeyEvent(NS_KEY_DOWN, kevent, w, p, event);
nsWindow * widgetWindow = (nsWindow *) p ;
widgetWindow->OnKey(NS_KEY_DOWN, kevent.keyCode, &kevent);
return FALSE;
}
//==============================================================
void nsGtkWidget_KeyReleaseMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
gint nsGtkWidget_KeyReleaseMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p)
{
nsKeyEvent kevent;
nsGtkWidget_InitNSKeyEvent(NS_KEY_UP, kevent, w, p, event);
nsWindow * widgetWindow = (nsWindow *) p ;
widgetWindow->OnKey(NS_KEY_UP, kevent.keyCode, &kevent);
return FALSE;
}
//==============================================================
void nsGtkWidget_Menu_Callback(GtkWidget *w, gpointer p)
gint nsGtkWidget_Menu_Callback(GtkWidget *w, gpointer p)
{
nsIMenuItem * menuItem = (nsIMenuItem *)p;
if (menuItem != NULL) {
@ -585,4 +608,52 @@ void nsGtkWidget_Menu_Callback(GtkWidget *w, gpointer p)
nsEventStatus status;
mevent.widget->DispatchEvent((nsGUIEvent *)&mevent, status);
}
return FALSE;
}
gint nsGtkWidget_Resize_EventHandler(GtkWidget *w, GtkAllocation *allocation, gpointer data)
{
nsWindow *win = (nsWindow*)data;
nsRect winBounds, sizeBounds;
win->GetBounds(winBounds);
g_print("resize event handler:\n\tallocation->w=%d allocation->h=%d window.w=%d window.h=%d\n",
allocation->width, allocation->height, winBounds.width, winBounds.height);
if (winBounds.width != allocation->width ||
winBounds.height != allocation->height) {
g_print("\tAllocation != current window bounds. Resize.\n");
nsSizeEvent sizeEvent;
sizeEvent.eventStructType = NS_SIZE_EVENT;
sizeEvent.message = NS_SIZE;
sizeEvent.point.x = winBounds.x;
sizeEvent.point.y = winBounds.y;
sizeEvent.time = PR_IntervalNow();
// nsGUIEvent
sizeEvent.widget = win;
sizeEvent.nativeMsg = nsnull;
winBounds.width = sizeBounds.width = allocation->width;
winBounds.height = sizeBounds.height = allocation->height;
sizeBounds.x = 0;
sizeBounds.y = 0;
// nsSizeEvent
sizeEvent.windowSize = &sizeBounds;
sizeEvent.mWinWidth = winBounds.width;
sizeEvent.mWinHeight = winBounds.height;
win->OnResize(sizeEvent);
// win->SetBounds(winBounds);
nsPaintEvent pevent;
pevent.message = NS_PAINT;
pevent.widget = win;
pevent.time = PR_IntervalNow();
pevent.rect = (nsRect *)&sizeBounds;
win->OnPaint(pevent);
}
return FALSE;
}

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

@ -16,44 +16,44 @@
* Reserved.
*/
#ifndef __nsXtEventHandler_h
#define __nsXtEventHandler_h
#ifndef __nsGtkEventHandler_h
#define __nsGtkEventHandler_h
#include <gtk/gtk.h>
#include <gdk/gdk.h>
class nsIWidget;
class nsIMenuItem;
void nsGtkWidget_KeyPressMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p);
void nsGtkWidget_KeyReleaseMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p);
void nsGtkWidget_ExposureMask_EventHandler(GtkWidget * w, GdkEventExpose * event, gpointer p);
void nsGtkWidget_ButtonPressMask_EventHandler(GtkWidget * w, GdkEvent * event, gpointer p);
void nsGtkWidget_ButtonReleaseMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p);
void nsGtkWidget_ButtonMotionMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p);
void nsGtkWidget_MotionMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p);
void nsGtkWidget_EnterMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p);
void nsGtkWidget_LeaveMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p);
//----------------------------------------------------
void nsGtkWidget_FSBCancel_Callback(GtkWidget *w, gpointer p);
void nsGtkWidget_FSBOk_Callback(GtkWidget *w, gpointer p);
gint nsGtkWidget_KeyPressMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p);
gint nsGtkWidget_KeyReleaseMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p);
gint nsGtkWidget_ExposureMask_EventHandler(GtkWidget * w, GdkEventExpose * event, gpointer p);
gint nsGtkWidget_ButtonPressMask_EventHandler(GtkWidget * w, GdkEvent * event, gpointer p);
gint nsGtkWidget_ButtonReleaseMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p);
gint nsGtkWidget_ButtonMotionMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p);
gint nsGtkWidget_MotionMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p);
gint nsGtkWidget_EnterMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p);
gint nsGtkWidget_LeaveMask_EventHandler(GtkWidget *w, GdkEvent * event, gpointer p);
gint nsGtkWidget_Resize_EventHandler(GtkWidget *w, GtkAllocation *allocation, gpointer data);
//----------------------------------------------------
void nsGtkWidget_Focus_Callback(GtkWidget *w, gpointer p);
void nsGtkWidget_Scrollbar_Callback(GtkWidget *w, gpointer p);
void CheckButton_Toggle_Callback(GtkWidget *w, gpointer p);
gint nsGtkWidget_FSBCancel_Callback(GtkWidget *w, gpointer p);
gint nsGtkWidget_FSBOk_Callback(GtkWidget *w, gpointer p);
void nsGtkWidget_RadioButton_ArmCallback(GtkWidget *w, gpointer p);
void nsGtkWidget_RadioButton_DisArmCallback(GtkWidget *w, gpointer p);
//----------------------------------------------------
gint nsGtkWidget_Focus_Callback(GtkWidget *w, gpointer p);
gint nsGtkWidget_Scrollbar_Callback(GtkWidget *w, gpointer p);
void nsGtkWidget_Text_Callback(GtkWidget *w, GdkEvent* event, gpointer p);
void nsGtkWidget_Resize_Callback(GtkWidget *w, gpointer p);
void nsGtkWidget_Expose_Callback(GtkWidget *w, gpointer p);
gint CheckButton_Toggle_Callback(GtkWidget *w, gpointer p);
void nsGtkWidget_Refresh_Callback(gpointer call_data);
gint nsGtkWidget_RadioButton_ArmCallback(GtkWidget *w, gpointer p);
gint nsGtkWidget_RadioButton_DisArmCallback(GtkWidget *w, gpointer p);
void nsGtkWidget_Menu_Callback(GtkWidget *w, gpointer p);
gint nsGtkWidget_Text_Callback(GtkWidget *w, GdkEvent* event, gpointer p);
gint nsGtkWidget_Expose_Callback(GtkWidget *w, gpointer p);
#endif // __nsXtEventHandler.h
gint nsGtkWidget_Refresh_Callback(gpointer call_data);
gint nsGtkWidget_Menu_Callback(GtkWidget *w, gpointer p);
#endif // __nsGtkEventHandler.h

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

@ -29,11 +29,11 @@
g.green=NS_GET_G(n); \
g.blue=NS_GET_R(n);
// #define DBG 1
//#define DBG 1
nsWidget::nsWidget()
{
// XXX Shouldn't this be done in nsBaseWidget?
// XXX Shouldn't this be done in nsBaseWidget?
NS_INIT_REFCNT();
mBackground = NS_RGB(214,214,214);
mGC = nsnull;
@ -136,23 +136,41 @@ NS_METHOD nsWidget::IsVisible(PRBool &aState)
NS_METHOD nsWidget::Move(PRUint32 aX, PRUint32 aY)
{
#ifdef DBG
g_print("nsWidget::Move(%3d,%3d) - %s %p\n", aX, aY, mWidget->name, this);
g_print("nsWidget::Move(%3d,%3d) - %s %p\n", aX, aY, mWidget->name, this);
#endif
mBounds.x = aX;
mBounds.y = aY;
gtk_layout_move(GTK_LAYOUT(mWidget->parent), mWidget, aX, aY);
//XtVaSetValues(mWidget, XmNx, aX, XmNy, GetYCoord(aY), nsnull);
return NS_OK;
}
NS_METHOD nsWidget::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint)
{
#ifdef DBG
g_print("nsWidget::Resize(%3d,%3d) - %s %p\n", aWidth, aHeight, mWidget->name, this);
g_print("nsWidget::Resize(%3d,%3d) - %s %p %s\n", aWidth, aHeight, mWidget->name, this, aRepaint ? "paint" : "no paint");
#endif
mBounds.width = aWidth;
mBounds.height = aHeight;
gtk_widget_set_usize(mWidget, aWidth, aHeight);
if (aRepaint && GTK_IS_WIDGET (mWidget) &&
GTK_WIDGET_REALIZED (GTK_WIDGET(mWidget))) {
GdkEventExpose event;
event.type = GDK_EXPOSE;
event.send_event = TRUE;
event.window = GTK_WIDGET(mWidget)->window;
event.area.width = mBounds.width;
event.area.height = mBounds.height;
event.area.x = 0;
event.area.y = 0;
event.count = 0;
gdk_window_ref (event.window);
gtk_widget_event (GTK_WIDGET(mWidget), (GdkEvent*) &event);
gdk_window_unref (event.window);
}
return NS_OK;
}
@ -218,7 +236,7 @@ NS_METHOD nsWidget::SetForegroundColor(const nscolor &aColor)
style = gtk_style_copy(mWidget->style);
style->fg[GTK_STATE_NORMAL] = color;
gtk_widget_set_style(mWidget, style);
return NS_OK;
}
@ -251,7 +269,7 @@ NS_METHOD nsWidget::SetBackgroundColor(const nscolor &aColor)
style = gtk_style_copy(mWidget->style);
style->bg[GTK_STATE_NORMAL] = color;
gtk_widget_set_style(mWidget, style);
return NS_OK;
}
@ -297,20 +315,20 @@ NS_METHOD nsWidget::SetCursor(nsCursor aCursor)
{
if (!mWidget || !mWidget->window)
return NS_ERROR_FAILURE;
// Only change cursor if it's changing
if (aCursor != mCursor) {
GdkCursor *newCursor = 0;
switch(aCursor) {
case eCursor_select:
newCursor = gdk_cursor_new(GDK_XTERM);
break;
case eCursor_wait:
newCursor = gdk_cursor_new(GDK_WATCH);
break;
case eCursor_hyperlink:
newCursor = gdk_cursor_new(GDK_HAND2);
break;
@ -343,7 +361,7 @@ NS_METHOD nsWidget::SetCursor(nsCursor aCursor)
NS_ASSERTION(PR_FALSE, "Invalid cursor type");
break;
}
if (nsnull != newCursor) {
mCursor = aCursor;
gdk_window_set_cursor(mWidget->window, newCursor);
@ -475,7 +493,7 @@ nsresult nsWidget::StandardWindowCreate(nsIWidget *aParent,
gtk_widget_push_colormap(gdk_rgb_get_cmap());
gtk_widget_push_visual(gdk_rgb_get_visual());
BaseCreate(aParent, aRect, aHandleEventFunction, aContext,
BaseCreate(aParent, aRect, aHandleEventFunction, aContext,
aAppShell, aToolkit, aInitData);
if (aParent) {
@ -511,7 +529,7 @@ nsresult nsWidget::StandardWindowCreate(nsIWidget *aParent,
gtk_widget_pop_colormap();
gtk_widget_pop_visual();
return NS_OK;
}

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

@ -18,7 +18,6 @@
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include "gtklayout.h"
#include <gtk/gtkprivate.h>
#include "nsWindow.h"
@ -45,8 +44,7 @@ static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID);
extern GtkWidget *gAppContext;
void DoResize(GtkWidget *w, GtkAllocation *allocation, gpointer data);
static void window_realize_callback(GtkWidget *window, gpointer data);
static gint window_realize_callback(GtkWidget *window, gpointer data);
static void set_icon (GdkWindow * w);
//-------------------------------------------------------------------------
@ -122,10 +120,12 @@ NS_METHOD nsWindow::RemoveTooltips()
return NS_OK;
}
static void window_realize_callback(GtkWidget *window, gpointer data)
static gint window_realize_callback(GtkWidget *window, gpointer data)
{
if (window->window)
set_icon(window->window);
return FALSE;
}
static void set_icon (GdkWindow * w)
@ -250,19 +250,7 @@ void nsWindow::InitCallbacks(char * aName)
"motion_notify_event",
GTK_SIGNAL_FUNC(nsGtkWidget_ButtonMotionMask_EventHandler),
this);
/*
XtAddEventHandler(mWidget,
PointerMotionMask,
PR_FALSE,
nsXtWidget_MotionMask_EventHandler,
this);
XtAddEventHandler(mWidget,
EnterWindowMask,
PR_FALSE,
nsXtWidget_EnterMask_EventHandler,
this);
*/
gtk_signal_connect(GTK_OBJECT(mWidget),
"enter_notify_event",
GTK_SIGNAL_FUNC(nsGtkWidget_EnterMask_EventHandler),
@ -290,8 +278,8 @@ void nsWindow::InitCallbacks(char * aName)
gtk_signal_connect(GTK_OBJECT(mWidget),
"size_allocate",
GTK_SIGNAL_FUNC(DoResize),
this);
GTK_SIGNAL_FUNC(nsGtkWidget_Resize_EventHandler),
this);
}
//-------------------------------------------------------------------------
@ -316,7 +304,7 @@ NS_METHOD nsWindow::Show(PRBool bState)
//-------------------------------------------------------------------------
NS_METHOD nsWindow::Resize(PRUint32 aWidth, PRUint32 aHeight, PRBool aRepaint)
{
nsWidget::Resize(aWidth, aHeight,aRepaint);
nsWidget::Resize(aWidth, aHeight, aRepaint);
#if 0
NS_NOTYETIMPLEMENTED("nsWindow::Resize");
if (DBG) printf("$$$$$$$$$ %s::Resize %d %d Repaint: %s\n",
@ -340,15 +328,7 @@ NS_METHOD nsWindow::Resize(PRUint32 aX, PRUint32 aY, PRUint32 aWidth, PRUint32 a
{
nsWindow::Resize(aWidth, aHeight, aRepaint);
nsWidget::Move(aX,aY);
#if 0
NS_NOTYETIMPLEMENTED("nsWindow::Resize");
mBounds.x = aX;
mBounds.y = aY;
mBounds.width = aWidth;
mBounds.height = aHeight;
XtVaSetValues(mWidget, XmNx, aX, XmNy, GetYCoord(aY),
XmNwidth, aWidth, XmNheight, aHeight, nsnull);
#endif
return NS_OK;
}
@ -360,7 +340,7 @@ NS_METHOD nsWindow::Resize(PRUint32 aX, PRUint32 aY, PRUint32 aWidth, PRUint32 a
NS_METHOD nsWindow::SetBounds(const nsRect &aRect)
{
mBounds = aRect;
//Resize(mBounds.x, mBounds.y, mBounds.width, mBounds.height, PR_TRUE);
return NS_OK;
}
@ -784,44 +764,41 @@ PRUint32 nsWindow::GetYCoord(PRUint32 aNewY)
}
//
//-----------------------------------------------------
// Resize handler code for child and main windows.
//-----------------------------------------------------
//
gint ResetResize(gpointer call_data)
static gint DoResize(GtkWidget *w, GtkAllocation *allocation, gpointer data)
{
nsWindow* widgetWindow = (nsWindow*)call_data;
widgetWindow->SetResized(PR_FALSE);
return FALSE;
}
nsWindow *win = (nsWindow*)data;
gint DoRefresh(gpointer call_data)
{
nsWindow *win = (nsWindow*)call_data;
nsRect bounds;
win->GetResizeRect(&bounds);
nsRect bounds;
win->GetBounds(bounds);
g_print("DoResized called a->w %d a->h %d b.w %d b.h %d\n",
allocation->width, allocation->height, bounds.width, bounds.height);
if (bounds.width != allocation->width ||
bounds.height != allocation->height) {
g_print("RESIZE!\n");
nsSizeEvent sizeEvent;
sizeEvent.eventStructType = NS_SIZE_EVENT;
sizeEvent.message = NS_SIZE;
sizeEvent.point.x = 0;
sizeEvent.point.y = 0;
sizeEvent.point.x = bounds.x;
sizeEvent.point.y = bounds.y;
sizeEvent.time = PR_IntervalNow();
// nsGUIEvent
sizeEvent.widget = win;
sizeEvent.nativeMsg = nsnull;
bounds.width = allocation->width;
bounds.height = allocation->height;
bounds.x = 0;
bounds.y = 0;
// nsSizeEvent
sizeEvent.windowSize = &bounds;
sizeEvent.mWinWidth = bounds.width;
sizeEvent.mWinHeight = bounds.height;
win->SetBounds(bounds);
win->OnResize(sizeEvent);
win->SetBounds(bounds);
nsPaintEvent pevent;
pevent.message = NS_PAINT;
@ -829,36 +806,8 @@ gint DoRefresh(gpointer call_data)
pevent.time = PR_IntervalNow();
pevent.rect = (nsRect *)&bounds;
win->OnPaint(pevent);
// gtk_idle_add((GtkFunction)ResetResize, win);
gtk_timeout_add(10, (GtkFunction)ResetResize, win);
return FALSE;
}
void DoResize(GtkWidget *w, GtkAllocation *allocation, gpointer data)
{
// g_print("DoResized called\n");
nsWindow *win = (nsWindow*)data;
nsRect bounds;
bounds.width = allocation->width;
bounds.height = allocation->height;
bounds.x = 0;
bounds.y = 0;
win->SetResizeRect(bounds);
if (!win->GetResized()) {
if (win->IsChild()) {
DoRefresh(win);
}
else {
// gtk_idle_add((GtkFunction)DoRefresh, win);
gtk_timeout_add(250, (GtkFunction)DoRefresh, win);
}
}
win->SetResized(PR_TRUE);
return TRUE; /* Stop the handling of this signal */
}
NS_METHOD nsWindow::SetMenuBar(nsIMenuBar * aMenuBar)