logo       
Google Custom Search
    AddThis Social Bookmark Button

Re: geometry of gtk window relative to root window: msg#00048

Subject: Re: geometry of gtk window relative to root window
Riswick, J.G.A. van wrote:

HI

How does one get the geometry of a gtk window relative to the root?
I tried

  my $width  = $widget->allocation->[0];
  my $height = $widget->allocation->[1];

but that always returns 0...


the Gdk window is the one for which you can get a position.
try this:

   $win = new Gtk::Window 'toplevel';
   $win->add_events ( 'button-press-mask' );
   $win->signal_connect ( button_press_event => sub {
                  use Data::Dumper;
                  print Dumper( [ $win->window->get_position ] );
                  1;
                  } );
   $win->signal_connect ( delete_event => sub { Gtk->main_quit; 1 } );
   $win->show;
   Gtk->main;

move the window and click in it, then do it again. looks like the root window coordinates of the Gdk window. for child windows it tells you the position relative to the upper left corner of the parent.



Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>