/usr/lib/perl5/Tk/DragDrop/SunDrop.pm is in perl-tk 1:804.030-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 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | package Tk::DragDrop::SunDrop;
require Tk::DragDrop::Rect;
use vars qw($VERSION);
$VERSION = '4.006'; # sprintf '4.%03d', q$Revision: #5 $ =~ /\D(\d+)\s*$/;
use base qw(Tk::DragDrop::Rect);
use strict;
use Tk::DragDrop::SunConst;
Tk::DragDrop->Type('Sun');
BEGIN
{
# Define the Rect API as members of the array
my @fields = qw(name win X Y width height flags ancestor widget);
my $i = 0;
no strict 'refs';
for ($i=0; $i < @fields; $i++)
{
my $j = $i;
*{"$fields[$i]"} = sub { shift->[$j] };
}
}
sub Preview
{
my ($site,$token,$e,$kind,$flags) = (@_);
$token->BackTrace('No flags') unless defined $flags;
my $sflags = $site->flags;
return if ($kind == _motion && !($sflags & MOTION));
return if ($kind != _motion && !($sflags & ENTERLEAVE));
my $data = pack('LLSSLL',$kind,$e->t,$e->X,$e->Y,$site->name,$flags);
$token->SendClientMessage('_SUN_DRAGDROP_PREVIEW',$site->win,32,$data);
}
sub Enter
{
my ($site,$token,$e) = @_;
$token->AcceptDrop;
$site->Preview($token,$e,_enter,0);
}
sub Leave
{
my ($site,$token,$e) = @_;
$token->RejectDrop;
$site->Preview($token,$e,_leave,0);
}
sub Motion
{
my ($site,$token,$e) = @_;
$site->Preview($token,$e,_motion,0);
}
sub HandleDone
{
my ($token,$seln,$offset,$max) = @_;
$token->Done;
return '';
}
sub HandleAck
{
my ($w,$seln,$offset,$max) = @_;
return '';
}
sub HandleItem
{
my ($w,$seln,$offset,$max) = @_;
return undef;
}
sub HandleCount
{
my ($w,$seln,$offset,$max) = @_;
return 1;
}
sub Drop
{
my ($site,$token,$seln,$e) = @_;
my $w = $token->parent;
$w->SelectionHandle('-selection'=>$seln,'-type'=>'_SUN_DRAGDROP_ACK',[\&HandleAck,$token,$seln]);
$w->SelectionHandle('-selection'=>$seln,'-type'=>'_SUN_DRAGDROP_DONE',[\&HandleDone,$token,$seln]);
my $atom = $w->InternAtom($seln);
my $flags = ACK_FLAG | TRANSIENT_FLAG;
my $data = pack('LLSSLL',$atom,$e->t,$e->X,$e->Y,$site->name,$flags);
$w->SendClientMessage('_SUN_DRAGDROP_TRIGGER',$site->win,32,$data);
}
sub FindSite
{
my ($class,$token,$X,$Y) = @_;
$token->{'SunDD'} = [] unless exists $token->{'SunDD'};
my $site = $class->SUPER::FindSite($token,$X,$Y);
if (!defined $site)
{
my $id = $token->PointToWindow($X,$Y);
while ($id)
{
my @prop;
Tk::catch { @prop = $token->property('get','_SUN_DRAGDROP_INTEREST', $id) };
if (!$@ && shift(@prop) eq '_SUN_DRAGDROP_INTEREST' && shift(@prop) == 0)
{
# This is a "toplevel" which has some sites associated with it.
my ($bx,$by) = $token->WindowXY($id);
$token->{'SunDDSeen'} = {} unless exists $token->{'SunDDSeen'};
return $site if $token->{'SunDDSeen'}{$id};
$token->{'SunDDSeen'}{$id} = 1;
my $sites = $token->{'SunDD'};
my $count = shift(@prop);
while (@prop && $count-- > 0)
{
my ($xid,$sn,$flags,$kind,$n) = splice(@prop,0,5);
if ($kind != 0)
{
warn "Don't understand site type $kind";
last;
}
while (@prop >= 4 && $n-- > 0)
{
my ($x,$y,$w,$h) = splice(@prop,0,4);
push(@$sites,bless [$sn,$xid,$x+$bx,$y+$by,$w,$h,$flags,$id,$token],$class);
}
}
return $class->SUPER::FindSite($token,$X,$Y);
}
$id = $token->PointToWindow($X,$Y,$id)
}
}
return $site;
}
my $busy = 0;
sub NewDrag
{
my ($class,$token) = @_;
delete $token->{'SunDD'} unless $busy;
delete $token->{'SunDDSeen'};
}
sub SiteList
{
my ($class,$token) = @_;
return @{$token->{'SunDD'}};
}
1;
__END__
# this code is obsolete now that we look at properties ourselves
# which means we don't need dropsite manager running
# On Sun's running OpenLook the window manager or dropsite mananger
# watches for and caches site info in a special selection
# This code got sites from that
#
sub SiteList
{
my ($class,$token) = @_;
unless (1 || $busy || exists $token->{'SunDD'})
{
Carp::confess('Already doing it!') if ($busy++);
my @data = ();
my @sites = ();
my $mw = $token->MainWindow;
$token->{'SunDD'} = \@sites;
Tk::catch {
@data = $mw->SelectionGet( '-selection'=>'_SUN_DRAGDROP_DSDM', '_SUN_DRAGDROP_SITE_RECTS');
};
if ($@)
{
$token->configure('-cursor'=>'hand2');
$token->grab(-global);
}
else
{
while (@data)
{
my $version = shift(@data);
if ($version != 0)
{
warn "Unexpected site version $version";
last;
}
push(@sites,bless [splice(@data,0,7)],$class);
}
}
$busy--;
}
return @{$token->{'SunDD'}};
}
1;
|