aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--configure.ac5
-rw-r--r--src/core/mb-window-manager.c65
-rw-r--r--src/theme-engines/mb-wm-theme.c207
4 files changed, 185 insertions, 107 deletions
diff --git a/ChangeLog b/ChangeLog
index f63758d..79c70aa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2008-02-15 Tomas Frydrych <tf@o-hand.com>
+
+ * configure.ac:
+ Improved help for --enable-compositing-manager.
+
+ * src/theme-engines/mb-wm-theme.c:
+ (mb_wm_theme_new):
+ Try to load default theme when no theme is specified.
+ Turn compositing on by default.
+
+ * src/core/mb-window-manager.c:
+ (mb_wm_process_cmdline):
+ Added -help option for those uncomfortable with self-documenting
+ source code.
+
2008-02-14 Tomas Frydrych <tf@o-hand.com>
* data/themes/Default/theme.xml:
diff --git a/configure.ac b/configure.ac
index cb89a68..490e1d7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,7 +33,10 @@ AC_ARG_ENABLE(debug,
[want_debug=$enableval], [want_debug=no])
AC_ARG_ENABLE(compositing-manager,
- [ --enable-compositing-manager Enable compositing manager],
+ [ --enable-compositing-manager@<:@=BACKEND@:>@ Enable compositing manager,
+ optionally choosing compositor backend. Available
+ backends are: 'default' (XRender based backend),
+ 'clutter' (Clutter based backend).],
[comp_mgr=$enableval], [comp_mgr=no])
AC_ARG_ENABLE(glib-main-loop,
diff --git a/src/core/mb-window-manager.c b/src/core/mb-window-manager.c
index 415c182..c4234a6 100644
--- a/src/core/mb-window-manager.c
+++ b/src/core/mb-window-manager.c
@@ -1,3 +1,23 @@
+/*
+ * Matchbox Window Manager II - A lightweight window manager not for the
+ * desktop.
+ *
+ * Authored By Matthew Allum <mallum@o-hand.com>
+ * Tomas Frydrych <tf@o-hand.com>
+ *
+ * Copyright (c) 2005, 2007, 2008 OpenedHand Ltd - http://o-hand.com
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
#include "mb-wm.h"
#include "../client-types/mb-wm-client-app.h"
#include "../client-types/mb-wm-client-panel.h"
@@ -1418,6 +1438,34 @@ mb_wm_init (MBWMObject *this, va_list vap)
}
static void
+mb_wm_cmdline_help (const char *arg0, Bool quit)
+{
+ FILE * f = stdout;
+ const char * name;
+ char * p = strrchr (arg0, '/');
+
+ if (p)
+ name = p+1;
+ else
+ name = arg0;
+
+ fprintf (f, "\nThis is Matchbox Window Manager 2.\n");
+
+ fprintf (f, "\nUsage: %s [options]\n\n", name);
+ fprintf (f, "Options:\n");
+ fprintf (f, " -display display : X display to connect to (alternatively, display\n"
+ " can be specified using the DISPLAY environment\n"
+ " variable).\n");
+ fprintf (f, " -sm-client-id id : Session id.\n");
+ fprintf (f, " -theme-always-reload : Reload theme even if it matches the currently\n"
+ " loaded theme.\n");
+ fprintf (f, " -theme theme : Load the specified theme\n");
+
+ if (quit)
+ exit (0);
+}
+
+static void
mb_wm_process_cmdline (MBWindowManager *wm)
{
int i;
@@ -1427,9 +1475,17 @@ mb_wm_process_cmdline (MBWindowManager *wm)
for (i = 0; i < argc; ++i)
{
- /* These need to have a value after the name parameter */
- if (i < argc - 1)
+ if (!strcmp(argv[i], "-help") || !strcmp(argv[i], "--help"))
+ {
+ mb_wm_cmdline_help (argv[0], True);
+ }
+ else if (!strcmp(argv[i], "-theme-always-reload"))
{
+ wm->flags |= MBWindowManagerFlagAlwaysReloadTheme;
+ }
+ else if (i < argc - 1)
+ {
+ /* These need to have a value after the name parameter */
if (!strcmp(argv[i], "-display"))
{
mb_wm_init_xdpy (wm, argv[++i]);
@@ -1443,11 +1499,6 @@ mb_wm_process_cmdline (MBWindowManager *wm)
theme_path = argv[++i];
}
}
-
- if (!strcmp(argv[i], "-theme-always-reload"))
- {
- wm->flags |= MBWindowManagerFlagAlwaysReloadTheme;
- }
}
/*
diff --git a/src/theme-engines/mb-wm-theme.c b/src/theme-engines/mb-wm-theme.c
index 5005b5f..bf3b99a 100644
--- a/src/theme-engines/mb-wm-theme.c
+++ b/src/theme-engines/mb-wm-theme.c
@@ -362,19 +362,27 @@ struct expat_data
MBWMTheme *
mb_wm_theme_new (MBWindowManager * wm, const char * theme_path)
{
- MBWMTheme *theme = NULL;
- int theme_type = 0;
- char *path = NULL;
- char buf[256];
- XML_Parser par = NULL;
- FILE *file = NULL;
- MBWMList *xml_clients = NULL;
- char *img = NULL;
- MBWMColor clr_lowlight;
- MBWMColor clr_shadow;
+ MBWMTheme *theme = NULL;
+ int theme_type = 0;
+ char *path = NULL;
+ char buf[256];
+ XML_Parser par = NULL;
+ FILE *file = NULL;
+ MBWMList *xml_clients = NULL;
+ char *img = NULL;
+ MBWMColor clr_lowlight;
+ MBWMColor clr_shadow;
MBWMCompMgrShadowType shadow_type;
- Bool compositing;
- Bool shaped;
+ Bool compositing;
+ Bool shaped;
+ struct stat st;
+
+ /*
+ * If no theme specified, we try to load the default one, if that fails,
+ * we automatically fallback on the built-in defaults.
+ */
+ if (!theme_path)
+ theme_path = "Default";
/* Attempt to parse the xml theme, if any, retrieving the theme type
*
@@ -382,122 +390,119 @@ mb_wm_theme_new (MBWindowManager * wm, const char * theme_path)
* type *before* we can create the underlying object on which the
* init method operates.
*/
- if (theme_path)
+
+ if (*theme_path == '/')
+ {
+ if (!stat (theme_path, &st))
+ path = (char *) theme_path;
+ }
+ else
{
- struct stat st;
+ const char *home = getenv("HOME");
+ int size;
- if (*theme_path == '/')
+ if (home)
{
- if (!stat (theme_path, &st))
- path = (char *) theme_path;
- }
- else
- {
- const char *home = getenv("HOME");
- int size;
-
- if (home)
- {
- const char *fmt = "%s/.themes/%s/matchbox2/theme.xml";
+ const char *fmt = "%s/.themes/%s/matchbox2/theme.xml";
- size = strlen (theme_path) + strlen (fmt) + strlen (home);
- path = alloca (size);
- snprintf (path, size, fmt, home, theme_path);
+ size = strlen (theme_path) + strlen (fmt) + strlen (home);
+ path = alloca (size);
+ snprintf (path, size, fmt, home, theme_path);
- if (stat (path, &st))
- path = NULL;
- }
+ if (stat (path, &st))
+ path = NULL;
+ }
- if (!path)
- {
- const char * fmt = "%s/themes/%s/matchbox2/theme.xml";
+ if (!path)
+ {
+ const char * fmt = "%s/themes/%s/matchbox2/theme.xml";
- size = strlen (theme_path) + strlen (fmt) + strlen (DATADIR);
- path = alloca (size);
- snprintf (path, size, fmt, DATADIR, theme_path);
+ size = strlen (theme_path) + strlen (fmt) + strlen (DATADIR);
+ path = alloca (size);
+ snprintf (path, size, fmt, DATADIR, theme_path);
- if (stat (path, &st))
- path = NULL;
- }
+ if (stat (path, &st))
+ path = NULL;
}
+ }
- if (path)
+ if (path)
+ {
+ struct expat_data udata;
+ udata.compositing = True;
+
+ if (!(file = fopen (path, "r")) ||
+ !(par = XML_ParserCreate(NULL)))
{
- struct expat_data udata;
+ goto default_theme;
+ }
- if (!(file = fopen (path, "r")) ||
- !(par = XML_ParserCreate(NULL)))
- {
- goto default_theme;
- }
+ memset (&udata, 0, sizeof (struct expat_data));
+ udata.par = par;
- memset (&udata, 0, sizeof (struct expat_data));
- udata.par = par;
+ XML_SetElementHandler (par,
+ xml_element_start_cb,
+ xml_element_end_cb);
- XML_SetElementHandler (par,
- xml_element_start_cb,
- xml_element_end_cb);
+ XML_SetUserData(par, (void *)&udata);
- XML_SetUserData(par, (void *)&udata);
+ while (fgets (buf, sizeof (buf), file) &&
+ XML_Parse(par, buf, strlen(buf), 0));
- while (fgets (buf, sizeof (buf), file) &&
- XML_Parse(par, buf, strlen(buf), 0));
+ XML_Parse(par, NULL, 0, 1);
- XML_Parse(par, NULL, 0, 1);
+ if (udata.version == 2)
+ {
+ theme_type = udata.theme_type;
+ xml_clients = udata.xml_clients;
- if (udata.version == 2)
+ if (udata.img)
{
- theme_type = udata.theme_type;
- xml_clients = udata.xml_clients;
-
- if (udata.img)
+ if (*udata.img == '/')
+ img = udata.img;
+ else
{
- if (*udata.img == '/')
- img = udata.img;
- else
- {
- int len = strlen (path) + strlen (udata.img);
- char * s;
- char * p = malloc (len + 1);
- strncpy (p, path, len);
-
- s = strrchr (p, '/');
+ int len = strlen (path) + strlen (udata.img);
+ char * s;
+ char * p = malloc (len + 1);
+ strncpy (p, path, len);
- if (s)
- {
- *(s+1) = 0;
- strcat (p, udata.img);
- }
- else
- {
- strncpy (p, udata.img, len);
- }
+ s = strrchr (p, '/');
- img = p;
- free (udata.img);
+ if (s)
+ {
+ *(s+1) = 0;
+ strcat (p, udata.img);
}
+ else
+ {
+ strncpy (p, udata.img, len);
+ }
+
+ img = p;
+ free (udata.img);
}
}
+ }
- clr_lowlight.r = udata.color_lowlight.r;
- clr_lowlight.g = udata.color_lowlight.g;
- clr_lowlight.b = udata.color_lowlight.b;
- clr_lowlight.a = udata.color_lowlight.a;
- clr_lowlight.set = udata.color_lowlight.set;
+ clr_lowlight.r = udata.color_lowlight.r;
+ clr_lowlight.g = udata.color_lowlight.g;
+ clr_lowlight.b = udata.color_lowlight.b;
+ clr_lowlight.a = udata.color_lowlight.a;
+ clr_lowlight.set = udata.color_lowlight.set;
- clr_shadow.r = udata.color_shadow.r;
- clr_shadow.g = udata.color_shadow.g;
- clr_shadow.b = udata.color_shadow.b;
- clr_shadow.a = udata.color_shadow.a;
- clr_shadow.set = udata.color_shadow.set;
+ clr_shadow.r = udata.color_shadow.r;
+ clr_shadow.g = udata.color_shadow.g;
+ clr_shadow.b = udata.color_shadow.b;
+ clr_shadow.a = udata.color_shadow.a;
+ clr_shadow.set = udata.color_shadow.set;
- shadow_type = udata.shadow_type;
- compositing = udata.compositing;
- shaped = udata.shaped;
+ shadow_type = udata.shadow_type;
+ compositing = udata.compositing;
+ shaped = udata.shaped;
- xml_stack_free (udata.stack);
- }
- }
+ xml_stack_free (udata.stack);
+ }
if (theme_type)
{
@@ -530,6 +535,8 @@ mb_wm_theme_new (MBWindowManager * wm, const char * theme_path)
MBWMObjectPropThemeColorLowlight, &clr_lowlight,
MBWMObjectPropThemeColorShadow, &clr_shadow,
MBWMObjectPropThemeShadowType, shadow_type,
+ MBWMObjectPropThemeCompositing, compositing,
+ MBWMObjectPropThemeShaped, shaped,
NULL));
}
@@ -906,6 +913,8 @@ xml_element_start_cb (void *data, const char *tag, const char **expat_attr)
{
if (!strcmp (*(p+1), "yes") || !strcmp (*(p+1), "1"))
exd->compositing = True;
+ else
+ exd->compositing = False;
}
p += 2;