1 # Copyright (c) 2003-2009 Mikhael Goikhman
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 package FVWM
::Tracker
::PageInfo
;
21 use FVWM
::Tracker
qw(base);
35 $self->add_handler(M_NEW_PAGE
, sub {
37 $self->calculate_internals($event->args);
40 $self->request_windowlist_events;
42 my $result = $self->SUPER::start
;
44 $self->delete_handlers;
46 $self->add_handler(M_NEW_PAGE
| M_NEW_DESK
, sub {
48 if ($event->type == M_NEW_DESK
) {
49 my $old_desk_n = $self->{data
}->{desk_n
};
50 my $new_desk_n = $event->args->{desk_n
};
51 $self->{data
}->{desk_n
} = $new_desk_n;
52 my $really_changed = $old_desk_n != $new_desk_n;
53 $self->notify("desk only changed", $really_changed);
54 return unless $really_changed;
56 $self->calculate_internals($event->args);
57 $self->notify("page only changed");
59 $self->notify("desk/page changed");
65 sub calculate_internals
($$) {
68 my $data = $self->{data
};
70 @
$data{keys %$args} = values %$args;
71 $data->{page_nx
} = int($data->{vp_x
} / $data->{vp_width
});
72 $data->{page_ny
} = int($data->{vp_y
} / $data->{vp_height
});
77 my $data = $self->{data
};
78 my $string = join(', ', map { "$_=$data->{$_}" } sort keys %$data) . "\n";
79 $string =~ s/^(.*?)(, d.*?)(, p.*?), (v.*)$/$1$3$2\n$4/s;
89 This B<FVWM::Tracker> subclass provides an information about the current
90 fvwm page and desk and screen dimensions. Like with all trackers, this
91 information is automatically brought up to the date for the entire tracker
92 object life and may be retrieved by its C<data> method.
94 This tracker defines the following observables that enable additional way
103 Using B<FVWM::Module> $module object:
105 my $page_tracker = $module->track("PageInfo");
106 my $page_hash = $page_tracker->data;
107 my $curr_desk = $page_hash->{'desk_n'};
109 =head1 OVERRIDDEN METHODS
115 Returns hash ref representing the current page/desk, with the following keys
116 (the fvwm variable equivalents are shown on the right):
121 desk_pages_x $[desk.pagesx]
122 desk_pages_y $[desk.pagesy]
124 vp_height $[vp.height]
130 Returns 2 debug lines representing the current page data (as described in
131 C<data>) in the human readable format.
137 Mikhael Goikhman <migo@homemail.com>.
141 For more information, see L<FVWM::Module> and L<FVWM::Tracker>.