After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 108931 - gnome terminal does not save geometry & active tabs in session
gnome terminal does not save geometry & active tabs in session
Status: RESOLVED FIXED
Product: gnome-terminal
Classification: Core
Component: general
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: Havoc Pennington
GNOME Terminal Maintainers
Depends on:
Blocks:
 
 
Reported: 2003-03-22 01:48 UTC by Mariano Suárez-Alvarez
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
This adds geometry & active tab to session (10.07 KB, patch)
2003-03-22 01:49 UTC, Mariano Suárez-Alvarez
none Details | Review
Patch to add --active (3.17 KB, patch)
2003-03-24 07:08 UTC, Mariano Suárez-Alvarez
none Details | Review
Patch to add --tab and --window (3.30 KB, patch)
2003-03-24 07:09 UTC, Mariano Suárez-Alvarez
none Details | Review
Fixed patch to add --tab and --window (2.87 KB, patch)
2003-03-25 23:57 UTC, Mariano Suárez-Alvarez
none Details | Review

Description Mariano Suárez-Alvarez 2003-03-22 01:48:07 UTC
gnome-terminal does not save the geometry of its
windows to the session, and it does not save the
active tab in each window (for some reason, I feel
the ``first'' tab is the leftmost one, not the
rightmost one, so each time I log in, I have to
activate it. Minor problem, I know...)
Comment 1 Mariano Suárez-Alvarez 2003-03-22 01:49:41 UTC
Created attachment 15161 [details] [review]
This adds geometry & active tab to session
Comment 2 Mariano Suárez-Alvarez 2003-03-22 01:59:55 UTC
The patch adds geometry to the RestartCommand in the session,
and four new cmdline options:

--window: like --window-with-profile but using the default profile

--tab: like --tab-with-profile but using the default profile

--repeat: repeats the last tab COUNT times, so u can say 

   gnome-terminal --repeat 3

and you get 4 tabs (the "extra" tab can be avoided,  but that would
change the behaviour of the existing cmdline options...)

--active: makes the last specified tab the active one.

The first three are just convenient (I think there should be --profile
and --profile-internal-id options, and --tab-with-profile, etc, should
be dropped, because that would make options a bit more orthogonal),
and the --active one is needed to store active tabs in the session.

Cheers,

-- m
Comment 3 Havoc Pennington 2003-03-22 06:32:35 UTC
Saving --geometry is wrong, that is the window manager's
responsibility according to the specifications. 

I like --active and saving --active in the session, would like to see
that part of the patch split out.

--window/--tab/--repeat seem like they're adding extra options that
aren't needed. They may have been a better way to do it from scratch, 
but deprecating --window-with-profile isn't very easy (it breaks lots 
of existing sessions and desktop files), and so we would just have 
the duplication forever. What is wrong with "--window-with-profile
default" other than extra typing?
Comment 4 Mariano Suárez-Alvarez 2003-03-22 07:16:46 UTC
Funny, I have just read you yourself comment that "metacity _can't_ do
it, there isn't enough information available." in 84984 ;)

I think I'm running the latest metacity (2.4.34) and it does not save
geometry, at least not for gnome-terminals... Maybe that is a metacity
bug, granted, but I could refer you to 84984.

I'll post the --active patch, if you want it.

Apart from extra typing (never to be overlooked) it's a bit annoying
to have to know how the default profile is called (it's not
necessarily Default...), and having to specify it anyway defeats the
whole concept of defaultness, at least from the command line point of
view.

I don't feel that strongly about --repeat, though "gnome-terminal
--repeat 4" is a lot less typing than "gnome-terminal
--tab-with-profile=Default --tab-with-profile=Default
--tab-with-profile=Default --tab-with-profile=Default," isn't it?

This is not abstract: I do start gnome-terminals from the command line
 quite frequently, and up to now now the command-line rewriting was
being done by a script.

One thing I would love, and which is not difficult though I cannot
think of what the UI should be like, is a save-state-to-a-launcher,
pretty much like the save-state-to-session, but which sets up
something one can put on the desktop for you to click on.

Btw, how does one (if possible) specify a geometry for a window which
includes the workspace?
Comment 5 Havoc Pennington 2003-03-22 07:47:02 UTC
84984 is about saving within a session, while this patch is about 
saving across sessions. There is a spec for saving across. 
Saving within is harder but there's a metacity patch for it
still in the works.

If saving across sessions doesn't work, then it is a metacity bug
probably. See ~/.metacity/sessions (and ignore the way gnome-session
fails to run DiscardCommand to clean up those files...) and 
metacity/src/session.c

I guess --tab/--window aren't so bad. --repeat I'm still having
trouble talking myself into. ;-)

