--- deliantra/Deliantra-Client/DC/UI.pm 2007/07/21 13:56:00 1.395 +++ deliantra/Deliantra-Client/DC/UI.pm 2007/07/21 14:00:02 1.396 @@ -1136,6 +1136,25 @@ } } + +sub start_dragging { + my ($self, $ev) = @_; + + $self->grab_focus; + + my $ox = $self->{vp}{view_x}; + my $oy = $self->{vp}{view_y}; + + $self->{motion} = sub { + my ($ev, $x, $y) = @_; + + $ox -= $ev->{xrel}; + $oy -= $ev->{yrel}; + + $self->{vp}->set_offset ($ox, $oy); + }; +} + sub invoke_mouse_wheel { my ($self, $ev) = @_; @@ -1152,17 +1171,7 @@ my ($self, $ev, $x, $y) = @_; if ($ev->{button} == 2) { - $self->grab_focus; - - my $ox = $self->{vp}{view_x} + $ev->{x}; - my $oy = $self->{vp}{view_y} + $ev->{y}; - - $self->{motion} = sub { - my ($ev, $x, $y) = @_; - - $self->{vp}->set_offset ($ox - $ev->{x}, $oy - $ev->{y}); - $self->update; - }; + $self->start_dragging ($ev); return 1; }