[gtk+/rendering-cleanup: 57/65] gdk: Move window beeps into GdkWindowImpl
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/rendering-cleanup: 57/65] gdk: Move window beeps into GdkWindowImpl
- Date: Thu, 2 Dec 2010 11:56:14 +0000 (UTC)
commit 5e39013f1092a78fe8edad126432e7c9333a14ec
Author: Benjamin Otte <otte redhat com>
Date: Thu Nov 25 12:28:08 2010 +0100
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?)
gdk/gdkinternals.h | 1 -
gdk/gdkwindow.c | 12 ++++++++----
gdk/gdkwindowimpl.c | 10 +++++++++-
gdk/gdkwindowimpl.h | 3 +++
gdk/quartz/gdkwindow-quartz.c | 8 --------
gdk/win32/gdkwindow-win32.c | 6 ------
gdk/x11/gdkwindow-x11.c | 22 ++++++++++++----------
7 files changed, 32 insertions(+), 30 deletions(-)
---
diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h
index 830e5d7..8aede53 100644
--- a/gdk/gdkinternals.h
+++ b/gdk/gdkinternals.h
@@ -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,
diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c
index 9e84e2a..36d13f6 100644
--- a/gdk/gdkwindow.c
+++ b/gdk/gdkwindow.c
@@ -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);
}
/**
diff --git a/gdk/gdkwindowimpl.c b/gdk/gdkwindowimpl.c
index 57aed07..ef81fcf 100644
--- a/gdk/gdkwindowimpl.c
+++ b/gdk/gdkwindowimpl.c
@@ -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
diff --git a/gdk/gdkwindowimpl.h b/gdk/gdkwindowimpl.h
index dfcf3b4..0332a31 100644
--- a/gdk/gdkwindowimpl.h
+++ b/gdk/gdkwindowimpl.h
@@ -158,6 +158,9 @@ struct _GdkWindowImplClass
cairo_surface_t *surface,
gint width,
gint height);
+
+ /* optional */
+ gboolean (* beep) (GdkWindow *window);
};
/* Interface Functions */
diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c
index 42117ac..40b9dbb 100644
--- a/gdk/quartz/gdkwindow-quartz.c
+++ b/gdk/quartz/gdkwindow-quartz.c
@@ -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)
diff --git a/gdk/win32/gdkwindow-win32.c b/gdk/win32/gdkwindow-win32.c
index ad291b2..bcbdca3 100644
--- a/gdk/win32/gdkwindow-win32.c
+++ b/gdk/win32/gdkwindow-win32.c
@@ -3122,12 +3122,6 @@ gdk_window_configure_finished (GdkWindow *window)
}
void
-_gdk_windowing_window_beep (GdkWindow *window)
-{
- gdk_display_beep (_gdk_display);
-}
-
-void
gdk_window_set_opacity (GdkWindow *window,
gdouble opacity)
{
diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c
index d3c4a8e..725f77a 100644
--- a/gdk/x11/gdkwindow-x11.c
+++ b/gdk/x11/gdkwindow-x11.c
@@ -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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]