in reply to Identify Tk state iconic to normal events

Bind all events? Other ideas UTSL Re^8: Query the height of Tk::Text widget with word wrap (tk without no tray icon overrideredirect splashscreen state zoomed deiconify Tk::Splashscreen Tk::StayOnTop
  • Comment on Re: Identify Tk state iconic to normal events

Replies are listed 'Best First'.
Re^2: Identify Tk state iconic to normal events
by Anonymous Monk on Jul 21, 2019 at 08:47 UTC
    Heh
    #!/usr/bin/perl -- use strict; use warnings; use Tk; use Data::Dump qw/ dd /; my @tags = ( "<KeyPress>", "<KeyRelease>", "<ButtonPress>", "<ButtonRelease>", "<FocusIn>", "<FocusOut>", "<Expose>", "<MapRequest>", "<ConfigureRequest>", "<ResizeRequest>", "<Activate>", "<Deactivate>", "<Activate>", "<Destroy>", "<Map>", "<ButtonPress>", "<Button>", "<Enter>", "<MapRequest>", "<ButtonRelease>", "<Expose>", "<Motion>", "<Circulate>", "<FocusIn>", "<MouseWheel>", "<FocusOut>", "<Property>", "<Colormap>", "<Gravity>", "<Reparent>", "<Configure>", "<Key>", "<ResizeRequest>", "<ConfigureRequest>", "<KeyRelease>", "<Unmap>", "<Create>", "<Leave>", "<Visibility>", "<Deactivate>", ); my $mw = tkinit(); $mw->Button( qw/ -text exit -command /, sub { $Tk::widget->toplevel->destroy; } )->pack; my %seen; for my $bindtag ( @tags ) { $mw->bind( $mw, $bindtag, sub { $seen{$bindtag}++; print qq{$bindtag \$e $Tk::event \$w $Tk::widget \@_ @_\n} +; } ); } my $redirect = 0; $mw->geometry( '480x480+50+50' ); $mw->overrideredirect( $redirect = !$redirect ); $mw->withdraw; $mw->deiconify; $mw->raise; $mw->repeat( 1000, sub { $Tk::widget->overrideredirect( $redirect = !$redirect ); $Tk::widget->deiconify; $Tk::widget->raise; } ); dd \%seen; $mw->MainLoop; dd \%seen; __END__ <Visibility> $e XEvent=SCALAR(0xf45c24) $w Tk::Button=HASH(0xf56344) @ +_ Tk::Button=HASH(0xf56344) <Configure> $e XEvent=SCALAR(0xf648a4) $w MainWindow=HASH(0xf27a84) @_ + MainWindow=HASH(0xf27a84) <Expose> $e XEvent=SCALAR(0xf64864) $w MainWindow=HASH(0xf27a84) @_ Ma +inWindow=HASH(0xf27a84) <Key> $e XEvent=SCALAR(0xf28494) $w MainWindow=HASH(0xf27a84) @_ MainW +indow=HASH(0xf27a84) <FocusIn> $e XEvent=SCALAR(0xf647d4) $w Tk::Button=HASH(0xf56344) @_ T +k::Button=HASH(0xf56344) <KeyRelease> $e XEvent=SCALAR(0xf64794) $w Tk::Button=HASH(0xf56344) @ +_ Tk::Button=HASH(0xf56344) <Destroy> $e XEvent=SCALAR(0xf56514) $w Tk::Button=HASH(0xf56344) @_ T +k::Button=HASH(0xf56344) <Destroy> $e XEvent=SCALAR(0xf27b84) $w MainWindow=HASH(0xf27a84) @_ M +ainWindow=HASH(0xf27a84) { "<Button>" => 1, "<ButtonRelease>" => 1, "<Configure>" => 36, "<Destroy>" => 2, "<Enter>" => 3, "<Expose>" => 24, "<FocusIn>" => 16, "<FocusOut>" => 14, "<Key>" => 96, "<KeyRelease>" => 97, "<Leave>" => 2, "<Map>" => 25, "<Motion>" => 21, "<Visibility>" => 48, }

      Thank you. The answer it led me too, while counter intuitive, was FocusIn(A widget has gained the keyboard focus) is the 'only' event(at least in the provided tags) that is generated when a window in iconic state becomes visible. Your code helped me to find that!
      Please note it had to be modified as the logic you employed does not see an Icon appear in Ubuntu Activities Bar so no user interaction viable to restore it once withdrawn.