From: "Rodolfo García Peñas (kix)" <[email protected]>
This patch avoid update (create) the Workspace Menu when wmaker
is starting. When wmaker is starting, the scr->current_workspace
is NULL, so we can check it in wWorkspaceMenuUpdate() and do nothing.
--------------------------8<----------------------------------
@@ -751,7 +751,12 @@ void wWorkspaceMenuUpdate(WScreen * scr, WMenu * menu)
WMenuEntry *entry;
int tmp;
- if (!menu)
+ /*
+ * If the scr->current_workspace doesn't exists yet
+ * is because we are starting wmaker, so we don't need
+ * the workspace menu yet
+ */
+ if (!menu || !scr->current_workspace)
return;
--------------------------8<----------------------------------
So, now we don't need check in that function if the scr->current_workspace
exists:
--------------------------8<----------------------------------
- if (scr->current_workspace) {
- menu->entries[scr->current_workspace +
MC_WORKSPACE1]->flags.indicator_on = 1;
- wMenuRealize(menu);
- }
+ /* Update the workspace's menu */
+ menu->entries[scr->current_workspace +
MC_WORKSPACE1]->flags.indicator_on = 1;
+ wMenuRealize(menu);
--------------------------8<----------------------------------
The problem is, in the function wWorkspaceRestoreState(), scr->workspace_menu
could be "not NULL" and therefore it crash if the entries don't exits. So we
need check it first. I used the variable "menu" to make the lines shorter and
clear than "scr->workspace_menu":
--------------------------8<----------------------------------
@@ -868,9 +872,13 @@ void wWorkspaceRestoreState(WScreen *scr)
wWorkspaceNew(scr);
if (scr->workspace_menu) {
- wfree(scr->workspace_menu->entries[i +
MC_WORKSPACE1]->text);
- scr->workspace_menu->entries[i + MC_WORKSPACE1]->text =
wstrdup(WMGetFromPLString(pstr));
- scr->workspace_menu->flags.realized = 0;
+ menu = scr->workspace_menu;
+ if (menu->entries[i + MC_WORKSPACE1] &&
+ menu->entries[i + MC_WORKSPACE1]->text) {
+ wfree(menu->entries[i + MC_WORKSPACE1]->text);
+ menu->entries[i + MC_WORKSPACE1]->text =
wstrdup(WMGetFromPLString(pstr));
+ menu->flags.realized = 0;
+ }
--------------------------8<----------------------------------
---
src/workspace.c | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/src/workspace.c b/src/workspace.c
index 9eaeb15..dcbe6e8 100644
--- a/src/workspace.c
+++ b/src/workspace.c
@@ -743,7 +743,7 @@ WMenu *wWorkspaceMenuMake(WScreen * scr, Bool titled)
return wsmenu;
}
-void wWorkspaceMenuUpdate(WScreen * scr, WMenu * menu)
+void wWorkspaceMenuUpdate(WScreen *scr, WMenu *menu)
{
int i;
long ws;
@@ -751,7 +751,12 @@ void wWorkspaceMenuUpdate(WScreen * scr, WMenu * menu)
WMenuEntry *entry;
int tmp;
- if (!menu)
+ /*
+ * If the scr->current_workspace doesn't exists yet
+ * is because we are starting wmaker, so we don't need
+ * the workspace menu yet
+ */
+ if (!menu || !scr->current_workspace)
return;
if (menu->entry_no < scr->workspace_count + MC_WORKSPACE1) {
@@ -785,17 +790,15 @@ void wWorkspaceMenuUpdate(WScreen * scr, WMenu * menu)
menu->entries[i + MC_WORKSPACE1]->flags.indicator_on = 0;
}
- if (scr->current_workspace) {
- menu->entries[scr->current_workspace +
MC_WORKSPACE1]->flags.indicator_on = 1;
- wMenuRealize(menu);
- }
+ /* Update the workspace's menu */
+ menu->entries[scr->current_workspace +
MC_WORKSPACE1]->flags.indicator_on = 1;
+ wMenuRealize(menu);
/* don't let user destroy current workspace */
- if (scr->current_workspace == scr->workspace_count - 1) {
+ if (scr->current_workspace == scr->workspace_count - 1)
wMenuSetEnabled(menu, MC_DESTROY_LAST, False);
- } else {
+ else
wMenuSetEnabled(menu, MC_DESTROY_LAST, True);
- }
/* back to last workspace */
if (scr->workspace_count && scr->last_workspace !=
scr->current_workspace)
@@ -845,6 +848,7 @@ void wWorkspaceSaveState(WScreen * scr, WMPropList *
old_state)
void wWorkspaceRestoreState(WScreen *scr)
{
WMPropList *parr, *pstr, *wks_state, *clip_state;
+ WMenu *menu = NULL;
int i, j;
make_keys();
@@ -868,9 +872,13 @@ void wWorkspaceRestoreState(WScreen *scr)
wWorkspaceNew(scr);
if (scr->workspace_menu) {
- wfree(scr->workspace_menu->entries[i +
MC_WORKSPACE1]->text);
- scr->workspace_menu->entries[i + MC_WORKSPACE1]->text =
wstrdup(WMGetFromPLString(pstr));
- scr->workspace_menu->flags.realized = 0;
+ menu = scr->workspace_menu;
+ if (menu->entries[i + MC_WORKSPACE1] &&
+ menu->entries[i + MC_WORKSPACE1]->text) {
+ wfree(menu->entries[i + MC_WORKSPACE1]->text);
+ menu->entries[i + MC_WORKSPACE1]->text =
wstrdup(WMGetFromPLString(pstr));
+ menu->flags.realized = 0;
+ }
}
wfree(scr->workspaces[i]->name);
--
1.7.10.4
--
To unsubscribe, send mail to [email protected].