forked from AuroraMiddleware/gtk
gdk: Move window beeps into GdkWindowImpl
One less magic function. Also refactored it to make it easier to implement. It now returns TRUE if it beeped and FALSE if it failed to do so. A default implementation exists that just returns FALSE for all the backends that can't beep windows (read: everything but X11 with XKB - and why on earth do keyboard libs implement beeping?)
This commit is contained in:
parent
1269f8424f
commit
4d1604c77d
@ -356,7 +356,6 @@ gulong _gdk_windowing_window_get_next_serial (GdkDisplay *display);
|
||||
void _gdk_windowing_window_get_offsets (GdkWindow *window,
|
||||
gint *x_offset,
|
||||
gint *y_offset);
|
||||
void _gdk_windowing_window_beep (GdkWindow *window);
|
||||
|
||||
|
||||
void _gdk_windowing_get_device_state (GdkDisplay *display,
|
||||
|
@ -8065,10 +8065,14 @@ gdk_window_beep (GdkWindow *window)
|
||||
toplevel = get_event_toplevel (window);
|
||||
display = gdk_window_get_display (window);
|
||||
|
||||
if (toplevel && !gdk_window_is_offscreen (toplevel))
|
||||
_gdk_windowing_window_beep (toplevel);
|
||||
else
|
||||
gdk_display_beep (display);
|
||||
if (toplevel)
|
||||
{
|
||||
if (GDK_WINDOW_IMPL_CLASS (toplevel)->beep (window))
|
||||
return;
|
||||
}
|
||||
|
||||
/* If windows fail to beep, we beep the display. */
|
||||
gdk_display_beep (display);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -33,10 +33,18 @@
|
||||
|
||||
G_DEFINE_TYPE (GdkWindowImpl, gdk_window_impl, G_TYPE_OBJECT);
|
||||
|
||||
static gboolean
|
||||
gdk_window_impl_beep (GdkWindow *window)
|
||||
{
|
||||
/* FALSE means windows can't beep, so the display will be
|
||||
* made to beep instead. */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_window_impl_class_init (GdkWindowImplClass *klass)
|
||||
gdk_window_impl_class_init (GdkWindowImplClass *impl_class)
|
||||
{
|
||||
impl_class->beep = gdk_window_impl_beep;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -158,6 +158,9 @@ struct _GdkWindowImplClass
|
||||
cairo_surface_t *surface,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
/* optional */
|
||||
gboolean (* beep) (GdkWindow *window);
|
||||
};
|
||||
|
||||
/* Interface Functions */
|
||||
|
@ -2919,14 +2919,6 @@ gdk_window_destroy_notify (GdkWindow *window)
|
||||
check_grab_destroy (window);
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_windowing_window_beep (GdkWindow *window)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_WINDOW (window));
|
||||
|
||||
gdk_display_beep (_gdk_display);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_window_set_opacity (GdkWindow *window,
|
||||
gdouble opacity)
|
||||
|
@ -3121,12 +3121,6 @@ gdk_window_configure_finished (GdkWindow *window)
|
||||
g_return_if_fail (GDK_IS_WINDOW (window));
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_windowing_window_beep (GdkWindow *window)
|
||||
{
|
||||
gdk_display_beep (_gdk_display);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_window_set_opacity (GdkWindow *window,
|
||||
gdouble opacity)
|
||||
|
@ -5350,24 +5350,25 @@ gdk_window_configure_finished (GdkWindow *window)
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
_gdk_windowing_window_beep (GdkWindow *window)
|
||||
static gboolean
|
||||
gdk_x11_window_beep (GdkWindow *window)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
|
||||
g_return_if_fail (GDK_IS_WINDOW (window));
|
||||
|
||||
display = GDK_WINDOW_DISPLAY (window);
|
||||
|
||||
#ifdef HAVE_XKB
|
||||
if (GDK_DISPLAY_X11 (display)->use_xkb)
|
||||
XkbBell (GDK_DISPLAY_XDISPLAY (display),
|
||||
GDK_WINDOW_XID (window),
|
||||
0,
|
||||
None);
|
||||
else
|
||||
{
|
||||
XkbBell (GDK_DISPLAY_XDISPLAY (display),
|
||||
GDK_WINDOW_XID (window),
|
||||
0,
|
||||
None);
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
gdk_display_beep (display);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -5591,5 +5592,6 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
|
||||
impl_class->resize_cairo_surface = gdk_window_x11_resize_cairo_surface;
|
||||
impl_class->get_shape = gdk_x11_window_get_shape;
|
||||
impl_class->get_input_shape = gdk_x11_window_get_input_shape;
|
||||
impl_class->beep = gdk_x11_window_beep;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user