make this always return FALSE for now, to avoid bug reports.

2002-12-08  Havoc Pennington  <hp@pobox.com>

	* src/prefs.c (meta_prefs_get_application_based): make this always
	return FALSE for now, to avoid bug reports.

	* src/util.c (ensure_logfile): put "opened log file" message on
	stderr so it will normally land in ~/.xsession-errors

	* configure.in: remove extra AC_ARG_PROGRAM

	* src/display.c (event_callback): handle the toggle-verbose message

	* src/tools/metacity-message.c: add a toggle-verbose message, been
	meaning to do this for a while.

	* src/util.c (meta_set_verbose): if verbose mode is enabled and we
	don't support it, then exit.

	* src/prefs.c: allow building without gconf (currently means some
	prefs are no-ops)

	* src/util.c, src/util.h: support defining macros to
	kill all verbose output entirely. (Removes the code and strings
	associated with it)

	* configure.in: don't get METACITY_PROPS_LIBS if not building the
	config dialog.
	(HAVE_GCONF): allow building sans gconf, if you are size-sensitive
	and not using gnome.
	(WITH_VERBOSE_MODE): add ability to disable all the verbose debug
	spew strings, to shrink the binary.
	(--disable-sm): allow SM support to be forced on or off
	(--disable-startup-notification): allow forcing this on or off
This commit is contained in:
Havoc Pennington
2002-12-08 19:17:17 +00:00
committed by Havoc Pennington
parent 15d28dfd97
commit 8d314aead8
13 changed files with 309 additions and 69 deletions

View File

@ -38,11 +38,9 @@ delete_ping_reply_func (MetaDisplay *display,
Window xwindow,
void *user_data)
{
MetaWindow *window = user_data;
meta_topic (META_DEBUG_PING,
"Got reply to delete ping for %s\n",
window->desc);
((MetaWindow*)user_data)->desc);
/* we do nothing */
}

View File

