mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-20 12:58:08 +01:00
WindowMaker: New function wGetWorkspaceNumber
The new function wGetWorkspaceNumber returns the workspace number for a given workspace name. The code of this function is already used in session.c and wdefaults.c and now is moved to workspace.c In wSessionRestoreLastWorkspace the char value is checked before calling the function, because without string, the function don't do nothing.
This commit is contained in:
committed by
Carlos R. Mafra
parent
761fd37e51
commit
ad373ef0dd
@@ -518,8 +518,8 @@ void wSessionRestoreState(WScreen * scr)
|
|||||||
void wSessionRestoreLastWorkspace(WScreen * scr)
|
void wSessionRestoreLastWorkspace(WScreen * scr)
|
||||||
{
|
{
|
||||||
WMPropList *wks;
|
WMPropList *wks;
|
||||||
int w, i;
|
int w;
|
||||||
char *tmp;
|
char *value;
|
||||||
|
|
||||||
make_keys();
|
make_keys();
|
||||||
|
|
||||||
@@ -532,23 +532,18 @@ void wSessionRestoreLastWorkspace(WScreen * scr)
|
|||||||
if (!wks || !WMIsPLString(wks))
|
if (!wks || !WMIsPLString(wks))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tmp = WMGetFromPLString(wks);
|
value = WMGetFromPLString(wks);
|
||||||
|
|
||||||
|
if (!value)
|
||||||
|
return;
|
||||||
|
|
||||||
/* clean up */
|
/* clean up */
|
||||||
WMPLSetCaseSensitive(False);
|
WMPLSetCaseSensitive(False);
|
||||||
|
|
||||||
if (sscanf(tmp, "%i", &w) != 1) {
|
/* Get the workspace number for the workspace name */
|
||||||
w = -1;
|
w = wGetWorkspaceNumber(scr, value);
|
||||||
for (i = 0; i < scr->workspace_count; i++) {
|
|
||||||
if (strcmp(scr->workspaces[i]->name, tmp) == 0) {
|
wfree(value);
|
||||||
w = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
w--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (w != scr->current_workspace && w < scr->workspace_count)
|
if (w != scr->current_workspace && w < scr->workspace_count)
|
||||||
wWorkspaceChange(scr, w);
|
wWorkspaceChange(scr, w);
|
||||||
|
|||||||
@@ -433,7 +433,7 @@ RImage *wDefaultGetImage(WScreen * scr, char *winstance, char *wclass, int max_s
|
|||||||
int wDefaultGetStartWorkspace(WScreen * scr, char *instance, char *class)
|
int wDefaultGetStartWorkspace(WScreen * scr, char *instance, char *class)
|
||||||
{
|
{
|
||||||
WMPropList *value;
|
WMPropList *value;
|
||||||
int w, i;
|
int w;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
|
|
||||||
if (!ANoTitlebar)
|
if (!ANoTitlebar)
|
||||||
@@ -452,17 +452,10 @@ int wDefaultGetStartWorkspace(WScreen * scr, char *instance, char *class)
|
|||||||
if (!tmp || strlen(tmp) == 0)
|
if (!tmp || strlen(tmp) == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (sscanf(tmp, "%i", &w) != 1) {
|
/* Get the workspace number for the workspace name */
|
||||||
w = -1;
|
w = wGetWorkspaceNumber(scr, tmp);
|
||||||
for (i = 0; i < scr->workspace_count; i++) {
|
|
||||||
if (strcmp(scr->workspaces[i]->name, tmp) == 0) {
|
wfree(value);
|
||||||
w = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
w--;
|
|
||||||
}
|
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -877,3 +877,23 @@ void wWorkspaceRestoreState(WScreen * scr)
|
|||||||
WMPostNotificationName(WMNWorkspaceNameChanged, scr, (void *)(uintptr_t) i);
|
WMPostNotificationName(WMNWorkspaceNameChanged, scr, (void *)(uintptr_t) i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Returns the workspace number for a given workspace name */
|
||||||
|
int wGetWorkspaceNumber(WScreen * scr, char * value)
|
||||||
|
{
|
||||||
|
int w, i;
|
||||||
|
|
||||||
|
if (sscanf(value, "%i", &w) != 1) {
|
||||||
|
w = -1;
|
||||||
|
for (i = 0; i < scr->workspace_count; i++) {
|
||||||
|
if (strcmp(scr->workspaces[i]->name, value) == 0) {
|
||||||
|
w = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
w--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ typedef struct WWorkspace {
|
|||||||
|
|
||||||
void wWorkspaceMake(WScreen *scr, int count);
|
void wWorkspaceMake(WScreen *scr, int count);
|
||||||
int wWorkspaceNew(WScreen *scr);
|
int wWorkspaceNew(WScreen *scr);
|
||||||
|
int wGetWorkspaceNumber(WScreen * scr, char * value);
|
||||||
Bool wWorkspaceDelete(WScreen *scr, int workspace);
|
Bool wWorkspaceDelete(WScreen *scr, int workspace);
|
||||||
void wWorkspaceChange(WScreen *scr, int workspace);
|
void wWorkspaceChange(WScreen *scr, int workspace);
|
||||||
void wWorkspaceForceChange(WScreen *scr, int workspace);
|
void wWorkspaceForceChange(WScreen *scr, int workspace);
|
||||||
|
|||||||
Reference in New Issue
Block a user