[gtk+] API: gdk: gdk_display_get_device_state() => gdk_device_get_position()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] API: gdk: gdk_display_get_device_state() => gdk_device_get_position()
- Date: Mon, 27 Dec 2010 18:19:55 +0000 (UTC)
commit 0c285341a959ddbaad4ecc75e5f1a1ad66c5274e
Author: Benjamin Otte <otte redhat com>
Date: Mon Dec 27 18:03:38 2010 +0100
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.
docs/reference/gdk/gdk3-sections.txt | 2 +-
gdk/gdk.symbols | 2 +-
gdk/gdkdevice.c | 37 ++++++++++++++++++++
gdk/gdkdevice.h | 4 ++
gdk/gdkdisplay.c | 63 ++++++++++-----------------------
gdk/gdkdisplay.h | 6 ---
gtk/gtkcolorsel.c | 3 +-
gtk/gtkdnd.c | 8 +---
gtk/gtkhandlebox.c | 7 ++--
gtk/gtkmenu.c | 3 +-
gtk/gtknotebook.c | 5 +--
gtk/gtkwindow.c | 12 +++---
12 files changed, 77 insertions(+), 75 deletions(-)
---
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt
index 6aa124d..b1141d6 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -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
diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols
index 7da506b..7545fe2 100644
--- a/gdk/gdk.symbols
+++ b/gdk/gdk.symbols
@@ -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
diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c
index 714c8cd..39af300 100644
--- a/gdk/gdkdevice.c
+++ b/gdk/gdkdevice.c
@@ -399,6 +399,43 @@ gdk_device_get_state (GdkDevice *device,
}
/**
+ * 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
* @window: the window with respect to which which the event coordinates will be reported
diff --git a/gdk/gdkdevice.h b/gdk/gdkdevice.h
index ef142eb..ecce89a 100644
--- a/gdk/gdkdevice.h
+++ b/gdk/gdkdevice.h
@@ -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,
diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c
index a3dd068..e7f7fc5 100644
--- a/gdk/gdkdisplay.c
+++ b/gdk/gdkdisplay.c
@@ -697,48 +697,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.
* @device: pointer #GdkDevice to query info to.
@@ -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 *
diff --git a/gdk/gdkdisplay.h b/gdk/gdkdisplay.h
index bda19c2..100b9c3 100644
--- a/gdk/gdkdisplay.h
+++ b/gdk/gdkdisplay.h
@@ -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,
diff --git a/gtk/gtkcolorsel.c b/gtk/gtkcolorsel.c
index 8f90a89..b6a4e4e 100644
--- a/gtk/gtkcolorsel.c
+++ b/gtk/gtkcolorsel.c
@@ -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;
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index 48d726b..bb90456 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -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;
}
diff --git a/gtk/gtkhandlebox.c b/gtk/gtkhandlebox.c
index 0c2ca50..ef458d4 100644
--- a/gtk/gtkhandlebox.c
+++ b/gtk/gtkhandlebox.c
@@ -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;
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index 67f3083..cb203e8 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -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.
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index ee8f451..742662d 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -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);
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index c21e0d3..78a2a62 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]