API: gdk: Make gdk_display_get_window_at_device_position() a device API

It's now called gdk_device_get_window_at_position(). It doesn't make
sense to keep device-specific API part of the display.
This commit is contained in:
Benjamin Otte 2010-12-27 18:45:39 +01:00
parent 0c285341a9
commit 9746991548
9 changed files with 52 additions and 56 deletions

View File

@ -126,7 +126,6 @@ gdk_display_set_double_click_distance
gdk_display_get_pointer gdk_display_get_pointer
gdk_display_list_devices gdk_display_list_devices
gdk_display_get_window_at_pointer gdk_display_get_window_at_pointer
gdk_display_get_window_at_device_position
GdkDisplayPointerHooks GdkDisplayPointerHooks
gdk_display_set_pointer_hooks gdk_display_set_pointer_hooks
GdkDisplayDeviceHooks GdkDisplayDeviceHooks
@ -705,6 +704,7 @@ gdk_device_ungrab
<SUBSECTION> <SUBSECTION>
gdk_device_get_state gdk_device_get_state
gdk_device_get_position gdk_device_get_position
gdk_device_get_window_at_position
gdk_device_get_history gdk_device_get_history
gdk_device_free_history gdk_device_free_history
GdkTimeCoord GdkTimeCoord

View File

@ -63,6 +63,7 @@ gdk_device_get_position
gdk_device_get_source gdk_device_get_source
gdk_device_get_state gdk_device_get_state
gdk_device_get_type G_GNUC_CONST gdk_device_get_type G_GNUC_CONST
gdk_device_get_window_at_position
gdk_device_grab gdk_device_grab
gdk_device_grab_info_libgtk_only gdk_device_grab_info_libgtk_only
gdk_device_list_axes gdk_device_list_axes
@ -97,7 +98,6 @@ gdk_display_get_n_screens
gdk_display_get_pointer gdk_display_get_pointer
gdk_display_get_screen gdk_display_get_screen
gdk_display_get_type G_GNUC_CONST gdk_display_get_type G_GNUC_CONST
gdk_display_get_window_at_device_position
gdk_display_get_window_at_pointer gdk_display_get_window_at_pointer
gdk_display_has_pending gdk_display_has_pending
gdk_display_is_closed gdk_display_is_closed

View File

