Drop gdk_display_get_monitor_at_point

This api expects global coordinates, and
is unused.
This commit is contained in:
Matthias Clasen 2019-05-29 05:50:48 +00:00
parent a8899cc6a3
commit 879f22fd27
4 changed files with 2 additions and 80 deletions

View File

@ -95,7 +95,6 @@ gdk_display_list_seats
gdk_display_get_n_monitors
gdk_display_get_monitor
gdk_display_get_primary_monitor
gdk_display_get_monitor_at_point
gdk_display_get_monitor_at_surface
gdk_display_get_clipboard
gdk_display_get_primary_clipboard

View File

@ -1614,66 +1614,6 @@ gdk_display_get_primary_monitor (GdkDisplay *display)
return GDK_DISPLAY_GET_CLASS (display)->get_primary_monitor (display);
}
/**
* gdk_display_get_monitor_at_point:
* @display: a #GdkDisplay
* @x: the x coordinate of the point
* @y: the y coordinate of the point
*
* Gets the monitor in which the point (@x, @y) is located,
* or a nearby monitor if the point is not in any monitor.
*
* Returns: (transfer none): the monitor containing the point
*/
GdkMonitor *
gdk_display_get_monitor_at_point (GdkDisplay *display,
int x,
int y)
{
GdkMonitor *nearest = NULL;
int nearest_dist = G_MAXINT;
int n_monitors, i;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
n_monitors = gdk_display_get_n_monitors (display);
for (i = 0; i < n_monitors; i++)
{
GdkMonitor *monitor;
GdkRectangle geometry;
int dist_x, dist_y, dist;
monitor = gdk_display_get_monitor (display, i);
gdk_monitor_get_geometry (monitor, &geometry);
if (x < geometry.x)
dist_x = geometry.x - x;
else if (geometry.x + geometry.width <= x)
dist_x = x - (geometry.x + geometry.width) + 1;
else
dist_x = 0;
if (y < geometry.y)
dist_y = geometry.y - y;
else if (geometry.y + geometry.height <= y)
dist_y = y - (geometry.y + geometry.height) + 1;
else
dist_y = 0;
dist = dist_x + dist_y;
if (dist < nearest_dist)
{
nearest_dist = dist;
nearest = monitor;
}
if (nearest_dist == 0)
break;
}
return nearest;
}
/**
* gdk_display_get_monitor_at_surface:
* @display: a #GdkDisplay
@ -1727,12 +1667,7 @@ gdk_display_get_monitor_at_surface (GdkDisplay *display,
}
}
if (best)
return best;
return gdk_display_get_monitor_at_point (display,
win.x + win.width / 2,
win.y + win.height / 2);
return best;
}
void

View File

@ -114,10 +114,6 @@ GdkMonitor * gdk_display_get_monitor (GdkDisplay *display,
GDK_AVAILABLE_IN_ALL
GdkMonitor * gdk_display_get_primary_monitor (GdkDisplay *display);
GDK_AVAILABLE_IN_ALL
GdkMonitor * gdk_display_get_monitor_at_point (GdkDisplay *display,
int x,
int y);
GDK_AVAILABLE_IN_ALL
GdkMonitor * gdk_display_get_monitor_at_surface (GdkDisplay *display,
GdkSurface *surface);

View File

@ -146,8 +146,6 @@ get_monitor_for_rect (GdkDisplay *display,
GdkMonitor *monitor;
GdkRectangle workarea;
GdkRectangle intersection;
gint x;
gint y;
gint i;
for (i = 0; i < gdk_display_get_n_monitors (display); i++)
@ -165,13 +163,7 @@ get_monitor_for_rect (GdkDisplay *display,
}
}
if (best_monitor)
return best_monitor;
x = rect->x + rect->width / 2;
y = rect->y + rect->height / 2;
return gdk_display_get_monitor_at_point (display, x, y);
return best_monitor;
}
static gint