This is a nifty trick I discovered for fixing a "problem" with fullscreen PerlTk windows.
First of all, by "fullscreen window," I mean a window with no chrome (no title bar or borders), is positioned in the top left corner of the screen and extends to the screen's width and height.
Here's code that would do that:
The problem is that when you do overrideredirect(1)... not only does the window lose its chrome, but it loses its entry on the Windows task bar too.
So you have your fullscreen window open, but if you Alt+Tab away from it and it becomes lost under your other windows, it's hard to switch back to it. It has no task bar entry, or any entry you can pick by doing Alt+Tab.
The trick I figured out: create a "control window," which is just a little toplevel window, so it will have a taskbar entry. When this window gains focus, it sends the focus to the fullscreen window, bringing it back to the top (like it should).
So that makes a tiny 50x50 window, hidden off screen, and when you focus on it, $main (the fullscreen mainwindow) steals the focus, bringing it back to cover the full screen again.
First of all, by "fullscreen window," I mean a window with no chrome (no title bar or borders), is positioned in the top left corner of the screen and extends to the screen's width and height.
Here's code that would do that:
Code:
my $main = MainWindow->new (
-title => 'Test',
-background => 'black',
);
my $w = $main->screenwidth;
my $h = $main->screenheight;
$main->overrideredirect (1);
$main->MoveToplevelWindow (0,0);
$main->geometry (join('x',$w,$h));
The problem is that when you do overrideredirect(1)... not only does the window lose its chrome, but it loses its entry on the Windows task bar too.
So you have your fullscreen window open, but if you Alt+Tab away from it and it becomes lost under your other windows, it's hard to switch back to it. It has no task bar entry, or any entry you can pick by doing Alt+Tab.
The trick I figured out: create a "control window," which is just a little toplevel window, so it will have a taskbar entry. When this window gains focus, it sends the focus to the fullscreen window, bringing it back to the top (like it should).
Code:
# Create a "control window"
my $control = $main->Toplevel (
-title => 'FS Window',
);
$control->geometry ("50x50");
$control->MoveToplevelWindow(-150,-150);
# Bind FocusIn on the control window
$control->bind ('<FocusIn>', sub {
$main->focusForce;
});
So that makes a tiny 50x50 window, hidden off screen, and when you focus on it, $main (the fullscreen mainwindow) steals the focus, bringing it back to cover the full screen again.