aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xwin/winprefs.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-01-28 15:21:45 +0100
committermarha <marha@users.sourceforge.net>2012-01-28 15:21:45 +0100
commit59bda88ffb9deb72a727e7d6b4c141fd7d4678f4 (patch)
treea797879cc0fe54172dba50354b635b1f595081db /xorg-server/hw/xwin/winprefs.c
parent829194c926fa1e3bd45e4fe740e0bc42efe6ace6 (diff)
parent1aee8dafb5391e093f3a111f906ab0d8b6775510 (diff)
downloadvcxsrv-59bda88ffb9deb72a727e7d6b4c141fd7d4678f4.tar.gz
vcxsrv-59bda88ffb9deb72a727e7d6b4c141fd7d4678f4.tar.bz2
vcxsrv-59bda88ffb9deb72a727e7d6b4c141fd7d4678f4.zip
Merge remote-tracking branch 'origin/released'
Conflicts: xorg-server/hw/xwin/InitOutput.c xorg-server/hw/xwin/win.h xorg-server/hw/xwin/winclipboardthread.c xorg-server/hw/xwin/winclipboardunicode.c xorg-server/hw/xwin/winclipboardwndproc.c xorg-server/hw/xwin/winclipboardwrappers.c xorg-server/hw/xwin/winengine.c xorg-server/hw/xwin/winkeybd.c xorg-server/hw/xwin/winkeybd.h xorg-server/hw/xwin/winkeynames.h xorg-server/hw/xwin/winmouse.c xorg-server/hw/xwin/winmultiwindowwm.c xorg-server/hw/xwin/winmultiwindowwndproc.c xorg-server/hw/xwin/winprefs.c xorg-server/hw/xwin/winwindow.h xorg-server/hw/xwin/winwndproc.c
Diffstat (limited to 'xorg-server/hw/xwin/winprefs.c')
-rw-r--r--xorg-server/hw/xwin/winprefs.c78
1 files changed, 58 insertions, 20 deletions
diff --git a/xorg-server/hw/xwin/winprefs.c b/xorg-server/hw/xwin/winprefs.c
index 440cdd2e7..b003f455d 100644
--- a/xorg-server/hw/xwin/winprefs.c
+++ b/xorg-server/hw/xwin/winprefs.c
@@ -53,8 +53,8 @@ extern const char *winGetBaseDir(void);
extern const char *g_pszLogFile;
-/* From winmultiwindowflex.l, the real parser */
-extern void parse_file (FILE *fp);
+/* From winprefslex.l, the real parser */
+extern int parse_file (FILE *fp);
/* Currently in use command ID, incremented each new menu item created */
@@ -712,6 +712,54 @@ winIconIsOverride(unsigned hiconIn)
/*
+ * Open and parse the XWinrc config file @path.
+ * If @path is NULL, use the built-in default.
+ */
+static int
+winPrefsLoadPreferences (char *path)
+{
+ FILE *prefFile = NULL;
+
+ if (path)
+ prefFile = fopen (path, "r");
+ else
+ {
+ char defaultPrefs[] =
+ "MENU rmenu {\n"
+ " \"How to customize this menu\" EXEC \"xterm +tb -e man XWinrc\"\n"
+ " \"Launch xterm\" EXEC xterm\n"
+ " \"Load .XWinrc\" RELOAD\n"
+ " SEPARATOR\n"
+ "}\n"
+ "\n"
+ "ROOTMENU rmenu\n";
+
+ path = "built-in default";
+ prefFile = fmemopen(defaultPrefs, strlen(defaultPrefs), "r");
+ }
+
+ if (!prefFile)
+ {
+ ErrorF ("LoadPreferences: %s not found\n", path);
+ return FALSE;
+ }
+
+ ErrorF ("LoadPreferences: Loading %s\n", path);
+
+ if((parse_file (prefFile)) != 0)
+ {
+ ErrorF ("LoadPreferences: %s is badly formed!\n", path);
+ fclose (prefFile);
+ return FALSE;
+ }
+
+ fclose (prefFile);
+ return TRUE;
+}
+
+
+
+/*
* Try and open ~/.XWinrc and system.XWinrc
* Load it into prefs structure for use by other functions
*/
@@ -720,16 +768,15 @@ LoadPreferences (void)
{
char *home;
char fname[PATH_MAX+NAME_MAX+2];
- FILE *prefFile;
char szDisplay[512];
char *szEnvDisplay;
int i, j;
char param[PARAM_MAX+1];
char *srcParam, *dstParam;
+ int parsed = FALSE;
/* First, clear all preference settings */
memset (&pref, 0, sizeof(pref));
- prefFile = NULL;
/* Now try and find a ~/.xwinrc file */
home = getenv ("HOME");
@@ -739,16 +786,11 @@ LoadPreferences (void)
if (fname[strlen(fname)-1]!='/')
strcat (fname, "/");
strcat (fname, ".XWinrc");
-
- prefFile = fopen (fname, "r");
- if (prefFile)
- {
- winDebug ("winPrefsLoadPreferences: %s\n", fname);
- }
+ parsed = winPrefsLoadPreferences(fname);
}
/* No home file found, check system default */
- if (!prefFile)
+ if (!parsed)
{
char buffer[MAX_PATH];
#ifdef RELOCATE_PROJECTROOT
@@ -757,18 +799,14 @@ LoadPreferences (void)
strncpy(buffer, SYSCONFDIR"/X11/system.XWinrc", sizeof(buffer));
#endif
buffer[sizeof(buffer)-1] = 0;
- prefFile = fopen (buffer, "r");
- if (prefFile)
- {
- winDebug ("winPrefsLoadPreferences: %s\n", buffer);
- }
+ parsed = winPrefsLoadPreferences(buffer);
}
- /* If we could open it, then read the settings and close it */
- if (prefFile)
+ /* Neither user nor system configuration found, or were badly formed */
+ if (!parsed)
{
- parse_file (prefFile);
- fclose (prefFile);
+ ErrorF ("LoadPreferences: See \"man XWinrc\" to customize the XWin menu.\n");
+ parsed = winPrefsLoadPreferences(NULL);
}
/* Setup a DISPLAY environment variable, need to allocate on heap */