GNOME Bugzilla – Bug 453678
Truncated workspace names
Last modified: 2008-03-21 02:57:15 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:
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.
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.
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.
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.
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/ .
Committed. http://svn.gnome.org/viewvc/metacity?rev=3657&view=rev