mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-10 02:40:11 +00:00
API: gdk: gdk_display_get_device_state() => gdk_device_get_position()
The API was not display-specific, but belonged to the device. Also, we didn't find a user of the modifier mask, so we dropped it.
This commit is contained in:
parent
586283ecbb
commit
0c285341a9
@ -124,7 +124,6 @@ gdk_display_add_client_message_filter
|
||||
gdk_display_set_double_click_time
|
||||
gdk_display_set_double_click_distance
|
||||
gdk_display_get_pointer
|
||||
gdk_display_get_device_state
|
||||
gdk_display_list_devices
|
||||
gdk_display_get_window_at_pointer
|
||||
gdk_display_get_window_at_device_position
|
||||
@ -705,6 +704,7 @@ gdk_device_ungrab
|
||||
|
||||
<SUBSECTION>
|
||||
gdk_device_get_state
|
||||
gdk_device_get_position
|
||||
gdk_device_get_history
|
||||
gdk_device_free_history
|
||||
GdkTimeCoord
|
||||
|
@ -59,6 +59,7 @@ gdk_device_get_mode
|
||||
gdk_device_get_name
|
||||
gdk_device_get_n_axes
|
||||
gdk_device_get_n_keys
|
||||
gdk_device_get_position
|
||||
gdk_device_get_source
|
||||
gdk_device_get_state
|
||||
gdk_device_get_type G_GNUC_CONST
|
||||
@ -89,7 +90,6 @@ gdk_display_get_default_cursor_size
|
||||
gdk_display_get_default_group
|
||||
gdk_display_get_default_screen
|
||||
gdk_display_get_device_manager
|
||||
gdk_display_get_device_state
|
||||
gdk_display_get_event
|
||||
gdk_display_get_maximal_cursor_size
|
||||
gdk_display_get_name
|
||||
|
@ -398,6 +398,43 @@ gdk_device_get_state (GdkDevice *device,
|
||||
GDK_DEVICE_GET_CLASS (device)->get_state (device, window, axes, mask);
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_device_get_position:
|
||||
* @device: pointer device to query status about.
|
||||
* @screen: (out) (transfer none) (allow-none): location to store the #GdkScreen
|
||||
* the @device is on, or %NULL.
|
||||
* @x: (out) (allow-none): location to store root window X coordinate of @device, or %NULL.
|
||||
* @y: (out) (allow-none): location to store root window Y coordinate of @device, or %NULL.
|
||||
*
|
||||
* Gets the current location of @device.
|
||||
*
|
||||
* Since: 3.0
|
||||
**/
|
||||
void
|
||||
gdk_device_get_position (GdkDevice *device,
|
||||
GdkScreen **screen,
|
||||
gint *x,
|
||||
gint *y)
|
||||
{
|
||||
GdkScreen *tmp_screen;
|
||||
GdkDisplay *display;
|
||||
gint tmp_x, tmp_y;
|
||||
GdkModifierType tmp_mask;
|
||||
|
||||
g_return_if_fail (GDK_IS_DEVICE (device));
|
||||
g_return_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD);
|
||||
|
||||
display = gdk_device_get_display (device);
|
||||
display->device_hooks->get_device_state (display, device, &tmp_screen, &tmp_x, &tmp_y, &tmp_mask);
|
||||
|
||||
if (screen)
|
||||
*screen = tmp_screen;
|
||||
if (x)
|
||||
*x = tmp_x;
|
||||
if (y)
|
||||
*y = tmp_y;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_device_get_history:
|
||||
* @device: a #GdkDevice
|
||||
|
@ -189,6 +189,10 @@ void gdk_device_get_state (GdkDevice *device,
|
||||
GdkWindow *window,
|
||||
gdouble *axes,
|
||||
GdkModifierType *mask);
|
||||
void gdk_device_get_position (GdkDevice *device,
|
||||
GdkScreen **screen,
|
||||
gint *x,
|
||||
gint *y);
|
||||
gboolean gdk_device_get_history (GdkDevice *device,
|
||||
GdkWindow *window,
|
||||
guint32 start,
|
||||
|
@ -696,48 +696,6 @@ _gdk_display_enable_motion_hints (GdkDisplay *display,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_display_get_device_state:
|
||||
* @display: a #GdkDisplay.
|
||||
* @device: pointer device to query status about.
|
||||
* @screen: (out) (transfer none) (allow-none): location to store the #GdkScreen
|
||||
* the @device is on, or %NULL.
|
||||
* @x: (out) (allow-none): location to store root window X coordinate of @device, or %NULL.
|
||||
* @y: (out) (allow-none): location to store root window Y coordinate of @device, or %NULL.
|
||||
* @mask: (out) (allow-none): location to store current modifier mask for @device, or %NULL.
|
||||
*
|
||||
* Gets the current location and state of @device for a given display.
|
||||
*
|
||||
* Since: 3.0
|
||||
**/
|
||||
void
|
||||
gdk_display_get_device_state (GdkDisplay *display,
|
||||
GdkDevice *device,
|
||||
GdkScreen **screen,
|
||||
gint *x,
|
||||
gint *y,
|
||||
GdkModifierType *mask)
|
||||
{
|
||||
GdkScreen *tmp_screen;
|
||||
gint tmp_x, tmp_y;
|
||||
GdkModifierType tmp_mask;
|
||||
|
||||
g_return_if_fail (GDK_IS_DISPLAY (display));
|
||||
g_return_if_fail (GDK_IS_DEVICE (device));
|
||||
g_return_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD);
|
||||
|
||||
display->device_hooks->get_device_state (display, device, &tmp_screen, &tmp_x, &tmp_y, &tmp_mask);
|
||||
|
||||
if (screen)
|
||||
*screen = tmp_screen;
|
||||
if (x)
|
||||
*x = tmp_x;
|
||||
if (y)
|
||||
*y = tmp_y;
|
||||
if (mask)
|
||||
*mask = tmp_mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_display_get_window_at_device_position:
|
||||
* @display: a #GdkDisplay.
|
||||
@ -822,7 +780,7 @@ gdk_display_set_device_hooks (GdkDisplay *display,
|
||||
*
|
||||
* Since: 2.2
|
||||
*
|
||||
* Deprecated: 3.0: Use gdk_display_get_device_state() instead.
|
||||
* Deprecated: 3.0: Use gdk_device_get_position() instead.
|
||||
**/
|
||||
void
|
||||
gdk_display_get_pointer (GdkDisplay *display,
|
||||
@ -831,9 +789,26 @@ gdk_display_get_pointer (GdkDisplay *display,
|
||||
gint *y,
|
||||
GdkModifierType *mask)
|
||||
{
|
||||
GdkScreen *tmp_screen;
|
||||
gint tmp_x, tmp_y;
|
||||
GdkModifierType tmp_mask;
|
||||
|
||||
g_return_if_fail (GDK_IS_DISPLAY (display));
|
||||
|
||||
gdk_display_get_device_state (display, display->core_pointer, screen, x, y, mask);
|
||||
/* We call get_device_state here manually instead of gdk_device_get_position()
|
||||
* because we also care about the modifier mask */
|
||||
|
||||
display->device_hooks->get_device_state (display,
|
||||
display->core_pointer,
|
||||
&tmp_screen, &tmp_x, &tmp_y, &tmp_mask);
|
||||
if (screen)
|
||||
*screen = tmp_screen;
|
||||
if (x)
|
||||
*x = tmp_x;
|
||||
if (y)
|
||||
*y = tmp_y;
|
||||
if (mask)
|
||||
*mask = tmp_mask;
|
||||
}
|
||||
|
||||
static GdkWindow *
|
||||
|
@ -191,12 +191,6 @@ GdkDisplayPointerHooks *gdk_display_set_pointer_hooks (GdkDisplay
|
||||
#endif /* GDK_DISABLE_DEPRECATED */
|
||||
#endif /* GDK_MULTIDEVICE_SAFE */
|
||||
|
||||
void gdk_display_get_device_state (GdkDisplay *display,
|
||||
GdkDevice *device,
|
||||
GdkScreen **screen,
|
||||
gint *x,
|
||||
gint *y,
|
||||
GdkModifierType *mask);
|
||||
GdkWindow * gdk_display_get_window_at_device_position (GdkDisplay *display,
|
||||
GdkDevice *device,
|
||||
gint *win_x,
|
||||
|
@ -1804,7 +1804,6 @@ key_press (GtkWidget *invisible,
|
||||
GdkEventKey *event,
|
||||
gpointer data)
|
||||
{
|
||||
GdkDisplay *display = gtk_widget_get_display (invisible);
|
||||
GdkScreen *screen = gdk_event_get_screen ((GdkEvent *) event);
|
||||
GdkDevice *device, *pointer_device;
|
||||
guint state = event->state & gtk_accelerator_get_default_mod_mask ();
|
||||
@ -1813,7 +1812,7 @@ key_press (GtkWidget *invisible,
|
||||
|
||||
device = gdk_event_get_device ((GdkEvent * ) event);
|
||||
pointer_device = gdk_device_get_associated_device (device);
|
||||
gdk_display_get_device_state (display, pointer_device, NULL, &x, &y, NULL);
|
||||
gdk_device_get_position (pointer_device, NULL, &x, &y);
|
||||
|
||||
dx = 0;
|
||||
dy = 0;
|
||||
|
@ -2415,8 +2415,7 @@ gtk_drag_begin_internal (GtkWidget *widget,
|
||||
}
|
||||
else
|
||||
{
|
||||
gdk_display_get_device_state (gtk_widget_get_display (widget), pointer,
|
||||
&info->cur_screen, &info->cur_x, &info->cur_y, NULL);
|
||||
gdk_device_get_position (pointer, &info->cur_screen, &info->cur_x, &info->cur_y);
|
||||
}
|
||||
|
||||
g_signal_emit_by_name (widget, "drag-begin", info->context);
|
||||
@ -4160,10 +4159,7 @@ gtk_drag_motion_cb (GtkWidget *widget,
|
||||
|
||||
if (event->is_hint)
|
||||
{
|
||||
GdkDisplay *display = gtk_widget_get_display (widget);
|
||||
|
||||
gdk_display_get_device_state (display, event->device,
|
||||
&screen, &x_root, &y_root, NULL);
|
||||
gdk_device_get_position (event->device, &screen, &x_root, &y_root);
|
||||
event->x_root = x_root;
|
||||
event->y_root = y_root;
|
||||
}
|
||||
|
@ -1236,10 +1236,9 @@ gtk_handle_box_motion (GtkWidget *widget,
|
||||
new_x = 0;
|
||||
new_y = 0;
|
||||
screen = gtk_widget_get_screen (widget);
|
||||
gdk_display_get_device_state (gdk_screen_get_display (screen),
|
||||
event->device,
|
||||
&pointer_screen,
|
||||
&new_x, &new_y, NULL);
|
||||
gdk_device_get_position (event->device,
|
||||
&pointer_screen,
|
||||
&new_x, &new_y);
|
||||
if (pointer_screen != screen)
|
||||
{
|
||||
new_x = priv->orig_x;
|
||||
|
@ -4497,8 +4497,7 @@ gtk_menu_position (GtkMenu *menu,
|
||||
|
||||
screen = gtk_widget_get_screen (widget);
|
||||
pointer = _gtk_menu_shell_get_grab_device (GTK_MENU_SHELL (menu));
|
||||
gdk_display_get_device_state (gdk_screen_get_display (screen),
|
||||
pointer, &pointer_screen, &x, &y, NULL);
|
||||
gdk_device_get_position (pointer, &pointer_screen, &x, &y);
|
||||
|
||||
/* Get the minimum height for minimum width to figure out
|
||||
* the right place to popup the menu.
|
||||
|
@ -3596,9 +3596,8 @@ gtk_notebook_drag_failed (GtkWidget *widget,
|
||||
gint x, y;
|
||||
|
||||
display = gtk_widget_get_display (widget);
|
||||
gdk_display_get_device_state (gtk_widget_get_display (widget),
|
||||
gdk_drag_context_get_device (context),
|
||||
NULL, &x, &y, NULL);
|
||||
gdk_device_get_position (gdk_drag_context_get_device (context),
|
||||
NULL, &x, &y);
|
||||
|
||||
g_signal_emit (notebook, notebook_signals[CREATE_WINDOW], 0,
|
||||
priv->detached_tab->child, x, y, &dest_notebook);
|
||||
|
@ -6316,9 +6316,9 @@ get_monitor_containing_pointer (GtkWindow *window)
|
||||
device_manager = gdk_display_get_device_manager (display);
|
||||
pointer = gdk_device_manager_get_client_pointer (device_manager);
|
||||
|
||||
gdk_display_get_device_state (display, pointer,
|
||||
&pointer_screen,
|
||||
&px, &py, NULL);
|
||||
gdk_device_get_position (pointer,
|
||||
&pointer_screen,
|
||||
&px, &py);
|
||||
|
||||
if (pointer_screen == window_screen)
|
||||
monitor_num = gdk_screen_get_monitor_at_point (pointer_screen, px, py);
|
||||
@ -6518,9 +6518,9 @@ gtk_window_compute_configure_request (GtkWindow *window,
|
||||
device_manager = gdk_display_get_device_manager (display);
|
||||
pointer = gdk_device_manager_get_client_pointer (device_manager);
|
||||
|
||||
gdk_display_get_device_state (display, pointer,
|
||||
&pointer_screen,
|
||||
&px, &py, NULL);
|
||||
gdk_device_get_position (pointer,
|
||||
&pointer_screen,
|
||||
&px, &py);
|
||||
|
||||
if (pointer_screen == screen)
|
||||
monitor_num = gdk_screen_get_monitor_at_point (screen, px, py);
|
||||
|
Loading…
Reference in New Issue
Block a user