bell: Always flash window instead of frame

Traditionally visual alerts were implemented by flashing the focus
window's frame. As that only works for windows that we decorate,
flashing the whole window was added as a fallback for client-decorated
windows.

However that introduces some confusing inconsistency, better to just
always flash the entire window.

https://gitlab.gnome.org/GNOME/mutter/issues/491
This commit is contained in:
Florian Müllner 2019-03-06 23:51:41 +01:00 committed by Marco Trevisan
parent 303e02bdac
commit f8d62da2dc

View File

@ -34,10 +34,8 @@
* function then checks what kind of visual flash you like, and calls either * function then checks what kind of visual flash you like, and calls either
* bell_flash_fullscreen()-- which calls bell_flash_screen() to do * bell_flash_fullscreen()-- which calls bell_flash_screen() to do
* its work-- or bell_flash_frame(), which flashes the focussed window * its work-- or bell_flash_frame(), which flashes the focussed window
* using bell_flash_window_frame(), unless there is no such window, in * using bell_flash_window(), unless there is no such window, in
* which case it flashes the screen instead. bell_flash_window_frame() * which case it flashes the screen instead.
* flashes the frame and calls bell_unflash_frame() as a timeout to
* remove the flash.
* *
* The visual bell was the result of a discussion in Bugzilla here: * The visual bell was the result of a discussion in Bugzilla here:
* <http://bugzilla.gnome.org/show_bug.cgi?id=99886>. * <http://bugzilla.gnome.org/show_bug.cgi?id=99886>.
@ -135,62 +133,6 @@ bell_flash_fullscreen (MetaDisplay *display)
meta_compositor_flash_display (display->compositor, display); meta_compositor_flash_display (display->compositor, display);
} }
/**
* bell_unflash_frame:
* @data: The frame to unflash, cast to a gpointer so it can go into
* a callback function.
*
* Makes a frame be not flashed; this is the timeout half of
* bell_flash_window_frame(). This is done simply by clearing the
* flash flag and queuing a redraw of the frame.
*
* If the configure script found we had no XKB, this does not exist.
*
* Returns: Always FALSE, so we don't get called again.
*/
/*
* Bug: This is the parallel to bell_flash_window_frame(), so it should
* really be called meta_bell_unflash_window_frame().
*/
static gboolean
bell_unflash_frame (gpointer data)
{
MetaFrame *frame = (MetaFrame *) data;
frame->is_flashing = 0;
meta_frame_queue_draw (frame);
return FALSE;
}
/**
* bell_flash_window_frame:
* @window: The window to flash
*
* 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.
*/
static void
bell_flash_window_frame (MetaWindow *window)
{
guint id;
g_assert (window->frame != NULL);
window->frame->is_flashing = 1;
meta_frame_queue_draw (window->frame);
/* Since this idle is added after the Clutter clock source, with
* the same priority, it will be executed after it as well, so
* we are guaranteed to get at least one frame drawn in the
* flashed state, no matter how loaded we are.
*/
id = g_timeout_add_full (META_PRIORITY_REDRAW, 100,
bell_unflash_frame, window->frame, NULL);
g_source_set_name_by_id (id, "[mutter] bell_unflash_frame");
}
static void static void
bell_flash_window (MetaWindow *window) bell_flash_window (MetaWindow *window)
{ {
@ -209,9 +151,7 @@ static void
bell_flash_frame (MetaDisplay *display, bell_flash_frame (MetaDisplay *display,
MetaWindow *window) MetaWindow *window)
{ {
if (window && window->frame) if (window)
bell_flash_window_frame (window);
else if (window)
bell_flash_window (window); bell_flash_window (window);
else else
bell_flash_fullscreen (display); bell_flash_fullscreen (display);