@@ -2370,8 +2370,8 @@ sub profile_default
23702370sub max_extents
23712371{
23722372 shift ;
2373- my @pos = @_ || $: :application-> pointerPos;
2374- my @sz = $: :application-> size;
2373+ my @pos = @_ ? @_ : $: :application-> pointerPos;
2374+ my @sz = $: :application-> size;
23752375 for my $r ( @{$: :application-> get_monitor_rects} ) {
23762376 next unless
23772377 $r -> [0] <= $pos [0] && $r -> [2] > $pos [0] &&
@@ -2407,6 +2407,60 @@ sub on_change
24072407 $self -> size(@sz );
24082408}
24092409
2410+ sub on_hint
2411+ {
2412+ my ( $self , $widget , @around ) = @_ ;
2413+
2414+ my (@pos , @size );
2415+ if ( 4 == (grep { $_ == -1 } @around )) {
2416+ @size = $widget -> size;
2417+ @pos = $widget -> client_to_screen(0,0);
2418+ } else {
2419+ @pos = @around [0,1];
2420+ $size [0] = $around [2] - $pos [0];
2421+ $size [1] = $around [3] - $pos [1];
2422+ }
2423+
2424+ $self -> set(
2425+ text => $widget -> hint,
2426+ color => $widget -> hintColor,
2427+ backColor => $widget -> hintBackColor,
2428+ );
2429+
2430+ my @psize = map { $: :application-> get_system_value($_ ) } (
2431+ sv::XPointer, sv::YPointer
2432+ );
2433+ my @mouse = $: :application-> pointerPos;
2434+ my @monitor = $: :application-> point_to_monitor(@mouse );
2435+ my @hsize = $self -> size;
2436+ my @fin = ($mouse [0] - $psize [0]/2, $pos [1] - $hsize [1] - 1);
2437+ $fin [1] = $mouse [1] - $hsize [1] - $psize [1]
2438+ if $fin [1] > $mouse [1] - $hsize [1] - $psize [1];
2439+ $fin [0] = $pos [0] - $hsize [0]
2440+ if $fin [0] + $hsize [0] > $monitor [2];
2441+ $fin [0] = $monitor [0]
2442+ if $fin [0] < $monitor [0];
2443+ $fin [1] = $pos [1] - $hsize [1]
2444+ if $fin [1] + $hsize [1] >= $monitor [3];
2445+ $fin [1] = $pos [1] + $size [1] + $psize [1]/2
2446+ if $fin [1] < $monitor [1];
2447+ $fin [1] = $monitor [2] - $hsize [1]
2448+ if $fin [1] + $hsize [1] >= $monitor [3];
2449+ $fin [1] = $monitor [1]
2450+ if $fin [1] < $monitor [1];
2451+ if (
2452+ $fin [0] <= $mouse [0] && $fin [0] + $hsize [0] >= $mouse [0] + $psize [0] &&
2453+ $fin [1] <= $mouse [1] && $fin [1] + $hsize [1] >= $mouse [1] + $psize [1]
2454+ ) {
2455+ $fin [0] = $mouse [0] + $psize [0];
2456+ $fin [1] = $mouse [1] - $psize [1] - $hsize [1];
2457+ }
2458+
2459+ $self -> origin(@fin );
2460+ $self -> show;
2461+ $self -> bring_to_front;
2462+ }
2463+
24102464sub on_paint
24112465{
24122466 my ($self ,$canvas ) = @_ ;
@@ -2646,6 +2700,20 @@ sub open_help
26462700 return $self -> {HelpClass }-> open ($link );
26472701}
26482702
2703+ sub point_to_monitor
2704+ {
2705+ shift ;
2706+ my @pos = @_ ? @_ : $: :application-> pointerPos;
2707+ for my $r ( @{$: :application-> get_monitor_rects} ) {
2708+ next unless
2709+ $r -> [0] <= $pos [0] && $r -> [2] > $pos [0] &&
2710+ $r -> [1] <= $pos [1] && $r -> [3] > $pos [1]
2711+ ;
2712+ return @$r ;
2713+ }
2714+ return (0,0,$: :application-> size);
2715+ }
2716+
26492717sub on_die
26502718{
26512719 my ($self , $err , $stack ) = @_ ;
0 commit comments