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 453678 - Truncated workspace names
Truncated workspace names
Status: RESOLVED FIXED
Product: metacity
Classification: Other
Component: general
2.18.x
Other All
: Normal minor
: ---
Assigned To: Thomas Thurman
Metacity maintainers list
Depends on:
Blocks:
 
 
Reported: 2007-07-04 13:27 UTC by Manuel Hermann
Modified: 2008-03-21 02:57 UTC
See Also:
GNOME target: ---
GNOME version: 2.17/2.18


Attachments
Don't truncate workspace names (1.36 KB, patch)
2008-01-01 02:19 UTC, Thomas Thurman
rejected Details | Review
Here's a better patch. For another example of the technique shown here, see http://blogs.gnome.org/tthurman/2008/03/21/sscanf/ . (1.14 KB, patch)
2008-03-21 02:55 UTC, Thomas Thurman
committed Details | Review

Description Manuel Hermann 2007-07-04 13:27:54 UTC
Please describe the problem:
If a workspace name begins with "Desk" fallowed by space fallowed by two numbers separated by a slash, then the name will be truncated in the "Move to different Workspace" context menu.

Example:
Workspace name: Desk 1/1 foo
Truncated to: Desk 1

Steps to reproduce:
1. Name a workspace to "Desk 1/1" or "Desk 1/2 foo"
2. Right click a window's title
3. Choose the 'Move to different Workspace' submenu


Actual results:
The submenu contains the workspace names truncated at the slash when the names is like described above.

Expected results:
Show the full name.

Does this happen every time?
Yes.

Other information:
Comment 1 Manuel Hermann 2007-07-04 13:40:32 UTC
On further testing I noticed that this Bug occures always whenever the workspace name begins with "Desk <number>". Anything after the number is truncated. Also, I noticed that the number after "Desk" is limited to 2147483647.
Comment 2 Thomas Thurman 2008-01-01 01:52:19 UTC
Confirmed.

Note that the magic word isn't necessarily "Desk"; the default is "Workspace", and it depends on your language (for mine it is "Gweithfan") and I think possibly your distribution as well.

The bug happens because of line 189 in the function get_workspace_name_with_accel() in ui/menu.c:

   if (sscanf (name, _("Workspace %d"), &number) == 1)

If the string matches "Workspace " plus a decimal number (...plus possibly other things), the entire string will be rewritten to (possibly) include an accelerator. The other things will be thrown away.

Patch coming up in a moment.
Comment 3 Thomas Thurman 2008-01-01 02:19:14 UTC
Created attachment 101930 [details] [review]
Don't truncate workspace names

Patch that fixes this. It uses the "a"=="allocate" GNU extension; is it okay to use that in Metacity? I can do it by allocating a buffer of the same length as "name" trivially, of course, if we have to support compilers that don't know about "a", but it's neater this way.
Comment 4 Thomas Thurman 2008-03-21 01:47:31 UTC
I'm taking the unusual step of rejecting my own patch after thinking about it some more.  I think the problem would be solved by making [everything which didn't match the first case *exactly*] match the second case.  Patch coming up for that in a moment.
Comment 5 Thomas Thurman 2008-03-21 02:55:02 UTC
Created attachment 107723 [details] [review]
Here's a better patch.  For another example of the technique shown here, see http://blogs.gnome.org/tthurman/2008/03/21/sscanf/ .

Here's a better patch.  For another example of the technique shown here, see http://blogs.gnome.org/tthurman/2008/03/21/sscanf/ .
Comment 6 Thomas Thurman 2008-03-21 02:57:15 UTC
Committed.
http://svn.gnome.org/viewvc/metacity?rev=3657&view=rev