in reply to Prevent overidedirect from being always on top

Here is something you might work on; you can turn off the overrideredirect flag. Possibly you could work out a system to remove the flag when you need to place something on top, then restore the flag when done.
#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = tkinit; $mw->geometry("200x300+200+200"); $mw->overrideredirect(1); # set the override-redirect flag $mw->packPropagate(0); # prevent the window being resized # for this demo $mw->Button( -text => 'Quit', -command => sub { Tk::exit(0) }, )->pack( -side => 'bottom', ); # after a delay: # withdraw # clear the override-redirect flag # re-map the window $mw->after( 4000, sub { $mw->withdraw; $mw->overrideredirect(0); $mw->deiconify; $mw->raise; } ); # NB: # "Mastering Perl/Tk" mentions that clearing # the override-redirect flag will not cause # the window manager to supply decorations. # This is true, but at least on KDE, clearing # the flag, then unmapping and mapping the # window puts decorations in place. # # Your mileage may vary. MainLoop;

Replies are listed 'Best First'.
Re^2: Prevent overidedirect from being always on top
by Anonymous Monk on Jan 28, 2015 at 01:58 UTC

    That is clever, but is it needed?

    as far as I can tell, it isn't needed, as the messagebox pops up on top of the notification no matter what happens

    #!/usr/bin/perl -- use strict; use warnings; use Tk; Main( @ARGV ); exit( 0 ); sub Main { my $mw = tkinit( ); $mw->geometry('+300+400'); my $notification = $mw->Toplevel( ); $notification->geometry('+400+400'); $notification->overrideredirect(1); # Remove window decorations $notification->withdraw; # Hide display window $notification->Label( -text => 'keep clicking toggle ', -foreground => 'white', -background => 'black', -height => 5 )->pack; $notification->Button( -text => 'Press Me', #~ -command => [ \&important_message, $notification ], ## not +needed -command => \&important_message, )->pack; $mw->Button( -text => 'Display Notification Window', -command => [ 'deiconify', $notification ], )->pack->focus; $mw->Button( -text => 'toggle topmost notification ', -command => [ \&toggle_topmost , $notification ], )->pack; $mw->Button( -text => 'hide notification ', -command => [ 'withdraw', $notification ], )->pack; ## $mw->WidgetDump; ## debugging aid MainLoop; } sub important_message { #~ my( $n ) = @_; my( $n ) = $Tk::widget; #~ my $msg = $mw->messageBox( ## works to raise above $notificatio +n on win32, might not work on all platforms my $msg = $n->messageBox( -icon => 'error', -message => "No tests selected", -title => 'Error', -type => 'Ok', -default => 'Ok', ); } sub toggle_topmost { my( $n ) = @_; warn $n->attributes; $n->attributes(-topmost => ! $n->attributes(-topmost ) );; $n->parent->raise; $n->parent->focus; } __END__ __END__