3 # This module uses Gtk-Perl to display the flash window when page is changed.
4 # It understands 2 dynamical commands:
5 # SendToModule /path/to/module-gtkflash format 'x = %d, y = %d'
6 # SendToModule /path/to/module-gtkflash stop
8 use lib
`fvwm-perllib dir`;
10 use General
::Parse
qw(get_tokens);
13 my $format = "(%d, %d)";
14 my $module = new FVWM
::Module
::Gtk
(Mask
=> M_NEW_PAGE
| M_STRING
);
16 $module->add_handler(M_STRING
, sub {
17 my ($module, $event) = @_;
18 my $line = $event->_text;
19 my ($action, @args) = get_tokens
($line);
21 if ($action eq "stop") {
23 } elsif ($action eq "format") {
28 my $last_window = undef;
29 $module->add_handler(M_NEW_PAGE
, sub {
30 my ($module, $event) = @_;
32 my $width = $event->_vp_width;
33 my $height = $event->_vp_height;
35 if (!$width || !$height) {
36 # this may happen when doing DeskTopSize 1x1 on page 2 2
39 my $page_nx = int($event->_vp_x / $width);
40 my $page_ny = int($event->_vp_y / $height);
42 # actually show the flash
43 my ($w, $h) = (100, 50);
44 my $string = sprintf($format, $page_nx, $page_ny);
46 my $window = new Gtk
::Window
('toplevel');
47 $window->set_title("FlashWindow");
48 $window->set_border_width(5);
49 $window->set_usize($w, $h);
50 $window->set_uposition(($width - $w) / 2, ($height - $h) / 2);
52 my $frame = new Gtk
::Frame
();
54 $frame->set_shadow_type('etched_out');
56 my $label = new Gtk
::Label
($string);
60 $last_window->destroy() if $last_window;
61 $last_window = $window;
63 # alarm is not called in perl-5.8.0, but called in earlier perls!..
64 # probably some problem with Gtk-Perl and perl-5.8.0
66 $last_window->destroy();
72 $module->send("Style FlashWindow UsePPosition, NoTitle, NoHandles, BorderWidth 10, StaysOnTop, WindowListSkip, NeverFocus");