RE: get_maximized



On Wed, 2006-09-06 at 15:49 +0200, Ratcliffe, Jeffrey (Peters) wrote:
How do I check whether a window has been maximized or not?

Connect a callback to the 'window-state-event' event, and check the
passed Gtk2::Gdk::Event::WindowState when the event is fired; the
changed_mask member of the event should contain the 'maximized' flag.

  $window->signal_connect(window_state_event => sub {
      my ($w, $event) = @_;

      if ($event->changed_mask & [ 'maximized', ]) {

This should read:

          if ($event->changed_mask * [ 'maximized', ]) {

(my memory is not that good anymore - ruined by too much C :-))

          print "The window has been maximized\n";
      }
  });

Thanks for the quick response.

That fires when a window is maximized, but also restored (bug?), and
doesn't tell me when the window is no longer maximized because it has
been moved whilst in the maximized state.

Any idea how to get the remaining info?

You should really read Gtk2::Gdk::Event::WindowState - I pointed you in
the right direction but this mailing list is not an excuse for not
reading the documentation.

Anyway, you want to keep a boolean flag ('$is_maximized') around and
check if the window has already been maximized or not.

The changed_mask shows you what changed since the last window state
event; if you removed the maximized state then you get it in the
bitmask.

Ciao,
 Emmanuele.

-- 
Emmanuele Bassi,  E: ebassi gmail com
W: http://www.emmanuelebassi.net
B: http://log.emmanuelebassi.net




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