From 6c7a36cc1bb1aeefee3f15d8258199c798fa6fbf Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Mon, 2 Oct 2000 18:55:22 +0000 Subject: [PATCH] Added support for the wxNO_FULL_PAINT_ON_REDRAW style, Minor flicker reduction (when not using abovementioned flag). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@8459 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/frame.cpp | 1 - src/gtk/window.cpp | 93 ++++++++++++++++++++++++++------------------- src/gtk1/frame.cpp | 1 - src/gtk1/window.cpp | 93 ++++++++++++++++++++++++++------------------- 4 files changed, 108 insertions(+), 80 deletions(-) diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index ad97f5f7d9..3705e6ab60 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -126,7 +126,6 @@ static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* win->m_width = alloc->width; win->m_height = alloc->height; - win->m_queuedFullRedraw = TRUE; win->GtkUpdateSize(); } } diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index d8d2b32408..1f192b978a 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -703,18 +703,23 @@ static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_ev gdk_event->area.width, gdk_event->area.height ); - if (gdk_event->count == 0) - { - wxEraseEvent eevent( win->GetId() ); - eevent.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent(eevent); + if (gdk_event->count == 0) + { + win->m_clipPaintRegion = TRUE; + + wxEraseEvent eevent( win->GetId() ); + eevent.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent(eevent); - wxPaintEvent event( win->GetId() ); - event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); + if (!win->m_isFrame) printf( "OnExpose\n" ); - win->GetUpdateRegion().Clear(); - } + wxPaintEvent event( win->GetId() ); + event.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent( event ); + + win->GetUpdateRegion().Clear(); + win->m_clipPaintRegion = FALSE; + } /* The following code will result in all window-less widgets being redrawn if the wxWindows class is given a chance to @@ -792,45 +797,52 @@ static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxW } */ + if ((win->HasFlag(wxNO_FULL_REPAINT_ON_RESIZE)) && + (win->GetChildren().GetCount() == 0)) + { + return; + } + + GtkPizza *pizza = GTK_PIZZA (widget); - if (!(GTK_WIDGET_APP_PAINTABLE (widget)) && - (pizza->clear_on_draw)) - { - gdk_window_clear_area( pizza->bin_window, + if (!(GTK_WIDGET_APP_PAINTABLE (widget)) && + (pizza->clear_on_draw)) + { + gdk_window_clear_area( pizza->bin_window, rect->x, rect->y, rect->width, rect->height); - } + } - win->GetUpdateRegion().Union( rect->x, rect->y, rect->width, rect->height ); + win->GetUpdateRegion().Union( rect->x, rect->y, rect->width, rect->height ); - win->m_clipPaintRegion = TRUE; + win->m_clipPaintRegion = TRUE; - wxClientDC dc(win); - wxEraseEvent eevent( win->GetId(), &dc ); - eevent.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent(eevent); + wxEraseEvent eevent( win->GetId() ); + eevent.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent(eevent); - wxPaintEvent event( win->GetId() ); - event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); + if (!win->m_isFrame) printf( "OnDraw\n" ); - win->GetUpdateRegion().Clear(); + wxPaintEvent event( win->GetId() ); + event.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent( event ); - win->m_clipPaintRegion = FALSE; + win->GetUpdateRegion().Clear(); + win->m_clipPaintRegion = FALSE; - GList *children = pizza->children; - while (children) + GList *children = pizza->children; + while (children) + { + GtkPizzaChild *child = (GtkPizzaChild*) children->data; + children = children->next; + + GdkRectangle child_area; + if (gtk_widget_intersect (child->widget, rect, &child_area)) { - GtkPizzaChild *child = (GtkPizzaChild*) children->data; - children = children->next; - - GdkRectangle child_area; - if (gtk_widget_intersect (child->widget, rect, &child_area)) - { - gtk_widget_draw (child->widget, &child_area /* (GdkRectangle*) NULL*/ ); - } + gtk_widget_draw (child->widget, &child_area /* (GdkRectangle*) NULL*/ ); } + } } //----------------------------------------------------------------------------- @@ -2383,14 +2395,17 @@ void wxWindow::PostCreation() gtk_pizza_set_external( GTK_PIZZA(m_wxwindow), TRUE ); - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "event", - GTK_SIGNAL_FUNC(gtk_window_event_event_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event", GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this ); gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw", GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); + + if (HasFlag(wxNO_FULL_REPAINT_ON_RESIZE)) + { + gtk_signal_connect( GTK_OBJECT(m_wxwindow), "event", + GTK_SIGNAL_FUNC(gtk_window_event_event_callback), (gpointer)this ); + } } #if (GTK_MINOR_VERSION > 0) diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index ad97f5f7d9..3705e6ab60 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -126,7 +126,6 @@ static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* win->m_width = alloc->width; win->m_height = alloc->height; - win->m_queuedFullRedraw = TRUE; win->GtkUpdateSize(); } } diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index d8d2b32408..1f192b978a 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -703,18 +703,23 @@ static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_ev gdk_event->area.width, gdk_event->area.height ); - if (gdk_event->count == 0) - { - wxEraseEvent eevent( win->GetId() ); - eevent.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent(eevent); + if (gdk_event->count == 0) + { + win->m_clipPaintRegion = TRUE; + + wxEraseEvent eevent( win->GetId() ); + eevent.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent(eevent); - wxPaintEvent event( win->GetId() ); - event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); + if (!win->m_isFrame) printf( "OnExpose\n" ); - win->GetUpdateRegion().Clear(); - } + wxPaintEvent event( win->GetId() ); + event.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent( event ); + + win->GetUpdateRegion().Clear(); + win->m_clipPaintRegion = FALSE; + } /* The following code will result in all window-less widgets being redrawn if the wxWindows class is given a chance to @@ -792,45 +797,52 @@ static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxW } */ + if ((win->HasFlag(wxNO_FULL_REPAINT_ON_RESIZE)) && + (win->GetChildren().GetCount() == 0)) + { + return; + } + + GtkPizza *pizza = GTK_PIZZA (widget); - if (!(GTK_WIDGET_APP_PAINTABLE (widget)) && - (pizza->clear_on_draw)) - { - gdk_window_clear_area( pizza->bin_window, + if (!(GTK_WIDGET_APP_PAINTABLE (widget)) && + (pizza->clear_on_draw)) + { + gdk_window_clear_area( pizza->bin_window, rect->x, rect->y, rect->width, rect->height); - } + } - win->GetUpdateRegion().Union( rect->x, rect->y, rect->width, rect->height ); + win->GetUpdateRegion().Union( rect->x, rect->y, rect->width, rect->height ); - win->m_clipPaintRegion = TRUE; + win->m_clipPaintRegion = TRUE; - wxClientDC dc(win); - wxEraseEvent eevent( win->GetId(), &dc ); - eevent.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent(eevent); + wxEraseEvent eevent( win->GetId() ); + eevent.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent(eevent); - wxPaintEvent event( win->GetId() ); - event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); + if (!win->m_isFrame) printf( "OnDraw\n" ); - win->GetUpdateRegion().Clear(); + wxPaintEvent event( win->GetId() ); + event.SetEventObject( win ); + win->GetEventHandler()->ProcessEvent( event ); - win->m_clipPaintRegion = FALSE; + win->GetUpdateRegion().Clear(); + win->m_clipPaintRegion = FALSE; - GList *children = pizza->children; - while (children) + GList *children = pizza->children; + while (children) + { + GtkPizzaChild *child = (GtkPizzaChild*) children->data; + children = children->next; + + GdkRectangle child_area; + if (gtk_widget_intersect (child->widget, rect, &child_area)) { - GtkPizzaChild *child = (GtkPizzaChild*) children->data; - children = children->next; - - GdkRectangle child_area; - if (gtk_widget_intersect (child->widget, rect, &child_area)) - { - gtk_widget_draw (child->widget, &child_area /* (GdkRectangle*) NULL*/ ); - } + gtk_widget_draw (child->widget, &child_area /* (GdkRectangle*) NULL*/ ); } + } } //----------------------------------------------------------------------------- @@ -2383,14 +2395,17 @@ void wxWindow::PostCreation() gtk_pizza_set_external( GTK_PIZZA(m_wxwindow), TRUE ); - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "event", - GTK_SIGNAL_FUNC(gtk_window_event_event_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event", GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this ); gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw", GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); + + if (HasFlag(wxNO_FULL_REPAINT_ON_RESIZE)) + { + gtk_signal_connect( GTK_OBJECT(m_wxwindow), "event", + GTK_SIGNAL_FUNC(gtk_window_event_event_callback), (gpointer)this ); + } } #if (GTK_MINOR_VERSION > 0)