Workspace could be implemented as --workspace, but perhaps this 
isn't much of an issue if we get window history in metacity, and 
with startup notification (terminals should always come up on the 
workspace where you clicked the launcher, if your launcher 
has StartupNotify=true - in GNOME 2.2 the launcher should have that).
So I'd like to hold off on --workspace until we have window history in
metacity and see if it's still an issue.
Comment 6 Mariano Suárez-Alvarez 2003-03-22 10:24:07 UTC
After rm'ing everything in .metacity/sessions it turns out that my
gnome-terminals do get positioned correctly (I had a couple of files
in there which were just an empty <metacity_session/> element; maybe
my .gnome2/session was pointing to one of them? I don't know since the
idea  came to me after deleting them...)

But window sizes do not get restored: gnome-terminals restarted with
the session all turn out in classic 80x24 size. After a lot of log
in/log out cycles, I discovered that the window is being initially
presented with the correct (ie, as saved in the session) size, and
then reset to 80x24, only this happens so fast I had not even noticed. 

The problem is neither gnome-terminal nor metacity, but vte. It turns
out that $GNOME_HOME/share/vte/termcaps/xterm (its default termcap)
includes the fields co#80 and li#24, so what's happening is that in
the absence of a --geometry spec in the RestartCommand, the
gnome-terminal window is created with the
.metacity/sessions/whatever.ms stored size, but immediately afterwards
it is resized into 80x24.

It's not vte's fault, though, since it is right in using the termcap
entry: gnome-terminal never calls vte_terminal_set_size upon
initialization from cmdline *unless* there is an explicit --geometry.

The only way out I see is having g-t store the window size actually
allocated to it by the wm when it presents the window, and then
calling vte_terminal_size appropiately.

Comment 7 Mariano Suárez-Alvarez 2003-03-24 07:08:21 UTC
Created attachment 15178 [details] [review]
Patch to add --active
Comment 8 Mariano Suárez-Alvarez 2003-03-24 07:09:04 UTC
Created attachment 15179 [details] [review]
Patch to add --tab and --window
Comment 9 Mariano Suárez-Alvarez 2003-03-24 07:48:28 UTC
Ok, those were orthogonal patches. --repeat is not included.

There is a little piece of ugliness IMO in that saying

  gnome-terminal --tab --tab --window --tab --tab

is not the same as doing

  gnome-terminal --tab --tab

twice. Indeed, in the first case, the window produced by --window has
*three* tabs. This behaviour is has nothing to do with the patches, as
it depends only on the logic already used in --tab-with-profile &c.

Btw, a bit off topic, but: (1) it'd be very useful if the case in the
parse_option_callback dealing with OPTION_COMPAT would include the
deprecated option longName in the message, and (2) unrecognized
options are ignored (after the paranoid OPTION_LAST case in
parse_option_callcack, there is a comment I don't understand which is
relevant to this?)
  
Comment 10 Havoc Pennington 2003-03-25 19:59:13 UTC
The --active patch is good to commit, all I noticed are three 
cases that need a space before parens ("active (" vs. "active(")

In the --tab/--window patch, the documentation for these
options still mentions the profile name; that isn't correct 
is it?

The code: "profile ? g_strdup (profile) : NULL" is not needed, 
as g_strdup() allows a NULL argument and just returns NULL then.
Similarly, in "if (it->profile) g_free (it->profile)" NULL 
is an acceptable argument to g_free().

--tab/--window patch looks good other than those items.

Re: off-topic items, having OPTION_COMPAT report the name 
of the option would indeed be good, I don't remember why 
I didn't do that. The comment about OPTION_LAST is that 
if you extend the OPTION_* enum the compiler will warn about 
how the switch statement doesn't handle new values.

If you patch the OPTION_COMPAT issue please open a new report, 
it's best to keep one issue per bug report or it gets 
kind of confusing.

Thanks a lot for the patches!
Comment 11 Mariano Suárez-Alvarez 2003-03-25 23:50:14 UTC
Next is the patch with the --window doc fixed and your comments about
the code. About spacing: yeah, I tried to keep general style, but I'm
more of a -npcs -sa{f,i,w} indenting kind of person; I'll try harder :)
Comment 12 Mariano Suárez-Alvarez 2003-03-25 23:57:23 UTC
Created attachment 15203 [details] [review]
Fixed patch to add --tab and --window
Comment 13 Havoc Pennington 2003-04-02 19:18:21 UTC
Patch applied in CVS, thanks. Will be in gnome-terminal 2.3.x/2.4.x
Comment 14 gnome.org 2004-10-21 20:08:10 UTC
OK, so what is the deal here?  My terminal still starts in 80x24 and the same
position of the screen every time.  Why is this marked resolved?  If it is a
metacity or vte problem, should there not be a comment:

This bug is a duplicate of metacity|vte bug #xxxxx (url) ?
Comment 15 Mariano Suárez-Alvarez 2004-10-31 11:15:33 UTC
What version of g-t are you using? Are you saving the session when you log out?