From c22fbaedbbadedd4714ea91c3b2847b9446ce49e Mon Sep 17 00:00:00 2001 From: "bryner%netscape.com" Date: Thu, 24 Jan 2002 01:18:36 +0000 Subject: [PATCH] Bug 120252 - paint flashing broken on gtk. Also removed a lot of old cruft, changed #ifdef NS_DEBUG (which we don't define any more) to #ifdef DEBUG. r=waterson, sr=blizzard. --- widget/src/gtk/nsDragService.cpp | 8 +- widget/src/gtk/nsWidget.cpp | 237 ++---------- widget/src/gtk/nsWidget.h | 5 - widget/src/gtk/nsWindow.cpp | 458 +---------------------- widget/src/gtk/nsWindow.h | 44 +-- widget/src/xpwidgets/nsBaseWidget.cpp | 11 +- widget/src/xpwidgets/nsBaseWidget.h | 3 +- widget/src/xpwidgets/nsXPLookAndFeel.cpp | 4 +- 8 files changed, 47 insertions(+), 723 deletions(-) diff --git a/widget/src/gtk/nsDragService.cpp b/widget/src/gtk/nsDragService.cpp index 424ec7fff027..75b3a4af0716 100644 --- a/widget/src/gtk/nsDragService.cpp +++ b/widget/src/gtk/nsDragService.cpp @@ -501,13 +501,7 @@ nsDragService::GetData (nsITransferable * aTransferable, nsPrimitiveHelpers::CreatePrimitiveForData(flavorStr, mTargetDragData, mTargetDragDataLen, getter_AddRefs(genericDataWrapper)); - rv = aTransferable->SetTransferData(flavorStr, genericDataWrapper, mTargetDragDataLen); -#ifdef NS_DEBUG - if ( rv != NS_OK ) - g_print("nsDragService:: Error setting data into transferable\n"); -#endif - - rv = NS_OK; + aTransferable->SetTransferData(flavorStr, genericDataWrapper, mTargetDragDataLen); // we found one, get out of this loop! PR_LOG(sDragLm, PR_LOG_DEBUG, ("dataFound and converted!\n")); break; diff --git a/widget/src/gtk/nsWidget.cpp b/widget/src/gtk/nsWidget.cpp index 702e463bd9f0..45cf1d2608bf 100644 --- a/widget/src/gtk/nsWidget.cpp +++ b/widget/src/gtk/nsWidget.cpp @@ -132,32 +132,6 @@ PRBool nsWidget::gRollupConsumeRollupEvent = PR_FALSE; PRBool nsWidget::mGDKHandlerInstalled = PR_FALSE; PRBool nsWidget::sTimeCBSet = PR_FALSE; -#ifdef NS_DEBUG -// debugging window -static GtkWidget *debugTopLevel = NULL; -static GtkWidget *debugBox = NULL; -static GtkWidget *debugEntryBox = NULL; -static GtkWidget *debugButton = NULL; -static GtkWidget *debugCheckBox = NULL; -nsWidget *nsWidget::debugWidget = NULL; -PRBool nsWidget::sDebugFeedback = PR_FALSE; -static PRBool debugCheckedDebugWindow = PR_FALSE; -static PRBool debugCallbackRegistered = PR_FALSE; - -static void debugHandleActivate(GtkEditable *editable, - gpointer user_data); -static void debugHandleClicked (GtkButton *button, - gpointer user_data); -static void debugHandleToggle (GtkToggleButton *button, - gpointer user_data); -static void debugSetupWindow (void); -static void debugDestroyWindow (void); -static int debugWindowPrefChanged (const char *newpref, void *data); -static void debugRegisterCallback (void); -static gint debugHandleWindowClose(GtkWidget *window, void *data); -const char *debugPrefName = "nglayout.widget.debugWindow"; -#endif /* NS_DEBUG */ - // // Keep track of the last widget being "dragged" // @@ -217,17 +191,6 @@ nsWidget::nsWidget() } dragServiceGTK->TargetSetTimeCallback(nsWidget::GetLastEventTime); } -#ifdef NS_DEBUG - // see if we need to set up the debugging window - if (!debugCheckedDebugWindow) { - debugSetupWindow(); - } - // this will set up the callback for when the debug - // pref changes - if (!debugCallbackRegistered) { - debugRegisterCallback(); - } -#endif /* NS_DEBUG */ } nsWidget::~nsWidget() @@ -244,11 +207,6 @@ nsWidget::~nsWidget() Destroy(); NS_ASSERTION(!ModalWidgetList::Find(this), "destroying widget without first clearing modality."); -#ifdef NS_DEBUG - if (mIsToplevel) { - g_print("nsWidget::~nsWidget() of toplevel: %d widgets still exist.\n", sWidgetCount); - } -#endif } @@ -869,7 +827,7 @@ NS_IMETHODIMP nsWidget::SetCursor(nsCursor aCursor) } #define CAPS_LOCK_IS_ON \ -(nsWidget::sDebugFeedback && (nsGtkUtils::gdk_keyboard_get_modifiers() & GDK_LOCK_MASK)) +(nsGtkUtils::gdk_keyboard_get_modifiers() & GDK_LOCK_MASK) NS_IMETHODIMP nsWidget::Validate() { @@ -888,8 +846,10 @@ NS_IMETHODIMP nsWidget::Invalidate(PRBool aIsSynchronous) if (!GTK_WIDGET_REALIZED(mWidget) || !GTK_WIDGET_VISIBLE(mWidget)) return NS_ERROR_FAILURE; -#ifdef NS_DEBUG - if (CAPS_LOCK_IS_ON) +#ifdef DEBUG + // Check the pref _before_ checking caps lock, because checking + // caps lock requires a server round-trip. + if (debug_GetCachedBoolPref("nglayout.debug.invalidate_dumping") && CAPS_LOCK_IS_ON) { debug_DumpInvalidate(stdout, this, @@ -898,7 +858,7 @@ NS_IMETHODIMP nsWidget::Invalidate(PRBool aIsSynchronous) debug_GetName(mWidget), debug_GetRenderXID(mWidget)); } -#endif // NS_DEBUG +#endif // DEBUG mUpdateArea->SetTo(0, 0, mBounds.width, mBounds.height); @@ -924,8 +884,10 @@ NS_IMETHODIMP nsWidget::Invalidate(const nsRect & aRect, PRBool aIsSynchronous) mUpdateArea->Union(aRect.x, aRect.y, aRect.width, aRect.height); -#ifdef NS_DEBUG - if (CAPS_LOCK_IS_ON) +#ifdef DEBUG + // Check the pref _before_ checking caps lock, because checking + // caps lock requires a server round-trip. + if (debug_GetCachedBoolPref("nglayout.debug.invalidate_dumping") && CAPS_LOCK_IS_ON) { debug_DumpInvalidate(stdout, this, @@ -934,7 +896,7 @@ NS_IMETHODIMP nsWidget::Invalidate(const nsRect & aRect, PRBool aIsSynchronous) debug_GetName(mWidget), debug_GetRenderXID(mWidget)); } -#endif // NS_DEBUG +#endif // DEBUG if (aIsSynchronous) { @@ -981,8 +943,10 @@ NS_IMETHODIMP nsWidget::InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSyn nsRegionRect *r = &(regionRectSet->mRects[i]); -#ifdef NS_DEBUG - if (CAPS_LOCK_IS_ON) +#ifdef DEBUG + // Check the pref _before_ checking caps lock, because checking + // caps lock requires a server round-trip. + if (debug_GetCachedBoolPref("nglayout.debug.invalidate_dumping") && CAPS_LOCK_IS_ON) { nsRect rect(r->x, r->y, r->width, r->height); debug_DumpInvalidate(stdout, @@ -992,7 +956,7 @@ NS_IMETHODIMP nsWidget::InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSyn debug_GetName(mWidget), debug_GetRenderXID(mWidget)); } -#endif // NS_DEBUG +#endif // DEBUG if (aIsSynchronous) @@ -1330,7 +1294,7 @@ PRBool nsWidget::DispatchFocus(nsGUIEvent &aEvent) // ////////////////////////////////////////////////////////////////// -#ifdef NS_DEBUG +#ifdef DEBUG PRInt32 nsWidget::debug_GetRenderXID(GtkObject * aGtkWidget) { @@ -1366,7 +1330,7 @@ nsWidget::debug_GetName(GtkWidget * aGtkWidget) return nsCAutoString("null"); } -#endif // NS_DEBUG +#endif // DEBUG ////////////////////////////////////////////////////////////////// @@ -1382,13 +1346,16 @@ NS_IMETHODIMP nsWidget::DispatchEvent(nsGUIEvent *aEvent, { NS_ADDREF(aEvent->widget); -#ifdef NS_DEBUG +#ifdef DEBUG GtkObject *gw; void *nativeWidget = aEvent->widget->GetNativeData(NS_NATIVE_WIDGET); if (nativeWidget) { gw = GTK_OBJECT(nativeWidget); - if (CAPS_LOCK_IS_ON) + // Check the pref _before_ checking caps lock, because checking + // caps lock requires a server round-trip. + + if (debug_GetCachedBoolPref("nglayout.debug.event_dumping") && CAPS_LOCK_IS_ON) { debug_DumpEvent(stdout, aEvent->widget, @@ -1397,7 +1364,7 @@ NS_IMETHODIMP nsWidget::DispatchEvent(nsGUIEvent *aEvent, (PRInt32) debug_GetRenderXID(gw)); } } -#endif // NS_DEBUG +#endif // DEBUG if (nsnull != mMenuListener) { if (NS_MENU_EVENT == aEvent->eventStructType) @@ -2549,162 +2516,6 @@ GtkWindow *nsWidget::GetTopLevelWindow(void) return NULL; } -#ifdef NS_DEBUG - -static void setDebugWindow(void) -{ - gchar *text = NULL; - int val = 0; - - text = gtk_editable_get_chars(GTK_EDITABLE(debugEntryBox), 0, -1); - if (!text) { - return; - } - - if (strlen(text) == 0) { - g_print("setting value to null\n"); - nsWidget::debugWidget = NULL; - g_free(text); - return; - } - - if (strlen(text) < 3) { - g_print("string not long enough\n"); - return; - } - - if (memcmp(text, "0x", 2) != 0) { - g_print("string must begin in 0x\n"); - return; - } - - sscanf(&text[2], "%x", &val); - -#ifdef DEBUG - printf("setting value to 0x%x\n", val); -#endif - nsWidget::debugWidget = (nsWidget *)val; - - g_free(text); -} - -static void debugHandleActivate(GtkEditable *editable, - gpointer user_data) -{ - setDebugWindow(); -} - -static void debugHandleClicked (GtkButton *button, - gpointer user_data) -{ - setDebugWindow(); -} - -static void debugHandleToggle (GtkToggleButton *button, - gpointer user_data) -{ - if (gtk_toggle_button_get_active(button) == TRUE) { - nsWidget::sDebugFeedback = PR_TRUE; - } - else { - nsWidget::sDebugFeedback = PR_FALSE; - } -} - -static void debugDestroyWindow (void) -{ - // this will destroy all of the widgets inside the window, too. - gtk_widget_destroy(debugTopLevel); - debugTopLevel = NULL; - debugBox = NULL; - debugEntryBox = NULL; - debugButton = NULL; - debugCheckBox = NULL; - nsWidget::debugWidget = NULL; -} - -static void debugSetupWindow (void) -{ - PRBool enable_window = PR_FALSE; - nsresult rv; - - debugCheckedDebugWindow = PR_TRUE; - nsCOMPtr prefs(do_GetService(kPrefServiceCID, &rv)); - if (NS_SUCCEEDED(rv) && (prefs)) { - rv = prefs->GetBoolPref(debugPrefName, &enable_window); - if (NS_SUCCEEDED(rv) && enable_window) { - debugTopLevel = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_signal_connect(GTK_OBJECT(debugTopLevel), - "delete_event", - GTK_SIGNAL_FUNC(debugHandleWindowClose), - NULL); - - debugBox = gtk_hbox_new(PR_FALSE, 0); - gtk_container_add(GTK_CONTAINER(debugTopLevel), debugBox); - - debugEntryBox = gtk_entry_new(); - gtk_box_pack_start_defaults(GTK_BOX(debugBox), debugEntryBox); - gtk_signal_connect(GTK_OBJECT(debugEntryBox), "activate", - GTK_SIGNAL_FUNC(debugHandleActivate), NULL); - - debugButton = gtk_button_new_with_label("Set Window"); - gtk_box_pack_start_defaults(GTK_BOX(debugBox), debugButton); - gtk_signal_connect(GTK_OBJECT(debugButton), "clicked", - GTK_SIGNAL_FUNC(debugHandleClicked), NULL); - - debugCheckBox = gtk_check_button_new_with_label("Debug Feedback"); - gtk_box_pack_start_defaults(GTK_BOX(debugBox), debugCheckBox); - gtk_signal_connect(GTK_OBJECT(debugCheckBox), "toggled", - GTK_SIGNAL_FUNC(debugHandleToggle), NULL); - - gtk_widget_show_all(debugTopLevel); - } - } -} - -static int debugWindowPrefChanged (const char *newpref, void *data) -{ - PRBool enable_window; - nsresult rv; - nsCOMPtr prefs(do_GetService(kPrefServiceCID, &rv)); - if (NS_SUCCEEDED(rv) && (prefs)) { - rv = prefs->GetBoolPref(debugPrefName, &enable_window); - if (NS_SUCCEEDED(rv) && enable_window) { - if (!debugTopLevel) { - // this will trigger the creation of the window - debugCheckedDebugWindow = PR_FALSE; - debugSetupWindow(); - } - } - else if (NS_SUCCEEDED(rv) && (!enable_window)) { - if (debugTopLevel) { - debugDestroyWindow(); - } - } - } - return 0; -} - -static void debugRegisterCallback (void) -{ - nsresult rv; - - // make sure we don't call in here again - debugCallbackRegistered = PR_TRUE; - nsCOMPtr prefs(do_GetService(kPrefServiceCID, &rv)); - if (NS_SUCCEEDED(rv)) { - rv = prefs->RegisterCallback(debugPrefName, debugWindowPrefChanged, NULL); - } -} - -static gint debugHandleWindowClose(GtkWidget *window, void *data) -{ - debugDestroyWindow(); - return TRUE; -} - -#endif /* NS_DEBUG */ - void nsWidget::IMECommitEvent(GdkEventKey *aEvent) { NS_ASSERTION(0, "nsWidget::IMECommitEvent() shouldn't be called!\n"); } diff --git a/widget/src/gtk/nsWidget.h b/widget/src/gtk/nsWidget.h index 9654220a6f01..18223722a338 100644 --- a/widget/src/gtk/nsWidget.h +++ b/widget/src/gtk/nsWidget.h @@ -200,11 +200,6 @@ public: // get the toplevel window for this widget virtual GtkWindow *GetTopLevelWindow(void); -#ifdef NS_DEBUG - static nsWidget *debugWidget; - static PRBool sDebugFeedback; -#endif - PRBool OnKey(nsKeyEvent &aEvent) { return OnInput(aEvent); }; PRBool OnText(nsTextEvent &aEvent) { return OnInput(aEvent); }; diff --git a/widget/src/gtk/nsWindow.cpp b/widget/src/gtk/nsWindow.cpp index 9518d0283d5e..53931ef8ea59 100644 --- a/widget/src/gtk/nsWindow.cpp +++ b/widget/src/gtk/nsWindow.cpp @@ -99,10 +99,10 @@ extern "C" int usleep(unsigned int); #define MODAL_TIMERS_BROKEN #define CAPS_LOCK_IS_ON \ -(nsWidget::sDebugFeedback && (nsGtkUtils::gdk_keyboard_get_modifiers() & GDK_LOCK_MASK)) +(nsGtkUtils::gdk_keyboard_get_modifiers() & GDK_LOCK_MASK) #define WANT_PAINT_FLASHING \ -(CAPS_LOCK_IS_ON && debug_WantPaintFlashing()) +(debug_WantPaintFlashing() && CAPS_LOCK_IS_ON) #define kWindowPositionSlop 20 @@ -142,8 +142,6 @@ GHashTable *nsWindow::mWindowLookupTable = NULL; // this is the last window that had a drag event happen on it. nsWindow *nsWindow::mLastDragMotionWindow = NULL; -// we get our drop after the leave. -nsWindow *nsWindow::mLastLeaveWindow = NULL; PRBool gJustGotDeactivate = PR_FALSE; PRBool gJustGotActivate = PR_FALSE; @@ -181,8 +179,6 @@ NS_IMPL_ISUPPORTS_INHERITED0(nsWindow, nsWidget) nsWindow::nsWindow() { mShell = nsnull; - mResized = PR_FALSE; - mLowerLeft = PR_FALSE; mWindowType = eWindowType_child; mBorderStyle = eBorderStyle_default; mSuperWin = 0; @@ -197,8 +193,6 @@ nsWindow::nsWindow() if (mWindowLookupTable == NULL) { mWindowLookupTable = g_hash_table_new(g_direct_hash, g_direct_equal); } - if (mLastLeaveWindow == this) - mLastLeaveWindow = NULL; if (mLastDragMotionWindow == this) mLastDragMotionWindow = NULL; mBlockMozAreaFocusIn = PR_FALSE; @@ -317,11 +311,6 @@ NS_IMETHODIMP nsWindow::Destroy(void) } -PRBool nsWindow::IsChild() const -{ - return PR_FALSE; -} - void nsWindow::InvalidateWindowPos(void) { mCachedX = mCachedY = -1; @@ -450,7 +439,6 @@ nsWindow::DestroyNativeChildren(void) window = GDK_WINDOW_XWINDOW(mSuperWin->bin_window); if (window && !((GdkWindowPrivate *)mSuperWin->bin_window)->destroyed) { - //DumpWindowTree(); // get a list of children for this window XQueryTree(display, window, &root_return, &parent_return, &children_return, &nchildren_return); @@ -472,32 +460,6 @@ nsWindow::DestroyNativeChildren(void) XFree(children_return); } -void -nsWindow::ShowCrossAtLocation(guint x, guint y) -{ -#ifdef DEBUG - g_print("ShowCrossAtLocation %d, %d\n", x, y); -#endif - if (mSuperWin) { - GdkGC *gc = 0; - GdkColor white; - int i; - gc = gdk_gc_new(GDK_ROOT_PARENT()); - white.pixel = WhitePixel(gdk_display, DefaultScreen(gdk_display)); - gdk_gc_set_foreground(gc,&white); - gdk_gc_set_function(gc,GDK_XOR); - gdk_gc_set_subwindow(gc,GDK_INCLUDE_INFERIORS); - gdk_gc_set_line_attributes(gc, 4, GDK_LINE_SOLID, GDK_CAP_ROUND, GDK_JOIN_ROUND); - for (i=0; i < 2; i++) { - gdk_draw_line(mSuperWin->bin_window, gc, x - 20 , y, x + 20, y); - XSync(gdk_display, False); - usleep(200); - gdk_draw_line(mSuperWin->bin_window, gc, x, y - 20, x, y + 20); - } - gdk_gc_destroy(gc); - } -} - // This function will try to take a given native X window and try // to find the nsWindow * class that has it corresponds to. @@ -744,12 +706,6 @@ nsWindow::DoPaint (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, return; } -#ifdef NS_DEBUG - if (this == debugWidget) { - g_print("nsWindow::DoPaint %d %d %d %d\n", - aX, aY, aWidth, aHeight); - } -#endif // NS_DEBUG if (mEventCallback) { nsPaintEvent event; @@ -768,7 +724,7 @@ nsWindow::DoPaint (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, event.renderingContext = GetRenderingContext(); if (event.renderingContext) { -#ifdef NS_DEBUG +#ifdef DEBUG if (WANT_PAINT_FLASHING) { GdkWindow *gw = GetRenderWindow(GTK_OBJECT(mSuperWin)); @@ -791,7 +747,14 @@ nsWindow::DoPaint (PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight, nsGtkUtils::gdk_window_flash(gw,1,100000,area); } } -#endif // NS_DEBUG + + // Check the pref _before_ checking caps lock, because checking + // caps lock requires a server round-trip. + if (debug_GetCachedBoolPref("nglayout.debug.paint_dumping") && CAPS_LOCK_IS_ON) + debug_DumpPaintEvent(stdout, this, &event, + debug_GetName(GTK_OBJECT(mSuperWin)), + (PRInt32) debug_GetRenderXID(GTK_OBJECT(mSuperWin))); +#endif // DEBUG DispatchWindowEvent(&event); NS_RELEASE(event.renderingContext); @@ -1637,112 +1600,6 @@ nsWindow::HandleGDKEvent(GdkEvent *event) } } -#ifdef NS_DEBUG - -/* static */ -void -nsWindow::dumpWindowChildren(Window aWindow, unsigned int depth) -{ - Display *display; - Window window; - Window root_return; - Window parent_return; - Window *children_return; - unsigned int nchildren_return; - unsigned int i; - - display = GDK_DISPLAY(); - window = aWindow; - XQueryTree(display, window, &root_return, &parent_return, - &children_return, &nchildren_return); - -#ifdef DEBUG_DND_XLATE - printDepth(depth); - - g_print("Window 0x%lx ", window); -#endif - - GdkWindow *thisWindow = NULL; - - thisWindow = gdk_window_lookup(window); - - if (!thisWindow) - { - g_print("(none)\n"); - } - else - { - gpointer data; - // see if this is a real widget - gdk_window_get_user_data(thisWindow, &data); - if (data) - { - if (GTK_IS_WIDGET(data)) - { - g_print("(%s)\n", gtk_widget_get_name(GTK_WIDGET(data))); - } - else if (GDK_IS_SUPERWIN(data)) - { - g_print("(bin_window for nsWindow %p)\n", gtk_object_get_data(GTK_OBJECT(data), "nsWindow")); - } - else - { - g_print("(invalid GtkWidget)\n"); - } - } - else - { - // ok, see if it's a shell window - nsWindow *childWindow = (nsWindow *)g_hash_table_lookup(nsWindow::mWindowLookupTable, - thisWindow); - if (childWindow) - { - g_print("(shell_window for nsWindow %p)\n", NS_STATIC_CAST(void *, childWindow)); - } - } - } - - for (i=0; i < nchildren_return; i++) - { - dumpWindowChildren(children_return[i], depth + 1); - } - - // free the list of children - if (children_return) - XFree(children_return); - -} - -void -nsWindow::DumpWindowTree(void) -{ - if (mShell || mSuperWin) - { - GdkWindow *startWindow = NULL; - // see where we are starting - if (mShell) - { - g_print("dumping from shell for %p.\n", NS_STATIC_CAST(void *, this)); - startWindow = mShell->window; - } - else - { - g_print("dumping from superwin for %p.\n", NS_STATIC_CAST(void *, this)); - startWindow = mSuperWin->shell_window; - } - Window window; - window = GDK_WINDOW_XWINDOW(startWindow); - dumpWindowChildren(window, 0); - } - else - { - g_print("no windows for %p.\n", NS_STATIC_CAST(void *, this)); - } - -} - -#endif /* NS_DEBUG */ - void nsWindow::OnDestroySignal(GtkWidget* aGtkWidget) { @@ -2365,197 +2222,6 @@ nsresult nsWindow::SetIcon(GdkPixmap *pixmap, return NS_OK; } - - -void nsWindow::SendExposeEvent() -{ - mUpdateArea->Intersect(0, 0, mBounds.width, mBounds.height); - - nsPaintEvent event; - - event.rect = new nsRect(); - - event.message = NS_PAINT; - event.widget = this; - event.eventStructType = NS_PAINT_EVENT; - // event.point.x = event->xexpose.x; - // event.point.y = event->xexpose.y; - /* XXX fix this */ - event.time = 0; - - PRInt32 x, y, w, h; - mUpdateArea->GetBoundingBox(&x,&y,&w,&h); - - event.rect->x = x; - event.rect->y = y; - event.rect->width = w; - event.rect->height = h; - - if (event.rect->width == 0 || event.rect->height == 0) { - delete event.rect; - return; - } - - // print out stuff here incase the event got dropped on the floor above -#ifdef NS_DEBUG - if (CAPS_LOCK_IS_ON) - { - debug_DumpPaintEvent(stdout, - this, - &event, - debug_GetName(GTK_OBJECT(mSuperWin)), - (PRInt32) debug_GetRenderXID(GTK_OBJECT(mSuperWin))); - } -#endif // NS_DEBUG - - event.renderingContext = GetRenderingContext(); - if (event.renderingContext) { - DispatchWindowEvent(&event); - NS_RELEASE(event.renderingContext); - } - - - mUpdateArea->Subtract(event.rect->x, event.rect->y, event.rect->width, event.rect->height); - -#ifdef NS_DEBUG - if (WANT_PAINT_FLASHING) - { - GdkWindow *gw = GetRenderWindow(GTK_OBJECT(mSuperWin)); - if (gw) - { - GdkRectangle ar; - GdkRectangle * area = (GdkRectangle*) NULL; - - if (event.rect) - { - ar.x = event.rect->x; - ar.y = event.rect->y; - - ar.width = event.rect->width; - ar.height = event.rect->height; - - area = &ar; - } - - nsGtkUtils::gdk_window_flash(gw,1,100000,area); - } - } -#endif // NS_DEBUG - - delete event.rect; -} - - -/** - * Processes an Expose Event - * - **/ -PRBool nsWindow::OnExpose(nsPaintEvent &event) -{ - nsresult result = PR_TRUE; - - // call the event callback - if (mEventCallback) - { - event.renderingContext = nsnull; - - // printf("nsWindow::OnExpose\n"); - - // expose.. we didn't get an Invalidate, so we should up the count here - mUpdateArea->Union(event.rect->x, event.rect->y, event.rect->width, event.rect->height); - - SendExposeEvent(); - } - - return result; -} - -/** - * Processes an Draw Event - * - **/ -PRBool nsWindow::OnDraw(nsPaintEvent &event) -{ - nsresult result ; - - // call the event callback - if (mEventCallback) - { - event.renderingContext = nsnull; - - // XXX we SHOULD get an expose and not a draw for things, but we don't always with gtk <= 1.2.5 - // mUpdateArea->Union(event.rect->x, event.rect->y, event.rect->width, event.rect->height); - -#ifdef NS_DEBUG - if (CAPS_LOCK_IS_ON) - { - debug_DumpPaintEvent(stdout, - this, - &event, - debug_GetName(GTK_OBJECT(mSuperWin)), - (PRInt32) debug_GetRenderXID(GTK_OBJECT(mSuperWin))); - } -#endif // NS_DEBUG - - - // NS_ADDREF(mUpdateArea); - // event.region = mUpdateArea; - - // printf("\n\n"); - PRInt32 x, y, w, h; - mUpdateArea->GetBoundingBox(&x,&y,&w,&h); - // printf("should be painting x = %i , y = %i , w = %i , h = %i\n", x, y, w, h); - // printf("\n\n"); - event.rect->x = x; - event.rect->y = y; - event.rect->width = w; - event.rect->height = h; - - if (event.rect->width == 0 || event.rect->height == 0) - { - // printf("ignoring paint for 0x0\n"); - return NS_OK; - } - - - event.renderingContext = GetRenderingContext(); - if (event.renderingContext) { - result = DispatchWindowEvent(&event); - NS_RELEASE(event.renderingContext); - } - - - mUpdateArea->Subtract(event.rect->x, event.rect->y, event.rect->width, event.rect->height); - -#ifdef NS_DEBUG - if (WANT_PAINT_FLASHING) - { - GdkWindow * gw = GetRenderWindow(GTK_OBJECT(mSuperWin)); - if (gw) - { - GdkRectangle ar; - GdkRectangle * area = (GdkRectangle*) NULL; - - if (event.rect) - { - ar.x = event.rect->x; - ar.y = event.rect->y; - - ar.width = event.rect->width; - ar.height = event.rect->height; - - area = &ar; - } - - nsGtkUtils::gdk_window_flash(gw,1,100000,area); - } - } -#endif // NS_DEBUG - } - return result; -} - - NS_IMETHODIMP nsWindow::BeginResizingChildren(void) { // gtk_layout_freeze(GTK_LAYOUT(mWidget)); @@ -3142,103 +2808,6 @@ GtkWindow *nsWindow::GetTopLevelWindow(void) } ////////////////////////////////////////////////////////////////////// -// -// Draw signal -// -////////////////////////////////////////////////////////////////////// -void -nsWindow::InitDrawEvent(GdkRectangle * aArea, - nsPaintEvent & aPaintEvent, - PRUint32 aEventType) -{ - aPaintEvent.message = aEventType; - aPaintEvent.widget = (nsWidget *) this; - - aPaintEvent.eventStructType = NS_PAINT_EVENT; - // aPaintEvent.point.x = 0; - // aPaintEvent.point.y = 0; - aPaintEvent.point.x = aArea->x; - aPaintEvent.point.y = aArea->y; - aPaintEvent.time = GDK_CURRENT_TIME; - - if (aArea != NULL) - { - aPaintEvent.rect = new nsRect(aArea->x, - aArea->y, - aArea->width, - aArea->height); - } -} -////////////////////////////////////////////////////////////////////// -void -nsWindow::UninitDrawEvent(GdkRectangle * area, - nsPaintEvent & aPaintEvent, - PRUint32 aEventType) -{ - if (area != NULL) - { - delete aPaintEvent.rect; - } - - // While I'd think you should NS_RELEASE(aPaintEvent.widget) here, - // if you do, it is a NULL pointer. Not sure where it is getting - // released. -} -////////////////////////////////////////////////////////////////////// -/* static */ gint -nsWindow::DrawSignal(GtkWidget * /* aWidget */, - GdkRectangle * aArea, - gpointer aData) -{ - nsWindow * window = (nsWindow *) aData; - - NS_ASSERTION(nsnull != window,"window is null"); - - return window->OnDrawSignal(aArea); -} -////////////////////////////////////////////////////////////////////// -/* virtual */ gint -nsWindow::OnDrawSignal(GdkRectangle * aArea) -{ - //printf("nsWindow::OnDrawSignal()\n"); - - nsPaintEvent pevent; - - InitDrawEvent(aArea, pevent, NS_PAINT); - - nsWindow * win = (nsWindow *) this; - - NS_ADDREF(win); - - win->OnDraw(pevent); - - NS_RELEASE(win); - - UninitDrawEvent(aArea, pevent, NS_PAINT); - - return PR_TRUE; -} - -// Add an XATOM property to this window. -// Assuming XA_STRING type. -// Borrowed from xfe classic branch. -void nsWindow::StoreProperty(char *property, unsigned char *data) -{ - - // This needs to happen before properties start working. - // Not sure if calling this is ? overkill or not. - gtk_widget_show_all (mShell); - - // GetRenderWindow(mWidget), - gdk_property_change (mShell->window, - gdk_atom_intern (property, FALSE), /* property */ - XA_STRING, /* type */ - 8, /* *sizeof(GdkAtom) Format. ? */ - GDK_PROP_MODE_REPLACE, /* mode */ - (guchar *)data, /* data */ - (gint)strlen((char *)data)); /* size of data */ -} - // These are all of our drag and drop operations void @@ -3750,11 +3319,6 @@ ChildWindow::~ChildWindow() #endif } -PRBool ChildWindow::IsChild() const -{ - return PR_TRUE; -} - #ifdef USE_XIM nsresult nsWindow::KillICSpotTimer () { diff --git a/widget/src/gtk/nsWindow.h b/widget/src/gtk/nsWindow.h index 7337a8475492..a7af47877b52 100644 --- a/widget/src/gtk/nsWindow.h +++ b/widget/src/gtk/nsWindow.h @@ -58,7 +58,7 @@ class nsFont; class nsIAppShell; /** - * Native GTK++ window wrapper. + * Native GTK+ window wrapper. */ class nsWindow : public nsWidget @@ -134,23 +134,13 @@ public: gint ConvertBorderStyles(nsBorderStyle bs); - // Add an XATOM property to this window. - void StoreProperty(char *property, unsigned char *data); void InvalidateWindowPos(void); - virtual PRBool IsChild() const; - - // Utility methods - virtual PRBool OnExpose(nsPaintEvent &event); - virtual PRBool OnDraw(nsPaintEvent &event); - virtual PRBool OnScroll(nsScrollbarEvent & aEvent, PRUint32 cPos); // in nsWidget now // virtual PRBool OnResize(nsSizeEvent &aEvent); - static void SuperWinFilter(GdkSuperWin *superwin, XEvent *event, gpointer p); - void HandleXlibConfigureNotifyEvent(XEvent *event); // Return the GtkMozArea that is the nearest parent of this widget GtkWidget *GetMozArea(); @@ -166,7 +156,6 @@ public: PRBool GrabInProgress(void); // XXX Chris - fix these // virtual void OnButtonPressSignal(GdkEventButton * aGdkButtonEvent); - void ShowCrossAtLocation(guint x, guint y); // this will get the nsWindow with the grab. The return will not be // addrefed. @@ -184,24 +173,6 @@ public: void HandleMozAreaFocusOut(void); protected: - ////////////////////////////////////////////////////////////////////// - // - // Draw signal - // - ////////////////////////////////////////////////////////////////////// - void InitDrawEvent(GdkRectangle * aArea, - nsPaintEvent & aPaintEvent, - PRUint32 aEventType); - - void UninitDrawEvent(GdkRectangle * area, - nsPaintEvent & aPaintEvent, - PRUint32 aEventType); - - static gint DrawSignal(GtkWidget * aWidget, - GdkRectangle * aArea, - gpointer aData); - - virtual gint OnDrawSignal(GdkRectangle * aArea); virtual void OnRealize(GtkWidget *aWidget); virtual void OnDestroySignal(GtkWidget* aGtkWidget); @@ -213,11 +184,6 @@ protected: PRBool mIsTooSmall; - // Resize event management - nsRect mResizeRect; - int mResized; - PRBool mLowerLeft; - GtkWidget *mShell; /* used for toplevel windows */ GdkSuperWin *mSuperWin; GtkWidget *mMozArea; @@ -247,7 +213,6 @@ protected: // this is the last window that had a drag event happen on it. static nsWindow *mLastDragMotionWindow; - static nsWindow *mLastLeaveWindow; static GdkCursor *gsGtkCursorCache[eCursor_count_up_down + 1]; void InitDragEvent(nsMouseEvent &aEvent); @@ -336,11 +301,6 @@ protected: static guint DragMotionTimerCallback (gpointer aClosure); static void DragLeaveTimerCallback (nsITimer *aTimer, void *aClosure); -#ifdef NS_DEBUG - void DumpWindowTree(void); - static void dumpWindowChildren(Window aWindow, unsigned int depth); -#endif - #ifdef USE_XIM protected: PRBool mIMEEnable; @@ -396,7 +356,6 @@ private: nsresult SetIcon(GdkPixmap *window_pixmap, GdkBitmap *window_mask); nsresult SetIcon(); - void SendExposeEvent(); PRBool mLastGrabFailed; void NativeGrab(PRBool aGrab); @@ -415,7 +374,6 @@ class ChildWindow : public nsWindow { public: ChildWindow(); ~ChildWindow(); - virtual PRBool IsChild() const; }; #endif // Window_h__ diff --git a/widget/src/xpwidgets/nsBaseWidget.cpp b/widget/src/xpwidgets/nsBaseWidget.cpp index 0c323eb7ae57..55f01ad4d680 100644 --- a/widget/src/xpwidgets/nsBaseWidget.cpp +++ b/widget/src/xpwidgets/nsBaseWidget.cpp @@ -43,7 +43,7 @@ #include "nsGfxCIID.h" #include "nsWidgetsCID.h" -#ifdef NS_DEBUG +#ifdef DEBUG #include "nsIServiceManager.h" #include "nsIPref.h" @@ -92,7 +92,7 @@ nsBaseWidget::nsBaseWidget() printf("WIDGETS+ = %d\n", gNumWidgets); #endif -#ifdef NS_DEBUG +#ifdef DEBUG debug_RegisterPrefCallbacks(); #endif @@ -801,7 +801,7 @@ nsBaseWidget::SetIcon(const nsAReadableString&) return NS_OK; } -#ifdef NS_DEBUG +#ifdef DEBUG ////////////////////////////////////////////////////////////// // // Convert a GUI event message code to a string. @@ -932,7 +932,8 @@ static PRBool debug_GetBoolPref(nsIPref * aPrefs,const char * aPrefName) return value; } ////////////////////////////////////////////////////////////// -static PRBool debug_GetCachedBoolPref(const char * aPrefName) +PRBool +nsBaseWidget::debug_GetCachedBoolPref(const char * aPrefName) { NS_ASSERTION(nsnull != aPrefName,"cmon, pref name is null."); @@ -1168,7 +1169,7 @@ nsBaseWidget::debug_DumpInvalidate(FILE * aFileOut, } ////////////////////////////////////////////////////////////// -#endif // NS_DEBUG +#endif // DEBUG diff --git a/widget/src/xpwidgets/nsBaseWidget.h b/widget/src/xpwidgets/nsBaseWidget.h index 1478dff92817..d878861c289f 100644 --- a/widget/src/xpwidgets/nsBaseWidget.h +++ b/widget/src/xpwidgets/nsBaseWidget.h @@ -196,7 +196,7 @@ protected: CREATE_HACK }; -#ifdef NS_DEBUG +#ifdef DEBUG protected: static nsAutoString debug_GuiEventToString(nsGUIEvent * aGuiEvent); static PRBool debug_WantPaintFlashing(); @@ -220,6 +220,7 @@ protected: const nsCAutoString & aWidgetName, PRInt32 aWindowID); + static PRBool debug_GetCachedBoolPref(const char* aPrefName); #endif }; diff --git a/widget/src/xpwidgets/nsXPLookAndFeel.cpp b/widget/src/xpwidgets/nsXPLookAndFeel.cpp index 1f27e15f58d7..5b6df20b3800 100644 --- a/widget/src/xpwidgets/nsXPLookAndFeel.cpp +++ b/widget/src/xpwidgets/nsXPLookAndFeel.cpp @@ -43,7 +43,7 @@ static int PR_CALLBACK colorPrefChanged(const char* aPref, void* aData); #include "nsIServiceManager.h" #include "nsIPref.h" -#ifdef NS_DEBUG +#ifdef DEBUG #include "nsSize.h" #endif @@ -484,7 +484,7 @@ nsXPLookAndFeel::LookAndFeelChanged() } -#ifdef NS_DEBUG +#ifdef DEBUG // This method returns the actual (or nearest estimate) // of the Navigator size for a given form control for a given font // and font size. This is used in NavQuirks mode to see how closely