This is the mail archive of the cygwin-xfree@cygwin.com 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]

[patch] cursor


Hi again Harold,

Here is another patch. It's about the windows mouse cursor.
- It maybe just a matter of preferences but for me, I prefer if the windows cursor is hidden in the client area of X if it isn't active. I personnally find it ugly to have two mouse cursors on top of each other :p. It's then not necessary to show/hide the mouse upon (de)activation. This simplifies the code a bit.
- Moreover, the cursor state is global to the application, not to each window. So I made fCursor a global variable, which simplifies the code more (doesn't care about ScreenPrivLast anymore). Potentially, we could get rid of fCursor altogether by using GetCursorInfo instead (don't know about performance issues though).
- Last, WM_NCMOUSEMOVE calls the default winproc. This should fix the min/max/close button highlight problem on WinXP (Although I don't have XP so I can't test)

Jehan

--- xc/programs/Xserver/hw/xwin.orig/InitOutput.c	2002-06-07 20:19:20.000000000 -0700
+++ xc/programs/Xserver/hw/xwin/InitOutput.c	2002-06-08 15:38:24.000000000 -0700
@@ -32,6 +32,7 @@
 
 int		g_iNumScreens = 0;
 winScreenInfo	g_ScreenInfo[MAXSCREENS];
+Bool		g_fCursor;
 int		g_iLastScreen = -1;
 int		g_fdMessageQueue = WIN_FD_INVALID;
 int		g_iScreenPrivateIndex = -1;
@@ -188,6 +189,9 @@
        */
       g_iNumScreens = 1;
       g_iLastScreen = 0;
+      
+      /* Windows cursor is visible by default */
+      g_fCursor = TRUE; 
     }
 }
 
--- xc/programs/Xserver/hw/xwin.orig/win.h	2002-06-07 18:37:28.000000000 -0700
+++ xc/programs/Xserver/hw/xwin/win.h	2002-06-08 15:27:02.000000000 -0700
@@ -344,7 +344,6 @@
   Bool			fEnabled;
   Bool			fClosed;
   Bool			fActive;
-  Bool			fCursor;
     
   int			iDeltaZ;
 
@@ -430,6 +429,7 @@
 } winPrivScreenRec, *winPrivScreenPtr;
 
 extern winScreenInfo		g_ScreenInfo[];
+extern Bool			g_fCursor;
 extern miPointerScreenFuncRec	g_winPointerCursorFuncs;
 extern DWORD			g_dwEvents;
 extern int			g_fdMessageQueue;
--- xc/programs/Xserver/hw/xwin.orig/winallpriv.c	2001-10-29 13:10:24.000000000 -0800
+++ xc/programs/Xserver/hw/xwin/winallpriv.c	2002-06-08 15:20:14.000000000 -0700
@@ -77,7 +77,6 @@
 
   /* Intialize private structure members */
   pScreenPriv->fActive = TRUE;
-  pScreenPriv->fCursor = TRUE;
 
   /* Save the screen private pointer */
   winSetScreenPriv (pScreen, pScreenPriv);
--- xc/programs/Xserver/hw/xwin.orig/winwndproc.c	2002-06-07 18:20:06.000000000 -0700
+++ xc/programs/Xserver/hw/xwin/winwndproc.c	2002-06-08 15:55:34.000000000 -0700
@@ -49,7 +49,6 @@
   static ScreenPtr		pScreen = NULL;
   static HWND			hwndLastMouse = NULL;
   static unsigned long		ulServerGeneration = 0;
-  winPrivScreenPtr		pScreenPrivLast;
   int				iScanCode;
   int				i;
   static HWND			hwndLastPrivates = NULL;
@@ -171,46 +170,12 @@
 			       GET_Y_LPARAM(lParam));
 
 
-      /* Sometimes we hide, sometimes we show */
-      if (hwndLastMouse != NULL && hwndLastMouse != hwnd)
-	{
-	  /* Cursor is now over NC area of another screen */
-	  pScreenPrivLast = GetProp (hwndLastMouse, WIN_SCR_PROP);
-	  if (pScreenPrivLast == NULL)
-	    {
-	      ErrorF ("winWindowProc () - WM_MOUSEMOVE - Couldn't obtain "
-		      "last screen privates\n");
-	      return 0;
-	    }
-
-	  /* Show cursor if last screen is still hiding it */
-	  if (!pScreenPrivLast->fCursor)
-	    {
-	      pScreenPrivLast->fCursor = TRUE;
-	      ShowCursor (TRUE);
-	    }
-
-	  /* Hide cursor for our screen if we are not hiding it */
-	  if (pScreenPriv->fCursor)
-	    {
-	      pScreenPriv->fCursor = FALSE;
-	      ShowCursor (FALSE);
-	    }
-	}
-      else if (pScreenPriv->fActive
-	  && pScreenPriv->fCursor)
+      if (g_fCursor)
 	{
 	  /* Hide Windows cursor */
-	  pScreenPriv->fCursor = FALSE;
+	  g_fCursor = FALSE;
 	  ShowCursor (FALSE);
 	}
