summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBill Haneman <billh@src.gnome.org>2003-01-28 15:07:43 +0000
committerBill Haneman <billh@src.gnome.org>2003-01-28 15:07:43 +0000
commitb4243647105667b0d346f991c647d8e57bfed033 (patch)
tree82255a87796fb3a2ea3020bede91ca62b0da5fb5 /src
parent4fb05e54ab1616d5842dba31ff1d9832cce704be (diff)
downloadmetacity-b4243647105667b0d346f991c647d8e57bfed033.tar.gz
metacity-b4243647105667b0d346f991c647d8e57bfed033.tar.bz2
Reinstated visual-bell patch, fix for bug 99886.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/common.h3
-rw-r--r--src/display.c24
-rw-r--r--src/display.h3
-rw-r--r--src/frame.c6
-rw-r--r--src/frame.h1
-rw-r--r--src/metacity.schemas.in51
-rw-r--r--src/prefs.c131
-rw-r--r--src/prefs.h17
-rw-r--r--src/screen.c1
-rw-r--r--src/screen.h2
-rw-r--r--src/theme.c6
12 files changed, 241 insertions, 6 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 3571b85..6b10875 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,6 +11,8 @@ EGGFILES= \
metacity_SOURCES= \
async-getprop.c \
async-getprop.h \
+ bell.h \
+ bell.c \
common.h \
core.c \
core.h \
diff --git a/src/common.h b/src/common.h
index f88dce5..440b56c 100644
--- a/src/common.h
+++ b/src/common.h
@@ -42,7 +42,8 @@ typedef enum
META_FRAME_MAXIMIZED = 1 << 9,
META_FRAME_ALLOWS_SHADE = 1 << 10,
META_FRAME_ALLOWS_MOVE = 1 << 11,
- META_FRAME_FULLSCREEN = 1 << 12
+ META_FRAME_FULLSCREEN = 1 << 12,
+ META_FRAME_IS_FLASHING = 1 << 13
} MetaFrameFlags;
typedef enum
diff --git a/src/display.c b/src/display.c
index a19e9e4..36971cc 100644
--- a/src/display.c
+++ b/src/display.c
@@ -34,6 +34,7 @@
#include "prefs.h"
#include "resizepopup.h"
#include "workspace.h"
+#include "bell.h"
#include <X11/Xatom.h>
#include <X11/cursorfont.h>
#ifdef HAVE_SOLARIS_XINERAMA
@@ -48,6 +49,9 @@
#ifdef HAVE_SHAPE
#include <X11/extensions/shape.h>
#endif
+#ifdef HAVE_XKB
+#include <X11/XKBlib.h>
+#endif
#include <string.h>
#define USE_GDK_DISPLAY
@@ -311,6 +315,8 @@ meta_display_open (const char *name)
/* we have to go ahead and do this so error handlers work */
all_displays = g_slist_prepend (all_displays, display);
+ meta_bell_init (display);
+
meta_display_init_keys (display);
update_window_grab_modifiers (display);
@@ -1908,6 +1914,19 @@ event_callback (XEvent *event,
}
break;
default:
+#ifdef HAVE_XKB
+ if (event->type == display->xkb_base_event_type)
+ {
+ XkbAnyEvent *xkb_ev = (XkbAnyEvent *) event;
+
+ switch (xkb_ev->xkb_type)
+ {
+ case XkbBellNotify:
+ meta_bell_notify (display, xkb_ev);
+ break;
+ }
+ }
+#endif
break;
}
@@ -3965,4 +3984,9 @@ prefs_changed_callback (MetaPreference pref,
g_slist_free (windows);
}
+ else if (pref == META_PREF_AUDIBLE_BELL)
+ {
+ MetaDisplay *display = data;
+ meta_bell_set_audible (display, meta_prefs_bell_is_audible ());
+ }
}
diff --git a/src/display.h b/src/display.h
index 8bcf50d..c5dae68 100644
--- a/src/display.h
+++ b/src/display.h
@@ -246,6 +246,9 @@ struct _MetaDisplay
MetaResizePopup *grab_resize_popup;
GTimeVal grab_last_moveresize_time;
Time grab_motion_notify_time;
+#ifdef HAVE_XKB
+ int xkb_base_event_type;
+#endif
#ifdef HAVE_XSYNC
/* alarm monitoring client's _METACITY_UPDATE_COUNTER */
XSyncAlarm grab_update_alarm;
diff --git a/src/frame.c b/src/frame.c
index 10ae0a5..4d22cac 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -21,6 +21,7 @@
#include <config.h>
#include "frame.h"
+#include "bell.h"
#include "errors.h"
#include "keybindings.h"
@@ -59,6 +60,7 @@ meta_window_ensure_frame (MetaWindow *window)
frame->mapped = FALSE;
frame->need_reapply_frame_shape = TRUE;
+ frame->is_flashing = FALSE;
attrs.event_mask = EVENT_MASK;
@@ -162,6 +164,7 @@ meta_window_destroy_frame (MetaWindow *window)
frame = window->frame;
+ meta_bell_notify_frame_destroy (frame);
meta_ui_remove_frame (window->screen->ui, frame->xwindow);
/* Unparent the client window; it may be destroyed,
@@ -258,6 +261,9 @@ meta_frame_get_flags (MetaFrame *frame)
if (frame->window->fullscreen)
flags |= META_FRAME_FULLSCREEN;
+ if (frame->is_flashing)
+ flags |= META_FRAME_IS_FLASHING;
+
return flags;
}
diff --git a/src/frame.h b/src/frame.h
index afa1955..02de0ab 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -58,6 +58,7 @@ struct _MetaFrame
guint mapped : 1;
guint need_reapply_frame_shape : 1;
+ guint is_flashing : 1; /* used by the visual bell flash */
};
void meta_window_ensure_frame (MetaWindow *window);
diff --git a/src/metacity.schemas.in b/src/metacity.schemas.in
index f37b20e..0c0bb03 100644
--- a/src/metacity.schemas.in
+++ b/src/metacity.schemas.in
@@ -178,6 +178,57 @@
</schema>
<schema>
+ <key>/apps/metacity/visual_bell</key>
+ <applyto>/apps/metacity/general/visual_bell</applyto>
+ <owner>metacity</owner>
+ <type>bool</type>
+ <default>false</default>
+ <locale name="C">
+ <short>Enable Visual Bell</short>
+ <long>Turns on a visual indication when an application or the system
+ issues a 'bell' or 'beep'; useful for the hard-of-hearing and for use
+ in noisy environments, or when 'audible bell' is off.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/metacity/general/audible_bell</key>
+ <applyto>/apps/metacity/general/audible_bell</applyto>
+ <owner>metacity</owner>
+ <type>bool</type>
+ <default>true</default>
+ <locale name="C">
+ <short>System Bell is Audible</short>
+ <long>Determines whether applications or the system can generate audible
+ 'beeps'; may be used in conjunction with 'visual bell' to
+ allow silent 'beeps'.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
+ <key>/schemas/apps/metacity/general/visual_bell_type</key>
+ <applyto>/apps/metacity/general/visual_bell_type</applyto>
+ <owner>metacity</owner>
+ <type>string</type>
+ <default>fullscreen</default>
+ <locale name="C">
+ <short>Visual Bell Type</short>
+ <long>
+ Tells Metacity how to implement the visual indication that
+ the system bell or another application 'bell' indicator has
+ been rung. Currently there are two valid values, "fullscreen",
+ which causes a fullscreen white-black flash, and "frame_flash" which
+ causes the titlebar of the application which sent the bell signal to
+ flash. If the application which sent the bell is unknown (as is
+ usually the case for the default "system beep"), the currently
+ focused window's titlebar is flashed.
+ </long>
+ </locale>
+ </schema>
+
+ <schema>
<key>/schemas/apps/metacity/workspace_names/name</key>
<applyto>/apps/metacity/workspace_names/name_1</applyto>
<applyto>/apps/metacity/workspace_names/name_2</applyto>
diff --git a/src/prefs.c b/src/prefs.c
index fede2e9..512a555 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -54,6 +54,10 @@
#define KEY_WORKSPACE_NAME_PREFIX "/apps/metacity/workspace_names/name_"
+#define KEY_VISUAL_BELL "/apps/metacity/general/visual_bell"
+#define KEY_AUDIBLE_BELL "/apps/metacity/general/audible_bell"
+#define KEY_VISUAL_BELL_TYPE "/apps/metacity/general/visual_bell_type"
+
#ifdef HAVE_GCONF
static GConfClient *default_client = NULL;
static GList *changes = NULL;
@@ -73,6 +77,9 @@ static gboolean application_based = FALSE;
static gboolean disable_workarounds = FALSE;
static gboolean auto_raise = FALSE;
static gboolean auto_raise_delay = 500;
+static gboolean provide_visual_bell = TRUE;
+static gboolean bell_is_audible = TRUE;
+static MetaVisualBellType visual_bell_type = META_VISUAL_BELL_INVALID;
static MetaButtonLayout button_layout = {
{
META_BUTTON_FUNCTION_MENU,
@@ -98,6 +105,8 @@ static gboolean update_titlebar_font (const char *value);
static gboolean update_mouse_button_mods (const char *value);
static gboolean update_focus_mode (const char *value);
static gboolean update_theme (const char *value);
+static gboolean update_visual_bell (gboolean v1, gboolean v2);
+static gboolean update_visual_bell_type (const char *value);
static gboolean update_num_workspaces (int value);
static gboolean update_application_based (gboolean value);
static gboolean update_disable_workarounds (gboolean value);
@@ -273,7 +282,7 @@ meta_prefs_init (void)
GError *err = NULL;
char *str_val;
int int_val;
- gboolean bool_val;
+ gboolean bool_val, bool_val_2;
if (default_client != NULL)
return;
@@ -360,6 +369,20 @@ meta_prefs_init (void)
g_free (str_val);
#endif /* HAVE_GCONF */
+ bool_val = gconf_client_get_bool (default_client, KEY_VISUAL_BELL,
+ &err);
+ cleanup_error (&err);
+ bool_val_2 = gconf_client_get_bool (default_client, KEY_AUDIBLE_BELL,
+ &err);
+ cleanup_error (&err);
+ update_visual_bell (bool_val, bool_val_2);
+
+ str_val = gconf_client_get_string (default_client, KEY_VISUAL_BELL_TYPE,
+ &err);
+ cleanup_error (&err);
+ update_visual_bell_type (str_val);
+ g_free (str_val);
+
/* Load keybindings prefs */
init_bindings ();
@@ -375,7 +398,7 @@ meta_prefs_init (void)
NULL,
NULL,
&err);
- cleanup_error (&err);
+ cleanup_error (&err);
#endif /* HAVE_GCONF */
}
@@ -674,6 +697,37 @@ change_notify (GConfClient *client,
if (update_button_layout (str))
queue_changed (META_PREF_BUTTON_LAYOUT);
}
+ else if (strcmp (key, KEY_VISUAL_BELL) == 0)
+ {
+ gboolean b;
+
+ b = value ? gconf_value_get_bool (value) : provide_visual_bell;
+ if (update_visual_bell (b, bell_is_audible))
+ queue_changed (META_PREF_VISUAL_BELL);
+ }
+ else if (strcmp (key, KEY_AUDIBLE_BELL) == 0)
+ {
+ gboolean b;
+
+ b = value ? gconf_value_get_bool (value) : bell_is_audible;
+ if (update_visual_bell (provide_visual_bell, b))
+ queue_changed (META_PREF_AUDIBLE_BELL);
+ }
+ else if (strcmp (key, KEY_VISUAL_BELL_TYPE) == 0)
+ {
+ const char * str;
+
+ if (value && value->type != GCONF_VALUE_STRING)
+ {
+ meta_warning (_("GConf key \"%s\" is set to an invalid type\n"),
+ KEY_VISUAL_BELL_TYPE);
+ goto out;
+ }
+
+ str = value ? gconf_value_get_string (value) : NULL;
+ if (update_visual_bell_type (str))
+ queue_changed (META_PREF_VISUAL_BELL_TYPE);
+ }
else
{
meta_topic (META_DEBUG_PREFS, "Key %s doesn't mean anything to Metacity\n",
@@ -803,8 +857,51 @@ update_use_system_font (gboolean value)
return old != value;
}
+
+static MetaVisualBellType
+visual_bell_type_from_string (const char *value)
+{
+ if (value)
+ {
+ if (!strcmp (value, "fullscreen"))
+ {
+ return META_VISUAL_BELL_FULLSCREEN_FLASH;
+ }
+ else if (!strcmp (value, "frame_flash"))
+ {
+ return META_VISUAL_BELL_FRAME_FLASH;
+ }
+ }
+ return META_VISUAL_BELL_FULLSCREEN_FLASH;
+}
+
+static gboolean
+update_visual_bell_type (const char *value)
+{
+ MetaVisualBellType old_bell_type;
+
+ old_bell_type = visual_bell_type;
+ visual_bell_type = visual_bell_type_from_string (value);
+
+ return (visual_bell_type != old_bell_type);
+}
#endif /* HAVE_GCONF */
+static gboolean
+update_visual_bell (gboolean visual_bell, gboolean audible_bell)
+{
+ gboolean old_visual = provide_visual_bell;
+ gboolean old_audible = bell_is_audible;
+ gboolean has_changed;
+
+ provide_visual_bell = visual_bell;
+ bell_is_audible = audible_bell;
+ has_changed = (old_visual != provide_visual_bell) ||
+ (old_audible != bell_is_audible);
+
+ return has_changed;
+}
+
#ifdef HAVE_GCONF
static gboolean
update_titlebar_font (const char *value)
@@ -1191,6 +1288,18 @@ meta_preference_to_string (MetaPreference pref)
case META_PREF_WORKSPACE_NAMES:
return "WORKSPACE_NAMES";
break;
+
+ case META_PREF_VISUAL_BELL:
+ return "VISUAL_BELL";
+ break;
+
+ case META_PREF_AUDIBLE_BELL:
+ return "AUDIBLE_BELL";
+ break;
+
+ case META_PREF_VISUAL_BELL_TYPE:
+ return "VISUAL_BELL_TYPE";
+ break;
}
return "(unknown)";
@@ -1775,6 +1884,24 @@ meta_prefs_get_button_layout (MetaButtonLayout *button_layout_p)
*button_layout_p = button_layout;
}
+gboolean
+meta_prefs_get_visual_bell ()
+{
+ return provide_visual_bell;
+}
+
+gboolean
+meta_prefs_bell_is_audible ()
+{
+ return bell_is_audible;
+}
+
+MetaVisualBellType
+meta_prefs_get_visual_bell_type ()
+{
+ return visual_bell_type;
+}
+
void
meta_prefs_get_screen_bindings (const MetaKeyPref **bindings,
int *n_bindings)
diff --git a/src/prefs.h b/src/prefs.h
index a7bef31..45e9d7f 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -42,7 +42,10 @@ typedef enum
META_PREF_DISABLE_WORKAROUNDS,
META_PREF_COMMANDS,
META_PREF_BUTTON_LAYOUT,
- META_PREF_WORKSPACE_NAMES
+ META_PREF_WORKSPACE_NAMES,
+ META_PREF_VISUAL_BELL,
+ META_PREF_AUDIBLE_BELL,
+ META_PREF_VISUAL_BELL_TYPE
} MetaPreference;
typedef void (* MetaPrefsChangedFunc) (MetaPreference pref,
@@ -233,6 +236,18 @@ void meta_prefs_get_window_binding (const char *name,
unsigned int *keysym,
MetaVirtualModifier *modifiers);
+typedef enum
+{
+ META_VISUAL_BELL_INVALID = 0,
+ META_VISUAL_BELL_FULLSCREEN_FLASH,
+ META_VISUAL_BELL_FRAME_FLASH
+
+} MetaVisualBellType;
+
+gboolean meta_prefs_get_visual_bell (void);
+gboolean meta_prefs_bell_is_audible (void);
+MetaVisualBellType meta_prefs_get_visual_bell_type (void);
+
#endif
diff --git a/src/screen.c b/src/screen.c
index 2f65aa9..70549ce 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -523,6 +523,7 @@ meta_screen_new (MetaDisplay *display,
screen->current_cursor = -1; /* invalid/unset */
screen->default_xvisual = DefaultVisualOfScreen (screen->xscreen);
screen->default_depth = DefaultDepthOfScreen (screen->xscreen);
+ screen->flash_window = None;
screen->wm_sn_selection_window = new_wm_sn_owner;
screen->wm_sn_atom = wm_sn_atom;
diff --git a/src/screen.h b/src/screen.h
index 16e9070..dd47da9 100644
--- a/src/screen.h
+++ b/src/screen.h
@@ -70,6 +70,8 @@ struct _MetaScreen
MetaCursor current_cursor;
+ Window flash_window;
+
Window wm_sn_selection_window;
Atom wm_sn_atom;
Time wm_sn_timestamp;
diff --git a/src/theme.c b/src/theme.c
index f1b6f41..b07d7cd 100644
--- a/src/theme.c
+++ b/src/theme.c
@@ -4760,8 +4760,10 @@ theme_get_style (MetaTheme *theme,
resize = META_FRAME_RESIZE_LAST; /* compiler */
break;
}
-
- if (flags & META_FRAME_HAS_FOCUS)
+
+ /* re invert the styles used for focus/unfocussed while flashing a frame */
+ if (((flags & META_FRAME_HAS_FOCUS) && !(flags & META_FRAME_IS_FLASHING))
+ || (!(flags & META_FRAME_HAS_FOCUS) && (flags & META_FRAME_IS_FLASHING)))
focus = META_FRAME_FOCUS_YES;
else
focus = META_FRAME_FOCUS_NO;