mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 05:50:10 +00:00
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.
This commit is contained in:
parent
94076bc353
commit
1258d17943
@ -294,9 +294,26 @@ gdk_screen_get_monitor_at_point (GdkScreen *screen,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);
|
||||
gint num_monitors, i;
|
||||
|
||||
return GDK_SCREEN_GET_CLASS (screen)->get_monitor_at_point (screen, x,y);
|
||||
g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);
|
||||
|
||||
num_monitors = gdk_screen_get_n_monitors (screen);
|
||||
|
||||
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
|
||||
void (*get_monitor_geometry) (GdkScreen *screen,
|
||||
gint monitor_num,
|
||||
GdkRectangle *dest);
|
||||
gint (*get_monitor_at_point) (GdkScreen *screen,
|
||||
gint x,
|
||||
gint y);
|
||||
};
|
||||
|
||||
GType gdk_screen_get_type (void);
|
||||
|
@ -49,9 +49,6 @@ static gint gdk_screen_x11_get_n_monitors (GdkScreen *scre
|
||||
static void gdk_screen_x11_get_monitor_geometry (GdkScreen *screen,
|
||||
gint num_monitor,
|
||||
GdkRectangle *dest);
|
||||
static gint gdk_screen_x11_get_monitor_at_point (GdkScreen *screen,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
GType gdk_screen_x11_get_type ();
|
||||
static gpointer parent_class = NULL;
|
||||
@ -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_n_monitors = gdk_screen_x11_get_n_monitors;
|
||||
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;
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
@ -259,31 +255,6 @@ gdk_screen_x11_get_monitor_geometry (GdkScreen *screen,
|
||||
*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 *
|
||||
gdk_x11_screen_get_xscreen (GdkScreen *screen)
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ main (int argc, char *argv[])
|
||||
|
||||
num_monitors = gdk_screen_get_n_monitors (screen);
|
||||
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++)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user