@ -252,7 +252,8 @@ meta_display_open (const char *name)
"_NET_WM_ACTION_CLOSE",
"_NET_WM_STATE_ABOVE",
"_NET_WM_STATE_BELOW",
"_NET_STARTUP_ID"
"_NET_STARTUP_ID",
"_METACITY_TOGGLE_VERBOSE"
};
Atom atoms[G_N_ELEMENTS(atom_names)];
@ -387,6 +388,7 @@ meta_display_open (const char *name)
display->atom_net_wm_state_above = atoms[75];
display->atom_net_wm_state_below = atoms[76];
display->atom_net_startup_id = atoms[77];
display->atom_metacity_toggle_verbose = atoms[78];
display->prop_hooks = NULL;
meta_display_init_window_prop_hooks (display);
@ -1665,6 +1667,12 @@ event_callback (XEvent *event,
(int) event->xclient.data.l[0]);
meta_set_keybindings_disabled (!event->xclient.data.l[0]);
}
else if (event->xclient.message_type ==
display->atom_metacity_toggle_verbose)
{
meta_verbose ("Received toggle verbose message\n");
meta_set_verbose (!meta_is_verbose ());
}
else if (event->xclient.message_type ==
display->atom_wm_protocols)
{

View File

@ -161,6 +161,7 @@ struct _MetaDisplay
Atom atom_net_wm_state_above;
Atom atom_net_wm_state_below;
Atom atom_net_startup_id;
Atom atom_metacity_toggle_verbose;
/* This is the actual window from focus events,
* not the one we last set

View File

@ -23,7 +23,9 @@
#include "prefs.h"
#include "ui.h"
#include "util.h"
#ifdef HAVE_GCONF
#include <gconf/gconf-client.h>
#endif
#include <string.h>
#include <stdlib.h>
@ -52,10 +54,13 @@
#define KEY_WORKSPACE_NAME_PREFIX "/apps/metacity/workspace_names/name_"
#ifdef HAVE_GCONF
static GConfClient *default_client = NULL;
static GList *listeners = NULL;
static GList *changes = NULL;
static guint changed_idle;
#endif
static GList *listeners = NULL;
static gboolean use_system_font = TRUE;
static PangoFontDescription *titlebar_font = NULL;
static MetaVirtualModifier mouse_button_mods = Mod1Mask;
@ -87,7 +92,7 @@ static char *commands[MAX_COMMANDS] = { NULL, };
static char *workspace_names[MAX_REASONABLE_WORKSPACES] = { NULL, };
#ifdef HAVE_GCONF
static gboolean update_use_system_font (gboolean value);
static gboolean update_titlebar_font (const char *value);
static gboolean update_mouse_button_mods (const char *value);
@ -104,17 +109,13 @@ static gboolean update_window_binding (const char *name,
const char *value);
static gboolean update_screen_binding (const char *name,
const char *value);
static void init_bindings (void);
static gboolean update_binding (MetaKeyPref *binding,
const char *value);
static gboolean update_command (const char *name,
const char *value);
static void init_commands (void);
static gboolean update_workspace_name (const char *name,
const char *value);
static void init_workspace_names (void);
static void queue_changed (MetaPreference pref);
static void change_notify (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
@ -122,6 +123,14 @@ static void change_notify (GConfClient *client,
static char* gconf_key_for_workspace_name (int i);
static void queue_changed (MetaPreference pref);
#endif /* HAVE_GCONF */
static void init_bindings (void);
static void init_commands (void);
static void init_workspace_names (void);
typedef struct
{
MetaPrefsChangedFunc func;
@ -167,6 +176,7 @@ meta_prefs_remove_listener (MetaPrefsChangedFunc func,
meta_bug ("Did not find listener to remove\n");
}
#ifdef HAVE_GCONF
static void
emit_changed (MetaPreference pref)
{
@ -190,7 +200,9 @@ emit_changed (MetaPreference pref)
g_list_free (copy);
}
#endif /* HAVE_GCONF */
#ifdef HAVE_GCONF
static gboolean
changed_idle_handler (gpointer data)
{
@ -218,7 +230,9 @@ changed_idle_handler (gpointer data)
return FALSE;
}
#endif /* HAVE_GCONF */
#ifdef HAVE_GCONF
static void
queue_changed (MetaPreference pref)
{
@ -236,7 +250,9 @@ queue_changed (MetaPreference pref)
changed_idle = g_idle_add_full (META_PRIORITY_PREFS_NOTIFY,
changed_idle_handler, NULL, NULL);
}
#endif /* HAVE_GCONF */
#ifdef HAVE_GCONF
static void
cleanup_error (GError **error)
{
@ -248,10 +264,12 @@ cleanup_error (GError **error)
*error = NULL;
}
}
#endif /* HAVE_GCONF */
void
meta_prefs_init (void)
{
#ifdef HAVE_GCONF
GError *err = NULL;
char *str_val;
int int_val;
@ -340,6 +358,7 @@ meta_prefs_init (void)
cleanup_error (&err);
update_button_layout (str_val);
g_free (str_val);
#endif /* HAVE_GCONF */
/* Load keybindings prefs */
init_bindings ();
@ -349,15 +368,18 @@ meta_prefs_init (void)
/* workspace names */
init_workspace_names ();
#ifdef HAVE_GCONF
gconf_client_notify_add (default_client, "/apps/metacity",
change_notify,
NULL,
NULL,
&err);
cleanup_error (&err);
cleanup_error (&err);
#endif /* HAVE_GCONF */
}
#ifdef HAVE_GCONF
/* from eel */
static gboolean
str_has_prefix (const char *haystack, const char *needle)
@ -662,7 +684,9 @@ change_notify (GConfClient *client,
/* nothing */
return; /* AIX compiler wants something after a label like out: */
}
#endif /* HAVE_GCONF */
#ifdef HAVE_GCONF
static gboolean
update_mouse_button_mods (const char *value)
{
@ -692,7 +716,9 @@ update_mouse_button_mods (const char *value)
return old_mods != mouse_button_mods;
}
#endif /* HAVE_GCONF */
#ifdef HAVE_GCONF
static gboolean
update_focus_mode (const char *value)
{
@ -713,7 +739,9 @@ update_focus_mode (const char *value)
return (old_mode != focus_mode);
}
#endif /* HAVE_GCONF */
#ifdef HAVE_GCONF
static gboolean
update_theme (const char *value)
{
@ -745,7 +773,7 @@ update_theme (const char *value)
return changed;
}
#endif /* HAVE_GCONF */
MetaVirtualModifier
meta_prefs_get_mouse_button_mods (void)
@ -765,6 +793,7 @@ meta_prefs_get_theme (void)
return current_theme;
}
#ifdef HAVE_GCONF
static gboolean
update_use_system_font (gboolean value)
{
@ -774,7 +803,9 @@ update_use_system_font (gboolean value)
return old != value;
}
#endif /* HAVE_GCONF */
#ifdef HAVE_GCONF
static gboolean
update_titlebar_font (const char *value)
{
@ -806,7 +837,9 @@ update_titlebar_font (const char *value)
return TRUE;
}
}
#endif /* HAVE_GCONF */
#ifdef HAVE_GCONF
static gboolean
button_layout_equal (const MetaButtonLayout *a,
const MetaButtonLayout *b)
@ -950,6 +983,7 @@ update_button_layout (const char *value)
return changed;
}
#endif /* HAVE_GCONF */
const PangoFontDescription*
meta_prefs_get_titlebar_font (void)
@ -960,6 +994,7 @@ meta_prefs_get_titlebar_font (void)
return titlebar_font;
}
#ifdef HAVE_GCONF
static gboolean
update_num_workspaces (int value)
{
@ -979,6 +1014,7 @@ update_num_workspaces (int value)
return old != num_workspaces;
}
#endif /* HAVE_GCONF */
int
meta_prefs_get_num_workspaces (void)
@ -986,6 +1022,7 @@ meta_prefs_get_num_workspaces (void)
return num_workspaces;
}
#ifdef HAVE_GCONF
static gboolean
update_application_based (gboolean value)
{
@ -995,13 +1032,17 @@ update_application_based (gboolean value)
return old != application_based;
}
#endif /* HAVE_GCONF */
gboolean
meta_prefs_get_application_based (void)
{
return FALSE; /* For now, we never want this to do anything */
return application_based;
}
#ifdef HAVE_GCONF
static gboolean
update_disable_workarounds (gboolean value)
{
@ -1022,6 +1063,7 @@ update_disable_workarounds (gboolean value)
return old != disable_workarounds;
}
#endif /* HAVE_GCONF */
gboolean
meta_prefs_get_disable_workarounds (void)
@ -1029,6 +1071,7 @@ meta_prefs_get_disable_workarounds (void)
return disable_workarounds;
}
#ifdef HAVE_GCONF
static MetaActionDoubleClickTitlebar
action_double_click_titlebar_from_string (const char *str)
{
@ -1089,7 +1132,9 @@ update_auto_raise_delay (int value)
return old != auto_raise_delay;
}
#endif /* HAVE_GCONF */
#ifdef WITH_VERBOSE_MODE
const char*
meta_preference_to_string (MetaPreference pref)
{
@ -1145,10 +1190,12 @@ meta_preference_to_string (MetaPreference pref)
return "(unknown)";
}
#endif /* WITH_VERBOSE_MODE */
void
meta_prefs_set_num_workspaces (int n_workspaces)
{
#ifdef HAVE_GCONF
GError *err;
if (default_client == NULL)
@ -1172,6 +1219,7 @@ meta_prefs_set_num_workspaces (int n_workspaces)
err->message);
g_error_free (err);
}
#endif /* HAVE_GCONF */
}
/* Indexes must correspond to MetaKeybindingAction */
@ -1253,6 +1301,7 @@ static MetaKeyPref window_bindings[] = {
static void
init_bindings (void)
{
#ifdef HAVE_GCONF
int i;
GError *err;
@ -1297,11 +1346,13 @@ init_bindings (void)
++i;
}
#endif /* HAVE_GCONF */
}
static void
init_commands (void)
{
#ifdef HAVE_GCONF
int i;
GError *err;
@ -1324,11 +1375,13 @@ init_commands (void)
++i;
}
#endif /* HAVE_GCONF */
}
static void
init_workspace_names (void)
{
#ifdef HAVE_GCONF
int i;
GError *err;
@ -1353,8 +1406,10 @@ init_workspace_names (void)
++i;
}
#endif /* HAVE_GCONF */
}
#ifdef HAVE_GCONF
static gboolean
update_binding (MetaKeyPref *binding,
const char *value)
@ -1506,6 +1561,7 @@ update_command (const char *name,
return TRUE;
}
#endif /* HAVE_GCONF */
const char*
meta_prefs_get_command (int i)
@ -1525,6 +1581,7 @@ meta_prefs_get_gconf_key_for_command (int i)
return key;
}
#ifdef HAVE_GCONF
static gboolean
update_workspace_name (const char *name,
const char *value)
@ -1601,6 +1658,7 @@ update_workspace_name (const char *name,
return TRUE;
}
#endif /* HAVE_GCONF */
const char*
meta_prefs_get_workspace_name (int i)
@ -1620,6 +1678,7 @@ void
meta_prefs_change_workspace_name (int i,
const char *name)
{
#ifdef HAVE_GCONF
char *key;
GError *err;
@ -1663,8 +1722,10 @@ meta_prefs_change_workspace_name (int i,
}
g_free (key);
#endif /* HAVE_GCONF */
}
#ifdef HAVE_GCONF
static char*
gconf_key_for_workspace_name (int i)
{
@ -1674,6 +1735,7 @@ gconf_key_for_workspace_name (int i)
return key;
}
#endif /* HAVE_GCONF */
void
meta_prefs_get_button_layout (MetaButtonLayout *button_layout_p)

