Commit 1258d179 authored by Erwann Chenede -'s avatar Erwann Chenede - Committed by Erwann Chenede

make gdk_screen_get_monitor_at_point cross platform instead of backend

2002-05-02 Erwann Chenede - <erwann.chenede@sun.com>

  * gdk/gdkscreen.c (gdk_screen_get_monitor_at_point):
  * gdk/gdkscreen.h :
  * gdk/x11/gdkscreen-x11.c :
  make gdk_screen_get_monitor_at_point cross platform instead
  of backend dependant. #80480
  * tests/testxinerama.c (main):
  changed the warning message.
parent 94076bc3
...@@ -294,9 +294,26 @@ gdk_screen_get_monitor_at_point (GdkScreen *screen, ...@@ -294,9 +294,26 @@ gdk_screen_get_monitor_at_point (GdkScreen *screen,
gint x, gint x,
gint y) gint y)
{ {
gint num_monitors, i;
g_return_val_if_fail (GDK_IS_SCREEN (screen), -1); g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);
num_monitors = gdk_screen_get_n_monitors (screen);
return GDK_SCREEN_GET_CLASS (screen)->get_monitor_at_point (screen, x,y); for (i=0;i<num_monitors;i++)
{
GdkRectangle monitor;
gdk_screen_get_monitor_geometry (screen, i, &monitor);
if (x >= monitor.x &&
x < monitor.x + monitor.width &&
y >= monitor.y &&
y < (monitor.y + monitor.height))
return i;
}
return -1;
} }
/** /**
......
...@@ -65,9 +65,6 @@ struct _GdkScreenClass ...@@ -65,9 +65,6 @@ struct _GdkScreenClass
void (*get_monitor_geometry) (GdkScreen *screen, void (*get_monitor_geometry) (GdkScreen *screen,
gint monitor_num, gint monitor_num,
GdkRectangle *dest); GdkRectangle *dest);
gint (*get_monitor_at_point) (GdkScreen *screen,
gint x,
gint y);
}; };
GType gdk_screen_get_type (void); GType gdk_screen_get_type (void);
......
...@@ -49,9 +49,6 @@ static gint gdk_screen_x11_get_n_monitors (GdkScreen *scre ...@@ -49,9 +49,6 @@ static gint gdk_screen_x11_get_n_monitors (GdkScreen *scre
static void gdk_screen_x11_get_monitor_geometry (GdkScreen *screen, static void gdk_screen_x11_get_monitor_geometry (GdkScreen *screen,
gint num_monitor, gint num_monitor,
GdkRectangle *dest); GdkRectangle *dest);
static gint gdk_screen_x11_get_monitor_at_point (GdkScreen *screen,
gint x,
gint y);
GType gdk_screen_x11_get_type (); GType gdk_screen_x11_get_type ();
static gpointer parent_class = NULL; static gpointer parent_class = NULL;
...@@ -100,7 +97,6 @@ gdk_screen_x11_class_init (GdkScreenX11Class * klass) ...@@ -100,7 +97,6 @@ gdk_screen_x11_class_init (GdkScreenX11Class * klass)
screen_class->get_window_at_pointer = gdk_screen_x11_get_window_at_pointer; screen_class->get_window_at_pointer = gdk_screen_x11_get_window_at_pointer;
screen_class->get_n_monitors = gdk_screen_x11_get_n_monitors; screen_class->get_n_monitors = gdk_screen_x11_get_n_monitors;
screen_class->get_monitor_geometry = gdk_screen_x11_get_monitor_geometry; screen_class->get_monitor_geometry = gdk_screen_x11_get_monitor_geometry;
screen_class->get_monitor_at_point = gdk_screen_x11_get_monitor_at_point;
G_OBJECT_CLASS (klass)->finalize = gdk_screen_x11_finalize; G_OBJECT_CLASS (klass)->finalize = gdk_screen_x11_finalize;
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
...@@ -259,31 +255,6 @@ gdk_screen_x11_get_monitor_geometry (GdkScreen *screen, ...@@ -259,31 +255,6 @@ gdk_screen_x11_get_monitor_geometry (GdkScreen *screen,
*dest = screen_x11->monitors[num_monitor]; *dest = screen_x11->monitors[num_monitor];
} }
static gint
gdk_screen_x11_get_monitor_at_point (GdkScreen *screen,
gint x,
gint y)
{
GdkScreenX11 *screen_x11 = GDK_SCREEN_X11 (screen);
int i;
GdkRectangle *monitor;
g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);
for (i = 0, monitor = screen_x11->monitors;
i < screen_x11->num_monitors;
i++, monitor++)
{
if (x >= monitor->x &&
x < monitor->x + monitor->width &&
y >= monitor->y &&
y < (monitor->y + monitor->height))
return i;
}
return -1;
}
Screen * Screen *
gdk_x11_screen_get_xscreen (GdkScreen *screen) gdk_x11_screen_get_xscreen (GdkScreen *screen)
{ {
......
...@@ -42,7 +42,7 @@ main (int argc, char *argv[]) ...@@ -42,7 +42,7 @@ main (int argc, char *argv[])
num_monitors = gdk_screen_get_n_monitors (screen); num_monitors = gdk_screen_get_n_monitors (screen);
if (num_monitors == 1) if (num_monitors == 1)
g_warning ("The current display does not support xinerama."); g_warning ("The default screen of the current display only has one monitor.");
for (i=0; i<num_monitors; i++) for (i=0; i<num_monitors; i++)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment