Applet resizing and Mixer applet in CVS HEAD



Hi folks,

Is anyone else getting strange behaviour with CVS head applet resizing?

I first noticed it when I wrote the screenshooter applet. I wanted my
applet to show either an hbox or vbox depending on panel orientation
_and_ size. The trouble is when moving an applet from a BOTTOM
oriented TINY panel to a RIGHT oriented NORMAL panel. The signals
recieved by the applet are
Change Orient
then
Change Size

The problem is that if you ask the panel for its size in the Orient
signal handler, it reports the old size (tiny), then the last signal
arrives with the correct size _and_ orient.

A futher problem is that if you ask the panel for its size and
orientation at applet startup, you seem to get the values for the main
panel. (On my desktop I have a TINY main panel, oriented BOTTOM, and a
NORMAL secondary panel, oriented RIGHT, if you ask the panel at
startup what the size and orient are, you get TINY BOTTOM, even if you
add the applet to the secondary panel - BUG?)

So it boils down to this. On startup, the applet screws up its
appearance. This is demonstrated by the mixer applet in head, and my
own screenshooter until I worked around it. The reason it screws up is
that is gets three requests to change orientation at startup:

1) Startup Code  : Orient = WRONG, Size=WRONG
2) Change Orient : Orient = RIGHT, Size=WRONG
3) Change Size   : Orient = RIGHT, Size=RIGHT

All these signals happen very close together, and I don't think the
applet gets to gtk_main_iteration inbetween. This screws up
orientation and appearance. (I can take a screenshot if anyone is
interested ;-)

The fix is kludgy, but works, I have applied it to screenshooter, and
the fix for mixer is included below. I actually went a bit further
than this in my applet, to avoid unecessary refreshes etc, so I wrote
a function that determines whether a change in orientation is
necessary, and I have combined both signal handlers (size and
orientation) into one function. I didn't want to screw too much with
someone else code here though...

Thanks. (I hope I made sense of that)

Tom.
-- 
            .-------------------------------------------------------.
    .^.     | Tom Gilbert, England | tom@tomgilbert.freeserve.co.uk |
    /V\     |----------------------| www.tomgilbert.freeserve.co.uk |
   // \\    | Sites I recommend:   `--------------------------------|
  /(   )\   | www.freshmeat.net www.enlightenment.org www.gnome.org |
   ^^-^^    `-------------------------------------------------------'
--- mixer.c.old	Fri Oct  1 18:45:28 1999
+++ mixer.c	Fri Oct  1 19:10:30 1999
@@ -541,6 +541,8 @@
 
 	mx = gtk_object_get_user_data(GTK_OBJECT(w));	
 
+	gtk_widget_hide(w);
+
 	if(md->size == SIZE_TINY) {
 		/* hide one box */
 		if((ORIENT_UP == md->orient) || (ORIENT_DOWN == md->orient))
@@ -569,10 +571,7 @@
 
 	md->orient = o;
 	
-	/* without this, the mixer sometimes draws itself incorrectly
-	   if you drag the panel around the screen a lot. */
-	while(gtk_events_pending())
-		gtk_main_iteration();
+	gtk_widget_show(w);
 }
 static void
 applet_change_size(GtkWidget *w, PanelSizeType o)
@@ -584,7 +583,9 @@
 
 	(*md->update_func) (mixerw, mvol);
 
-	mx = gtk_object_get_user_data(GTK_OBJECT(w));	
+	mx = gtk_object_get_user_data(GTK_OBJECT(w));
+
+	gtk_widget_hide(w);
 	
 	md->size = o;
 
@@ -606,10 +607,7 @@
 		}
 	}
 
-	/* without this, the mixer sometimes draws itself incorrectly
-	   if you drag the panel around the screen a lot. */
-	while(gtk_events_pending())
-		gtk_main_iteration();
+	gtk_widget_show(w);
 }
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]