@ -435,6 +435,45 @@ gdk_device_get_position (GdkDevice *device,
*y = tmp_y; *y = tmp_y;
} }
/**
* gdk_device_get_window_at_position:
* @device: pointer #GdkDevice to query info to.
* @win_x: (out) (allow-none): return location for the X coordinate of the device location,
* relative to the window origin, or %NULL.
* @win_y: (out) (allow-none): return location for the Y coordinate of the device location,
* relative to the window origin, or %NULL.
*
* Obtains the window underneath @device, returning the location of the device in @win_x and @win_y. Returns
* %NULL if the window tree under @device is not known to GDK (for example, belongs to another application).
*
* Returns: (transfer none): the #GdkWindow under the device position, or %NULL.
*
* Since: 3.0
**/
GdkWindow *
gdk_device_get_window_at_position (GdkDevice *device,
gint *win_x,
gint *win_y)
{
GdkDisplay *display;
gint tmp_x, tmp_y;
GdkWindow *window;
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, NULL);
display = gdk_device_get_display (device);
window = display->device_hooks->window_at_device_position (display, device, &tmp_x, &tmp_y);
if (win_x)
*win_x = tmp_x;
if (win_y)
*win_y = tmp_y;
return window;
}
/** /**
* gdk_device_get_history: * gdk_device_get_history:
* @device: a #GdkDevice * @device: a #GdkDevice

View File

@ -193,6 +193,11 @@ void gdk_device_get_position (GdkDevice *device,
GdkScreen **screen, GdkScreen **screen,
gint *x, gint *x,
gint *y); gint *y);
GdkWindow *
gdk_device_get_window_at_position
(GdkDevice *device,
gint *win_x,
gint *win_y);
gboolean gdk_device_get_history (GdkDevice *device, gboolean gdk_device_get_history (GdkDevice *device,
GdkWindow *window, GdkWindow *window,
guint32 start, guint32 start,

View File

@ -696,45 +696,6 @@ _gdk_display_enable_motion_hints (GdkDisplay *display,
} }
} }
/**
* gdk_display_get_window_at_device_position:
* @display: a #GdkDisplay.
* @device: pointer #GdkDevice to query info to.
* @win_x: (out) (allow-none): return location for the X coordinate of the device location,
* relative to the window origin, or %NULL.
* @win_y: (out) (allow-none): return location for the Y coordinate of the device location,
* relative to the window origin, or %NULL.
*
* Obtains the window underneath @device, returning the location of the device in @win_x and @win_y. Returns
* %NULL if the window tree under @device is not known to GDK (for example, belongs to another application).
*
* Returns: (transfer none): the #GdkWindow under the device position, or %NULL.
*
* Since: 3.0
**/
GdkWindow *
gdk_display_get_window_at_device_position (GdkDisplay *display,
GdkDevice *device,
gint *win_x,
gint *win_y)
{
gint tmp_x, tmp_y;
GdkWindow *window;
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, NULL);
window = display->device_hooks->window_at_device_position (display, device, &tmp_x, &tmp_y);
if (win_x)
*win_x = tmp_x;
if (win_y)
*win_y = tmp_y;
return window;
}
/** /**
* gdk_display_set_device_hooks: * gdk_display_set_device_hooks:
* @display: a #GdkDisplay. * @display: a #GdkDisplay.
@ -890,7 +851,7 @@ gdk_window_real_window_get_device_position (GdkDisplay *display,
* *
* Since: 2.2 * Since: 2.2
* *
* Deprecated: 3.0: Use gdk_display_get_window_at_device_position() instead. * Deprecated: 3.0: Use gdk_device_get_window_at_position() instead.
**/ **/
GdkWindow * GdkWindow *
gdk_display_get_window_at_pointer (GdkDisplay *display, gdk_display_get_window_at_pointer (GdkDisplay *display,
@ -899,7 +860,7 @@ gdk_display_get_window_at_pointer (GdkDisplay *display,
{ {
g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL); g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
return gdk_display_get_window_at_device_position (display, display->core_pointer, win_x, win_y); return gdk_device_get_window_at_position (display->core_pointer, win_x, win_y);
} }
static void static void

View File

@ -191,11 +191,6 @@ GdkDisplayPointerHooks *gdk_display_set_pointer_hooks (GdkDisplay
#endif /* GDK_DISABLE_DEPRECATED */ #endif /* GDK_DISABLE_DEPRECATED */
#endif /* GDK_MULTIDEVICE_SAFE */ #endif /* GDK_MULTIDEVICE_SAFE */
GdkWindow * gdk_display_get_window_at_device_position (GdkDisplay *display,
GdkDevice *device,
gint *win_x,
gint *win_y);
GdkDisplayDeviceHooks *gdk_display_set_device_hooks (GdkDisplay *display, GdkDisplayDeviceHooks *gdk_display_set_device_hooks (GdkDisplay *display,
const GdkDisplayDeviceHooks *new_hooks); const GdkDisplayDeviceHooks *new_hooks);

View File

@ -4951,8 +4951,7 @@ gdk_window_get_pointer (GdkWindow *window,
* corner of @window. * corner of @window.
* *
* Return value: (transfer none): The window underneath @device (as with * Return value: (transfer none): The window underneath @device (as with
* gdk_display_get_window_at_device_position()), or %NULL if the * gdk_device_get_window_at_position()), or %NULL if the window is not known to GDK.
* window is not known to GDK.
* *
* Since: 3.0 * Since: 3.0
**/ **/
@ -5007,7 +5006,7 @@ gdk_window_get_device_position (GdkWindow *window,
* *
* Return value: (transfer none): window under the mouse pointer * Return value: (transfer none): window under the mouse pointer
* *
* Deprecated: 3.0: Use gdk_display_get_window_at_device_position() instead. * Deprecated: 3.0: Use gdk_device_get_window_at_position() instead.
**/ **/
GdkWindow* GdkWindow*
gdk_window_at_pointer (gint *win_x, gdk_window_at_pointer (gint *win_x,

View File

@ -1710,8 +1710,7 @@ grab_color_at_pointer (GdkScreen *screen,
if (!pixbuf) if (!pixbuf)
{ {
gint x, y; gint x, y;
GdkDisplay *display = gdk_screen_get_display (screen); GdkWindow *window = gdk_device_get_window_at_position (device, &x, &y);
GdkWindow *window = gdk_display_get_window_at_device_position (display, device, &x, &y);
if (!window) if (!window)
return; return;
pixbuf = gdk_pixbuf_get_from_window (window, pixbuf = gdk_pixbuf_get_from_window (window,

View File

@ -536,9 +536,7 @@ gtk_tooltip_trigger_tooltip_query (GdkDisplay *display)
/* Trigger logic as if the mouse moved */ /* Trigger logic as if the mouse moved */
device = gdk_device_manager_get_client_pointer (gdk_display_get_device_manager (display)); device = gdk_device_manager_get_client_pointer (gdk_display_get_device_manager (display));
window = gdk_display_get_window_at_device_position (display, window = gdk_device_get_window_at_position (device, &x, &y);
device,
&x, &y);
if (!window) if (!window)
return; return;