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.
This commit is contained in:
Matthias Clasen 2005-01-18 20:59:31 +00:00 committed by Matthias Clasen
parent 37e2d4d892
commit 3f8461b769
8 changed files with 82 additions and 22 deletions

View File

@ -1,3 +1,12 @@
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>
* gtk/gtkstyle.c (gtk_default_draw_check)

View File

@ -1,3 +1,12 @@
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>
* gtk/gtkstyle.c (gtk_default_draw_check)

View File

@ -1,3 +1,12 @@
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>
* gtk/gtkstyle.c (gtk_default_draw_check)

View File

@ -98,6 +98,7 @@ gdk_display_supports_cursor_alpha
gdk_display_supports_cursor_color
gdk_display_supports_selection_notification
gdk_display_sync
gdk_display_warp_pointer
gdk_drag_abort
gdk_drag_action_get_type G_GNUC_CONST
gdk_drag_begin

View File

@ -154,6 +154,10 @@ void gdk_display_get_pointer (GdkDisplay *disp
GdkWindow * gdk_display_get_window_at_pointer (GdkDisplay *display,
gint *win_x,
gint *win_y);
void gdk_display_warp_pointer (GdkDisplay *display,
GdkScreen *screen,
gint x,
gint y);
GdkDisplayPointerHooks *gdk_display_set_pointer_hooks (GdkDisplay *display,
const GdkDisplayPointerHooks *new_hooks);

View File

@ -2140,6 +2140,15 @@ _gdk_windowing_get_pointer (GdkDisplay *display,
_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*
_gdk_windowing_window_at_pointer (GdkDisplay *display,
gint *win_x,

View File

@ -3265,6 +3265,42 @@ _gdk_windowing_window_get_pointer (GdkDisplay *display,
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*
_gdk_windowing_window_at_pointer (GdkDisplay *display,
gint *win_x,

View File

@ -63,14 +63,6 @@
#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 */
#define GTK_CUSTOM_PALETTE_WIDTH 10
#define GTK_CUSTOM_PALETTE_HEIGHT 2
@ -1283,10 +1275,13 @@ key_press (GtkWidget *invisible,
gpointer data)
{
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 ();
gint x, y;
gint dx, dy;
gdk_display_get_pointer (display, NULL, &x, &y, NULL);
dx = 0;
dy = 0;
@ -1296,10 +1291,7 @@ key_press (GtkWidget *invisible,
case GDK_Return:
case GDK_KP_Enter:
case GDK_KP_Space:
gdk_display_get_pointer (display,
NULL, &x, &y, NULL);
grab_color_at_mouse (gdk_event_get_screen ((GdkEvent *)event),
x, y, data);
grab_color_at_mouse (screen, x, y, data);
/* fall through */
case GDK_Escape:
@ -1340,16 +1332,7 @@ key_press (GtkWidget *invisible,
return FALSE;
}
#ifdef GDK_WINDOWING_X11
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
gdk_display_warp_pointer (display, screen, x + dx, y + dy);
return TRUE;