View File

@ -19,11 +19,17 @@
* 02111-1307, USA.
*/
#include <config.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <stdlib.h>
#include <string.h>
#include <libintl.h>
#define _(x) dgettext (GETTEXT_PACKAGE, x)
#define N_(x) x
static void
send_restart (void)
{
@ -108,10 +114,41 @@ send_set_keybindings (gboolean enabled)
XSync (gdk_display, False);
}
#ifdef WITH_VERBOSE_MODE
static void
send_toggle_verbose (void)
{
XEvent xev;
xev.xclient.type = ClientMessage;
xev.xclient.serial = 0;
xev.xclient.send_event = True;
xev.xclient.display = gdk_display;
xev.xclient.window = gdk_x11_get_default_root_xwindow ();
xev.xclient.message_type = XInternAtom (gdk_display,
"_METACITY_TOGGLE_VERBOSE",
False);
xev.xclient.format = 32;
xev.xclient.data.l[0] = 0;
xev.xclient.data.l[1] = 0;
xev.xclient.data.l[2] = 0;
XSendEvent (gdk_display,
gdk_x11_get_default_root_xwindow (),
False,
SubstructureRedirectMask | SubstructureNotifyMask,
&xev);
XFlush (gdk_display);
XSync (gdk_display, False);
}
#endif
static void
usage (void)
{
g_printerr ("Usage: metacity-message (restart|reload-theme|enable-keybindings|disable-keybindings)\n");
g_printerr (_("Usage: %s\n"),
"metacity-message (restart|reload-theme|enable-keybindings|disable-keybindings|toggle-verbose)");
exit (1);
}
@ -131,6 +168,15 @@ main (int argc, char **argv)
send_set_keybindings (TRUE);
else if (strcmp (argv[1], "disable-keybindings") == 0)
send_set_keybindings (FALSE);
else if (strcmp (argv[1], "toggle-verbose") == 0)
{
#ifndef WITH_VERBOSE_MODE
g_printerr (_("Metacity was compiled without support for verbose mode\n"));
return 1;
#else
send_toggle_verbose ();
#endif
}
else
usage ();

