mirror of
https://github.com/gryf/wmaker.git
synced 2026-02-09 01:45:48 +01:00
- s/sprintf/snprintf
- updated some po's - fixed crash bug when removing WINDOWS_MENU or WORKSPACE_MENU from rootmenu - some other stuff i forgot
This commit is contained in:
@@ -320,7 +320,7 @@ updateDockNumbers(WScreen *scr)
|
||||
my_v_mask, &my_gc_values);
|
||||
|
||||
ws_numbers = wmalloc(20);
|
||||
sprintf(ws_numbers, "%i [ %i ]", scr->current_workspace+1,
|
||||
snprintf(ws_numbers, 20, "%i [ %i ]", scr->current_workspace+1,
|
||||
((scr->current_workspace/10)+1));
|
||||
length = strlen(ws_numbers);
|
||||
|
||||
@@ -457,14 +457,14 @@ wAppIconPaint(WAppIcon *aicon)
|
||||
if (index > 0) {
|
||||
char buf[16];
|
||||
|
||||
sprintf(buf, "%i", index);
|
||||
snprintf(buf, sizeof(buf), "%i", index);
|
||||
|
||||
WMDrawString(scr->wmscreen, aicon->icon->core->window,
|
||||
scr->clip_title_gc, scr->title_font,
|
||||
1, 1, buf, strlen(buf));
|
||||
3, 3, buf, strlen(buf));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (aicon->omnipresent)
|
||||
drawCorner(aicon->icon);
|
||||
|
||||
|
||||
@@ -360,8 +360,9 @@ appiconBalloon(WObjDescriptor *object)
|
||||
char *tmp;
|
||||
|
||||
if (aicon->command && aicon->wm_class) {
|
||||
tmp = wmalloc(strlen(aicon->command)+strlen(aicon->wm_class)+8);
|
||||
sprintf(tmp, "%s (%s)", aicon->wm_class, aicon->command);
|
||||
int len = strlen(aicon->command)+strlen(aicon->wm_class)+8;
|
||||
tmp = wmalloc(len);
|
||||
snprintf(tmp, len, "%s (%s)", aicon->wm_class, aicon->command);
|
||||
scr->balloon->text = tmp;
|
||||
} else if (aicon->command) {
|
||||
scr->balloon->text = wstrdup(aicon->command);
|
||||
|
||||
@@ -702,6 +702,9 @@ WDefaultEntry optionList[] = {
|
||||
{"VMaximizeKey", "None", (void*)WKBD_VMAXIMIZE,
|
||||
NULL, getKeybind, setKeyGrab
|
||||
},
|
||||
{"HMaximizeKey", "None", (void*)WKBD_HMAXIMIZE,
|
||||
NULL, getKeybind, setKeyGrab
|
||||
},
|
||||
{"RaiseKey", "\"Meta+Up\"", (void*)WKBD_RAISE,
|
||||
NULL, getKeybind, setKeyGrab
|
||||
},
|
||||
@@ -968,7 +971,7 @@ wDefaultsInitDomain(char *domain, Bool requireDictionary)
|
||||
}
|
||||
|
||||
/* global system dictionary */
|
||||
sprintf(path, "%s/WindowMaker/%s", SYSCONFDIR, domain);
|
||||
snprintf(path, sizeof(path), "%s/WindowMaker/%s", SYSCONFDIR, domain);
|
||||
if (stat(path, &stbuf)>=0) {
|
||||
shared_dict = ReadProplistFromFile(path);
|
||||
if (shared_dict) {
|
||||
@@ -1063,7 +1066,7 @@ wDefaultsCheckDomains(void *foo)
|
||||
WDWindowMaker->timestamp = stbuf.st_mtime;
|
||||
|
||||
/* global dictionary */
|
||||
sprintf(path, "%s/WindowMaker/WindowMaker", SYSCONFDIR);
|
||||
snprintf(path, sizeof(path), "%s/WindowMaker/WindowMaker", SYSCONFDIR);
|
||||
if (stat(path, &stbuf)>=0) {
|
||||
shared_dict = ReadProplistFromFile(path);
|
||||
if (shared_dict && !PLIsDictionary(shared_dict)) {
|
||||
@@ -3240,15 +3243,17 @@ setWorkspaceBack(WScreen *scr, WDefaultEntry *entry, proplist_t value,
|
||||
char *command;
|
||||
char *text;
|
||||
char *dither;
|
||||
int len;
|
||||
|
||||
SetupEnvironment(scr);
|
||||
text = PLGetDescription(value);
|
||||
command = wmalloc(strlen(text)+40);
|
||||
len = strlen(text)+40;
|
||||
command = wmalloc(len);
|
||||
dither = wPreferences.no_dithering ? "-m" : "-d";
|
||||
if (wPreferences.smooth_workspace_back)
|
||||
sprintf(command, "wmsetbg %s -S -p '%s' &", dither, text);
|
||||
snprintf(command, len, "wmsetbg %s -S -p '%s' &", dither, text);
|
||||
else
|
||||
sprintf(command, "wmsetbg %s -p '%s' &", dither, text);
|
||||
snprintf(command, len, "wmsetbg %s -p '%s' &", dither, text);
|
||||
wfree(text);
|
||||
system(command);
|
||||
wfree(command);
|
||||
|
||||
73
src/dialog.c
73
src/dialog.c
@@ -381,8 +381,11 @@ drawIconProc(WMList *lPtr, int index, Drawable d, char *text,
|
||||
whitecolor = WMWhiteColor(wmscr);
|
||||
|
||||
dirfile = wexpandpath(WMGetListSelectedItem(panel->dirList)->text);
|
||||
file = wmalloc(strlen(dirfile)+strlen(text)+4);
|
||||
sprintf(file, "%s/%s", dirfile, text);
|
||||
{
|
||||
int len = strlen(dirfile)+strlen(text)+4;
|
||||
file = wmalloc(len);
|
||||
snprintf(file, len, "%s/%s", dirfile, text);
|
||||
}
|
||||
wfree(dirfile);
|
||||
|
||||
if ((state & WLDSSelected) != 0) {
|
||||
@@ -691,12 +694,13 @@ wIconChooserDialog(WScreen *scr, char **file, char *instance, char *class)
|
||||
|
||||
{
|
||||
char *tmp;
|
||||
int len = (instance ? strlen(instance) : 0)
|
||||
+ (class ? strlen(class) : 0) + 32;
|
||||
|
||||
tmp = wmalloc((instance ? strlen(instance) : 0)
|
||||
+ (class ? strlen(class) : 0) + 32);
|
||||
tmp = wmalloc(len);
|
||||
|
||||
if (tmp && (instance || class))
|
||||
sprintf(tmp, "%s [%s.%s]", _("Icon Chooser"), instance, class);
|
||||
snprintf(tmp, len, "%s [%s.%s]", _("Icon Chooser"), instance, class);
|
||||
else
|
||||
strcpy(tmp, _("Icon Chooser"));
|
||||
|
||||
@@ -1155,7 +1159,7 @@ handleLogoPush(XEvent *event, void *data)
|
||||
WMReleaseFont(panel->oldFont);
|
||||
panel->oldFont = NULL;
|
||||
}
|
||||
sprintf(version, _("Version %s"), VERSION);
|
||||
snprintf(version, sizeof(version), _("Version %s"), VERSION);
|
||||
WMSetLabelText(panel->versionL, version);
|
||||
XFlush(WMScreenDisplay(WMWidgetScreen(panel->versionL)));
|
||||
}
|
||||
@@ -1176,8 +1180,8 @@ wShowInfoPanel(WScreen *scr)
|
||||
WMPixmap *logo;
|
||||
WMSize size;
|
||||
WMFont *font;
|
||||
char version[32];
|
||||
char buffer[512];
|
||||
char *strbuf = NULL;
|
||||
char buffer[256];
|
||||
Window parent;
|
||||
WWindow *wwin;
|
||||
RColor color1, color2;
|
||||
@@ -1264,13 +1268,13 @@ wShowInfoPanel(WScreen *scr)
|
||||
WMSetLabelTextAlignment(panel->name2L, WACenter);
|
||||
WMSetLabelText(panel->name2L, _("Window Manager for X"));
|
||||
|
||||
|
||||
sprintf(version, _("Version %s"), VERSION);
|
||||
|
||||
snprintf(buffer, sizeof(buffer), _("Version %s"), VERSION);
|
||||
panel->versionL = WMCreateLabel(panel->win);
|
||||
WMResizeWidget(panel->versionL, 310, 16);
|
||||
WMMoveWidget(panel->versionL, 30, 95);
|
||||
WMSetLabelTextAlignment(panel->versionL, WARight);
|
||||
WMSetLabelText(panel->versionL, version);
|
||||
WMSetLabelText(panel->versionL, buffer);
|
||||
WMSetLabelWraps(panel->versionL, False);
|
||||
|
||||
panel->copyrL = WMCreateLabel(panel->win);
|
||||
@@ -1284,44 +1288,50 @@ wShowInfoPanel(WScreen *scr)
|
||||
WMSetLabelFont(panel->copyrL, font);
|
||||
}
|
||||
|
||||
strbuf = NULL;
|
||||
snprintf(buffer, sizeof(buffer), _("Using visual 0x%x: %s %ibpp "),
|
||||
(unsigned)scr->w_visual->visualid,
|
||||
visuals[scr->w_visual->class], scr->w_depth);
|
||||
|
||||
strbuf = wstrappend(strbuf, buffer);
|
||||
|
||||
switch (scr->w_depth) {
|
||||
case 15:
|
||||
strcpy(version, _("32 thousand"));
|
||||
strbuf = wstrappend(strbuf, _("(32 thousand colors)\n"));
|
||||
break;
|
||||
case 16:
|
||||
strcpy(version, _("64 thousand"));
|
||||
strbuf = wstrappend(strbuf, _("(64 thousand colors)\n"));
|
||||
break;
|
||||
case 24:
|
||||
case 32:
|
||||
strcpy(version, _("16 million"));
|
||||
strbuf = wstrappend(strbuf, _("(16 million colors)\n"));
|
||||
break;
|
||||
default:
|
||||
sprintf(version, "%d", 1<<scr->w_depth);
|
||||
snprintf(buffer, sizeof(buffer), _("(%d colors)\n"), 1<<scr->w_depth);
|
||||
strbuf = wstrappend(strbuf, buffer);
|
||||
break;
|
||||
}
|
||||
|
||||
sprintf(buffer, _("Using visual 0x%x: %s %ibpp (%s colors)\n"),
|
||||
(unsigned)scr->w_visual->visualid,
|
||||
visuals[scr->w_visual->class], scr->w_depth, version);
|
||||
|
||||
|
||||
#if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO)
|
||||
{
|
||||
struct mallinfo ma = mallinfo();
|
||||
sprintf(buffer+strlen(buffer),
|
||||
snprintf(buffer, sizeof(buffer),
|
||||
_("Total allocated memory: %i kB. Total memory in use: %i kB.\n"),
|
||||
(ma.arena+ma.hblkhd)/1024, (ma.uordblks+ma.hblkhd)/1024);
|
||||
|
||||
|
||||
strbuf = wstrappend(strbuf, buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
strcat(buffer, _("Supported image formats: "));
|
||||
strbuf = wstrappend(strbuf, _("Supported image formats: "));
|
||||
strl = RSupportedFileFormats();
|
||||
for (i=0; strl[i]!=NULL; i++) {
|
||||
strcat(buffer, strl[i]);
|
||||
strcat(buffer, " ");
|
||||
strbuf = wstrappend(strbuf, strl[i]);
|
||||
strbuf = wstrappend(strbuf, " ");
|
||||
}
|
||||
|
||||
strcat(buffer, _("\nAdditional support for: "));
|
||||
strbuf = wstrappend(strbuf, _("\nAdditional support for: "));
|
||||
{
|
||||
char *list[8];
|
||||
char buf[80];
|
||||
@@ -1350,24 +1360,25 @@ wShowInfoPanel(WScreen *scr)
|
||||
}
|
||||
strcat(buf, list[i]);
|
||||
}
|
||||
strcat(buffer, buf);
|
||||
strbuf = wstrappend(strbuf, buf);
|
||||
}
|
||||
|
||||
if (wPreferences.no_sound) {
|
||||
strcat(buffer, _("\nSound disabled"));
|
||||
strbuf = wstrappend(strbuf, _("\nSound disabled"));
|
||||
} else {
|
||||
strcat(buffer, _("\nSound enabled"));
|
||||
strbuf = wstrappend(strbuf, _("\nSound enabled"));
|
||||
}
|
||||
|
||||
|
||||
panel->infoL = WMCreateLabel(panel->win);
|
||||
WMResizeWidget(panel->infoL, 350, 75);
|
||||
WMMoveWidget(panel->infoL, 15, 115);
|
||||
WMSetLabelText(panel->infoL, buffer);
|
||||
WMSetLabelText(panel->infoL, strbuf);
|
||||
if (font) {
|
||||
WMSetLabelFont(panel->infoL, font);
|
||||
WMReleaseFont(font);
|
||||
}
|
||||
wfree(strbuf);
|
||||
|
||||
|
||||
WMRealizeWidget(panel->win);
|
||||
@@ -1681,10 +1692,10 @@ wShowCrashingDialogPanel(int whatSig)
|
||||
WMMoveWidget(panel->noteL, 10, 90);
|
||||
WMSetLabelTextAlignment(panel->noteL, WAJustified);
|
||||
#ifdef SYS_SIGLIST_DECLARED
|
||||
sprintf(buf, _("Window Maker received signal %i\n(%s)."),
|
||||
snprintf(buf, sizeof(buf), _("Window Maker received signal %i\n(%s)."),
|
||||
whatSig, sys_siglist[whatSig]);
|
||||
#else
|
||||
sprintf(buf, _("Window Maker received signal %i."), whatSig);
|
||||
snprintf(buf, sizeof(buf), _("Window Maker received signal %i."), whatSig);
|
||||
#endif
|
||||
WMSetLabelText(panel->noteL, buf);
|
||||
|
||||
|
||||
25
src/dock.c
25
src/dock.c
@@ -210,7 +210,7 @@ renameCallback(WMenu *menu, WMenuEntry *entry)
|
||||
|
||||
name = wstrdup(dock->screen_ptr->workspaces[wspace]->name);
|
||||
|
||||
sprintf(buffer, _("Type the name for workspace %i:"), wspace+1);
|
||||
snprintf(buffer, sizeof(buffer), _("Type the name for workspace %i:"), wspace+1);
|
||||
if (wInputDialog(dock->screen_ptr, _("Rename Workspace"), buffer,
|
||||
&name)) {
|
||||
wWorkspaceRename(dock->screen_ptr, wspace, name);
|
||||
@@ -1250,8 +1250,8 @@ wClipIconPaint(WAppIcon *aicon)
|
||||
|
||||
length = strlen(workspace->name);
|
||||
ws_name = wmalloc(length + 1);
|
||||
sprintf(ws_name, "%s", workspace->name);
|
||||
sprintf(ws_number, "%i", scr->current_workspace + 1);
|
||||
snprintf(ws_name, length+1, "%s", workspace->name);
|
||||
snprintf(ws_number, sizeof(ws_number), "%i", scr->current_workspace + 1);
|
||||
nlength = strlen(ws_number);
|
||||
|
||||
gc = scr->clip_title_gc;
|
||||
@@ -1332,9 +1332,9 @@ make_icon_state(WAppIcon *btn)
|
||||
buggy = btn->buggy_app ? dYes : dNo;
|
||||
|
||||
if (btn == btn->icon->core->screen_ptr->clip_icon)
|
||||
sprintf(buffer, "%i,%i", btn->x_pos, btn->y_pos);
|
||||
snprintf(buffer, sizeof(buffer), "%i,%i", btn->x_pos, btn->y_pos);
|
||||
else
|
||||
sprintf(buffer, "%hi,%hi", btn->xindex, btn->yindex);
|
||||
snprintf(buffer, sizeof(buffer), "%hi,%hi", btn->xindex, btn->yindex);
|
||||
position = PLMakeString(buffer);
|
||||
|
||||
node = PLMakeDictionaryFromEntries(dCommand, command,
|
||||
@@ -1400,13 +1400,13 @@ dockSaveState(WDock *dock)
|
||||
NULL);
|
||||
|
||||
if (dock->type == WM_DOCK) {
|
||||
sprintf(buffer, "Applications%i", dock->screen_ptr->scr_height);
|
||||
snprintf(buffer, sizeof(buffer), "Applications%i", dock->screen_ptr->scr_height);
|
||||
key = PLMakeString(buffer);
|
||||
PLInsertDictionaryEntry(dock_state, key, list);
|
||||
PLRelease(key);
|
||||
|
||||
|
||||
sprintf(buffer, "%i,%i", (dock->on_right_side ? -ICON_SIZE : 0),
|
||||
snprintf(buffer, sizeof(buffer), "%i,%i", (dock->on_right_side ? -ICON_SIZE : 0),
|
||||
dock->y_pos);
|
||||
value = PLMakeString(buffer);
|
||||
PLInsertDictionaryEntry(dock_state, dPosition, value);
|
||||
@@ -1833,7 +1833,7 @@ wDockRestoreState(WScreen *scr, proplist_t dock_state, int type)
|
||||
* If it does not exist, use Applications as default.
|
||||
*/
|
||||
|
||||
sprintf(buffer, "Applications%i", scr->scr_height);
|
||||
snprintf(buffer, sizeof(buffer), "Applications%i", scr->scr_height);
|
||||
|
||||
tmp = PLMakeString(buffer);
|
||||
apps = PLGetDictionaryEntry(dock_state, tmp);
|
||||
@@ -2153,8 +2153,9 @@ wDockAttachIcon(WDock *dock, WAppIcon *icon, int x, int y)
|
||||
|
||||
#ifdef OFFIX_DND
|
||||
if (icon->command && !icon->dnd_command) {
|
||||
icon->dnd_command = wmalloc(strlen(icon->command)+8);
|
||||
sprintf(icon->dnd_command, "%s %%d", icon->command);
|
||||
int len = strlen(icon->command)+8;
|
||||
icon->dnd_command = wmalloc(len);
|
||||
snprintf(icon->dnd_command, len, "%s %%d", icon->command);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3233,11 +3234,11 @@ trackDeadProcess(pid_t pid, unsigned char status, WDock *dock)
|
||||
if (status==111) {
|
||||
char msg[PATH_MAX];
|
||||
#ifdef OFFIX_DND
|
||||
sprintf(msg, _("Could not execute command \"%s\""),
|
||||
snprintf(msg, sizeof(msg), _("Could not execute command \"%s\""),
|
||||
icon->drop_launch && icon->dnd_command
|
||||
? icon->dnd_command : icon->command);
|
||||
#else
|
||||
sprintf(msg, _("Could not execute command \"%s\""),
|
||||
snprintf(msg, sizeof(msg), _("Could not execute command \"%s\""),
|
||||
icon->command);
|
||||
#endif
|
||||
wMessageDialog(dock->screen_ptr, _("Error"), msg,
|
||||
|
||||
@@ -205,9 +205,10 @@ panelBtnCallback(WMWidget *self, void *data)
|
||||
}
|
||||
if (!wIconChangeImageFile(panel->editedIcon->icon, text)) {
|
||||
char *buf;
|
||||
int len = strlen(text) + 64;
|
||||
|
||||
buf = wmalloc(strlen(text) + 64);
|
||||
sprintf(buf, _("Could not open specified icon file: %s"), text);
|
||||
buf = wmalloc(len);
|
||||
snprintf(buf, len, _("Could not open specified icon file: %s"), text);
|
||||
if (wMessageDialog(panel->wwin->screen_ptr, _("Error"), buf,
|
||||
_("OK"), _("Ignore"), NULL) == WAPRDefault) {
|
||||
if (text)
|
||||
|
||||
11
src/event.c
11
src/event.c
@@ -1433,6 +1433,17 @@ handleKeyPress(XEvent *event)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WKBD_HMAXIMIZE:
|
||||
if (ISMAPPED(wwin) && ISFOCUSED(wwin) && !WFLAGP(wwin, no_resizable)) {
|
||||
CloseWindowMenu(scr);
|
||||
|
||||
if (wwin->flags.maximized) {
|
||||
wUnmaximizeWindow(wwin);
|
||||
} else {
|
||||
wMaximizeWindow(wwin, MAX_HORIZONTAL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WKBD_RAISE:
|
||||
if (ISMAPPED(wwin) && ISFOCUSED(wwin)) {
|
||||
CloseWindowMenu(scr);
|
||||
|
||||
@@ -32,6 +32,21 @@ static char *PRED_XKBGROUP2_XPM[] = {
|
||||
"##..####..",
|
||||
"##.#####.#"
|
||||
};
|
||||
#elif defined LANGUAGE_SK
|
||||
static char *PRED_XKBGROUP2_XPM[] = {
|
||||
" 10 10 2 1",
|
||||
". c #000000",
|
||||
"# c None",
|
||||
"####..####",
|
||||
"####..####",
|
||||
"##......##",
|
||||
"##......##",
|
||||
"####..####",
|
||||
"#........#",
|
||||
"#........#",
|
||||
"####..####",
|
||||
"###....###",
|
||||
"##......##"};
|
||||
#else
|
||||
static char *PRED_XKBGROUP2_XPM[] = {
|
||||
" 10 10 2 1",
|
||||
|
||||
@@ -84,7 +84,7 @@ WCreateGeometryView(WMScreen *scr)
|
||||
|
||||
WMCreateEventHandler(gview->view, ExposureMask, handleEvents, gview);
|
||||
|
||||
sprintf(buffer, "%+05i, %+05i", 0, 0);
|
||||
snprintf(buffer, sizeof(buffer), "%+05i, %+05i", 0, 0);
|
||||
|
||||
gview->textSize.width = WMWidthOfString(gview->font, buffer,
|
||||
strlen(buffer));
|
||||
@@ -127,9 +127,11 @@ paint(WGeometryView *gview)
|
||||
char buffer[64];
|
||||
|
||||
if (gview->showPosition) {
|
||||
sprintf(buffer, "%+5i , %+5i ", gview->data.pos.x, gview->data.pos.y);
|
||||
snprintf(buffer, sizeof(buffer), "%+5i , %+5i ",
|
||||
gview->data.pos.x, gview->data.pos.y);
|
||||
} else {
|
||||
sprintf(buffer, "%+5i x %+5i ", gview->data.size.width, gview->data.size.height);
|
||||
snprintf(buffer, sizeof(buffer), "%+5i x %+5i ",
|
||||
gview->data.size.width, gview->data.size.height);
|
||||
}
|
||||
|
||||
WMDrawImageString(W_VIEW_SCREEN(gview->view),
|
||||
|
||||
17
src/icon.c
17
src/icon.c
@@ -466,14 +466,17 @@ getnameforicon(WWindow *wwin)
|
||||
int len;
|
||||
|
||||
if (wwin->wm_class && wwin->wm_instance) {
|
||||
suffix = wmalloc(strlen(wwin->wm_class)+strlen(wwin->wm_instance)+2);
|
||||
sprintf(suffix, "%s.%s", wwin->wm_instance, wwin->wm_class);
|
||||
int len = strlen(wwin->wm_class)+strlen(wwin->wm_instance)+2;
|
||||
suffix = wmalloc(len);
|
||||
snprintf(suffix, len, "%s.%s", wwin->wm_instance, wwin->wm_class);
|
||||
} else if (wwin->wm_class) {
|
||||
suffix = wmalloc(strlen(wwin->wm_class)+1);
|
||||
strcpy(suffix, wwin->wm_class);
|
||||
int len = strlen(wwin->wm_class)+1;
|
||||
suffix = wmalloc(len);
|
||||
snprintf(suffix, len, "%s", wwin->wm_class);
|
||||
} else if (wwin->wm_instance) {
|
||||
suffix = wmalloc(strlen(wwin->wm_instance)+1);
|
||||
strcpy(suffix, wwin->wm_instance);
|
||||
int len = strlen(wwin->wm_instance)+1;
|
||||
suffix = wmalloc(len);
|
||||
snprintf(suffix, len, "%s", wwin->wm_instance);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
@@ -481,7 +484,7 @@ getnameforicon(WWindow *wwin)
|
||||
prefix = wusergnusteppath();
|
||||
len = strlen(prefix)+64+strlen(suffix);
|
||||
path = wmalloc(len+1);
|
||||
sprintf(path, "%s/.AppInfo", prefix);
|
||||
snprintf(path, len, "%s/.AppInfo", prefix);
|
||||
|
||||
if (access(path, F_OK)!=0) {
|
||||
if (mkdir(path, S_IRUSR|S_IWUSR|S_IXUSR)) {
|
||||
|
||||
@@ -30,57 +30,58 @@
|
||||
#define WKBD_HIDE 4
|
||||
#define WKBD_MAXIMIZE 5
|
||||
#define WKBD_VMAXIMIZE 6
|
||||
#define WKBD_SELECT 7
|
||||
#define WKBD_HMAXIMIZE 7
|
||||
#define WKBD_SELECT 8
|
||||
/* Clip */
|
||||
#define WKBD_CLIPLOWER 8
|
||||
#define WKBD_CLIPRAISE 9
|
||||
#define WKBD_CLIPRAISELOWER 10
|
||||
#define WKBD_CLIPLOWER 9
|
||||
#define WKBD_CLIPRAISE 10
|
||||
#define WKBD_CLIPRAISELOWER 11
|
||||
/* window */
|
||||
#define WKBD_RAISE 11
|
||||
#define WKBD_LOWER 12
|
||||
#define WKBD_RAISELOWER 13
|
||||
#define WKBD_MOVERESIZE 14
|
||||
#define WKBD_SHADE 15
|
||||
#define WKBD_RAISE 12
|
||||
#define WKBD_LOWER 13
|
||||
#define WKBD_RAISELOWER 14
|
||||
#define WKBD_MOVERESIZE 15
|
||||
#define WKBD_SHADE 16
|
||||
/* window, menu */
|
||||
#define WKBD_CLOSE 16
|
||||
#define WKBD_CLOSE 17
|
||||
/* window */
|
||||
#define WKBD_FOCUSNEXT 17
|
||||
#define WKBD_FOCUSPREV 18
|
||||
#define WKBD_FOCUSNEXT 18
|
||||
#define WKBD_FOCUSPREV 19
|
||||
|
||||
#define WKBD_WORKSPACE1 20
|
||||
#define WKBD_WORKSPACE2 21
|
||||
#define WKBD_WORKSPACE3 22
|
||||
#define WKBD_WORKSPACE4 23
|
||||
#define WKBD_WORKSPACE5 24
|
||||
#define WKBD_WORKSPACE6 25
|
||||
#define WKBD_WORKSPACE7 26
|
||||
#define WKBD_WORKSPACE8 27
|
||||
#define WKBD_WORKSPACE9 28
|
||||
#define WKBD_WORKSPACE10 29
|
||||
#define WKBD_NEXTWORKSPACE 30
|
||||
#define WKBD_PREVWORKSPACE 31
|
||||
#define WKBD_NEXTWSLAYER 32
|
||||
#define WKBD_PREVWSLAYER 33
|
||||
#define WKBD_WORKSPACE1 21
|
||||
#define WKBD_WORKSPACE2 22
|
||||
#define WKBD_WORKSPACE3 23
|
||||
#define WKBD_WORKSPACE4 24
|
||||
#define WKBD_WORKSPACE5 25
|
||||
#define WKBD_WORKSPACE6 26
|
||||
#define WKBD_WORKSPACE7 27
|
||||
#define WKBD_WORKSPACE8 28
|
||||
#define WKBD_WORKSPACE9 29
|
||||
#define WKBD_WORKSPACE10 30
|
||||
#define WKBD_NEXTWORKSPACE 31
|
||||
#define WKBD_PREVWORKSPACE 32
|
||||
#define WKBD_NEXTWSLAYER 33
|
||||
#define WKBD_PREVWSLAYER 34
|
||||
|
||||
/* window shortcuts */
|
||||
#define WKBD_WINDOW1 34
|
||||
#define WKBD_WINDOW2 35
|
||||
#define WKBD_WINDOW3 36
|
||||
#define WKBD_WINDOW4 37
|
||||
#define WKBD_WINDOW5 38
|
||||
#define WKBD_WINDOW6 39
|
||||
#define WKBD_WINDOW7 40
|
||||
#define WKBD_WINDOW8 41
|
||||
#define WKBD_WINDOW9 42
|
||||
#define WKBD_WINDOW10 43
|
||||
#define WKBD_WINDOW1 35
|
||||
#define WKBD_WINDOW2 36
|
||||
#define WKBD_WINDOW3 37
|
||||
#define WKBD_WINDOW4 38
|
||||
#define WKBD_WINDOW5 39
|
||||
#define WKBD_WINDOW6 40
|
||||
#define WKBD_WINDOW7 41
|
||||
#define WKBD_WINDOW8 42
|
||||
#define WKBD_WINDOW9 43
|
||||
#define WKBD_WINDOW10 44
|
||||
|
||||
#define WKBD_SWITCH_SCREEN 44
|
||||
#define WKBD_SWITCH_SCREEN 45
|
||||
|
||||
#ifdef KEEP_XKB_LOCK_STATUS
|
||||
# define WKBD_TOGGLE 45
|
||||
# define WKBD_LAST 46
|
||||
# define WKBD_TOGGLE 46
|
||||
# define WKBD_LAST 47
|
||||
#else
|
||||
# define WKBD_LAST 45
|
||||
# define WKBD_LAST 46
|
||||
#endif /* KEEP_XKB_LOCK_STATUS */
|
||||
|
||||
|
||||
|
||||
44
src/kwm.c
44
src/kwm.c
@@ -685,7 +685,7 @@ wKWMGetWorkspaceName(WScreen *scr, int workspace)
|
||||
assert(workspace >= 0 && workspace < MAX_WORKSPACES);
|
||||
|
||||
if (_XA_KWM_DESKTOP_NAME_[workspace]==0) {
|
||||
sprintf(buffer, "KWM_DESKTOP_NAME_%d", workspace + 1);
|
||||
snprintf(buffer, sizeof(buffer), "KWM_DESKTOP_NAME_%d", workspace + 1);
|
||||
|
||||
_XA_KWM_DESKTOP_NAME_[workspace] = XInternAtom(dpy, buffer, False);
|
||||
}
|
||||
@@ -1511,7 +1511,7 @@ wKWMUpdateWorkspaceNameHint(WScreen *scr, int workspace)
|
||||
assert(workspace >= 0 && workspace < MAX_WORKSPACES);
|
||||
|
||||
if (_XA_KWM_DESKTOP_NAME_[workspace]==0) {
|
||||
sprintf(buffer, "KWM_DESKTOP_NAME_%d", workspace + 1);
|
||||
snprintf(buffer, sizeof(buffer), "KWM_DESKTOP_NAME_%d", workspace + 1);
|
||||
|
||||
_XA_KWM_DESKTOP_NAME_[workspace] = XInternAtom(dpy, buffer, False);
|
||||
}
|
||||
@@ -1583,7 +1583,7 @@ wKWMGetUsableArea(WScreen *scr, WArea *area)
|
||||
char buffer[64];
|
||||
|
||||
if (_XA_KWM_WINDOW_REGION_[0]==0) {
|
||||
sprintf(buffer, "KWM_WINDOW_REGION_%d", 1);
|
||||
snprintf(buffer, sizeof(buffer), "KWM_WINDOW_REGION_%d", 1);
|
||||
|
||||
_XA_KWM_WINDOW_REGION_[0] = XInternAtom(dpy, buffer, False);
|
||||
}
|
||||
@@ -1625,7 +1625,7 @@ wKWMSetUsableAreaHint(WScreen *scr, int workspace)
|
||||
assert(workspace >= 0 && workspace < MAX_WORKSPACES);
|
||||
|
||||
if (_XA_KWM_WINDOW_REGION_[workspace]==0) {
|
||||
sprintf(buffer, "KWM_WINDOW_REGION_%d", workspace+1);
|
||||
snprintf(buffer, sizeof(buffer), "KWM_WINDOW_REGION_%d", workspace+1);
|
||||
|
||||
_XA_KWM_WINDOW_REGION_[workspace] = XInternAtom(dpy, buffer, False);
|
||||
}
|
||||
@@ -1682,7 +1682,7 @@ writeSocket(int sock, char *data)
|
||||
{
|
||||
char buffer[128];
|
||||
|
||||
sprintf(buffer, "%i ", strlen(data));
|
||||
snprintf(buffer, sizeof(buffer), "%i ", strlen(data));
|
||||
write(sock, buffer, strlen(buffer));
|
||||
write(sock, data, strlen(data));
|
||||
}
|
||||
@@ -1692,15 +1692,16 @@ static int
|
||||
connectKFM(WScreen *scr)
|
||||
{
|
||||
char *path;
|
||||
char buffer[128];
|
||||
char *buffer;
|
||||
char *ptr;
|
||||
FILE *f;
|
||||
int pid;
|
||||
int sock = 0;
|
||||
struct sockaddr_un addr;
|
||||
char buf[256];
|
||||
|
||||
path = wstrconcat(wgethomedir(), "/.kde/share/apps/kfm/pid");
|
||||
strcpy(buffer, getenv("DISPLAY"));
|
||||
buffer = wstrdup(getenv("DISPLAY"));
|
||||
|
||||
ptr = strchr(buffer, ':');
|
||||
if (ptr)
|
||||
@@ -1712,12 +1713,12 @@ connectKFM(WScreen *scr)
|
||||
{
|
||||
char b[32];
|
||||
|
||||
sprintf(b, ".%i", scr->screen);
|
||||
strcat(buffer, b);
|
||||
snprintf(b, sizeof(b), ".%i", scr->screen);
|
||||
|
||||
buffer = wstrappend(buffer, b);
|
||||
}
|
||||
ptr = path;
|
||||
path = wstrconcat(ptr, buffer);
|
||||
wfree(ptr);
|
||||
path = wstrappend(path, buffer);
|
||||
wfree(buffer);
|
||||
|
||||
/* pid file */
|
||||
f = fopen(path, "r");
|
||||
@@ -1725,24 +1726,26 @@ connectKFM(WScreen *scr)
|
||||
if (!f)
|
||||
return -1;
|
||||
|
||||
buffer[0] = 0;
|
||||
fgets(buffer, 123, f);
|
||||
pid = atoi(buffer);
|
||||
*buf = 0;
|
||||
fgets(buf, sizeof(buf), f);
|
||||
buf[sizeof(buf)] = 0;
|
||||
pid = atoi(buf);
|
||||
if (pid <= 0)
|
||||
return -1;
|
||||
|
||||
if (kill(pid, 0) != 0)
|
||||
return -1;
|
||||
|
||||
buffer[0] = 0;
|
||||
fscanf(f, "%s", buffer);
|
||||
*buf = 0;
|
||||
fgets(buf, sizeof(buf), f);
|
||||
buf[sizeof(buf)] = 0;
|
||||
fclose(f);
|
||||
|
||||
sock = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (sock < 0)
|
||||
return -1;
|
||||
addr.sun_family = AF_UNIX;
|
||||
strcpy(addr.sun_path, buffer);
|
||||
strcpy(addr.sun_path, buf);
|
||||
|
||||
if (connect(sock, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
|
||||
close(sock);
|
||||
@@ -1751,17 +1754,18 @@ connectKFM(WScreen *scr)
|
||||
|
||||
path = wstrconcat(wgethomedir(), "/.kde/share/apps/kfm/magic");
|
||||
f = fopen(path, "r");
|
||||
wfree(path);
|
||||
if (!f) {
|
||||
return -1;
|
||||
}
|
||||
ptr = fgets(buffer, 123, f);
|
||||
ptr = fgets(buf, sizeof(buf), f);
|
||||
fclose(f);
|
||||
if (!ptr) {
|
||||
return -1;
|
||||
}
|
||||
puts(buffer);
|
||||
|
||||
ptr = wstrconcat("auth", buffer);
|
||||
ptr = wstrconcat("auth", buf);
|
||||
|
||||
writeSocket(sock, ptr);
|
||||
wfree(ptr);
|
||||
|
||||
16
src/main.c
16
src/main.c
@@ -220,17 +220,18 @@ SetupEnvironment(WScreen *scr)
|
||||
char buf[16];
|
||||
|
||||
if (multiHead) {
|
||||
tmp = wmalloc(strlen(DisplayName)+64);
|
||||
sprintf(tmp, "DISPLAY=%s", XDisplayName(DisplayName));
|
||||
int len = strlen(DisplayName)+64;
|
||||
tmp = wmalloc(len);
|
||||
snprintf(tmp, len, "DISPLAY=%s", XDisplayName(DisplayName));
|
||||
ptr = strchr(strchr(tmp, ':'), '.');
|
||||
if (ptr)
|
||||
*ptr = 0;
|
||||
sprintf(buf, ".%i", scr->screen);
|
||||
snprintf(buf, sizeof(buf), ".%i", scr->screen);
|
||||
strcat(tmp, buf);
|
||||
putenv(tmp);
|
||||
}
|
||||
tmp = wmalloc(60);
|
||||
sprintf(tmp, "WRASTER_COLOR_RESOLUTION%i=%i", scr->screen,
|
||||
snprintf(tmp, 60, "WRASTER_COLOR_RESOLUTION%i=%i", scr->screen,
|
||||
scr->rcontext->attribs->colors_per_channel);
|
||||
putenv(tmp);
|
||||
}
|
||||
@@ -735,8 +736,11 @@ main(int argc, char **argv)
|
||||
multiHead = False;
|
||||
|
||||
DisplayName = XDisplayName(DisplayName);
|
||||
str = wmalloc(strlen(DisplayName)+64);
|
||||
sprintf(str, "DISPLAY=%s", DisplayName);
|
||||
{
|
||||
int len = strlen(DisplayName)+64;
|
||||
str = wmalloc(len);
|
||||
snprintf(str, len, "DISPLAY=%s", DisplayName);
|
||||
}
|
||||
putenv(str);
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
@@ -2455,7 +2455,7 @@ saveMenuInfo(proplist_t dict, WMenu *menu, proplist_t key)
|
||||
proplist_t value, list;
|
||||
char buffer[256];
|
||||
|
||||
sprintf(buffer, "%i,%i", menu->frame_x, menu->frame_y);
|
||||
snprintf(buffer, sizeof(buffer), "%i,%i", menu->frame_x, menu->frame_y);
|
||||
value = PLMakeString(buffer);
|
||||
list = PLMakeArrayFromElements(value, NULL);
|
||||
if (menu->flags.lowered)
|
||||
@@ -2654,7 +2654,7 @@ restoreMenuRecurs(WScreen *scr, proplist_t menus, WMenu *menu, char *path)
|
||||
if (strlen(path) + strlen(menu->frame->title) > 510)
|
||||
return False;
|
||||
|
||||
sprintf(buffer, "%s\\%s", path, menu->frame->title);
|
||||
snprintf(buffer, sizeof(buffer), "%s\\%s", path, menu->frame->title);
|
||||
key = PLMakeString(buffer);
|
||||
entry = PLGetDictionaryEntry(menus, key);
|
||||
res = False;
|
||||
|
||||
15
src/misc.c
15
src/misc.c
@@ -81,7 +81,7 @@ static void
|
||||
putidef(char *line, char *name, int value)
|
||||
{
|
||||
char tmp[64];
|
||||
sprintf(tmp, "%i", value);
|
||||
snprintf(tmp, sizeof(tmp), "%i", value);
|
||||
strcat(line, name);
|
||||
strcat(line, tmp);
|
||||
}
|
||||
@@ -824,7 +824,7 @@ ExpandOptions(WScreen *scr, char *cmdline)
|
||||
case 'w':
|
||||
if (scr->focused_window
|
||||
&& scr->focused_window->flags.focused) {
|
||||
sprintf(tmpbuf, "0x%x",
|
||||
snprintf(tmpbuf, sizeof(tmpbuf), "0x%x",
|
||||
(unsigned int)scr->focused_window->client_win);
|
||||
slen = strlen(tmpbuf);
|
||||
olen += slen;
|
||||
@@ -842,7 +842,7 @@ ExpandOptions(WScreen *scr, char *cmdline)
|
||||
break;
|
||||
|
||||
case 'W':
|
||||
sprintf(tmpbuf, "0x%x",
|
||||
snprintf(tmpbuf, sizeof(tmpbuf), "0x%x",
|
||||
(unsigned int)scr->current_workspace + 1);
|
||||
slen = strlen(tmpbuf);
|
||||
olen += slen;
|
||||
@@ -1128,8 +1128,9 @@ EscapeWM_CLASS(char *name, char *class)
|
||||
}
|
||||
|
||||
if (ename && eclass) {
|
||||
ret = wmalloc(strlen(ename)+strlen(eclass)+4);
|
||||
sprintf(ret, "%s.%s", ename, eclass);
|
||||
int len = strlen(ename)+strlen(eclass)+4;
|
||||
ret = wmalloc(len);
|
||||
snprintf(ret, len, "%s.%s", ename, eclass);
|
||||
wfree(ename);
|
||||
wfree(eclass);
|
||||
} else if (ename) {
|
||||
@@ -1230,12 +1231,12 @@ SendHelperMessage(WScreen *scr, char type, int workspace, char *msg)
|
||||
|
||||
len = (msg ? strlen(msg) : 0) + (workspace >=0 ? 4 : 0) + 1 ;
|
||||
buffer = wmalloc(len+5);
|
||||
sprintf(buf, "%4i", len);
|
||||
snprintf(buf, len, "%4i", len);
|
||||
memcpy(buffer, buf, 4);
|
||||
buffer[4] = type;
|
||||
i = 5;
|
||||
if (workspace >= 0) {
|
||||
sprintf(buf, "%4i", workspace);
|
||||
snprintf(buf, sizeof(buf), "%4i", workspace);
|
||||
memcpy(&buffer[i], buf, 4);
|
||||
i += 4;
|
||||
buffer[i] = 0;
|
||||
|
||||
@@ -270,7 +270,7 @@ showGeometry(WWindow *wwin, int x1, int y1, int x2, int y2, int direction)
|
||||
|
||||
XDrawSegments(dpy, root, gc, segment, 4);
|
||||
|
||||
sprintf(num, "%i", (by - ty - wwin->normal_hints->base_height) /
|
||||
snprintf(num, sizeof(num), "%i", (by - ty - wwin->normal_hints->base_height) /
|
||||
wwin->normal_hints->height_inc);
|
||||
fw = WMWidthOfString(scr->info_text_font, num, strlen(num));
|
||||
|
||||
@@ -289,7 +289,7 @@ showGeometry(WWindow *wwin, int x1, int y1, int x2, int y2, int direction)
|
||||
s = 15;
|
||||
}
|
||||
mx = x1 + (x2 - x1)/2;
|
||||
sprintf(num, "%i", (x2 - x1 - wwin->normal_hints->base_width) /
|
||||
snprintf(num, sizeof(num), "%i", (x2 - x1 - wwin->normal_hints->base_width) /
|
||||
wwin->normal_hints->width_inc);
|
||||
fw = WMWidthOfString(scr->info_text_font, num, strlen(num));
|
||||
|
||||
|
||||
@@ -331,14 +331,16 @@ getLocalizedMenuFile(char *menu)
|
||||
{
|
||||
char *buffer;
|
||||
char *ptr;
|
||||
int len;
|
||||
|
||||
if (!Locale)
|
||||
return NULL;
|
||||
|
||||
buffer = wmalloc(strlen(menu)+32);
|
||||
len = strlen(menu)+32;
|
||||
buffer = wmalloc(len);
|
||||
|
||||
/* try menu.locale_name */
|
||||
sprintf(buffer, "%s.%s", menu, Locale);
|
||||
snprintf(buffer, len, "%s.%s", menu, Locale);
|
||||
if (access(buffer, F_OK)==0) {
|
||||
return buffer;
|
||||
}
|
||||
@@ -745,6 +747,14 @@ finish:
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cleanupWorkspaceMenu(WMenu *menu)
|
||||
{
|
||||
if (menu->frame->screen_ptr->workspace_menu == menu)
|
||||
menu->frame->screen_ptr->workspace_menu = NULL;
|
||||
}
|
||||
|
||||
|
||||
static WMenuEntry*
|
||||
addWorkspaceMenu(WScreen *scr, WMenu *menu, char *title)
|
||||
{
|
||||
@@ -756,8 +766,10 @@ addWorkspaceMenu(WScreen *scr, WMenu *menu, char *title)
|
||||
return NULL;
|
||||
} else {
|
||||
scr->flags.added_workspace_menu = 1;
|
||||
|
||||
|
||||
wsmenu = wWorkspaceMenuMake(scr, True);
|
||||
wsmenu->on_destroy = cleanupWorkspaceMenu;
|
||||
|
||||
scr->workspace_menu = wsmenu;
|
||||
entry = wMenuAddCallback(menu, title, NULL, NULL);
|
||||
wMenuEntrySetCascade(menu, entry, wsmenu);
|
||||
@@ -767,6 +779,15 @@ addWorkspaceMenu(WScreen *scr, WMenu *menu, char *title)
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
cleanupWindowsMenu(WMenu *menu)
|
||||
{
|
||||
if (menu->frame->screen_ptr->switch_menu == menu)
|
||||
menu->frame->screen_ptr->switch_menu = NULL;
|
||||
}
|
||||
|
||||
|
||||
static WMenuEntry*
|
||||
addWindowsMenu(WScreen *scr, WMenu *menu, char *title)
|
||||
{
|
||||
@@ -781,6 +802,7 @@ addWindowsMenu(WScreen *scr, WMenu *menu, char *title)
|
||||
scr->flags.added_windows_menu = 1;
|
||||
|
||||
wwmenu = wMenuCreate(scr, _("Window List"), False);
|
||||
wwmenu->on_destroy = cleanupWindowsMenu;
|
||||
scr->switch_menu = wwmenu;
|
||||
wwin = scr->focused_window;
|
||||
while (wwin) {
|
||||
@@ -794,6 +816,7 @@ addWindowsMenu(WScreen *scr, WMenu *menu, char *title)
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
||||
static WMenuEntry*
|
||||
addMenuEntry(WMenu *menu, char *title, char *shortcut, char *command,
|
||||
char *params, char *file_name)
|
||||
@@ -1131,7 +1154,8 @@ readMenuFile(WScreen *scr, char *file_name)
|
||||
if (!args) {
|
||||
wwarning(_("could not make arguments for menu file preprocessor"));
|
||||
} else {
|
||||
sprintf(command, "%s %s %s", CPP_PATH, args, file_name);
|
||||
snprintf(command, sizeof(command), "%s %s %s",
|
||||
CPP_PATH, args, file_name);
|
||||
wfree(args);
|
||||
file = popen(command, "r");
|
||||
if (!file) {
|
||||
@@ -1230,7 +1254,8 @@ readMenuPipe(WScreen *scr, char **file_name)
|
||||
if (!args) {
|
||||
wwarning(_("could not make arguments for menu file preprocessor"));
|
||||
} else {
|
||||
sprintf(command, "%s | %s %s", filename, CPP_PATH, args);
|
||||
snprintf(command, sizeof(command), "%s | %s %s",
|
||||
filename, CPP_PATH, args);
|
||||
|
||||
wfree(args);
|
||||
file = popen(command, "r");
|
||||
@@ -1746,6 +1771,7 @@ OpenRootMenu(WScreen *scr, int x, int y, int keyboard)
|
||||
|
||||
scr->flags.root_menu_changed_shortcuts = 0;
|
||||
scr->flags.added_workspace_menu = 0;
|
||||
scr->flags.added_windows_menu = 0;
|
||||
|
||||
if (scr->root_menu && scr->root_menu->flags.mapped) {
|
||||
menu = scr->root_menu;
|
||||
@@ -1798,8 +1824,9 @@ OpenRootMenu(WScreen *scr, int x, int y, int keyboard)
|
||||
menu = scr->root_menu;
|
||||
} else {
|
||||
/* new root menu */
|
||||
if (scr->root_menu)
|
||||
if (scr->root_menu) {
|
||||
wMenuDestroy(scr->root_menu, True);
|
||||
}
|
||||
scr->root_menu = menu;
|
||||
}
|
||||
if (menu) {
|
||||
|
||||
@@ -557,7 +557,7 @@ aquireManagerSelection(WScreen *scr)
|
||||
XEvent ev;
|
||||
Time timestamp;
|
||||
|
||||
sprintf(buffer, "WM_S%i", scr->screen);
|
||||
snprintf(buffer, sizeof(buffer), "WM_S%i", scr->screen);
|
||||
scr->managerAtom = XInternAtom(dpy, buffer, False);
|
||||
|
||||
/* for race-conditions... */
|
||||
@@ -1015,14 +1015,14 @@ wScreenRestoreState(WScreen *scr)
|
||||
path = wdefaultspathfordomain("WMState");
|
||||
else {
|
||||
char buf[16];
|
||||
sprintf(buf, "WMState.%i", scr->screen);
|
||||
snprintf(buf, sizeof(buf), "WMState.%i", scr->screen);
|
||||
path = wdefaultspathfordomain(buf);
|
||||
}
|
||||
scr->session_state = PLGetProplistWithPath(path);
|
||||
wfree(path);
|
||||
if (!scr->session_state && wScreenCount>1) {
|
||||
char buf[16];
|
||||
sprintf(buf, "WMState.%i", scr->screen);
|
||||
snprintf(buf, sizeof(buf), "WMState.%i", scr->screen);
|
||||
path = wdefaultspathfordomain(buf);
|
||||
scr->session_state = PLGetProplistWithPath(path);
|
||||
wfree(path);
|
||||
@@ -1125,7 +1125,7 @@ wScreenSaveState(WScreen *scr)
|
||||
str = wdefaultspathfordomain("WMState");
|
||||
else {
|
||||
char buf[16];
|
||||
sprintf(buf, "WMState.%i", scr->screen);
|
||||
snprintf(buf, sizeof(buf), "WMState.%i", scr->screen);
|
||||
str = wdefaultspathfordomain(buf);
|
||||
}
|
||||
path = PLMakeString(str);
|
||||
|
||||
@@ -215,7 +215,7 @@ makeWindowState(WWindow *wwin, WApplication *wapp)
|
||||
char **argv;
|
||||
int i;
|
||||
unsigned mask;
|
||||
char *class, *instance, *command=NULL, buffer[256];
|
||||
char *class, *instance, *command=NULL, buffer[512];
|
||||
proplist_t win_state, cmd, name, workspace;
|
||||
proplist_t shaded, miniaturized, hidden, geometry;
|
||||
proplist_t dock, shortcut;
|
||||
@@ -234,13 +234,13 @@ makeWindowState(WWindow *wwin, WApplication *wapp)
|
||||
|
||||
if (PropGetWMClass(win, &class, &instance)) {
|
||||
if (class && instance)
|
||||
sprintf(buffer, "%s.%s", instance, class);
|
||||
snprintf(buffer, sizeof(buffer), "%s.%s", instance, class);
|
||||
else if (instance)
|
||||
sprintf(buffer, "%s", instance);
|
||||
snprintf(buffer, sizeof(buffer), "%s", instance);
|
||||
else if (class)
|
||||
sprintf(buffer, ".%s", class);
|
||||
snprintf(buffer, sizeof(buffer), ".%s", class);
|
||||
else
|
||||
sprintf(buffer, ".");
|
||||
snprintf(buffer, sizeof(buffer), ".");
|
||||
|
||||
name = PLMakeString(buffer);
|
||||
cmd = PLMakeString(command);
|
||||
@@ -250,7 +250,8 @@ makeWindowState(WWindow *wwin, WApplication *wapp)
|
||||
shaded = wwin->flags.shaded ? sYes : sNo;
|
||||
miniaturized = wwin->flags.miniaturized ? sYes : sNo;
|
||||
hidden = wwin->flags.hidden ? sYes : sNo;
|
||||
sprintf(buffer, "%ix%i+%i+%i", wwin->client.width, wwin->client.height,
|
||||
snprintf(buffer, sizeof(buffer), "%ix%i+%i+%i",
|
||||
wwin->client.width, wwin->client.height,
|
||||
wwin->frame_x, wwin->frame_y);
|
||||
geometry = PLMakeString(buffer);
|
||||
|
||||
@@ -261,7 +262,7 @@ makeWindowState(WWindow *wwin, WApplication *wapp)
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(buffer, "%u", mask);
|
||||
snprintf(buffer, sizeof(buffer), "%u", mask);
|
||||
shortcut = PLMakeString(buffer);
|
||||
|
||||
win_state = PLMakeDictionaryFromEntries(sName, name,
|
||||
@@ -860,7 +861,7 @@ makeAttributeState(WWindow *wwin)
|
||||
#define W_FLAG(wwin, FLAG) ((wwin)->defined_user_flags.FLAG \
|
||||
? (wwin)->user_flags.FLAG : -1)
|
||||
|
||||
sprintf(buffer,
|
||||
snprintf(buffer, sizeof(buffer),
|
||||
"%i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i",
|
||||
W_FLAG(no_titlebar),
|
||||
W_FLAG(no_resizable),
|
||||
@@ -912,7 +913,7 @@ makeClientState(WWindow *wwin)
|
||||
proplist_t state;
|
||||
proplist_t tmp;
|
||||
char *str;
|
||||
char buffer[256];
|
||||
char buffer[512];
|
||||
int i;
|
||||
unsigned shortcuts;
|
||||
|
||||
@@ -940,13 +941,13 @@ makeClientState(WWindow *wwin)
|
||||
appendStringInArray(state, wwin->frame->name);
|
||||
|
||||
/* geometry */
|
||||
sprintf(buffer, "%i %i %i %i %i %i", wwin->frame_x, wwin->frame_y,
|
||||
snprintf(buffer, sizeof(buffer), "%i %i %i %i %i %i", wwin->frame_x, wwin->frame_y,
|
||||
wwin->client.width, wwin->client.height,
|
||||
wwin->flags.user_changed_width, wwin->flags.user_changed_height);
|
||||
appendStringInArray(state, buffer);
|
||||
|
||||
/* state */
|
||||
sprintf(buffer, "%i %i %i", wwin->flags.miniaturized,
|
||||
snprintf(buffer, sizeof(buffer), "%i %i %i", wwin->flags.miniaturized,
|
||||
wwin->flags.shaded, wwin->flags.maximized);
|
||||
appendStringInArray(state, buffer);
|
||||
|
||||
@@ -956,7 +957,7 @@ makeClientState(WWindow *wwin)
|
||||
PLRelease(tmp);
|
||||
|
||||
/* workspace */
|
||||
sprintf(buffer, "%i", wwin->frame->workspace);
|
||||
snprintf(buffer, sizeof(buffer), "%i", wwin->frame->workspace);
|
||||
appendStringInArray(state, buffer);
|
||||
|
||||
/* app state (repeated for all windows of the app) */
|
||||
@@ -971,7 +972,7 @@ makeClientState(WWindow *wwin)
|
||||
shortcuts |= 1 << i;
|
||||
}
|
||||
}
|
||||
sprintf(buffer, "%ui", shortcuts);
|
||||
snprintf(buffer, sizeof(buffer), "%ui", shortcuts);
|
||||
appendStringInArray(tmp, buffer);
|
||||
|
||||
return state;
|
||||
@@ -993,6 +994,7 @@ smSaveYourselfPhase2Proc(SmcConn smc_conn, SmPointer client_data)
|
||||
char *discardCmd = NULL;
|
||||
time_t t;
|
||||
proplist_t state;
|
||||
int len;
|
||||
|
||||
#ifdef DEBUG1
|
||||
puts("received SaveYourselfPhase2 SM message");
|
||||
@@ -1013,7 +1015,8 @@ smSaveYourselfPhase2Proc(SmcConn smc_conn, SmPointer client_data)
|
||||
if (!prefix)
|
||||
prefix = ".";
|
||||
|
||||
statefile = malloc(strlen(prefix)+64);
|
||||
len = strlen(prefix)+64;
|
||||
statefile = malloc(len);
|
||||
if (!statefile) {
|
||||
wwarning(_("out of memory while saving session state"));
|
||||
goto fail;
|
||||
@@ -1023,10 +1026,10 @@ smSaveYourselfPhase2Proc(SmcConn smc_conn, SmPointer client_data)
|
||||
i = 0;
|
||||
do {
|
||||
if (gsPrefix)
|
||||
sprintf(statefile, "%s/.AppInfo/WindowMaker/wmaker.%l%i.state",
|
||||
snprintf(statefile, len, "%s/.AppInfo/WindowMaker/wmaker.%l%i.state",
|
||||
prefix, t, i);
|
||||
else
|
||||
sprintf(statefile, "%s/wmaker.%l%i.state", prefix, t, i);
|
||||
snprintf(statefile, len, "%s/wmaker.%l%i.state", prefix, t, i);
|
||||
i++;
|
||||
} while (access(F_OK, statefile)!=-1);
|
||||
|
||||
@@ -1050,7 +1053,7 @@ smSaveYourselfPhase2Proc(SmcConn smc_conn, SmPointer client_data)
|
||||
|
||||
scr = wScreenWithNumber(i);
|
||||
|
||||
sprintf(buf, "%i", scr->screen);
|
||||
snprintf(buf, sizeof(buf), "%i", scr->screen);
|
||||
pscreen = PLMakeArrayFromElements(PLMakeString(buf), NULL);
|
||||
|
||||
wwin = scr->focused_window;
|
||||
@@ -1134,10 +1137,14 @@ smSaveYourselfPhase2Proc(SmcConn smc_conn, SmPointer client_data)
|
||||
prop[0].vals[j].value = statefile;
|
||||
prop[0].vals[j].length = strlen(statefile);
|
||||
|
||||
discardCmd = malloc(strlen(statefile)+8);
|
||||
if (!discardCmd)
|
||||
goto fail;
|
||||
sprintf(discardCmd, "rm %s", statefile);
|
||||
{
|
||||
int len = strlen(statefile)+8;
|
||||
|
||||
discardCmd = malloc(len);
|
||||
if (!discardCmd)
|
||||
goto fail;
|
||||
snprintf(discardCmd, len, "rm %s", statefile);
|
||||
}
|
||||
prop[2].name = SmDiscardCommand;
|
||||
prop[2].type = SmARRAY8;
|
||||
prop[2].vals[0] = discardCmd;
|
||||
@@ -1317,7 +1324,7 @@ wSessionConnectManager(char **argv, int argc)
|
||||
|
||||
/* The XSMP doc from X11R6.1 says it contains the user name,
|
||||
* but every client implementation I saw places the uid # */
|
||||
sprintf(uid, "%i", getuid());
|
||||
snprintf(uid, sizeof(uid), "%i", getuid());
|
||||
prop2val.value = uid;
|
||||
prop2val.length = strlen(uid);
|
||||
prop[1].name = SmUserID;
|
||||
@@ -1336,7 +1343,7 @@ wSessionConnectManager(char **argv, int argc)
|
||||
prop[2].vals = &prop3val;
|
||||
|
||||
/* Our PID. Not required but might be usefull */
|
||||
sprintf(pid, "%i", getpid());
|
||||
snprintf(pid, sizeof(pid), "%i", getpid());
|
||||
prop4val.value = pid;
|
||||
prop4val.length = strlen(pid);
|
||||
prop[3].name = SmProcessID;
|
||||
|
||||
@@ -715,6 +715,12 @@ static char *atomNames[] = {
|
||||
GNUSTEP_TITLEBAR_STATE
|
||||
};
|
||||
|
||||
static void
|
||||
handle_sigpipe(int signum)
|
||||
{
|
||||
if (0) signum=0; /* To avoid a gcc warning */
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------
|
||||
@@ -847,7 +853,12 @@ StartUp(Bool defaultScreenOnly)
|
||||
sigaction(SIGUSR2, &sig_action, NULL);
|
||||
|
||||
/* ignore dead pipe */
|
||||
sig_action.sa_handler = SIG_IGN;
|
||||
sig_action.sa_handler = &handle_sigpipe;
|
||||
/* Because POSIX mandates that only signal with handlers are reset
|
||||
accross an exec*(), we do not want to propagate ignoring SIGPIPEs
|
||||
to children. Hence the dummy handler.
|
||||
Philippe Troin <phil@fifi.org>
|
||||
*/
|
||||
sig_action.sa_flags = SA_RESTART;
|
||||
sigaction(SIGPIPE, &sig_action, NULL);
|
||||
|
||||
|
||||
@@ -181,6 +181,7 @@ UpdateSwitchMenu(WScreen *scr, WWindow *wwin, int action)
|
||||
WMenu *switchmenu = scr->switch_menu;
|
||||
WMenuEntry *entry;
|
||||
char title[MAX_MENU_TEXT_LENGTH+6];
|
||||
int len = MAX_MENU_TEXT_LENGTH+6;
|
||||
int i;
|
||||
int checkVisibility = 0;
|
||||
|
||||
@@ -201,11 +202,11 @@ UpdateSwitchMenu(WScreen *scr, WWindow *wwin, int action)
|
||||
|
||||
if (wwin->flags.internal_window || WFLAGP(wwin, skip_window_list))
|
||||
return;
|
||||
|
||||
|
||||
if (wwin->frame->title)
|
||||
sprintf(title, "%s", wwin->frame->title);
|
||||
snprintf(title, len, "%s", wwin->frame->title);
|
||||
else
|
||||
sprintf(title, "%s", DEF_WINDOW_TITLE);
|
||||
snprintf(title, len, "%s", DEF_WINDOW_TITLE);
|
||||
t = ShrinkString(scr->menu_entry_font, title, MAX_WINDOWLIST_WIDTH);
|
||||
|
||||
if (IS_OMNIPRESENT(wwin))
|
||||
@@ -220,9 +221,9 @@ UpdateSwitchMenu(WScreen *scr, WWindow *wwin, int action)
|
||||
entry->flags.indicator = 1;
|
||||
entry->rtext = wmalloc(MAX_WORKSPACENAME_WIDTH+8);
|
||||
if (IS_OMNIPRESENT(wwin))
|
||||
sprintf(entry->rtext, "[*]");
|
||||
snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH, "[*]");
|
||||
else
|
||||
sprintf(entry->rtext, "[%s]",
|
||||
snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH, "[%s]",
|
||||
scr->workspaces[wwin->frame->workspace]->name);
|
||||
|
||||
if (wwin->flags.hidden) {
|
||||
@@ -262,7 +263,8 @@ UpdateSwitchMenu(WScreen *scr, WWindow *wwin, int action)
|
||||
snprintf(title, MAX_MENU_TEXT_LENGTH, "%s",
|
||||
wwin->frame->title);
|
||||
else
|
||||
sprintf(title, "%s", DEF_WINDOW_TITLE);
|
||||
snprintf(title, MAX_MENU_TEXT_LENGTH, "%s",
|
||||
DEF_WINDOW_TITLE);
|
||||
|
||||
t = ShrinkString(scr->menu_entry_font, title, MAX_WINDOWLIST_WIDTH);
|
||||
entry->text = t;
|
||||
@@ -278,10 +280,11 @@ UpdateSwitchMenu(WScreen *scr, WWindow *wwin, int action)
|
||||
int it, ion;
|
||||
|
||||
if (IS_OMNIPRESENT(wwin)) {
|
||||
sprintf(entry->rtext, "[*]");
|
||||
snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH,
|
||||
"[*]");
|
||||
} else {
|
||||
sprintf(entry->rtext, "[%s]",
|
||||
scr->workspaces[wwin->frame->workspace]->name);
|
||||
snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH,
|
||||
"[%s]", scr->workspaces[wwin->frame->workspace]->name);
|
||||
}
|
||||
|
||||
rt = entry->rtext;
|
||||
@@ -362,9 +365,9 @@ UpdateSwitchMenuWorkspace(WScreen *scr, int workspace)
|
||||
if (wwin->frame->workspace==workspace
|
||||
&& !IS_OMNIPRESENT(wwin)) {
|
||||
if (IS_OMNIPRESENT(wwin))
|
||||
sprintf(menu->entries[i]->rtext, "[*]");
|
||||
snprintf(menu->entries[i]->rtext, MAX_WORKSPACENAME_WIDTH,"[*]");
|
||||
else
|
||||
sprintf(menu->entries[i]->rtext, "[%s]",
|
||||
snprintf(menu->entries[i]->rtext, MAX_WORKSPACENAME_WIDTH,"[%s]",
|
||||
scr->workspaces[wwin->frame->workspace]->name);
|
||||
menu->flags.realized = 0;
|
||||
}
|
||||
|
||||
@@ -357,8 +357,9 @@ wUserMenuGet(WScreen *scr, WWindow *wwin)
|
||||
char *path = NULL;
|
||||
char *tmp;
|
||||
if ( wwin->wm_instance && wwin->wm_class ) {
|
||||
tmp=wmalloc(strlen(wwin->wm_instance)+strlen(wwin->wm_class)+7);
|
||||
sprintf(tmp,"%s.%s.menu",wwin->wm_instance,wwin->wm_class);
|
||||
int len = strlen(wwin->wm_instance)+strlen(wwin->wm_class)+7;
|
||||
tmp=wmalloc(len);
|
||||
snprintf(tmp,len,"%s.%s.menu",wwin->wm_instance,wwin->wm_class);
|
||||
path = wfindfile(DEF_USER_MENU_PATHS,tmp);
|
||||
wfree(tmp);
|
||||
|
||||
|
||||
@@ -1792,7 +1792,7 @@ wWindowUpdateName(WWindow *wwin, char *newTitle)
|
||||
|
||||
#ifndef NO_WINDOW_ENUMERATOR
|
||||
if (instIndex > 0) {
|
||||
sprintf(prefix, " [%i]", instIndex);
|
||||
snprintf(prefix, sizeof(prefix), " [%i]", instIndex);
|
||||
|
||||
title = wstrconcat(title, prefix);
|
||||
}
|
||||
|
||||
@@ -262,20 +262,22 @@ updateMakeShortcutMenu(WMenu *menu, WWindow *wwin)
|
||||
WMenu *smenu = menu->cascades[menu->entries[MC_SHORTCUT]->cascade];
|
||||
int i;
|
||||
char *buffer;
|
||||
int buflen;
|
||||
KeyCode kcode;
|
||||
|
||||
if (!smenu)
|
||||
return;
|
||||
|
||||
buffer = wmalloc(strlen(_("Set Shortcut"))+16);
|
||||
buflen = strlen(_("Set Shortcut"))+16;
|
||||
buffer = wmalloc(buflen);
|
||||
|
||||
for (i=WO_ENTRIES; i<smenu->entry_no; i++) {
|
||||
char *tmp;
|
||||
int shortcutNo = i-WO_ENTRIES;
|
||||
WMenuEntry *entry = smenu->entries[i];
|
||||
WMArray *shortSelWindows = wwin->screen_ptr->shortcutWindows[shortcutNo];
|
||||
|
||||
sprintf(buffer, "%s %i", _("Set Shortcut"), shortcutNo+1);
|
||||
|
||||
snprintf(buffer, buflen, "%s %i", _("Set Shortcut"), shortcutNo+1);
|
||||
|
||||
if (!shortSelWindows) {
|
||||
entry->flags.indicator_on = 0;
|
||||
|
||||
@@ -380,9 +380,10 @@ showIconFor(WMScreen *scrPtr, InspectorPanel *panel,
|
||||
|
||||
if (!path) {
|
||||
char *buf;
|
||||
int len = strlen(file)+80;
|
||||
|
||||
buf = wmalloc(strlen(file)+80);
|
||||
sprintf(buf, _("Could not find icon \"%s\" specified for this window"),
|
||||
buf = wmalloc(len);
|
||||
snprintf(buf, len, _("Could not find icon \"%s\" specified for this window"),
|
||||
file);
|
||||
wMessageDialog(panel->frame->screen_ptr, _("Error"), buf,
|
||||
_("OK"), NULL, NULL);
|
||||
@@ -396,9 +397,10 @@ showIconFor(WMScreen *scrPtr, InspectorPanel *panel,
|
||||
|
||||
if (!pixmap) {
|
||||
char *buf;
|
||||
int len = strlen(file)+80;
|
||||
|
||||
buf = wmalloc(strlen(file)+80);
|
||||
sprintf(buf, _("Could not open specified icon \"%s\":%s"),
|
||||
buf = wmalloc(len);
|
||||
snprintf(buf, len, _("Could not open specified icon \"%s\":%s"),
|
||||
file, RMessageForError(RErrorCode));
|
||||
wMessageDialog(panel->frame->screen_ptr, _("Error"), buf,
|
||||
_("OK"), NULL, NULL);
|
||||
@@ -1123,18 +1125,20 @@ selectSpecification(WMWidget *bPtr, void *data)
|
||||
InspectorPanel *panel = (InspectorPanel*)data;
|
||||
char *str;
|
||||
WWindow *wwin = panel->inspected;
|
||||
|
||||
int len;
|
||||
|
||||
if (bPtr == panel->defaultRb && (wwin->wm_instance || wwin->wm_class)) {
|
||||
WMSetButtonEnabled(panel->applyBtn, False);
|
||||
} else {
|
||||
WMSetButtonEnabled(panel->applyBtn, True);
|
||||
}
|
||||
|
||||
len = 16 + strlen(wwin->wm_instance ? wwin->wm_instance : "?")
|
||||
+ strlen(wwin->wm_class ? wwin->wm_class : "?");
|
||||
|
||||
str = wmalloc(16 + strlen(wwin->wm_instance ? wwin->wm_instance : "?")
|
||||
+ strlen(wwin->wm_class ? wwin->wm_class : "?"));
|
||||
str = wmalloc(len);
|
||||
|
||||
sprintf(str, _("Inspecting %s.%s"),
|
||||
snprintf(str, len, _("Inspecting %s.%s"),
|
||||
wwin->wm_instance ? wwin->wm_instance : "?",
|
||||
wwin->wm_class ? wwin->wm_class : "?");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user