This is the mail archive of the cygwin-xfree mailing list for the Cygwin XFree86 project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: cursor warp [+PATCH]

Jon TURNEY wrote:
Tom George wrote:
Cursor warping does not work with the -multiwindow option. It works fine in the single window mode. I saw some vague references to this but nothing to indicate it will be fixed. Are there any plans to fix this?

The first step towards fixing this is a description of the problem that can be understood by someone who isn't in front of your computer :-)

Otherwise, Cygwin/X work great!

> Tom George wrote:
I have an application that uses XWarpPointer to relocate the cursor on the screen. I recognize that this is not recommended protocol but it is very useful for this application.

If cygwin X is started without the -multiwindow option, cursor warping works as expected. However, if the -multiwindow option is included, it seems that all calls to XWarpPointer are ignored. Maybe I am doing something wrong on startup or there is an alternate way to warp the cursor.

I saw that there was some early references to this problem related to positioning the cursor on startup
( but no apparent resolution. If possible, I would like to see the XWarpPointer function work as documented for any windowing configuration.

Much better :-) Even I can understand what the problem is now. (but for some reason your 2nd mail didn't appear on gmane, so I almost missed it)

The 'cursor positioning on startup' issue is subtly different: the X server internally generates a pointer warp at startup to move the pointer to the centre of the screen. XWin takes special steps to ignore this warp, so that merely launching the X server doesn't disrupt what the user was doing.

Attached patch enables XWarpCursor to do something in -multiwindow and -rootless modes.

Also attached is a small application which functions as testcase for this.

Cygwin/X: Allow pointer warping to work in rootless modes

Mouse pointer warping in multiwindow/rootless mode was never implemented,
due to concerns that moving the  mouse pointer without asking might be rude

This patch allows X applications to move the mouse pointer in rootless modes,
Let's hope they don't abuse this privilege ;-)

 xserver/hw/xwin/wincursor.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Index: xorg-server-1.5.3/xserver/hw/xwin/wincursor.c
--- xorg-server-1.5.3.orig/xserver/hw/xwin/wincursor.c	2008-11-05 16:52:16.000000000 +0000
+++ xorg-server-1.5.3/xserver/hw/xwin/wincursor.c	2009-01-12 19:42:54.000000000 +0000
@@ -99,8 +99,16 @@
-  /* Only update the Windows cursor position if we are active */
-  if (pScreenPriv->hwndScreen == GetForegroundWindow ())
+  /*
+     Only update the Windows cursor position if root window is active,
+     or we are in a rootless mode
+  */
+  if ((pScreenPriv->hwndScreen == GetForegroundWindow ())
+      || pScreenPriv->pScreenInfo->fRootless
+      || pScreenPriv->pScreenInfo->fMultiWindow
+      )
       /* Get the client area coordinates */
       GetClientRect (pScreenPriv->hwndScreen, &rcClient);
   Testcase for: Cursor warping

  To compile: 
  gcc -Wall -o test-warp test-warp.c `pkg-config --cflags --libs gtk+-2.0 glib-2.0`

  To use:
  X -multiwindow &
  export DISPLAY=:0
  Press 'Warp' button, cursor should move elsewhere


#include <glib/gprintf.h>
#include <gtk/gtk.h>
#include <gdk/gdkx.h>

GtkWidget *main_window;

static void warp_cursor( GtkWidget *widget,
                         gpointer   data )
  Display *dpy = GDK_DISPLAY();
  XWarpPointer(dpy, None, None, 0,0,0,0, +100,+100);

static void destroy( GtkWidget *widget,
                     gpointer   data )
  gtk_main_quit ();

int main( int   argc,
          char *argv[] )
    GtkWidget *button;
    gtk_init (&argc, &argv);

    main_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_window_set_decorated (GTK_WINDOW(main_window), TRUE);

    g_signal_connect (G_OBJECT (main_window), "destroy",
		      G_CALLBACK (destroy), NULL);
    gtk_container_set_border_width (GTK_CONTAINER (main_window), 10);

    button = gtk_button_new_with_label ("Warp");
    g_signal_connect (G_OBJECT (button), "clicked",
		      G_CALLBACK (warp_cursor), NULL);

    gtk_container_add (GTK_CONTAINER (main_window), button);
    gtk_widget_show (button);
    gtk_widget_show (main_window);

    gtk_main ();
    return 0;

Unsubscribe info:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]