View File

@ -104,7 +104,7 @@ ensure_logfile (void)
}
else
{
g_print (_("Opened log file %s\n"), filename);
g_printerr (_("Opened log file %s\n"), filename);
}
g_free (filename);
@ -120,6 +120,11 @@ meta_is_verbose (void)
void
meta_set_verbose (gboolean setting)
{
#ifndef WITH_VERBOSE_MODE
if (setting)
meta_fatal (_("Metacity was compiled without support for verbose mode\n"));
#endif
if (setting)
ensure_logfile ();
@ -172,8 +177,9 @@ utf8_fputs (const char *str,
return retval;
}
#ifdef WITH_VERBOSE_MODE
void
meta_debug_spew (const char *format, ...)
meta_debug_spew_real (const char *format, ...)
{
va_list args;
gchar *str;
@ -198,9 +204,11 @@ meta_debug_spew (const char *format, ...)
g_free (str);
}
#endif /* WITH_VERBOSE_MODE */
#ifdef WITH_VERBOSE_MODE
void
meta_verbose (const char *format, ...)
meta_verbose_real (const char *format, ...)
{
va_list args;
gchar *str;
@ -225,7 +233,9 @@ meta_verbose (const char *format, ...)
g_free (str);
}
#endif /* WITH_VERBOSE_MODE */
#ifdef WITH_VERBOSE_MODE
static const char*
topic_name (MetaDebugTopic topic)
{
@ -275,9 +285,9 @@ topic_name (MetaDebugTopic topic)
static int sync_count = 0;
void
meta_topic (MetaDebugTopic topic,
const char *format,
...)
meta_topic_real (MetaDebugTopic topic,
const char *format,
...)
{
va_list args;
gchar *str;
@ -309,6 +319,7 @@ meta_topic (MetaDebugTopic topic,
g_free (str);
}
#endif /* WITH_VERBOSE_MODE */
void
meta_bug (const char *format, ...)

View File

@ -33,10 +33,11 @@ void meta_set_syncing (gboolean setting);
gboolean meta_get_replace_current_wm (void);
void meta_set_replace_current_wm (gboolean setting);
void meta_debug_spew (const char *format,
...) G_GNUC_PRINTF (1, 2);
void meta_verbose (const char *format,
...) G_GNUC_PRINTF (1, 2);
void meta_debug_spew_real (const char *format,
...) G_GNUC_PRINTF (1, 2);
void meta_verbose_real (const char *format,
...) G_GNUC_PRINTF (1, 2);
void meta_bug (const char *format,
...) G_GNUC_PRINTF (1, 2);
void meta_warning (const char *format,
@ -67,9 +68,9 @@ typedef enum
} MetaDebugTopic;
void meta_topic (MetaDebugTopic topic,
const char *format,
...) G_GNUC_PRINTF (2, 3);
void meta_topic_real (MetaDebugTopic topic,
const char *format,
...) G_GNUC_PRINTF (2, 3);
void meta_push_no_msg_prefix (void);
void meta_pop_no_msg_prefix (void);
@ -84,6 +85,30 @@ void meta_print_backtrace (void);
#define _(x) dgettext (GETTEXT_PACKAGE, x)
#define N_(x) x
#endif
/* To disable verbose mode, we make these functions into no-ops */
#ifdef WITH_VERBOSE_MODE
#define meta_debug_spew meta_debug_spew_real
#define meta_verbose meta_verbose_real
#define meta_topic meta_topic_real
#else
# ifdef G_HAVE_ISO_VARARGS
# define meta_debug_spew(...)
# define meta_verbose(...)
# define meta_topic(...)
# elif defined(G_HAVE_GNUC_VARARGS)
# define meta_debug_spew(format...)
# define meta_verbose(format...)
# define meta_topic(format...)
# else
# error "This compiler does not support varargs macros and thus verbose mode can't be disabled meaningfully"
# endif
#endif /* !WITH_VERBOSE_MODE */
#endif /* META_UTIL_H */

View File

@ -131,6 +131,7 @@ void meta_window_flush_move_resize (MetaWindow *window);
static void meta_window_apply_session_info (MetaWindow *window,
const MetaWindowSessionInfo *info);
#ifdef WITH_VERBOSE_MODE
static const char*
wm_state_to_string (int state)
{
@ -146,6 +147,7 @@ wm_state_to_string (int state)
return "Unknown";
}
#endif
MetaWindow*
meta_window_new (MetaDisplay *display,

View File

@ -415,6 +415,7 @@ meta_workspace_get_work_area (MetaWorkspace *workspace,
*area = workspace->work_area;
}
#ifdef WITH_VERBOSE_MODE
static char *
meta_motion_direction_to_string (MetaMotionDirection direction)
{
@ -432,7 +433,9 @@ meta_motion_direction_to_string (MetaMotionDirection direction)
return "Unknown";
}
#endif /* WITH_VERBOSE_MODE */
#ifdef WITH_VERBOSE_MODE
static char *
meta_screen_corner_to_string (MetaScreenCorner corner)
{
@ -450,6 +453,7 @@ meta_screen_corner_to_string (MetaScreenCorner corner)
return "Unknown";
}
#endif /* WITH_VERBOSE_MODE */
MetaWorkspace*
meta_workspace_get_neighbor (MetaWorkspace *workspace,