/usr/lib/perl5/AnyEvent/Impl/FLTK.pm is in libanyevent-perl 7.010-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | =head1 NAME
AnyEvent::Impl::FLTK - AnyEvent adaptor for FLTK (Fast Light Toolkit version two)
=head1 SYNOPSIS
use AnyEvent;
use FLTK;
# this module gets loaded automatically as required
=head1 DESCRIPTION
This module provides transparent support for AnyEvent. You don't have to
do anything to make FLTK work with AnyEvent except by loading FLTK before
creating the first AnyEvent watcher.
This implementation is not to be confused with AnyEvent::Impl::FLTK by
Sanko Robinson. That implementation is completely broken, and the author
is apparently unreachable.
In any case, FLTK suffers from typical GUI-ToolKit diseases, such as O(n)
or worse for every operation (adding a timer, destroying a timer etc.),
the typical Not-Well-Tested Perl Interface disases such as non-random
memory corruption and the typical Event-Loop-as-an-Afterthrough issues,
such as multiple watchers on the same fd silently overwriting the others.
It doesn't have native idle, signal or child watchers, so all of these are
emulated.
=cut
package AnyEvent::Impl::FLTK;
use AnyEvent (); BEGIN { AnyEvent::common_sense }
use FLTK 0.532 ();
use Scalar::Util ();
#*AE::timer = \&EV::timer;
#*AE::signal = \&EV::signal;
#*AE::idle = \&EV::idle;
# FLTK::get_time_secs returns a glob :/
# on unix, fltk uses gettimeofday, so we are likely compatible
# on windows, fltk uses GetTickCount, to which we are unlikely to be compatible with.
#sub time { FLTK::get_time_secs }
#*now = \&time;
sub timer_interval_cb {
my $id = shift; # add_timeout kills @_, so we have to make a copy :(
$id->[0] = FLTK::add_timeout $id->[1], \&timer_interval_cb, $id;
&{ $id->[2] }
}
sub timer {
my ($class, %arg) = @_;
my $cb = $arg{cb};
if ($arg{interval}) {
my $id = [undef, $arg{interval}, $cb];
$id->[0] = FLTK::add_timeout $arg{after}, \&timer_interval_cb, $id;
return bless $id, "AnyEvent::Impl::FLTK::timer"
} else {
# non-repeating timers can be done very efficiently
# also, FLTK doesn't like callable objects
return FLTK::add_timeout $arg{after}, sub { &$cb }
}
}
sub AnyEvent::Impl::FLTK::timer::DESTROY {
undef $_[0][0];
}
sub io {
my ($class, %arg) = @_;
# only one watcher/fd :(
my $cb = $arg{cb};
my ($fh, $ev) = AnyEvent::_dupfh $arg{poll}, $arg{fh},
FLTK::READ,
FLTK::WRITE | (AnyEvent::WIN32 ? FLTK::EXCEPT : 0);
# fltk hardcodes poll constants and aliases EXCEPT with POLLERR,
# which is grossly wrong, but likely it doesn't use poll on windows.
FLTK::add_fd $fh, $ev, sub { &$cb }
}
# use signal and child emulation - fltk has no facilities for that
# fltk idle watchers are like EV::check watchers, and fltk check watchers
# are like EV::prepare watchers. both are called when the loop is busy,
# so we have to use idle watcher emulation.
sub _poll {
FLTK::wait;
}
sub AnyEvent::CondVar::Base::_wait {
FLTK::wait until exists $_[0]{_ae_sent};
}
#sub loop {
# FLTK::run;
#}
=head1 SEE ALSO
L<AnyEvent>, L<FLTK>.
=head1 AUTHOR
Marc Lehmann <schmorp@schmorp.de>
http://anyevent.schmorp.de
=cut
1
|