2006-10-01 18:30:10 -04:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
2002-12-16 20:08:29 -05:00
|
|
|
/* Metacity visual bell */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2002 Sun Microsystems Inc.
|
2006-01-10 14:43:21 -05:00
|
|
|
* Copyright (C) 2005, 2006 Elijah Newren
|
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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2008-01-13 11:32:56 -05:00
|
|
|
/**
|
2008-06-29 14:46:01 -04:00
|
|
|
* \file bell.c Ring the bell or flash the screen
|
2008-01-13 11:32:56 -05:00
|
|
|
*
|
|
|
|
* Sometimes, X programs "ring the bell", whatever that means. Metacity lets
|
|
|
|
* 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
|
|
|
|
* its work-- or bell_flash_frame(), which flashes the focussed window
|
|
|
|
* using bell_flash_window_frame(), unless there is no such window, in
|
|
|
|
* which case it flashes the screen instead. bell_flash_window_frame()
|
|
|
|
* flashes the frame and calls bell_unflash_frame() as a timeout to
|
2008-01-13 11:32:56 -05:00
|
|
|
* remove the flash.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2002-12-16 20:08:29 -05:00
|
|
|
#include <config.h>
|
|
|
|
#include "bell.h"
|
2008-05-18 20:00:09 -04:00
|
|
|
#include "screen-private.h"
|
2002-12-16 20:08:29 -05:00
|
|
|
#include "prefs.h"
|
|
|
|
|
2008-01-13 11:32:56 -05:00
|
|
|
/**
|
|
|
|
* Flashes one entire screen. This is done by making a window the size of the
|
|
|
|
* whole screen (or reusing the old one, if it's still around), mapping it,
|
|
|
|
* painting it white and then black, and then unmapping it. We set saveunder so
|
|
|
|
* that all the windows behind it come back immediately.
|
|
|
|
*
|
|
|
|
* Unlike frame flashes, we don't do fullscreen flashes with a timeout; rather,
|
|
|
|
* we do them in one go, because we don't have to rely on the theme code
|
|
|
|
* redrawing the frame for us in order to do the flash.
|
|
|
|
*
|
|
|
|
* \param display The display which owns the screen (rather redundant)
|
|
|
|
* \param screen The screen to flash
|
|
|
|
*
|
|
|
|
* \bug The way I read it, this appears not to do the flash
|
|
|
|
* the first time we flash a particular display. Am I wrong?
|
|
|
|
*
|
|
|
|
* \bug This appears to destroy our current XSync status.
|
|
|
|
*/
|
2002-12-16 20:08:29 -05:00
|
|
|
static void
|
2008-06-29 14:46:01 -04:00
|
|
|
bell_flash_screen (MetaDisplay *display,
|
2002-12-16 20:08:29 -05:00
|
|
|
MetaScreen *screen)
|
|
|
|
{
|
|
|
|
Window root = screen->xroot;
|
Merge of all the changes on the constraints_experiments branch. This is
2005-11-18 Elijah Newren <newren@gmail.com>
Merge of all the changes on the constraints_experiments branch.
This is just a summary, to get the full ChangeLog of those
changes (approx. 2000 lines):
cvs -q -z3 update -Pd -r constraints_experiments
cvs -q -z3 diff -pu -r CONSTRAINTS_EXPERIMENTS_BRANCHPOINT ChangeLog
Bugs fixed:
unfiled - constraints.c is overly complicated[1]
unfiled - constraints.c is not robust when all constraints
cannot simultaneously be met (constraints need to be
prioritized)
unfiled - keep-titlebar-onscreen constraint is decoration
unaware (since get_outermost_onscreen_positions()
forgets to include decorations)
unfiled - keyboard snap-moving and snap-resizing snap to hidden
edges
109553 - gravity w/ simultaneous move & resize doesn't work
113601 - maximize vertical and horizontal should toggle and be
constrained
122196 - windows show up under vertical panels
122670 - jerky/random resizing of window via keyboard[2]
124582 - keyboard and mouse snap-resizing and snap-moving
erroneously moves the window multidimensionally
136307 - don't allow apps to resize themselves off the screen
(*cough* filechooser *cough*)
142016, 143784 - windows should not span multiple xineramas
unless placed there by the user
143145 - clamp new windows to screensize and force them
onscreen, if they'll fit
144126 - Handle pathological strut lists sanely[3]
149867 - fixed aspect ratio windows are difficult to resize[4]
152898 - make screen edges consistent; allow easy slamming of
windows into the left, right, and bottom edges of the
screen too.
154706 - bouncing weirdness at screen edge with keyboard moving
or resizing
156699 - avoid struts when placing windows, if possible (nasty
a11y blocker)
302456 - dragging offscreen too restrictive
304857 - wireframe moving off the top of the screen is misleading
308521 - make uni-directional resizing easier with
alt-middle-drag and prevent the occasional super
annoying resize-the-wrong-side(s) behavior
312007 - snap-resize moves windows with a minimum size
constraint
312104 - resizing the top of a window can cause the bottom to
grow
319351 - don't instantly snap on mouse-move-snapping, remove
braindeadedness of having order of releasing shift and
releasing button press matter so much
[1] fixed in my opinion, anyway.
[2] Actually, it's not totally fixed--it's just annoying
instead of almost completely unusable. Matthias had a
suggestion that may fix the remainder of the problems (see
http://tinyurl.com/bwzuu).
[3] This bug was originally about not-quite-so-pathological
cases but was left open for the worse cases. The code from
the branch handles the remainder of the cases mentioned in
this bug.
[4] Actually, although it's far better there's still some minor
issues left: a slight drift that's only noticeable after
lots of resizing, and potential problems with partially
onscreen constraints due to not clearing any
fixed_directions flags (aspect ratio windows get resized in
both directions and thus aren't fixed in one of them)
New feature:
81704 - edge resistance for user move and resize operations;
in particular 3 different kinds of resistance are
implemented:
Pixel-Distance: window movement is resisted when it
aligns with an edge unless the movement is greater than
a threshold number of pixels
Timeout: window movement past an edge is prevented until
a certain amount of time has elapsed during the
operation since the first request to move it past that
edge
Keyboard-Buildup: when moving or resizing with the
keyboard, once a window is aligned with a certain edge
it cannot move past until the correct direction has
been pressed enough times (e.g. 2 or 3 times)
Major changes:
- constraints.c has been rewritten; very few lines of code from
the old version remain. There is a comment near the top of
the function explaining the basics of how the new framework
works. A more detailed explanation can be found in
doc/how-constraints-works.txt
- edge-resistance.[ch] are new files implementing edge-resistance.
- boxes.[ch] are new files containing low-level error-prone
functions used heavily in constraints.c and edge-resistance.c,
among various places throughout the code. testboxes.c
contains a thorough testsuite for the boxes.[ch] functions
compiled into a program, testboxes.
- meta_window_move_resize_internal() *must* be told the gravity
of the associated operation (if it's just a move operation,
the gravity will be ignored, but for resize and move+resize
the correct value is needed)
- the craziness of different values that
meta_window_move_resize_internal() accepts has been documented
in a large comment at the beginning of the function. It may
be possible to clean this up some, but until then things will
remain as they were before--caller beware.
- screen and xinerama usable areas (i.e. places not covered by
e.g. panels) are cached in the workspace now, as are the
screen and xinerama edges. These get updated with the
workarea in src/workspace.c:ensure_work_areas_validated()
2005-11-19 09:58:50 -05:00
|
|
|
int width = screen->rect.width;
|
|
|
|
int height = screen->rect.height;
|
2002-12-16 20:08:29 -05:00
|
|
|
|
|
|
|
if (screen->flash_window == None)
|
|
|
|
{
|
A load of fixes of issues reported by sparse. Closes bug #152849
2004-09-17 Kjartan Maraas <kmaraas@gnome.org>
* src/bell.c: (meta_bell_flash_screen):
* src/compositor.c:
* src/effects.c: (meta_effects_draw_box_animation):
* src/fixedtip.c: (meta_fixed_tip_show):
* src/frame.c: (find_argb_visual):
* src/frames.c: (unsigned_long_hash), (meta_frames_manage_window),
(meta_frames_apply_shapes):
* src/iconcache.c: (find_largest_sizes), (find_best_size):
* src/keybindings.c: (meta_spawn_command_line_async_on_screen):
* src/main.c: (main):
* src/menu.c: (meta_window_menu_new):
* src/prefs.c: (meta_prefs_get_visual_bell),
(meta_prefs_bell_is_audible), (meta_prefs_get_visual_bell_type),
(meta_prefs_get_action_double_click_titlebar),
(meta_prefs_get_auto_raise), (meta_prefs_get_auto_raise_delay),
(meta_prefs_get_reduced_resources):
* src/screen.c: (meta_create_offscreen_window):
* src/tabpopup.c: (meta_ui_tab_popup_get_selected):
* src/theme-parser.c: (meta_theme_load):
* src/theme.c: (meta_gtk_widget_get_font_desc):
* src/tools/metacity-mag.c: (mouse_press), (begin_area_grab):
* src/util.c: (meta_unsigned_long_hash): A load of fixes of issues
reported by sparse. Closes bug #152849
2004-09-16 19:18:22 -04:00
|
|
|
Visual *visual = (Visual *)CopyFromParent;
|
2002-12-16 20:08:29 -05:00
|
|
|
XSetWindowAttributes xswa;
|
|
|
|
int depth = CopyFromParent;
|
|
|
|
xswa.save_under = True;
|
|
|
|
xswa.override_redirect = True;
|
|
|
|
/*
|
|
|
|
* TODO: use XGetVisualInfo and determine which is an
|
|
|
|
* overlay, if one is present, and use the Overlay visual
|
|
|
|
* for this window (for performance reasons).
|
|
|
|
* Not sure how to tell this yet...
|
|
|
|
*/
|
|
|
|
screen->flash_window = XCreateWindow (display->xdisplay, root,
|
|
|
|
0, 0, width, height,
|
|
|
|
0, depth,
|
|
|
|
InputOutput,
|
|
|
|
visual,
|
|
|
|
/* note: XSun doesn't like SaveUnder here */
|
|
|
|
CWSaveUnder | CWOverrideRedirect,
|
|
|
|
&xswa);
|
|
|
|
XSelectInput (display->xdisplay, screen->flash_window, ExposureMask);
|
|
|
|
XMapWindow (display->xdisplay, screen->flash_window);
|
|
|
|
XSync (display->xdisplay, False);
|
|
|
|
XFlush (display->xdisplay);
|
|
|
|
XUnmapWindow (display->xdisplay, screen->flash_window);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* just draw something in the window */
|
|
|
|
GC gc = XCreateGC (display->xdisplay, screen->flash_window, 0, NULL);
|
|
|
|
XMapWindow (display->xdisplay, screen->flash_window);
|
|
|
|
XSetForeground (display->xdisplay, gc,
|
|
|
|
WhitePixel (display->xdisplay,
|
|
|
|
XScreenNumberOfScreen (screen->xscreen)));
|
|
|
|
XFillRectangle (display->xdisplay, screen->flash_window, gc,
|
|
|
|
0, 0, width, height);
|
|
|
|
XSetForeground (display->xdisplay, gc,
|
|
|
|
BlackPixel (display->xdisplay,
|
|
|
|
XScreenNumberOfScreen (screen->xscreen)));
|
|
|
|
XFillRectangle (display->xdisplay, screen->flash_window, gc,
|
|
|
|
0, 0, width, height);
|
|
|
|
XFlush (display->xdisplay);
|
|
|
|
XSync (display->xdisplay, False);
|
|
|
|
XUnmapWindow (display->xdisplay, screen->flash_window);
|
2005-10-03 15:22:40 -04:00
|
|
|
XFreeGC (display->xdisplay, gc);
|
2002-12-16 20:08:29 -05:00
|
|
|
}
|
2005-02-25 15:14:08 -05:00
|
|
|
|
|
|
|
if (meta_prefs_get_focus_mode () != META_FOCUS_MODE_CLICK &&
|
|
|
|
!display->mouse_mode)
|
|
|
|
meta_display_increment_focus_sentinel (display);
|
2002-12-16 20:08:29 -05:00
|
|
|
XFlush (display->xdisplay);
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
* \param display The display the event came in on
|
|
|
|
* \param xkb_ev The bell event
|
|
|
|
*/
|
2002-12-16 20:08:29 -05:00
|
|
|
#ifdef HAVE_XKB
|
|
|
|
static void
|
2008-06-29 14:46:01 -04:00
|
|
|
bell_flash_fullscreen (MetaDisplay *display,
|
2002-12-16 20:08:29 -05:00
|
|
|
XkbAnyEvent *xkb_ev)
|
|
|
|
{
|
|
|
|
XkbBellNotifyEvent *xkb_bell_ev = (XkbBellNotifyEvent *) xkb_ev;
|
|
|
|
MetaScreen *screen;
|
|
|
|
|
|
|
|
g_assert (xkb_ev->xkb_type == XkbBellNotify);
|
|
|
|
if (xkb_bell_ev->window != None)
|
|
|
|
{
|
|
|
|
screen = meta_display_screen_for_xwindow (display, xkb_bell_ev->window);
|
|
|
|
if (screen)
|
2008-06-29 14:46:01 -04:00
|
|
|
bell_flash_screen (display, screen);
|
2002-12-16 20:08:29 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GSList *screen_list = display->screens;
|
|
|
|
while (screen_list)
|
|
|
|
{
|
|
|
|
screen = (MetaScreen *) screen_list->data;
|
2008-06-29 14:46:01 -04:00
|
|
|
bell_flash_screen (display, screen);
|
2002-12-16 20:08:29 -05:00
|
|
|
screen_list = screen_list->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-13 11:32:56 -05:00
|
|
|
/**
|
|
|
|
* Makes a frame be not flashed; this is the timeout half of
|
2008-06-29 14:46:01 -04:00
|
|
|
* bell_flash_window_frame(). This is done simply by clearing the
|
2008-01-16 22:49:24 -05:00
|
|
|
* flash flag and queuing a redraw of the frame.
|
2008-01-13 11:32:56 -05:00
|
|
|
*
|
|
|
|
* If the configure script found we had no XKB, this does not exist.
|
|
|
|
*
|
|
|
|
* \param data The frame to unflash, cast to a gpointer so it can go into
|
|
|
|
* a callback function.
|
|
|
|
* \return Always FALSE, so we don't get called again.
|
|
|
|
*
|
2008-06-29 14:46:01 -04:00
|
|
|
* \bug This is the parallel to bell_flash_window_frame(), so it should
|
2008-01-13 11:32:56 -05:00
|
|
|
* really be called meta_bell_unflash_window_frame().
|
|
|
|
*/
|
2002-12-16 20:08:29 -05:00
|
|
|
static gboolean
|
2008-06-29 14:46:01 -04:00
|
|
|
bell_unflash_frame (gpointer data)
|
2002-12-16 20:08:29 -05:00
|
|
|
{
|
|
|
|
MetaFrame *frame = (MetaFrame *) data;
|
|
|
|
frame->is_flashing = 0;
|
|
|
|
meta_frame_queue_draw (frame);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-01-13 11:32:56 -05:00
|
|
|
/**
|
|
|
|
* Makes a frame flash and then return to normal shortly afterwards.
|
|
|
|
* This is done by setting a flag so that the theme
|
|
|
|
* code will temporarily draw the frame as focussed if it's unfocussed and
|
|
|
|
* vice versa, and then queueing a redraw. Lastly, we create a timeout so
|
|
|
|
* that the flag can be unset and the frame re-redrawn.
|
|
|
|
*
|
|
|
|
* If the configure script found we had no XKB, this does not exist.
|
|
|
|
*
|
|
|
|
* \param window The window to flash
|
|
|
|
*/
|
2002-12-16 20:08:29 -05:00
|
|
|
static void
|
2008-06-29 14:46:01 -04:00
|
|
|
bell_flash_window_frame (MetaWindow *window)
|
2002-12-16 20:08:29 -05:00
|
|
|
{
|
|
|
|
g_assert (window->frame != NULL);
|
|
|
|
window->frame->is_flashing = 1;
|
|
|
|
meta_frame_queue_draw (window->frame);
|
|
|
|
g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, 100,
|
2008-06-29 14:46:01 -04:00
|
|
|
bell_unflash_frame, window->frame, NULL);
|
2002-12-16 20:08:29 -05:00
|
|
|
}
|
|
|
|
|
2008-01-13 11:32:56 -05:00
|
|
|
/**
|
|
|
|
* Flashes the frame of the focussed window. If there is no focussed window,
|
|
|
|
* flashes the screen.
|
|
|
|
*
|
|
|
|
* \param display The display the bell event came in on
|
|
|
|
* \param xkb_ev The bell event we just received
|
|
|
|
*/
|
2002-12-16 20:08:29 -05:00
|
|
|
static void
|
2008-06-29 14:46:01 -04:00
|
|
|
bell_flash_frame (MetaDisplay *display,
|
2002-12-16 20:08:29 -05:00
|
|
|
XkbAnyEvent *xkb_ev)
|
|
|
|
{
|
|
|
|
XkbBellNotifyEvent *xkb_bell_event = (XkbBellNotifyEvent *) xkb_ev;
|
|
|
|
MetaWindow *window;
|
|
|
|
|
|
|
|
g_assert (xkb_ev->xkb_type == XkbBellNotify);
|
|
|
|
window = meta_display_lookup_x_window (display, xkb_bell_event->window);
|
2003-06-11 13:55:28 -04:00
|
|
|
if (!window && (display->focus_window) && (display->focus_window->frame))
|
2002-12-16 20:08:29 -05:00
|
|
|
{
|
|
|
|
window = display->focus_window;
|
|
|
|
}
|
|
|
|
if (window)
|
|
|
|
{
|
2008-06-29 14:46:01 -04:00
|
|
|
bell_flash_window_frame (window);
|
2002-12-16 20:08:29 -05:00
|
|
|
}
|
|
|
|
else /* revert to fullscreen flash if there's no focussed window */
|
|
|
|
{
|
2008-06-29 14:46:01 -04:00
|
|
|
bell_flash_fullscreen (display, xkb_ev);
|
2002-12-16 20:08:29 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
*
|
|
|
|
* If the configure script found we had no XKB, this does not exist.
|
|
|
|
*
|
|
|
|
* \param display The display the bell event came in on
|
|
|
|
* \param xkb_ev The bell event we just received
|
|
|
|
*
|
|
|
|
* \bug This should be merged with meta_bell_notify().
|
|
|
|
*/
|
2002-12-16 20:08:29 -05:00
|
|
|
static void
|
2008-06-29 14:46:01 -04:00
|
|
|
bell_visual_notify (MetaDisplay *display,
|
2002-12-16 20:08:29 -05:00
|
|
|
XkbAnyEvent *xkb_ev)
|
|
|
|
{
|
|
|
|
switch (meta_prefs_get_visual_bell_type ())
|
|
|
|
{
|
|
|
|
case META_VISUAL_BELL_FULLSCREEN_FLASH:
|
2008-06-29 14:46:01 -04:00
|
|
|
bell_flash_fullscreen (display, xkb_ev);
|
2002-12-16 20:08:29 -05:00
|
|
|
break;
|
|
|
|
case META_VISUAL_BELL_FRAME_FLASH:
|
2008-06-29 14:46:01 -04:00
|
|
|
bell_flash_frame (display, xkb_ev); /* does nothing yet */
|
2002-12-16 20:08:29 -05:00
|
|
|
break;
|
|
|
|
case META_VISUAL_BELL_INVALID:
|
|
|
|
/* do nothing */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_bell_notify (MetaDisplay *display,
|
|
|
|
XkbAnyEvent *xkb_ev)
|
|
|
|
{
|
|
|
|
/* flash something */
|
|
|
|
if (meta_prefs_get_visual_bell ())
|
2008-06-29 14:46:01 -04:00
|
|
|
bell_visual_notify (display, xkb_ev);
|
2002-12-16 20:08:29 -05:00
|
|
|
}
|
2008-01-13 11:32:56 -05:00
|
|
|
#endif /* HAVE_XKB */
|
2002-12-16 20:08:29 -05:00
|
|
|
|
2008-06-30 12:42:19 -04:00
|
|
|
void
|
2002-12-16 20:08:29 -05:00
|
|
|
meta_bell_set_audible (MetaDisplay *display, gboolean audible)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_XKB
|
|
|
|
XkbChangeEnabledControls (display->xdisplay,
|
|
|
|
XkbUseCoreKbd,
|
|
|
|
XkbAudibleBellMask,
|
|
|
|
audible ? XkbAudibleBellMask : 0);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
meta_bell_init (MetaDisplay *display)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_XKB
|
|
|
|
int xkb_base_error_type, xkb_opcode;
|
|
|
|
|
|
|
|
if (!XkbQueryExtension (display->xdisplay, &xkb_opcode,
|
|
|
|
&display->xkb_base_event_type,
|
|
|
|
&xkb_base_error_type,
|
|
|
|
NULL, NULL))
|
|
|
|
{
|
|
|
|
display->xkb_base_event_type = -1;
|
|
|
|
g_message ("could not find XKB extension.");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsigned int mask = XkbBellNotifyMask;
|
|
|
|
gboolean visual_bell_auto_reset = FALSE;
|
|
|
|
/* TRUE if and when non-broken version is available */
|
|
|
|
XkbSelectEvents (display->xdisplay,
|
|
|
|
XkbUseCoreKbd,
|
|
|
|
XkbBellNotifyMask,
|
|
|
|
XkbBellNotifyMask);
|
|
|
|
XkbChangeEnabledControls (display->xdisplay,
|
|
|
|
XkbUseCoreKbd,
|
|
|
|
XkbAudibleBellMask,
|
|
|
|
meta_prefs_bell_is_audible ()
|
|
|
|
? XkbAudibleBellMask : 0);
|
|
|
|
if (visual_bell_auto_reset) {
|
|
|
|
XkbSetAutoResetControls (display->xdisplay,
|
|
|
|
XkbAudibleBellMask,
|
|
|
|
&mask,
|
|
|
|
&mask);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_bell_shutdown (MetaDisplay *display)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_XKB
|
|
|
|
/* TODO: persist initial bell state in display, reset here */
|
|
|
|
XkbChangeEnabledControls (display->xdisplay,
|
|
|
|
XkbUseCoreKbd,
|
|
|
|
XkbAudibleBellMask,
|
|
|
|
XkbAudibleBellMask);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-06-30 12:42:19 -04:00
|
|
|
/**
|
|
|
|
* Deals with a frame being destroyed. This is important because if we're
|
|
|
|
* using a visual bell, we might be flashing the edges of the frame, and
|
|
|
|
* so we'd have a timeout function waiting ready to un-flash them. If the
|
|
|
|
* frame's going away, we can tell the timeout not to bother.
|
|
|
|
*
|
|
|
|
* \param frame The frame which is being destroyed
|
|
|
|
*/
|
2002-12-16 20:08:29 -05:00
|
|
|
void
|
|
|
|
meta_bell_notify_frame_destroy (MetaFrame *frame)
|
|
|
|
{
|
|
|
|
if (frame->is_flashing)
|
2006-01-09 23:50:17 -05:00
|
|
|
g_source_remove_by_funcs_user_data (&g_timeout_funcs, frame);
|
2002-12-16 20:08:29 -05:00
|
|
|
}
|