Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl/Tk Fullscreen Windows 1

Status
Not open for further replies.

Kirsle

Programmer
Jan 21, 2006
1,179
US
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:
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.
 
Thanks for sharing this experience.

I have been creating full size windows in the past, but I never figured it out that you loose the application (Alt+Tab )using $main->overrideredirect(1);

Good stuff mate!



dmazzini
GSM System and Telecomm Consultant

 
In my experience, overrideredirect(1) removes its entry from the task bar (next to the start button, to clear that up) so you can't simply click it to refocus the window like you could any other window.

And then doing Alt+Tab doesn't show an icon for the window either. It's not a blank icon, there's just no entry for it, you can't select it with Alt+Tab to focus it again.

That being said, the only way I've found to be able to focus the window again is to click inside the window. Do other people not have this problem?
 
Most applications don't use a fullscreen display, so maybe no-one else has noticed?

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Good information, even if it's not something I see myself using (though maybe if I find the time to work through something like this SDL guide, but then I'd be using SDL and not Tk).

You should write a FAQ for it, drop it into the existing GUI category so mine doesn't feel so lonely.

- Andrew
Text::Highlight - A language-neutral syntax highlighting module in Perl
also on SourceForge including demo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top