aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/hw/nxagent/Display.c
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2020-01-03 14:36:23 +0100
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2020-01-05 21:37:40 +0100
commit3cd622cf4085e8c4257ff17c2481d92d3bc443f9 (patch)
tree612691d310a69cf67e873e02e77a35f9699aee1b /nx-X11/programs/Xserver/hw/nxagent/Display.c
parent475961e651e69b92a25709d99c6c9743a23acd55 (diff)
downloadnx-libs-3cd622cf4085e8c4257ff17c2481d92d3bc443f9.tar.gz
nx-libs-3cd622cf4085e8c4257ff17c2481d92d3bc443f9.tar.bz2
nx-libs-3cd622cf4085e8c4257ff17c2481d92d3bc443f9.zip
Display.c: drop icon file support
The normal case was to use the builtin icons. There were two cases where the icon file was read from disk: 1) /usr/NX/share/images/nxagent.xpm was existing which normally is not there 2) case 2 was not true and nxagent.xpm was existing somewhere in the PATH (!) (replace nxagent.xpm by x2goagent.xpm if in x2gp mode) Scanning the path from the PATH variable for xpm files is kind of unexpected and dangerous, too (think of automounter triggers or invalid xpm files). Also remove the xpm files from the distribution.
Diffstat (limited to 'nx-X11/programs/Xserver/hw/nxagent/Display.c')
-rw-r--r--nx-X11/programs/Xserver/hw/nxagent/Display.c160
1 files changed, 16 insertions, 144 deletions
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Display.c b/nx-X11/programs/Xserver/hw/nxagent/Display.c
index c6412f38a..6d62a978f 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Display.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Display.c
@@ -1797,89 +1797,9 @@ FIXME: Is this needed?
nxagentDisplay = NULL;
}
-static FILE *nxagentLookForIconFile(char *iconName, const char *permission,
- char *return_path, int return_path_size)
-{
- char *path;
- char singlePath[PATH_MAX];
- FILE *fptr = NULL;
-
- #ifdef WIN32
- const char separator = ';';
- const char *slash = "\\";
- #else
- const char separator = ':';
- const char *slash = "/";
- #endif
-
- if ((path = getenv("PATH")) == NULL)
- {
- return NULL;
- }
-
- for (char *end = path; end != NULL && fptr == NULL; )
- {
- end = strchr(path, separator);
-
- /* separator found */
- if (end != NULL)
- {
- if ((end - path) > sizeof(singlePath) - 1)
- {
- fprintf(stderr, "Warning: PATH component too long - ignoring it.\n");
- path = end + 1;
- continue;
- }
-
- snprintf(singlePath, (unsigned long)(end - path + 1), "%s", path);
- path = end + 1;
- }
- else
- {
- if (strlen(path) > sizeof(singlePath) - 1)
- {
- fprintf(stderr, "Warning: PATH component too long - ignoring it.\n");
- return NULL;
- }
-
- snprintf(singlePath, sizeof(singlePath), "%s", path);
- }
-
- /* cut off trailing slashes, if any */
- while (singlePath[strlen(singlePath) - 1] == slash[0])
- {
- singlePath[strlen(singlePath) - 1] = '\0';
- }
-
- /* append slash and icon name */
- if (strlen(singlePath) + strlen(iconName) + 1 < sizeof(singlePath))
- {
- snprintf(singlePath + strlen(singlePath), sizeof(singlePath), "%s%s", slash, iconName);
-
- if ((fptr = fopen(singlePath, permission)) != NULL)
- {
- snprintf(return_path, return_path_size, "%s", singlePath);
- }
- }
- else
- {
- fprintf(stderr, "Warning: Icon path too long.\n");
- }
- }
-
- return fptr;
-}
Bool nxagentMakeIcon(Display *display, Pixmap *nxIcon, Pixmap *nxMask)
{
- char default_path [PATH_MAX];
- char icon_path [PATH_MAX];
- FILE *icon_fp;
- int status;
- Bool success = False;
- XlibPixmap IconPixmap;
- XlibPixmap IconShape;
- char* agent_icon_name;
char** agentIconData;
/*
@@ -1887,84 +1807,36 @@ Bool nxagentMakeIcon(Display *display, Pixmap *nxIcon, Pixmap *nxMask)
*/
if(nxagentX2go)
{
- agent_icon_name = X2GOAGENT_ICON_NAME;
agentIconData = x2goagentIconData;
}
else
{
- agent_icon_name = NXAGENT_ICON_NAME;
agentIconData = nxagentIconData;
}
- /* FIXME: use a compile time define here, /usr/NX is a nomachine path */
- snprintf(default_path, sizeof(default_path), "/usr/NX/share/images/%s", agent_icon_name);
-
- if ((icon_fp = fopen(default_path, "r")) == NULL)
+ XlibPixmap IconPixmap;
+ XlibPixmap IconShape;
+ if (XpmSuccess == XpmCreatePixmapFromData(display,
+ DefaultRootWindow(display),
+ agentIconData,
+ &IconPixmap,
+ &IconShape,
+ NULL))
{
- icon_fp = nxagentLookForIconFile(agent_icon_name, "r", icon_path, sizeof(icon_path));
+ *nxIcon = IconPixmap;
+ *nxMask = IconShape;
- if (icon_fp != NULL)
- {
- fclose (icon_fp);
- success = True;
- }
+ return True;
}
else
{
- fclose (icon_fp);
- success = True;
- snprintf(icon_path, sizeof(icon_path), "%s", default_path);
- }
-
- if (success)
- {
- status = XpmReadFileToPixmap(display,
- DefaultRootWindow(display),
- icon_path,
- &IconPixmap,
- &IconShape,
- NULL);
-
- if (status != XpmSuccess)
- {
- #ifdef TEST
- fprintf(stderr, "nxagentMakeIcon: Xpm operation failed with error '%s'.\n",
- XpmGetErrorString(status));
- #endif
-
- success = False;
- }
- }
-
- if (!success)
- {
- status = XpmCreatePixmapFromData(display,
- DefaultRootWindow(display),
- agentIconData,
- &IconPixmap,
- &IconShape,
- NULL);
-
- if (status != XpmSuccess)
- {
- #ifdef TEST
- fprintf(stderr, "nxagentMakeIcon: Xpm operation failed with error '%s'.\n",
- XpmGetErrorString(status));
- #endif
+ #ifdef TEST
+ fprintf(stderr, "%s: Xpm operation failed with error '%s'.\n", __func__,
+ XpmGetErrorString(status));
+ #endif
- success = False;
- }
- else
- {
- success = True;
- }
+ return False;
}
-
-
- *nxIcon = IconPixmap;
- *nxMask = IconShape;
-
- return success;
}
Bool nxagentXServerGeometryChanged(void)