-      else if (!pScreenPriv->fActive
-	       && !pScreenPriv->fCursor)
-	{
-	  /* Show Windows cursor */
-	  pScreenPriv->fCursor = TRUE;
-	  ShowCursor (TRUE);
-	}
 
       /* Deliver absolute cursor position to X Server */
       miPointerAbsoluteCursor (GET_X_LPARAM(lParam),
@@ -226,41 +191,20 @@
       if (pScreenPriv == NULL || pScreenInfo->fIgnoreInput)
 	break;
 
-      /* Non-client mouse movement, show Windows cursor */
-      if (hwndLastMouse != NULL && hwndLastMouse != hwnd)
-	{
-	  /* Cursor is now over NC area of another screen */
-	  pScreenPrivLast = GetProp (hwndLastMouse, WIN_SCR_PROP);
-	  if (pScreenPrivLast == NULL)
-	    {
-	      ErrorF ("winWindowProc () - WM_NCMOUSEMOVE - Couldn't obtain "
-		      "last screen privates\n");
-	      return 0;
-	    }
-
-	  /* Show cursor if last screen is still hiding it */
-	  if (!pScreenPrivLast->fCursor)
-	    {
-	      pScreenPrivLast->fCursor = TRUE;
-	      ShowCursor (TRUE);
-	    }
-
-	  /* Hide cursor for our screen if we are not hiding it */
-	  if (pScreenPriv->fCursor)
-	    {
-	      pScreenPriv->fCursor = FALSE;
-	      ShowCursor (FALSE);
-	    }
-	}
-      else if (!pScreenPriv->fCursor)
+      if (!g_fCursor)
 	{
-	  pScreenPriv->fCursor = TRUE;
+	  g_fCursor = TRUE;
 	  ShowCursor (TRUE);
 	}
 
       /* Store pointer to last window handle */
       hwndLastMouse = hwnd;
-      return 0;
+      
+      /*
+       * Uses default windows processing (handle minimize/maximize/close button
+       * highlight on WinXP 
+       */
+      return DefWindowProc(hwnd, message, wParam, lParam);
 
     case WM_LBUTTONDBLCLK:
     case WM_LBUTTONDOWN:
@@ -474,51 +418,6 @@
 	miPointerSetNewScreen (pScreenInfo->dwScreen, 0, 0);
 #endif
 
-      /* Handle showing or hiding the mouse */
-      if (hwndLastMouse != NULL && hwndLastMouse != hwnd)
-	{
-	  /*
-	   * Activation has transferred between screens.
-	   * This section is processed by the screen receiving
-	   * focus, as it is the only one that notices the difference
-	   * between hwndLastMouse and hwnd.
-	   */
-	  pScreenPrivLast = GetProp (hwndLastMouse, WIN_SCR_PROP);
-	  if (pScreenPrivLast == NULL)
-	    {
-	      ErrorF ("winWindowProc () - WM_ACTIVATE - Couldn't obtain last "
-		      "screen privates\n");
-	      return 0;
-	    }
-
-	  /* Show cursor if last screen is still hiding it */
-	  if (!pScreenPrivLast->fCursor)
-	    {
-	      pScreenPrivLast->fCursor = TRUE;
-	      ShowCursor (TRUE);
-	    }
-
-	  /* Hide cursor for our screen if we are not hiding it */
-	  if (pScreenPriv->fCursor)
-	    {
-	      pScreenPriv->fCursor = FALSE;
-	      ShowCursor (FALSE);
-	    }
-	}
-      else if ((LOWORD(wParam) == WA_ACTIVE
-		|| LOWORD(wParam) == WA_CLICKACTIVE)
-	       && pScreenPriv->fCursor)
-	{
-	  pScreenPriv->fCursor = FALSE;
-	  ShowCursor (FALSE);
-	}
-      else if (LOWORD(wParam) == WA_INACTIVE
-	       && !pScreenPriv->fCursor)
-	{
-	  pScreenPriv->fCursor = TRUE;
-	  ShowCursor (TRUE);
-	}
-
       /* Store last active window handle */
       hwndLastMouse = hwnd;
       return 0;
@@ -533,20 +432,6 @@
       /* Activate or deactivate */
       pScreenPriv->fActive = wParam;
 
-      /* Are we activating or deactivating? */
-      if (pScreenPriv->fActive
-	  && pScreenPriv->fCursor)
-	{
-	  pScreenPriv->fCursor = FALSE;
-	  ShowCursor (FALSE);
-	}
-      else if (!pScreenPriv->fActive
-	       && !pScreenPriv->fCursor)
-	{
-	  pScreenPriv->fCursor = TRUE;
-	  ShowCursor (TRUE);
-	}
-
       /* Call engine specific screen activation/deactivation function */
       (*pScreenPriv->pwinActivateApp) (pScreen);
       return 0;

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