mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-21 13:28:05 +01:00
Fix workspace renaming with Ctrl+left click
The Workspaces entry in the main menu allows to rename workspaces by
clicking on the workspace name while pressing the Ctrl key.
However since commit 63219247c6 ("Added shortcut to switch to last used workspace")
there is one more entry before the workspace name list, and that leads to
picking a wrong name to rename -- clicking on the first workspace asks to
rename the second workspace and so forth. Trying to rename the last workspace
leads to a segfault.
This happens because there is an explicit offset in the current code (- 2)
to account for the "non-workspace" entries in the menu. If one adds one
more entry that offset should be changed too (this is a prime example
of fragile code leading to bugs).
This commit is contained in:
@@ -1766,7 +1766,7 @@ static void menuMouseDown(WObjDescriptor * desc, XEvent * event)
|
|||||||
if (!close_on_exit && (bev->state & ControlMask) && smenu && entry->flags.editable) {
|
if (!close_on_exit && (bev->state & ControlMask) && smenu && entry->flags.editable) {
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
char *name;
|
char *name;
|
||||||
int number = entry_no - 2; /* Entries "New" and "Destroy Last" appear before workspaces */
|
int number = entry_no - 3; /* Entries "New", "Destroy Last" and "Last Used" appear before workspaces */
|
||||||
|
|
||||||
name = wstrdup(scr->workspaces[number]->name);
|
name = wstrdup(scr->workspaces[number]->name);
|
||||||
snprintf(buffer, sizeof(buffer), _("Type the name for workspace %i:"), number + 1);
|
snprintf(buffer, sizeof(buffer), _("Type the name for workspace %i:"), number + 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user