[gtk+] gdk: pull more precondition checks into the generic gdkscreen.c
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gdk: pull more precondition checks into the generic gdkscreen.c
- Date: Fri, 24 Feb 2012 15:45:29 +0000 (UTC)
commit 8c1c4dfd7c49b7efefffb404ae7480453fe5f278
Author: Michael Natterer <mitch gimp org>
Date: Fri Feb 24 16:44:44 2012 +0100
gdk: pull more precondition checks into the generic gdkscreen.c
gdk/broadway/gdkscreen-broadway.c | 8 --------
gdk/gdkscreen.c | 5 +++++
gdk/wayland/gdkscreen-wayland.c | 8 --------
gdk/x11/gdkscreen-x11.c | 8 --------
4 files changed, 5 insertions(+), 24 deletions(-)
---
diff --git a/gdk/broadway/gdkscreen-broadway.c b/gdk/broadway/gdkscreen-broadway.c
index f970be9..285aa98 100644
--- a/gdk/broadway/gdkscreen-broadway.c
+++ b/gdk/broadway/gdkscreen-broadway.c
@@ -150,8 +150,6 @@ static gint
gdk_broadway_screen_get_monitor_width_mm (GdkScreen *screen,
gint monitor_num)
{
- g_return_val_if_fail (monitor_num == 0, -1);
-
return gdk_screen_get_width_mm (screen);
}
@@ -159,8 +157,6 @@ static gint
gdk_broadway_screen_get_monitor_height_mm (GdkScreen *screen,
gint monitor_num)
{
- g_return_val_if_fail (monitor_num == 0, -1);
-
return gdk_screen_get_height_mm (screen);
}
@@ -168,8 +164,6 @@ static gchar *
gdk_broadway_screen_get_monitor_plug_name (GdkScreen *screen,
gint monitor_num)
{
- g_return_val_if_fail (monitor_num == 0, NULL);
-
return g_strdup ("browser");
}
@@ -180,8 +174,6 @@ gdk_broadway_screen_get_monitor_geometry (GdkScreen *screen,
{
GdkBroadwayScreen *broadway_screen = GDK_BROADWAY_SCREEN (screen);
- g_return_if_fail (monitor_num == 0);
-
if (dest)
{
dest->x = 0;
diff --git a/gdk/gdkscreen.c b/gdk/gdkscreen.c
index 0ed04b1..33e2ce9 100644
--- a/gdk/gdkscreen.c
+++ b/gdk/gdkscreen.c
@@ -725,6 +725,7 @@ gdk_screen_get_monitor_width_mm (GdkScreen *screen,
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);
g_return_val_if_fail (monitor_num >= 0, -1);
+ g_return_val_if_fail (monitor_num < gdk_screen_get_n_monitors (screen), -1);
return GDK_SCREEN_GET_CLASS (screen)->get_monitor_width_mm (screen, monitor_num);
}
@@ -746,6 +747,7 @@ gdk_screen_get_monitor_height_mm (GdkScreen *screen,
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);
g_return_val_if_fail (monitor_num >= 0, -1);
+ g_return_val_if_fail (monitor_num < gdk_screen_get_n_monitors (screen), -1);
return GDK_SCREEN_GET_CLASS (screen)->get_monitor_height_mm (screen, monitor_num);
}
@@ -770,6 +772,7 @@ gdk_screen_get_monitor_plug_name (GdkScreen *screen,
{
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
g_return_val_if_fail (monitor_num >= 0, NULL);
+ g_return_val_if_fail (monitor_num < gdk_screen_get_n_monitors (screen), NULL);
return GDK_SCREEN_GET_CLASS (screen)->get_monitor_plug_name (screen, monitor_num);
}
@@ -799,6 +802,7 @@ gdk_screen_get_monitor_geometry (GdkScreen *screen,
{
g_return_if_fail (GDK_IS_SCREEN (screen));
g_return_if_fail (monitor_num >= 0);
+ g_return_if_fail (monitor_num < gdk_screen_get_n_monitors (screen));
GDK_SCREEN_GET_CLASS(screen)->get_monitor_geometry (screen, monitor_num, dest);
}
@@ -829,6 +833,7 @@ gdk_screen_get_monitor_workarea (GdkScreen *screen,
{
g_return_if_fail (GDK_IS_SCREEN (screen));
g_return_if_fail (monitor_num >= 0);
+ g_return_if_fail (monitor_num < gdk_screen_get_n_monitors (screen));
GDK_SCREEN_GET_CLASS (screen)->get_monitor_workarea (screen, monitor_num, dest);
}
diff --git a/gdk/wayland/gdkscreen-wayland.c b/gdk/wayland/gdkscreen-wayland.c
index 47f70ef..ff03c5e 100644
--- a/gdk/wayland/gdkscreen-wayland.c
+++ b/gdk/wayland/gdkscreen-wayland.c
@@ -220,8 +220,6 @@ gdk_wayland_screen_get_monitor_width_mm (GdkScreen *screen,
{
GdkScreenWayland *screen_wayland = GDK_SCREEN_WAYLAND (screen);
- g_return_val_if_fail (monitor_num < screen_wayland->n_monitors, -1);
-
return screen_wayland->monitors[monitor_num].width_mm;
}
@@ -231,8 +229,6 @@ gdk_wayland_screen_get_monitor_height_mm (GdkScreen *screen,
{
GdkScreenWayland *screen_wayland = GDK_SCREEN_WAYLAND (screen);
- g_return_val_if_fail (monitor_num < screen_wayland->n_monitors, -1);
-
return screen_wayland->monitors[monitor_num].height_mm;
}
@@ -242,8 +238,6 @@ gdk_wayland_screen_get_monitor_plug_name (GdkScreen *screen,
{
GdkScreenWayland *screen_wayland = GDK_SCREEN_WAYLAND (screen);
- g_return_val_if_fail (monitor_num < screen_wayland->n_monitors, NULL);
-
return g_strdup (screen_wayland->monitors[monitor_num].output_name);
}
@@ -254,8 +248,6 @@ gdk_wayland_screen_get_monitor_geometry (GdkScreen *screen,
{
GdkScreenWayland *screen_wayland = GDK_SCREEN_WAYLAND (screen);
- g_return_if_fail (monitor_num < screen_wayland->n_monitors);
-
if (dest)
*dest = screen_wayland->monitors[monitor_num].geometry;
}
diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c
index 650336b..6a74636 100644
--- a/gdk/x11/gdkscreen-x11.c
+++ b/gdk/x11/gdkscreen-x11.c
@@ -213,8 +213,6 @@ gdk_x11_screen_get_monitor_width_mm (GdkScreen *screen,
{
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
- g_return_val_if_fail (monitor_num < x11_screen->n_monitors, -1);
-
return x11_screen->monitors[monitor_num].width_mm;
}
@@ -224,8 +222,6 @@ gdk_x11_screen_get_monitor_height_mm (GdkScreen *screen,
{
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
- g_return_val_if_fail (monitor_num < x11_screen->n_monitors, -1);
-
return x11_screen->monitors[monitor_num].height_mm;
}
@@ -235,8 +231,6 @@ gdk_x11_screen_get_monitor_plug_name (GdkScreen *screen,
{
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
- g_return_val_if_fail (monitor_num < x11_screen->n_monitors, NULL);
-
return g_strdup (x11_screen->monitors[monitor_num].output_name);
}
@@ -273,8 +267,6 @@ gdk_x11_screen_get_monitor_geometry (GdkScreen *screen,
{
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
- g_return_if_fail (monitor_num < x11_screen->n_monitors);
-
if (dest)
*dest = x11_screen->monitors[monitor_num].geometry;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]