2006-10-01 18:30:10 -04:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
Comprehensively rename to Mutter
Code:
All references in the code not related to themes, keybindings, or
GConf were changed from 'metacity' to 'mutter'. This includes, among other
things, strings, comments, the atoms used in the message protocol, and
the envvars used for debugging. The GConf schema file was reduced to
the 3 settings new to mutter.
The overall version was brought up to 2.27 to match current gnome.
Structure:
All files named '*metacity*' were renamed '*mutter*' with appropriate
changes in the automake system. Files removed are
doc/creating_themes, src/themes, doc/metacity-theme.dtd,
metacity.doap. These files will eventually end up in an external
gnome-wm-data module.
Installation location:
On the filesystem the mutter-plugindir was change from
$(libdir)/metacity/plugins/clutter to just $(libdir)/mutter/plugins.
The mutter-plugins.pc.in reflects these changes.
Note:
mutter.desktop.in and mutter-wm.desktop both continue to have
X-GNOME-WMSettingsModule=metacity set. This allows
gnome-control-center to continue using libmetacity.so for
configuration. This is fine since most the general keybindings and wm
settings are being read from /apps/metacity/* in gconf.
2009-06-10 06:29:20 -04:00
|
|
|
/* Mutter visual bell */
|
2002-12-16 20:08:29 -05:00
|
|
|
|
2014-05-02 09:34:02 -04:00
|
|
|
/*
|
2002-12-16 20:08:29 -05:00
|
|
|
* Copyright (C) 2002 Sun Microsystems Inc.
|
2006-01-10 14:43:21 -05:00
|
|
|
* Copyright (C) 2005, 2006 Elijah Newren
|
2014-05-02 09:34:02 -04:00
|
|
|
*
|
2002-12-16 20:08:29 -05:00
|
|
|
* 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 of the
|
|
|
|
* License, 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.
|
2014-05-02 09:34:02 -04:00
|
|
|
*
|
2002-12-16 20:08:29 -05:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2014-01-11 20:42:06 -05:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2002-12-16 20:08:29 -05:00
|
|
|
*/
|
|
|
|
|
2013-02-15 13:42:08 -05:00
|
|
|
/*
|
2023-03-28 10:35:11 -04:00
|
|
|
* bell:
|
2023-05-23 14:25:54 -04:00
|
|
|
*
|
2023-03-28 10:35:11 -04:00
|
|
|
* Ring the bell or flash the screen
|
2008-01-13 11:32:56 -05:00
|
|
|
*
|
Comprehensively rename to Mutter
Code:
All references in the code not related to themes, keybindings, or
GConf were changed from 'metacity' to 'mutter'. This includes, among other
things, strings, comments, the atoms used in the message protocol, and
the envvars used for debugging. The GConf schema file was reduced to
the 3 settings new to mutter.
The overall version was brought up to 2.27 to match current gnome.
Structure:
All files named '*metacity*' were renamed '*mutter*' with appropriate
changes in the automake system. Files removed are
doc/creating_themes, src/themes, doc/metacity-theme.dtd,
metacity.doap. These files will eventually end up in an external
gnome-wm-data module.
Installation location:
On the filesystem the mutter-plugindir was change from
$(libdir)/metacity/plugins/clutter to just $(libdir)/mutter/plugins.
The mutter-plugins.pc.in reflects these changes.
Note:
mutter.desktop.in and mutter-wm.desktop both continue to have
X-GNOME-WMSettingsModule=metacity set. This allows
gnome-control-center to continue using libmetacity.so for
configuration. This is fine since most the general keybindings and wm
settings are being read from /apps/metacity/* in gconf.
2009-06-10 06:29:20 -04:00
|
|
|
* Sometimes, X programs "ring the bell", whatever that means. Mutter lets
|
2008-01-13 11:32:56 -05:00
|
|
|
* the user configure the bell to be audible or visible (aka visual), and
|
|
|
|
* if it's visual it can be configured to be frame-flash or fullscreen-flash.
|
|
|
|
* We never get told about audible bells; X handles them just fine by itself.
|
|
|
|
*
|
|
|
|
* Visual bells come in at meta_bell_notify(), which checks we are actually
|
2008-06-29 14:46:01 -04:00
|
|
|
* in visual mode and calls through to bell_visual_notify(). That
|
2008-01-13 11:32:56 -05:00
|
|
|
* function then checks what kind of visual flash you like, and calls either
|
2008-06-29 14:46:01 -04:00
|
|
|
* bell_flash_fullscreen()-- which calls bell_flash_screen() to do
|
2020-08-26 05:49:50 -04:00
|
|
|
* its work-- or bell_flash_frame(), which flashes the focused window
|
2019-03-06 17:51:41 -05:00
|
|
|
* using bell_flash_window(), unless there is no such window, in
|
|
|
|
* which case it flashes the screen instead.
|
2008-01-13 11:32:56 -05:00
|
|
|
*
|
|
|
|
* The visual bell was the result of a discussion in Bugzilla here:
|
|
|
|
* <http://bugzilla.gnome.org/show_bug.cgi?id=99886>.
|
|
|
|
*
|
|
|
|
* Several of the functions in this file are ifdeffed out entirely if we are
|
|
|
|
* found not to have the XKB extension, which is required to do these clever
|
|
|
|
* things with bells; some others are entirely no-ops in that case.
|
|
|
|
*/
|
|
|
|
|
2018-07-10 04:36:24 -04:00
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "core/bell.h"
|
|
|
|
|
|
|
|
#include "compositor/compositor-private.h"
|
|
|
|
#include "core/util-private.h"
|
|
|
|
#include "core/window-private.h"
|
|
|
|
#include "meta/compositor.h"
|
|
|
|
|
2017-08-26 16:35:18 -04:00
|
|
|
G_DEFINE_TYPE (MetaBell, meta_bell, G_TYPE_OBJECT)
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
IS_AUDIBLE_CHANGED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint bell_signals [LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
|
|
static void
|
|
|
|
prefs_changed_callback (MetaPreference pref,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
MetaBell *bell = data;
|
|
|
|
|
|
|
|
if (pref == META_PREF_AUDIBLE_BELL)
|
|
|
|
{
|
|
|
|
g_signal_emit (bell, bell_signals[IS_AUDIBLE_CHANGED], 0,
|
|
|
|
meta_prefs_bell_is_audible ());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_bell_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
MetaBell *bell = META_BELL (object);
|
|
|
|
|
|
|
|
meta_prefs_remove_listener (prefs_changed_callback, bell);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (meta_bell_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_bell_class_init (MetaBellClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->finalize = meta_bell_finalize;
|
|
|
|
|
|
|
|
bell_signals[IS_AUDIBLE_CHANGED] =
|
|
|
|
g_signal_new ("is-audible-changed",
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
0,
|
|
|
|
NULL, NULL, NULL,
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
G_TYPE_BOOLEAN);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_bell_init (MetaBell *bell)
|
|
|
|
{
|
|
|
|
meta_prefs_add_listener (prefs_changed_callback, bell);
|
|
|
|
}
|
|
|
|
|
|
|
|
MetaBell *
|
|
|
|
meta_bell_new (MetaDisplay *display)
|
|
|
|
{
|
|
|
|
return g_object_new (META_TYPE_BELL, NULL);
|
|
|
|
}
|
|
|
|
|
2008-01-13 11:32:56 -05:00
|
|
|
/**
|
2011-11-02 11:34:45 -04:00
|
|
|
* bell_flash_fullscreen:
|
|
|
|
* @display: The display the event came in on
|
|
|
|
* @xkb_ev: The bell event
|
|
|
|
*
|
2008-01-13 11:32:56 -05:00
|
|
|
* Flashes one screen, or all screens, in response to a bell event.
|
|
|
|
* If the event is on a particular window, flash the screen that
|
|
|
|
* window is on. Otherwise, flash every screen on this display.
|
|
|
|
*
|
|
|
|
* If the configure script found we had no XKB, this does not exist.
|
|
|
|
*/
|
2002-12-16 20:08:29 -05:00
|
|
|
static void
|
2014-08-18 19:47:26 -04:00
|
|
|
bell_flash_fullscreen (MetaDisplay *display)
|
2002-12-16 20:08:29 -05:00
|
|
|
{
|
2017-08-26 15:43:17 -04:00
|
|
|
meta_compositor_flash_display (display->compositor, display);
|
2002-12-16 20:08:29 -05:00
|
|
|
}
|
|
|
|
|
2016-03-07 23:10:21 -05:00
|
|
|
static void
|
|
|
|
bell_flash_window (MetaWindow *window)
|
|
|
|
{
|
|
|
|
meta_compositor_flash_window (window->display->compositor, window);
|
|
|
|
}
|
|
|
|
|
2008-01-13 11:32:56 -05:00
|
|
|
/**
|
2011-11-02 11:34:45 -04:00
|
|
|
* bell_flash_frame:
|
|
|
|
* @display: The display the bell event came in on
|
|
|
|
* @xkb_ev: The bell event we just received
|
|
|
|
*
|
2014-08-18 19:47:26 -04:00
|
|
|
* Flashes the frame of the focused window. If there is no focused window,
|
2008-01-13 11:32:56 -05:00
|
|
|
* flashes the screen.
|
|
|
|
*/
|
2002-12-16 20:08:29 -05:00
|
|
|
static void
|
2014-05-02 09:34:02 -04:00
|
|
|
bell_flash_frame (MetaDisplay *display,
|
2014-08-18 19:47:26 -04:00
|
|
|
MetaWindow *window)
|
2002-12-16 20:08:29 -05:00
|
|
|
{
|
2019-03-06 17:51:41 -05:00
|
|
|
if (window)
|
2016-03-07 23:10:21 -05:00
|
|
|
bell_flash_window (window);
|
2016-03-18 23:28:42 -04:00
|
|
|
else
|
|
|
|
bell_flash_fullscreen (display);
|
2002-12-16 20:08:29 -05:00
|
|
|
}
|
|
|
|
|
2008-01-13 11:32:56 -05:00
|
|
|
/**
|
2011-11-02 11:34:45 -04:00
|
|
|
* bell_visual_notify:
|
|
|
|
* @display: The display the bell event came in on
|
|
|
|
* @xkb_ev: The bell event we just received
|
|
|
|
*
|
2008-01-13 11:32:56 -05:00
|
|
|
* Gives the user some kind of visual bell substitute, in response to a
|
|
|
|
* bell event. What this is depends on the "visual bell type" pref.
|
|
|
|
*/
|
2002-12-16 20:08:29 -05:00
|
|
|
static void
|
2014-05-02 09:34:02 -04:00
|
|
|
bell_visual_notify (MetaDisplay *display,
|
2014-08-18 19:47:26 -04:00
|
|
|
MetaWindow *window)
|
2002-12-16 20:08:29 -05:00
|
|
|
{
|
2014-05-02 09:34:02 -04:00
|
|
|
switch (meta_prefs_get_visual_bell_type ())
|
2002-12-16 20:08:29 -05:00
|
|
|
{
|
2011-06-24 12:14:15 -04:00
|
|
|
case G_DESKTOP_VISUAL_BELL_FULLSCREEN_FLASH:
|
2014-08-18 19:47:26 -04:00
|
|
|
bell_flash_fullscreen (display);
|
2002-12-16 20:08:29 -05:00
|
|
|
break;
|
2011-06-24 12:14:15 -04:00
|
|
|
case G_DESKTOP_VISUAL_BELL_FRAME_FLASH:
|
2014-08-18 19:47:26 -04:00
|
|
|
bell_flash_frame (display, window);
|
2002-12-16 20:08:29 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-18 19:47:26 -04:00
|
|
|
static gboolean
|
|
|
|
bell_audible_notify (MetaDisplay *display,
|
|
|
|
MetaWindow *window)
|
2002-12-16 20:08:29 -05:00
|
|
|
{
|
2018-12-09 06:58:00 -05:00
|
|
|
MetaSoundPlayer *player;
|
2009-02-11 19:53:23 -05:00
|
|
|
|
2018-12-09 06:58:00 -05:00
|
|
|
player = meta_display_get_sound_player (display);
|
|
|
|
meta_sound_player_play_from_theme (player,
|
|
|
|
"bell-window-system",
|
|
|
|
_("Bell event"),
|
|
|
|
NULL);
|
|
|
|
return TRUE;
|
2014-08-18 19:47:26 -04:00
|
|
|
}
|
|
|
|
|
2016-03-06 23:46:18 -05:00
|
|
|
gboolean
|
2014-08-18 19:47:26 -04:00
|
|
|
meta_bell_notify (MetaDisplay *display,
|
2016-03-06 23:46:18 -05:00
|
|
|
MetaWindow *window)
|
2014-08-18 19:47:26 -04:00
|
|
|
{
|
|
|
|
/* flash something */
|
|
|
|
if (meta_prefs_get_visual_bell ())
|
|
|
|
bell_visual_notify (display, window);
|
2009-02-11 19:53:23 -05:00
|
|
|
|
2014-08-18 19:47:26 -04:00
|
|
|
if (meta_prefs_bell_is_audible ())
|
2016-03-06 23:46:18 -05:00
|
|
|
return bell_audible_notify (display, window);
|
|
|
|
|
|
|
|
return TRUE;
|
2002-12-16 20:08:29 -05:00
|
|
|
}
|