Re: Getting window size (correctly)



Ok, so now I am really confused!

Try this out:

#! /usr/local/bin/perl
use Gtk;
init Gtk;
 
$window = new Gtk::Window('toplevel');
 
(undef, undef, $window_width, undef) = @{$window->allocation};
$window->signal_connect('configure_event', \&resize );
$window->signal_connect('destroy', sub { Gtk->exit( 0); });
$window->show();
main Gtk;
exit(0);
 
sub resize
{
        my ($window, $params, $event) = @_;
        my ($x, $y, $w, $h) = @{$window->allocation};
        print "allocation   : $x, $y, $w, $h\n";
        my ($x, $y, $w, $h) = $window->window->get_geometry;
        print "get_geometry : $x, $y, $w, $h\n\n";
}


If you run this it draws a window and prints out the geometry/allocation
data.

If you resize the window you'll see that the allocation number doesn't
change, but the geometry data does. If you move the window, the allocation
data catches the previous resize data to give the correct dimensions.

I guess that'll be the mostly bit in action :

...allocations all (well mostly) change on a window resize... 

Anyone got a way round this?

Cheers,

Bill.




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