Loading widget/src/gtk/nsGtkEventHandler.cpp +6 −14 Original line number Diff line number Diff line Loading @@ -167,12 +167,11 @@ void nsGtkWidget_InitNSMouseEvent(GdkEvent *aGev, if (anXEv != NULL) { // Do Mouse Event specific intialization anEvent.time = anXEv->time; /* anEvent.isShift = (anXEv->xbutton.state & ShiftMask) ? PR_TRUE : PR_FALSE; anEvent.isControl = (anXEv->xbutton.state & ControlMask) ? PR_TRUE : PR_FALSE; anEvent.isAlt = (anXEv->xbutton.state & Mod1Mask) ? PR_TRUE : PR_FALSE; */ anEvent.clickCount = anXEv->button; //XXX Fix for double-clicks anEvent.isShift = (anXEv->state & ShiftMask) ? PR_TRUE : PR_FALSE; anEvent.isControl = (anXEv->state & ControlMask) ? PR_TRUE : PR_FALSE; anEvent.isAlt = (anXEv->state & Mod1Mask) ? PR_TRUE : PR_FALSE; // anEvent.clickCount = anXEv->button; //XXX Fix for double-clicks anEvent.clickCount = 1; //XXX Fix for double-clicks anEvent.eventStructType = NS_MOUSE_EVENT; } Loading Loading @@ -228,7 +227,6 @@ void nsGtkWidget_ExposureMask_EventHandler(GtkWidget *w, GdkEventExpose *event, nsRect rect; nsGtkWidget_InitNSEvent((GdkEvent*)event, p, pevent, NS_PAINT); pevent.rect = (nsRect *)▭ XEvent xev; rect.x = event->area.x; rect.y = event->area.y; Loading @@ -245,6 +243,7 @@ void nsGtkWidget_ExposureMask_EventHandler(GtkWidget *w, GdkEventExpose *event, /* FIXME Display* display = XtDisplay(w); Window window = XtWindow(w); XEvent xev; XSync(display, FALSE); Loading Loading @@ -565,13 +564,6 @@ void nsGtkWidget_KeyReleaseMask_EventHandler(GtkWidget *w, GdkEvent * event, gpo widgetWindow->OnKey(NS_KEY_UP, kevent.keyCode, &kevent); } //============================================================== void nsGtkWidget_ResetResize_Callback(gpointer call_data) { nsWindow* widgetWindow = (nsWindow*)call_data; widgetWindow->SetResized(PR_FALSE); } //============================================================== void nsGtkWidget_Menu_Callback(GtkWidget *w, gpointer p) { Loading widget/src/gtk/nsGtkEventHandler.h +0 −2 Original line number Diff line number Diff line Loading @@ -54,8 +54,6 @@ void nsGtkWidget_Expose_Callback(GtkWidget *w, gpointer p); void nsGtkWidget_Refresh_Callback(gpointer call_data); void nsGtkWidget_ResetResize_Callback(gpointer p); void nsGtkWidget_Menu_Callback(GtkWidget *w, gpointer p); #endif // __nsXtEventHandler.h Loading widget/src/gtk/nsWindow.cpp +70 −45 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ #include "stdio.h" #define DBG 0 #define DBG 1 #if 0 #define DEBUG_shaver 1 #define DEBUG_pavlov 1 Loading @@ -45,6 +45,8 @@ static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID); extern GtkWidget *gAppContext; void DoResize(GtkWidget *w, GtkAllocation *allocation, gpointer data); //------------------------------------------------------------------------- // // nsWindow constructor Loading Loading @@ -214,6 +216,10 @@ void nsWindow::InitCallbacks(char * aName) "key_release_event", GTK_SIGNAL_FUNC(nsGtkWidget_KeyReleaseMask_EventHandler), this); gtk_signal_connect(GTK_OBJECT(mWidget), "size_allocate", GTK_SIGNAL_FUNC(DoResize), this); } //------------------------------------------------------------------------- Loading Loading @@ -480,10 +486,13 @@ nsIAppShell* nsWindow::GetAppShell() //------------------------------------------------------------------------- NS_METHOD nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) { #ifdef DBG g_print("nsWindow::Scroll\n"); #endif if (GTK_IS_LAYOUT(mWidget)) { #ifdef DBG g_print ("is layout dX = %d, dY = %d\n", aDx, aDy); #endif GtkAdjustment* horiz = gtk_layout_get_hadjustment(GTK_LAYOUT(mWidget)); GtkAdjustment* vert = gtk_layout_get_vadjustment(GTK_LAYOUT(mWidget)); horiz->value -= aDx; Loading Loading @@ -631,6 +640,13 @@ void nsWindow::OnDestroy() PRBool nsWindow::OnResize(nsSizeEvent &aEvent) { #ifdef DBG g_print("nsWindow::OnResize\n"); #endif if (GetResized() == PR_TRUE) return FALSE; nsRect* size = aEvent.windowSize; if (mEventCallback && !mIgnoreResize) { Loading Loading @@ -659,7 +675,9 @@ PRBool nsWindow::DispatchFocus(nsGUIEvent &aEvent) PRBool nsWindow::OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos) { #ifdef DBG g_print("nsWindow::OnScroll\n"); #endif return FALSE; } Loading Loading @@ -755,70 +773,75 @@ PRUint32 nsWindow::GetYCoord(PRUint32 aNewY) //----------------------------------------------------- // gint nsWindow_Refresh_Callback(gpointer p) gint ResetResize(gpointer call_data) { nsWindow* widgetWindow = (nsWindow*)call_data; widgetWindow->SetResized(PR_FALSE); return FALSE; } gint DoRefresh(gpointer call_data) { nsWindow* widgetWindow = (nsWindow*)p; nsWindow *win = (nsWindow*)call_data; nsRect bounds; widgetWindow->GetResizeRect(&bounds); win->GetResizeRect(&bounds); nsSizeEvent sizeEvent; sizeEvent.eventStructType = NS_SIZE_EVENT; sizeEvent.message = NS_SIZE; sizeEvent.point.x = 0; sizeEvent.point.y = 0; sizeEvent.time = PR_IntervalNow(); // nsGUIEvent sizeEvent.widget = win; sizeEvent.nativeMsg = nsnull; nsSizeEvent event; event.message = NS_SIZE; event.widget = widgetWindow; event.time = 0; //TBD event.windowSize = &bounds; // nsSizeEvent sizeEvent.windowSize = &bounds; sizeEvent.mWinWidth = bounds.width; sizeEvent.mWinHeight = bounds.height; win->SetBounds(bounds); win->OnResize(sizeEvent); widgetWindow->SetBounds(bounds); widgetWindow->OnResize(event); nsPaintEvent pevent; pevent.message = NS_PAINT; pevent.widget = widgetWindow; pevent.time = 0; pevent.widget = win; pevent.time = PR_IntervalNow(); pevent.rect = (nsRect *)&bounds; widgetWindow->OnPaint(pevent); win->OnPaint(pevent); gtk_timeout_add (50, (GtkFunction)nsGtkWidget_ResetResize_Callback, widgetWindow); gtk_timeout_add(50, (GtkFunction)ResetResize, win); return FALSE; } // // Resize a child window widget. All nsManageWidget's use // this to resize. The nsManageWidget passes all resize // request's directly to this function. extern "C" void nsWindow_ResizeWidget(GtkWidget *w) void DoResize(GtkWidget *w, GtkAllocation *allocation, gpointer data) { int width = 0; int height = 0; nsWindow *win = 0; g_print("DoResized called\n"); nsWindow *win = (nsWindow*)data; // Get the new size for the window win = gtk_object_get_user_data(GTK_OBJECT(w)); width = w->allocation.width; height = w->allocation.height; // XtVaGetValues(w, XmNuserData, &win, XmNwidth, &width, XmNheight, &height, nsnull); // Setup the resize rectangle for the window. nsRect bounds; bounds.width = width; bounds.height = height; bounds.width = allocation->width; bounds.height = allocation->height; bounds.x = 0; bounds.y = 0; win->SetResizeRect(bounds); if (!win->GetResized()) { DoRefresh(win); } /* if (!win->GetResized()) { if (win->IsChild()) { // Call refresh directly. Don't filter resize events. nsWindow_Refresh_Callback(win); } else { // XXX: KLUDGE: Do actual resize later. This lets most // of the resize events come through before actually // resizing. This is only needed for main (shell) // windows. This should be replaced with code that actually // Compresses the event queue. gtk_timeout_add (250, (GtkFunction)nsWindow_Refresh_Callback, win); gtk_timeout_add(250, (GtkFunction)DoRefresh, win); } } */ win->SetResized(PR_TRUE); } Loading @@ -830,6 +853,8 @@ NS_METHOD nsWindow::SetMenuBar(nsIMenuBar * aMenuBar) aMenuBar->GetNativeData(voidData); menubar = GTK_WIDGET(voidData); // gtk_menu_bar_set_shadow_type (GTK_MENU_BAR(menubar), GTK_SHADOW_NONE); gtk_box_pack_start(GTK_BOX(mVBox), menubar, FALSE, FALSE, 0); gtk_box_reorder_child(GTK_BOX(mVBox), menubar, 0); printf("adding menu bar (%p) to vbox (%p)\n", menubar, mVBox); Loading Loading
widget/src/gtk/nsGtkEventHandler.cpp +6 −14 Original line number Diff line number Diff line Loading @@ -167,12 +167,11 @@ void nsGtkWidget_InitNSMouseEvent(GdkEvent *aGev, if (anXEv != NULL) { // Do Mouse Event specific intialization anEvent.time = anXEv->time; /* anEvent.isShift = (anXEv->xbutton.state & ShiftMask) ? PR_TRUE : PR_FALSE; anEvent.isControl = (anXEv->xbutton.state & ControlMask) ? PR_TRUE : PR_FALSE; anEvent.isAlt = (anXEv->xbutton.state & Mod1Mask) ? PR_TRUE : PR_FALSE; */ anEvent.clickCount = anXEv->button; //XXX Fix for double-clicks anEvent.isShift = (anXEv->state & ShiftMask) ? PR_TRUE : PR_FALSE; anEvent.isControl = (anXEv->state & ControlMask) ? PR_TRUE : PR_FALSE; anEvent.isAlt = (anXEv->state & Mod1Mask) ? PR_TRUE : PR_FALSE; // anEvent.clickCount = anXEv->button; //XXX Fix for double-clicks anEvent.clickCount = 1; //XXX Fix for double-clicks anEvent.eventStructType = NS_MOUSE_EVENT; } Loading Loading @@ -228,7 +227,6 @@ void nsGtkWidget_ExposureMask_EventHandler(GtkWidget *w, GdkEventExpose *event, nsRect rect; nsGtkWidget_InitNSEvent((GdkEvent*)event, p, pevent, NS_PAINT); pevent.rect = (nsRect *)▭ XEvent xev; rect.x = event->area.x; rect.y = event->area.y; Loading @@ -245,6 +243,7 @@ void nsGtkWidget_ExposureMask_EventHandler(GtkWidget *w, GdkEventExpose *event, /* FIXME Display* display = XtDisplay(w); Window window = XtWindow(w); XEvent xev; XSync(display, FALSE); Loading Loading @@ -565,13 +564,6 @@ void nsGtkWidget_KeyReleaseMask_EventHandler(GtkWidget *w, GdkEvent * event, gpo widgetWindow->OnKey(NS_KEY_UP, kevent.keyCode, &kevent); } //============================================================== void nsGtkWidget_ResetResize_Callback(gpointer call_data) { nsWindow* widgetWindow = (nsWindow*)call_data; widgetWindow->SetResized(PR_FALSE); } //============================================================== void nsGtkWidget_Menu_Callback(GtkWidget *w, gpointer p) { Loading
widget/src/gtk/nsGtkEventHandler.h +0 −2 Original line number Diff line number Diff line Loading @@ -54,8 +54,6 @@ void nsGtkWidget_Expose_Callback(GtkWidget *w, gpointer p); void nsGtkWidget_Refresh_Callback(gpointer call_data); void nsGtkWidget_ResetResize_Callback(gpointer p); void nsGtkWidget_Menu_Callback(GtkWidget *w, gpointer p); #endif // __nsXtEventHandler.h Loading
widget/src/gtk/nsWindow.cpp +70 −45 Original line number Diff line number Diff line Loading @@ -36,7 +36,7 @@ #include "stdio.h" #define DBG 0 #define DBG 1 #if 0 #define DEBUG_shaver 1 #define DEBUG_pavlov 1 Loading @@ -45,6 +45,8 @@ static NS_DEFINE_IID(kIWidgetIID, NS_IWIDGET_IID); extern GtkWidget *gAppContext; void DoResize(GtkWidget *w, GtkAllocation *allocation, gpointer data); //------------------------------------------------------------------------- // // nsWindow constructor Loading Loading @@ -214,6 +216,10 @@ void nsWindow::InitCallbacks(char * aName) "key_release_event", GTK_SIGNAL_FUNC(nsGtkWidget_KeyReleaseMask_EventHandler), this); gtk_signal_connect(GTK_OBJECT(mWidget), "size_allocate", GTK_SIGNAL_FUNC(DoResize), this); } //------------------------------------------------------------------------- Loading Loading @@ -480,10 +486,13 @@ nsIAppShell* nsWindow::GetAppShell() //------------------------------------------------------------------------- NS_METHOD nsWindow::Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) { #ifdef DBG g_print("nsWindow::Scroll\n"); #endif if (GTK_IS_LAYOUT(mWidget)) { #ifdef DBG g_print ("is layout dX = %d, dY = %d\n", aDx, aDy); #endif GtkAdjustment* horiz = gtk_layout_get_hadjustment(GTK_LAYOUT(mWidget)); GtkAdjustment* vert = gtk_layout_get_vadjustment(GTK_LAYOUT(mWidget)); horiz->value -= aDx; Loading Loading @@ -631,6 +640,13 @@ void nsWindow::OnDestroy() PRBool nsWindow::OnResize(nsSizeEvent &aEvent) { #ifdef DBG g_print("nsWindow::OnResize\n"); #endif if (GetResized() == PR_TRUE) return FALSE; nsRect* size = aEvent.windowSize; if (mEventCallback && !mIgnoreResize) { Loading Loading @@ -659,7 +675,9 @@ PRBool nsWindow::DispatchFocus(nsGUIEvent &aEvent) PRBool nsWindow::OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos) { #ifdef DBG g_print("nsWindow::OnScroll\n"); #endif return FALSE; } Loading Loading @@ -755,70 +773,75 @@ PRUint32 nsWindow::GetYCoord(PRUint32 aNewY) //----------------------------------------------------- // gint nsWindow_Refresh_Callback(gpointer p) gint ResetResize(gpointer call_data) { nsWindow* widgetWindow = (nsWindow*)call_data; widgetWindow->SetResized(PR_FALSE); return FALSE; } gint DoRefresh(gpointer call_data) { nsWindow* widgetWindow = (nsWindow*)p; nsWindow *win = (nsWindow*)call_data; nsRect bounds; widgetWindow->GetResizeRect(&bounds); win->GetResizeRect(&bounds); nsSizeEvent sizeEvent; sizeEvent.eventStructType = NS_SIZE_EVENT; sizeEvent.message = NS_SIZE; sizeEvent.point.x = 0; sizeEvent.point.y = 0; sizeEvent.time = PR_IntervalNow(); // nsGUIEvent sizeEvent.widget = win; sizeEvent.nativeMsg = nsnull; nsSizeEvent event; event.message = NS_SIZE; event.widget = widgetWindow; event.time = 0; //TBD event.windowSize = &bounds; // nsSizeEvent sizeEvent.windowSize = &bounds; sizeEvent.mWinWidth = bounds.width; sizeEvent.mWinHeight = bounds.height; win->SetBounds(bounds); win->OnResize(sizeEvent); widgetWindow->SetBounds(bounds); widgetWindow->OnResize(event); nsPaintEvent pevent; pevent.message = NS_PAINT; pevent.widget = widgetWindow; pevent.time = 0; pevent.widget = win; pevent.time = PR_IntervalNow(); pevent.rect = (nsRect *)&bounds; widgetWindow->OnPaint(pevent); win->OnPaint(pevent); gtk_timeout_add (50, (GtkFunction)nsGtkWidget_ResetResize_Callback, widgetWindow); gtk_timeout_add(50, (GtkFunction)ResetResize, win); return FALSE; } // // Resize a child window widget. All nsManageWidget's use // this to resize. The nsManageWidget passes all resize // request's directly to this function. extern "C" void nsWindow_ResizeWidget(GtkWidget *w) void DoResize(GtkWidget *w, GtkAllocation *allocation, gpointer data) { int width = 0; int height = 0; nsWindow *win = 0; g_print("DoResized called\n"); nsWindow *win = (nsWindow*)data; // Get the new size for the window win = gtk_object_get_user_data(GTK_OBJECT(w)); width = w->allocation.width; height = w->allocation.height; // XtVaGetValues(w, XmNuserData, &win, XmNwidth, &width, XmNheight, &height, nsnull); // Setup the resize rectangle for the window. nsRect bounds; bounds.width = width; bounds.height = height; bounds.width = allocation->width; bounds.height = allocation->height; bounds.x = 0; bounds.y = 0; win->SetResizeRect(bounds); if (!win->GetResized()) { DoRefresh(win); } /* if (!win->GetResized()) { if (win->IsChild()) { // Call refresh directly. Don't filter resize events. nsWindow_Refresh_Callback(win); } else { // XXX: KLUDGE: Do actual resize later. This lets most // of the resize events come through before actually // resizing. This is only needed for main (shell) // windows. This should be replaced with code that actually // Compresses the event queue. gtk_timeout_add (250, (GtkFunction)nsWindow_Refresh_Callback, win); gtk_timeout_add(250, (GtkFunction)DoRefresh, win); } } */ win->SetResized(PR_TRUE); } Loading @@ -830,6 +853,8 @@ NS_METHOD nsWindow::SetMenuBar(nsIMenuBar * aMenuBar) aMenuBar->GetNativeData(voidData); menubar = GTK_WIDGET(voidData); // gtk_menu_bar_set_shadow_type (GTK_MENU_BAR(menubar), GTK_SHADOW_NONE); gtk_box_pack_start(GTK_BOX(mVBox), menubar, FALSE, FALSE, 0); gtk_box_reorder_child(GTK_BOX(mVBox), menubar, 0); printf("adding menu bar (%p) to vbox (%p)\n", menubar, mVBox); Loading