Context - Ubuntu 18.04.2 LTS Gnome-Shell 3.28.3 Perl 5.26.1 Tk 804.034
Goal - on starting a new Tk based GUI app session position the window($mw for reference) where the user last left it (implicit assumption that screen dimensions don't change between sessions)!
I encountered the following challenges in doing that:
1) - $mw->rooty not readily helpful as it reflects position after decoration & Ubuntu top task bar
2) - $mw->geometry return changes once $mw->withdraw
The code below demonstrates the issue - the results I get from running in my context are at the end of the code. My question relates to (2) and simply put is it a bug or am I missing/overlooking something?
As the app I am working on may see the window withrawn, raised, possibly moved, withdrawn ... ad nauseam I have yet to determine what complications ensure. So any 'better ways' gratefully accepted.
Changing starting pos("+10+0") to away from any potential complications with System task/activity bars still reflects the issue.
#!/usr/bin/perl use strict; use Tk; my $mw = MainWindow->new(-title=>'WTF'); $mw->geometry('+10+0'); $mw->overrideredirect(0); my $lab = $mw->Label(-text=>'This is a label in the MainWindow',-font= +>'fixed 24',-border=>0)->pack(-anchor=>'w'); $mw->update; $mw->protocol('WM_DELETE_WINDOW' => sub{printf "exit geometry=%s,rootx +=%d,rooty=%d;height:%.2f\n",$mw->geometry,$mw->rootx,$mw->rooty,$mw-> +height; Tk::exit}); printf "init geometry=%s,rootx=%d,rooty=%d;height:%.2f\n",$mw->geometr +y,$mw->rootx,$mw->rooty,$mw->height; $mw->withdraw; $mw->after(2000,sub{ $mw->state('normal'); return 1; } ); # MainLoop; exit(0); __END__ init geometry=497x32+10+0,rootx=10,rooty=57;height:32.00 exit geometry=497x32+0+19,rootx=10,rooty=57;height:32.00
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |