Hello, 

         When I switch from a window to a new one, I found by accident there
is obvious flickering in this process.

         Since it only happens when showing a new window, I think it's
because of the DFB lower redrawing mechanism.

         The problem can be reshown like this:

                   There are two windows (window1, window2) which can switch
to each other. Window1 has an image of "gtk.gif" on it, and a button with
label "forward" on it, which can be triggered to switch to window2;

Window2 has the same image of "gtk.gif" on it, and a button with label
"bckward" on it, which can be triggered to switch to window1. So, when
switching from window1 to window2, the gtk logo image flickers obviously;
When we switch back to the existing window1, no flickering occurs.

         The test code is below:

 

#include <gtk/gtk.h>

#include <gdk/gdk.h>

#include <gdk/gdkkeysyms.h>

#include <stdio.h>

#define WINDOW_ICON "gtk.gif"

GtkWidget* window1;

GtkWidget *window2;

static void win_back(GtkWidget *widget, gpointer data)

{

         gtk_widget_hide(window2);

         gtk_widget_show_all(window1);

 

         return;

}

static void win_next(GtkWidget *widget,gpointer data)

{

                            

         GtkWidget *table;

         GtkWidget *button;

         GtkAttachOptions ex,fl,exfl;

         GtkRcStyle *rc;

         GtkStyle   *style;

 

#if 0  // if dont destroy the latter window (window2), no flickering will
appear when forwarding, because it already exist when switching.

         if(window2)

         {

                   if(window1)

                            gtk_widget_hide(window1);

                   gtk_widget_show(window2);

                   return;

         }

#endif

 

                   window2 = gtk_window_new(GTK_WINDOW_TOPLEVEL);

         gtk_widget_set_name(window2,"window");

         gtk_window_set_title(GTK_WINDOW(window2),"Style App");

         //gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);

         gtk_window_set_default_size(GTK_WINDOW(window2),240,320);

 

         //-------------------------------- pack button into
table-----------------------

         table = gtk_table_new(3,3,TRUE);

         gtk_widget_set_name(table,"table");

         gtk_widget_show(table);

         

         exfl = (GtkAttachOptions)5;

         ex = GTK_EXPAND;

         fl = GTK_FILL;

 

         button = gtk_image_new_from_file(WINDOW_ICON);

         gtk_widget_show(button);

         gtk_table_attach (GTK_TABLE (table),      \

                            button, \

                        /* X direction */          /* Y direction */ \

                        1,2,                      1, 2,      \

                        (GtkAttachOptions)exfl,
(GtkAttachOptions)exfl,         \

                        1,                         1);      

 

         button = gtk_button_new_with_label("bckward");

         gtk_widget_show(button);

         gtk_widget_set_name(button,"buttonb");

         g_signal_connect (G_OBJECT (button), "clicked",G_CALLBACK
(win_back), window2);

 

         gtk_table_attach (GTK_TABLE (table),      \

                            button, \

                        /* X direction */          /* Y direction */ \

                        0,1,                      0, 1,      \

                        (GtkAttachOptions)exfl,
(GtkAttachOptions)exfl,         \

                        1,                         1);      

 

         gtk_container_add(GTK_CONTAINER(window2),table);

         gtk_widget_show(window2);    

         //gtk_widget_show_all(window);

         return;

}

int main(int argc, char **argv)

{

         GtkWidget *table;

         GtkWidget *button;

         GtkAttachOptions ex,fl,exfl;

 

         gtk_init(&argc, &argv);

 

         window1 = gtk_window_new(GTK_WINDOW_TOPLEVEL);

         gtk_widget_set_name(window1,"window");

         gtk_window_set_title(GTK_WINDOW(window1),"Style App");

         //gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);

         gtk_window_set_default_size(GTK_WINDOW(window1),240,320);

 

         //-------------------------------- pack button into
table-----------------------

         table = gtk_table_new(3,3,TRUE);

         gtk_widget_set_name(table,"table");

         

         exfl = (GtkAttachOptions)5;

         ex = GTK_EXPAND;

         fl = GTK_FILL;

 

         button = gtk_image_new_from_file(WINDOW_ICON);

         gtk_widget_set_name(button,"sbutton");

 

         gtk_table_attach (GTK_TABLE (table),      \

                            button, \

                        /* X direction */          /* Y direction */ \

                        1,2,                      1, 2,      \

                        (GtkAttachOptions)exfl,
(GtkAttachOptions)exfl,         \

                        1,                         1);      

 

         button = gtk_button_new_with_label("forward");

         gtk_widget_set_name(button,"buttonf");

         g_signal_connect (G_OBJECT (button), "clicked",G_CALLBACK
(win_next), window1);

 

         gtk_table_attach (GTK_TABLE (table),      \

                            button, \

                        /* X direction */          /* Y direction */ \

                        0,1,                      0, 1,      \

                        (GtkAttachOptions)exfl,
(GtkAttachOptions)exfl,         \

                        1,                         1);      

         gtk_container_add(GTK_CONTAINER(window1),table);

 

         gtk_widget_show(button);

         gtk_widget_show(table);

         gtk_widget_show_all(window1);

 

         gtk_main();

         

         return 0;

}

         Anyone can shed some light on me? Thanx in advance.

 

---------------------------------------

Best Wishes!

 

Zhang Hui

Email:  <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED]

Phone: 86-25-58748787-8215 

Samsung Electronics(China) R&D Center

---------------------------------------

 

Attachment: gtk.gif
Description: GIF image

_______________________________________________
directfb-dev mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev

Reply via email to