Commit 3f8461b7 authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen
Browse files

Add pointer warping to GDK. (#160437)

2005-01-18  Matthias Clasen  <mclasen@redhat.com>

	* gdk/gdkdisplay.h:
	* gdk/x11/gdkwindow-x11.c (gdk_display_warp_pointer):
	* gdk/win32/gdkwindow-win32.c (gdk_display_warp_pointer): Add
	pointer warping to GDK.  (#160437)

	* gtk/gtkcolorsel.c (key_press): Use gdk_display_warp_pointer.
parent 37e2d4d8
2005-01-18 Matthias Clasen <mclasen@redhat.com>
* gdk/gdkdisplay.h:
* gdk/x11/gdkwindow-x11.c (gdk_display_warp_pointer):
* gdk/win32/gdkwindow-win32.c (gdk_display_warp_pointer): Add
pointer warping to GDK. (#160437)
* gtk/gtkcolorsel.c (key_press): Use gdk_display_warp_pointer.
2005-01-18 Matthias Clasen <mclasen@redhat.com> 2005-01-18 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkstyle.c (gtk_default_draw_check) * gtk/gtkstyle.c (gtk_default_draw_check)
......
2005-01-18 Matthias Clasen <mclasen@redhat.com>
* gdk/gdkdisplay.h:
* gdk/x11/gdkwindow-x11.c (gdk_display_warp_pointer):
* gdk/win32/gdkwindow-win32.c (gdk_display_warp_pointer): Add
pointer warping to GDK. (#160437)
* gtk/gtkcolorsel.c (key_press): Use gdk_display_warp_pointer.
2005-01-18 Matthias Clasen <mclasen@redhat.com> 2005-01-18 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkstyle.c (gtk_default_draw_check) * gtk/gtkstyle.c (gtk_default_draw_check)
......
2005-01-18 Matthias Clasen <mclasen@redhat.com>
* gdk/gdkdisplay.h:
* gdk/x11/gdkwindow-x11.c (gdk_display_warp_pointer):
* gdk/win32/gdkwindow-win32.c (gdk_display_warp_pointer): Add
pointer warping to GDK. (#160437)
* gtk/gtkcolorsel.c (key_press): Use gdk_display_warp_pointer.
2005-01-18 Matthias Clasen <mclasen@redhat.com> 2005-01-18 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkstyle.c (gtk_default_draw_check) * gtk/gtkstyle.c (gtk_default_draw_check)
......
...@@ -98,6 +98,7 @@ gdk_display_supports_cursor_alpha ...@@ -98,6 +98,7 @@ gdk_display_supports_cursor_alpha
gdk_display_supports_cursor_color gdk_display_supports_cursor_color
gdk_display_supports_selection_notification gdk_display_supports_selection_notification
gdk_display_sync gdk_display_sync
gdk_display_warp_pointer
gdk_drag_abort gdk_drag_abort
gdk_drag_action_get_type G_GNUC_CONST gdk_drag_action_get_type G_GNUC_CONST
gdk_drag_begin gdk_drag_begin
......
...@@ -154,6 +154,10 @@ void gdk_display_get_pointer (GdkDisplay *disp ...@@ -154,6 +154,10 @@ void gdk_display_get_pointer (GdkDisplay *disp
GdkWindow * gdk_display_get_window_at_pointer (GdkDisplay *display, GdkWindow * gdk_display_get_window_at_pointer (GdkDisplay *display,
gint *win_x, gint *win_x,
gint *win_y); gint *win_y);
void gdk_display_warp_pointer (GdkDisplay *display,
GdkScreen *screen,
gint x,
gint y);
GdkDisplayPointerHooks *gdk_display_set_pointer_hooks (GdkDisplay *display, GdkDisplayPointerHooks *gdk_display_set_pointer_hooks (GdkDisplay *display,
const GdkDisplayPointerHooks *new_hooks); const GdkDisplayPointerHooks *new_hooks);
......
...@@ -2140,6 +2140,15 @@ _gdk_windowing_get_pointer (GdkDisplay *display, ...@@ -2140,6 +2140,15 @@ _gdk_windowing_get_pointer (GdkDisplay *display,
_gdk_windowing_window_get_pointer (display, root_window, x, y, mask); _gdk_windowing_window_get_pointer (display, root_window, x, y, mask);
} }
void
gdk_display_warp_pointer (GdkDisplay *display,
GdkScreen *screen,
gint x,
gint y)
{
SetCursorPos (x, y);
}
GdkWindow* GdkWindow*
_gdk_windowing_window_at_pointer (GdkDisplay *display, _gdk_windowing_window_at_pointer (GdkDisplay *display,
gint *win_x, gint *win_x,
......
...@@ -3265,6 +3265,42 @@ _gdk_windowing_window_get_pointer (GdkDisplay *display, ...@@ -3265,6 +3265,42 @@ _gdk_windowing_window_get_pointer (GdkDisplay *display,
return return_val; return return_val;
} }
/**
* gdk_display_warp_pointer:
* @display: a #GdkDisplay
* @screen: the screen of @display to warp the pointer to
* @x: the x coordinate of the destination
* @y: the y coordinate of the destination
*
* Warps the pointer of @display to the point @x,@y on
* the screen @screen, unless the pointer is confined
* to a window by a grab, in which case it will be moved
* as far as allowed by the grab. Warping the pointer
* creates events as if the user had moved the mouse
* instantaneously to the destination.
*
* Note that the pointer should normally be under the
* control of the user. This function was added to cover
* some rare use cases like keyboard navigation support
* for the color picker in the #GtkColorSelectionDialog.
*
* Since: 2.8
*/
void
gdk_display_warp_pointer (GdkDisplay *display,
GdkScreen *screen,
gint x,
gint y)
{
Display *xdisplay;
Window dest;
xdisplay = GDK_DISPLAY_XDISPLAY (display);
dest = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (screen));
XWarpPointer (xdisplay, None, dest, 0, 0, 0, 0, x, y);
}
GdkWindow* GdkWindow*
_gdk_windowing_window_at_pointer (GdkDisplay *display, _gdk_windowing_window_at_pointer (GdkDisplay *display,
gint *win_x, gint *win_x,
......
...@@ -63,14 +63,6 @@ ...@@ -63,14 +63,6 @@
#include <string.h> #include <string.h>
#ifdef GDK_WINDOWING_X11
#include <X11/Xlib.h>
#include "x11/gdkx.h"
#elif defined GDK_WINDOWING_WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
/* Number of elements in the custom palatte */ /* Number of elements in the custom palatte */
#define GTK_CUSTOM_PALETTE_WIDTH 10 #define GTK_CUSTOM_PALETTE_WIDTH 10
#define GTK_CUSTOM_PALETTE_HEIGHT 2 #define GTK_CUSTOM_PALETTE_HEIGHT 2
...@@ -1283,10 +1275,13 @@ key_press (GtkWidget *invisible, ...@@ -1283,10 +1275,13 @@ key_press (GtkWidget *invisible,
gpointer data) gpointer data)
{ {
GdkDisplay *display = gtk_widget_get_display (invisible); GdkDisplay *display = gtk_widget_get_display (invisible);
GdkScreen *screen = gdk_event_get_screen ((GdkEvent *)event);
guint state = event->state & gtk_accelerator_get_default_mod_mask (); guint state = event->state & gtk_accelerator_get_default_mod_mask ();
gint x, y; gint x, y;
gint dx, dy; gint dx, dy;
gdk_display_get_pointer (display, NULL, &x, &y, NULL);
dx = 0; dx = 0;
dy = 0; dy = 0;
...@@ -1296,10 +1291,7 @@ key_press (GtkWidget *invisible, ...@@ -1296,10 +1291,7 @@ key_press (GtkWidget *invisible,
case GDK_Return: case GDK_Return:
case GDK_KP_Enter: case GDK_KP_Enter:
case GDK_KP_Space: case GDK_KP_Space:
gdk_display_get_pointer (display, grab_color_at_mouse (screen, x, y, data);
NULL, &x, &y, NULL);
grab_color_at_mouse (gdk_event_get_screen ((GdkEvent *)event),
x, y, data);
/* fall through */ /* fall through */
case GDK_Escape: case GDK_Escape:
...@@ -1340,16 +1332,7 @@ key_press (GtkWidget *invisible, ...@@ -1340,16 +1332,7 @@ key_press (GtkWidget *invisible,
return FALSE; return FALSE;
} }
#ifdef GDK_WINDOWING_X11 gdk_display_warp_pointer (display, screen, x + dx, y + dy);
XWarpPointer (gdk_x11_display_get_xdisplay (display),
None, None, 0, 0, 0, 0, dx, dy);
#elif defined GDK_WINDOWING_WIN32
{
POINT point;
if (GetCursorPos (&point))
SetCursorPos (point.x + dx, point.y + dy);
}
#endif
return TRUE; return TRUE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment