[Xorg-commit] xc/programs/Xserver/hw/xwin win.h,1.1.4.1.2.11,1.1.4.1.2.12 winmultiwindowwindow.c,1.1.4.1.2.5,1.1.4.1.2.6 winmultiwindowwndproc.c,1.1.6.3,1.1.6.4 winscrinit.c,1.1.4.1.2.6,1.1.4.1.2.7 winwindow.h,1.1.4.1.2.4,1.1.4.1.2.5

Takuma Murakami xorg-commit at pdx.freedesktop.org
Wed May 9 17:30:30 EEST 2007


Committed by: takuma

Update of /cvs/xorg/xc/programs/Xserver/hw/xwin
In directory pdx:/tmp/cvs-serv31094

Modified Files:
      Tag: CYGWIN
	win.h winmultiwindowwindow.c winmultiwindowwndproc.c 
	winscrinit.c winwindow.h 
Log Message:
Improve move, resize, minimize, maximize, and restore operations on windows in multiwindow mode.  Reorganize message/event flow, add new scheme to propagate window changes between Windows and X layers, eliminate bunch of conditional branches and cache variables.  A couple of bugs should be fixed.


Index: win.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/win.h,v
retrieving revision 1.1.4.1.2.11
retrieving revision 1.1.4.1.2.12
diff -u -d -r1.1.4.1.2.11 -r1.1.4.1.2.12
--- a/win.h	15 Jan 2004 06:06:44 -0000	1.1.4.1.2.11
+++ b/win.h	21 Feb 2004 13:30:25 -0000	1.1.4.1.2.12
@@ -554,6 +554,8 @@
   ClipNotifyProcPtr			ClipNotify;
   RestackWindowProcPtr			RestackWindow;
   ReparentWindowProcPtr			ReparentWindow;
+  ResizeWindowProcPtr			ResizeWindow;
+  MoveWindowProcPtr			MoveWindow;
 #ifdef SHAPE
   SetShapeProcPtr			SetShape;
 #endif
@@ -1522,10 +1524,15 @@
 winReorderWindowsMultiWindow (ScreenPtr pScreen);
 
 void
-winMoveXWindow (WindowPtr pWin, int x, int y);
+winResizeWindowMultiWindow (WindowPtr pWin, int x, int y, unsigned int w,
+			    unsigned int h, WindowPtr pSib);
+void
+winMoveWindowMultiWindow (WindowPtr pWin, int x, int y,
+			  WindowPtr pSib, VTKind kind);
 
 void
-winResizeXWindow (WindowPtr pWin, int w, int h);
+winCopyWindowMultiWindow (WindowPtr pWin, DDXPointRec oldpt,
+			  RegionPtr oldRegion);
 
 void
 winWin32RootlessMoveResizeXWindow (WindowPtr pWin, int x, int y, int w, int h);
@@ -1533,6 +1540,8 @@
 XID
 winGetWindowID (WindowPtr pWin);
 
+int
+winAdjustXWindow (WindowPtr pWin, HWND hwnd);
 
 /*
  * winmultiwindowwndproc.c

Index: winmultiwindowwindow.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winmultiwindowwindow.c,v
retrieving revision 1.1.4.1.2.5
retrieving revision 1.1.4.1.2.6
diff -u -d -r1.1.4.1.2.5 -r1.1.4.1.2.6
--- a/winmultiwindowwindow.c	27 Jan 2004 05:39:29 -0000	1.1.4.1.2.5
+++ b/winmultiwindowwindow.c	21 Feb 2004 13:30:25 -0000	1.1.4.1.2.6
@@ -104,8 +104,6 @@
   pWinPriv->hWnd = NULL;
   pWinPriv->pScreenPriv = winGetScreenPriv(pWin->drawable.pScreen);
   pWinPriv->fXKilled = FALSE;
-  pWinPriv->fNeedRestore = FALSE;
-  pWinPriv->fAlwaysOnTop = FALSE;
  
   return fResult;
 }
@@ -141,6 +139,10 @@
 
 /*
  * PositionWindow - See Porting Layer Definition - p. 37
+ *
+ * This function adjusts the position and size of Windows window
+ * with respect to the underlying X window.  This is the inverse
+ * of winAdjustXWindow, which adjusts X window to Windows window.
  */
 
 Bool
@@ -167,10 +169,32 @@
   if (winGetScreenPriv(pWin->drawable.pScreen)->PositionWindow)
     fResult = winGetScreenPriv(pWin->drawable.pScreen)->PositionWindow (pWin, x, y);
   
+#if CYGWINDOWING_DEBUG
+  ErrorF ("winPositionWindowMultiWindow: (x, y) = (%d, %d)\n",
+	  x, y);
+#endif
+
   /* Bail out if the Windows window handle is bad */
   if (!hWnd)
-    return fResult;
+    {
+#if CYGWINDOWING_DEBUG
+      ErrorF ("\timmediately return since hWnd is NULL\n");
+#endif
+      return fResult;
+    }
 
+#if 0
+  if ( (pWin->drawable.width == 0) &&
+       (pWin->drawable.height == 0) )
+    {
+      /* The Windows window is in the iconic state. */
+#if CYGWINDOWING_DEBUG
+      ErrorF ("\timmediately return because drawable is 0x0\n");
+#endif
+      return fResult;
+    }
+#endif
+  
   /* Get the Windows window style and extended style */
   dwExStyle = GetWindowLongPtr (hWnd, GWL_EXSTYLE);
   dwStyle = GetWindowLongPtr (hWnd, GWL_STYLE);
@@ -228,6 +252,10 @@
       ErrorF ("winPositionWindowMultiWindow - Need to move\n");
 #endif
 
+#if CYGWINDOWING_DEBUG
+      ErrorF ("\tMoveWindow to (%ld, %ld) - %ldx%ld\n", rcNew.left, rcNew.top,
+	      rcNew.right - rcNew.left, rcNew.bottom - rcNew.top);
+#endif
       /* Change the position and dimensions of the Windows window */
       MoveWindow (hWnd,
 		  rcNew.left, rcNew.top,
@@ -368,7 +396,7 @@
   HWND                  hWnd = NULL;
   winWindowPriv(pWin);
 
-#if CYGMULTIWINDOW_DEBUG
+#if CYGMULTIWINDOW_DEBUG || CYGWINDOWING_DEBUG
   ErrorF ("winRestackMultiWindow - %08x\n", pWin);
 #endif
   
@@ -705,38 +733,6 @@
 
 
 /*
- * winMoveXWindow - 
- */
-
-void
-winMoveXWindow (WindowPtr pWin, int x, int y)
-{
-  XID *vlist = malloc(sizeof(long)*2);
-
-  (CARD32*)vlist[0] = x;
-  (CARD32*)vlist[1] = y;
-  ConfigureWindow (pWin, CWX | CWY, vlist, wClient(pWin));
-  free(vlist);
-}
-
-
-/*
- * winResizeXWindow - 
- */
-
-void
-winResizeXWindow (WindowPtr pWin, int w, int h)
-{
-  XID *vlist = malloc(sizeof(long)*2);
-
-  (CARD32*)vlist[0] = w;
-  (CARD32*)vlist[1] = h;
-  ConfigureWindow (pWin, CWWidth | CWHeight, vlist, wClient(pWin));
-  free(vlist);
-}
-
-
-/*
  * winFindWindow - 
  */
 
@@ -767,7 +763,7 @@
   DWORD dwWindowProcessID = 0;
 
 #if CYGMULTIWINDOW_DEBUG
-  ErrorF ("winOrderWindowsMultiWindow\n");
+  ErrorF ("winReorderWindowsMultiWindow\n");
 #endif
 
   pScreenPriv->fRestacking = TRUE;
@@ -783,8 +779,9 @@
 	{
 	  GetWindowThreadProcessId (hwnd, &dwWindowProcessID);
 
-	  if ((dwWindowProcessID == dwCurrentProcessID)
-	      && GetProp (hwnd, WIN_WINDOW_PROP))
+	  if ( (dwWindowProcessID == dwCurrentProcessID)
+	       && GetProp (hwnd, WIN_WINDOW_PROP)
+	       && !IsIconic (hwnd) ) /* ignore minimized windows */
 	    {
 	      pWinSib = pWin;
 	      pWin = GetProp (hwnd, WIN_WINDOW_PROP);
@@ -827,6 +824,10 @@
 {
   WindowPtr		pWin;
   winPrivWinPtr	pWinPriv;
+
+#if CYGWINDOWING_DEBUG
+  ErrorF ("winMinimizeWindow\n");
+#endif
   
   pWin = LookupIDByType (id, RT_WINDOW);
   
@@ -834,3 +835,148 @@
   
   ShowWindow (pWinPriv->hWnd, SW_MINIMIZE);
 }
+
+
+/*
+ * CopyWindow - See Porting Layer Definition - p. 39
+ */
+void
+winCopyWindowMultiWindow (WindowPtr pWin, DDXPointRec oldpt,
+			  RegionPtr oldRegion)
+{
+#if CYGWINDOWING_DEBUG
+  ErrorF ("CopyWindowMultiWindow\n");
+#endif
+  /* Call any wrapped CopyWindow function */
+  if (winGetScreenPriv(pWin->drawable.pScreen)->CopyWindow)
+    winGetScreenPriv(pWin->drawable.pScreen)->CopyWindow (pWin,
+							  oldpt,
+							  oldRegion);
+}
+
+
+/*
+ * MoveWindow - See Porting Layer Definition - p. 42
+ */
+void
+winMoveWindowMultiWindow (WindowPtr pWin, int x, int y,
+			  WindowPtr pSib, VTKind kind)
+{
+#if CYGWINDOWING_DEBUG
+  ErrorF ("MoveWindowMultiWindow to (%d, %d)\n", x, y);
+#endif
+  /* Call any wrapped MoveWindow function */
+  if (winGetScreenPriv(pWin->drawable.pScreen)->MoveWindow)
+    winGetScreenPriv(pWin->drawable.pScreen)->MoveWindow (pWin, x, y,
+							  pSib, kind);
+}
+
+
+/*
+ * ResizeWindow - See Porting Layer Definition - p. 42
+ */
+void
+winResizeWindowMultiWindow (WindowPtr pWin, int x, int y, unsigned int w,
+			    unsigned int h, WindowPtr pSib)
+{
+#if CYGWINDOWING_DEBUG
+  ErrorF ("ResizeWindowMultiWindow to (%d, %d) - %dx%d\n", x, y, w, h);
+#endif
+  /* Call any wrapped MoveWindow function */
+  if (winGetScreenPriv(pWin->drawable.pScreen)->ResizeWindow)
+    winGetScreenPriv(pWin->drawable.pScreen)->ResizeWindow (pWin, x, y,
+							    w, h, pSib);
+}
+
+
+/*
+ * winAdjustXWindow
+ *
+ * Move and resize X window with respect to corresponding Windows window.
+ * This is called from WM_MOVE/WM_SIZE handlers when the user performs
+ * any windowing operation (move, resize, minimize, maximize, restore).
+ *
+ * The functionality is the inverse of winPositionWindowMultiWindow, which
+ * adjusts Windows window with respect to X window.
+ */
+int
+winAdjustXWindow (WindowPtr pWin, HWND hwnd)
+{
+  RECT rcDraw; /* Rect made from pWin->drawable to be adjusted */
+  RECT rcWin;  /* The source: WindowRect from hwnd */
+  DrawablePtr pDraw;
+  XID vlist[4];
+  LONG dX, dY, dW, dH, x, y;
+  DWORD dwStyle, dwExStyle;
+
+#define WIDTH(rc) (rc.right - rc.left)
+#define HEIGHT(rc) (rc.bottom - rc.top)
+  
+#if CYGWINDOWING_DEBUG
+  ErrorF ("winAdjustXWindow\n");
+#endif
+
+  if (IsIconic (hwnd))
+    {
+#if CYGWINDOWING_DEBUG
+      ErrorF ("\timmediately return because the window is iconized\n");
+#endif
+      /*
+       * If the Windows window is minimized, its WindowRect has
+       * meaningless values so we don't adjust X window to it.
+       * Instead we put the X window to the bottom in Z order to
+       * be obscured by other windows.
+       */
+      vlist[0] = Below;
+      return ConfigureWindow (pWin, CWStackMode, vlist, wClient(pWin));
+    }
+  
+  pDraw = &pWin->drawable;
+
+  /* Calculate the window rect from the drawable */
+  x = pDraw->x + GetSystemMetrics (SM_XVIRTUALSCREEN);
+  y = pDraw->y + GetSystemMetrics (SM_YVIRTUALSCREEN);
+  SetRect (&rcDraw, x, y, x + pDraw->width, y + pDraw->height);
+  dwExStyle = GetWindowLongPtr (hwnd, GWL_EXSTYLE);
+  dwStyle = GetWindowLongPtr (hwnd, GWL_STYLE);
+  AdjustWindowRectEx (&rcDraw, dwStyle, FALSE, dwExStyle);
+
+  /* The source of adjust */
+  GetWindowRect (hwnd, &rcWin);
+
+  if (EqualRect (&rcDraw, &rcWin)) {
+    /* Bail if no adjust is needed */
+#if CYGWINDOWING_DEBUG
+    ErrorF ("\treturn because already adjusted\n");
+#endif
+    return 0;
+  }
+  
+  /* Calculate delta values */
+  dX = rcWin.left - rcDraw.left;
+  dY = rcWin.top - rcDraw.top;
+  dW = WIDTH(rcWin) - WIDTH(rcDraw);
+  dH = HEIGHT(rcWin) - HEIGHT(rcDraw);
+
+  /*
+   * Adjust.
+   * We may only need to move (vlist[0] and [1]), or only resize
+   * ([2] and [3]) but currently we set all the parameters and leave
+   * the decision to ConfigureWindow.  The reason is code simplicity.
+  */
+  vlist[0] = pDraw->x + dX - wBorderWidth(pWin)
+    - GetSystemMetrics(SM_XVIRTUALSCREEN);
+  vlist[1] = pDraw->y + dY - wBorderWidth(pWin)
+    - GetSystemMetrics(SM_YVIRTUALSCREEN);
+  vlist[2] = pDraw->width + dW;
+  vlist[3] = pDraw->height + dH;
+#if CYGWINDOWING_DEBUG
+  ErrorF ("\tConfigureWindow to (%ld, %ld) - %ldx%ld\n", vlist[0], vlist[1],
+	  vlist[2], vlist[3]);
+#endif
+  return ConfigureWindow (pWin, CWX | CWY | CWWidth | CWHeight,
+			  vlist, wClient(pWin));
+  
+#undef WIDTH
+#undef HEIGHT
+}

Index: winmultiwindowwndproc.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winmultiwindowwndproc.c,v
retrieving revision 1.1.6.3
retrieving revision 1.1.6.4
diff -u -d -r1.1.6.3 -r1.1.6.4
--- a/winmultiwindowwndproc.c	17 Feb 2004 06:26:16 -0000	1.1.6.3
+++ b/winmultiwindowwndproc.c	21 Feb 2004 13:30:25 -0000	1.1.6.4
@@ -206,7 +206,7 @@
 {
   WinXSizeHints sizeHints;
   RECT *rect;
-  int iWidth, iHeight, iTopBorder;
+  int iWidth, iHeight;
   POINT pt;
 
   /* Invalid input checking */
@@ -229,21 +229,19 @@
   iWidth = rect->right - rect->left;
   iHeight = rect->bottom - rect->top;
 
-  /* Get title bar height, there must be an easier way?! */
-  pt.x = pt.y = 0;
-  ClientToScreen(hwnd, &pt);
-  iTopBorder = pt.y - rect->top;
-  
   /* Now remove size of any borders */
   iWidth -= 2 * GetSystemMetrics(SM_CXSIZEFRAME);
-  iHeight -= GetSystemMetrics(SM_CYSIZEFRAME) + iTopBorder;
+  iHeight -= (GetSystemMetrics(SM_CYCAPTION)
+	      + 2 * GetSystemMetrics(SM_CYSIZEFRAME));
+	      
 
   /* Constrain the size to legal values */
   ConstrainSize (sizeHints, &iWidth, &iHeight);
 
   /* Add back the borders */
   iWidth += 2 * GetSystemMetrics(SM_CXSIZEFRAME);
-  iHeight += GetSystemMetrics(SM_CYSIZEFRAME) + iTopBorder;
+  iHeight += (GetSystemMetrics(SM_CYCAPTION)
+	      + 2 * GetSystemMetrics(SM_CYSIZEFRAME));
 
   /* Adjust size according to where we're dragging from */
   switch(wParam) {
@@ -321,10 +319,10 @@
       wmMsg.hwndWindow	= hwnd;
       wmMsg.iWindow	= (Window)GetProp (hwnd, WIN_WID_PROP);
 
-      wmMsg.iX		= pWinPriv->iX;
-      wmMsg.iY		= pWinPriv->iY;
-      wmMsg.iWidth	= pWinPriv->iWidth;
-      wmMsg.iHeight	= pWinPriv->iHeight;
+      wmMsg.iX		= pDraw->x;
+      wmMsg.iY		= pDraw->y;
+      wmMsg.iWidth	= pDraw->width;
+      wmMsg.iHeight	= pDraw->height;
 
       fWMMsgInitialized = TRUE;
 
@@ -375,7 +373,6 @@
 
       return 0;
 
-
     case WM_INIT_SYS_MENU:
       /*
        * Add whatever the setup file wants to for this window
@@ -387,30 +384,33 @@
       /*
        * Any window menu items go through here
        */
+#if CYGMULTIWINDOW_DEBUG
       switch (wParam & 0xFFF0) /* See MSDN for the magic number 0xFFF0 */
 	{
 	case SC_MINIMIZE:
-	  /* If minimizing then remove always-on-top, and store the setting */
-	  if (GetWindowLong (hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)
-	    pWinPriv->fAlwaysOnTop = TRUE;
-	  else
-	    pWinPriv->fAlwaysOnTop = FALSE;
-	  SetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0,
-		       SWP_NOMOVE|SWP_NOSIZE);
+	  ErrorF ("winTopLevelWindowProc - WM_SYSCOMMAND (SC_MINIMIZE)\n");
 	  break;
 
 	case SC_RESTORE:
-	  if (pWinPriv->fAlwaysOnTop)
-	    SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0,
-			 SWP_NOMOVE|SWP_NOSIZE);
+	  ErrorF ("winTopLevelWindowProc - WM_SYSCOMMAND (SC_RESTORE)\n");
 	  break;
 
+	case SC_MAXIMIZE:
+	  ErrorF ("winTopLevelWindowProc - WM_SYSCOMMAND (SC_MAXIMIZE)\n");
+	  break;
+	  
 	default:
+	  ErrorF ("winTopLevelWindowProc - WM_SYSCOMMAND (UNKNOWN)\n");
+#endif
 	  if (HandleCustomWM_COMMAND ((unsigned long)hwnd, LOWORD(wParam)))
-	    /* Don't pass customized menus to DefWindowProc */
-	    return 0;
+	    {
+	      /* Don't pass customized menus to DefWindowProc */
+	      return 0;
+	    }
+#if CYGMULTIWINDOW_DEBUG
 	  break;
 	}
+#endif
       break;
 
     case WM_INITMENU:
@@ -665,6 +665,42 @@
       if (wParam == VK_F4 && (GetKeyState (VK_MENU) & 0x8000))
 	  break;
 
+#if CYGWINDOWING_DEBUG
+      if (wParam == VK_ESCAPE)
+	{
+	  /* Place for debug: put any tests and dumps here */
+	  WINDOWPLACEMENT windPlace;
+	  RECT rc;
+	  LPRECT pRect;
+	  
+	  windPlace.length = sizeof (WINDOWPLACEMENT);
+	  GetWindowPlacement (hwnd, &windPlace);
+	  pRect = &windPlace.rcNormalPosition;
+	  ErrorF ("\nCYGWINDOWING Dump:\n"
+		  "\tdrawable: (%hd, %hd) - %hdx%hd\n", pDraw->x,
+		  pDraw->y, pDraw->width, pDraw->height);
+	  ErrorF ("\twindPlace: (%ld, %ld) - %ldx%ld\n", pRect->left,
+		  pRect->top, pRect->right - pRect->left,
+		  pRect->bottom - pRect->top);
+	  if (GetClientRect (hwnd, &rc))
+	    {
+	      pRect = &rc;
+	      ErrorF ("\tClientRect: (%ld, %ld) - %ldx%ld\n", pRect->left,
+		      pRect->top, pRect->right - pRect->left,
+		      pRect->bottom - pRect->top);
+	    }
+	  if (GetWindowRect (hwnd, &rc))
+	    {
+	      pRect = &rc;
+	      ErrorF ("\tWindowRect: (%ld, %ld) - %ldx%ld\n", pRect->left,
+		      pRect->top, pRect->right - pRect->left,
+		      pRect->bottom - pRect->top);
+	    }
+	  ErrorF ("\n");
+	  return 0;
+	}
+#endif
+      
       /* Pass the message to the root window */
       SendMessage (hwndScreen, message, wParam, lParam);
       return 0;
@@ -759,42 +795,13 @@
       break;
 
     case WM_MOVE:
-#if CYGMULTIWINDOW_DEBUG
-      ErrorF ("winTopLevelWindowProc - WM_MOVE - %d ms\n", GetTickCount ());
-#endif
-      
-      /* Bail if Windows window is not actually moving */
-      if (pWinPriv->iX == (short) LOWORD(lParam)
-	  && pWinPriv->iY == (short) HIWORD(lParam))
-	break;
-
-      /* Also bail if we're maximizing, we'll do the whole thing in WM_SIZE */
-      {
-	WINDOWPLACEMENT windPlace;
-	windPlace.length = sizeof (WINDOWPLACEMENT);
-
-	/* Get current window placement */
-	GetWindowPlacement (hwnd, &windPlace);
-
-	/* Bail if maximizing */
-	if (windPlace.showCmd == SW_MAXIMIZE
-	    || windPlace.showCmd == SW_SHOWMAXIMIZED)
-	  break;
-      } 
-
-      /* Get new position */
-      pWinPriv->iX = (short) LOWORD(lParam);
-      pWinPriv->iY = (short) HIWORD(lParam);
-
-#if CYGMULTIWINDOW_DEBUG
-      ErrorF ("\t(%d, %d)\n", pWinPriv->iX, pWinPriv->iY);
+#if CYGWINDOWING_DEBUG
+      ErrorF ("winTopLevelWindowProc - WM_MOVE to (%d, %d) - %d ms\n",
+	      (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam),
+	      (int)(GetTickCount ()));
 #endif
-
-      winMoveXWindow (pWin,
-		      (LOWORD(lParam) - wBorderWidth (pWin)
-		       - GetSystemMetrics (SM_XVIRTUALSCREEN)),
-		      (HIWORD(lParam) - wBorderWidth (pWin)
-		       - GetSystemMetrics (SM_YVIRTUALSCREEN)));
+      /* Adjust the X Window to the moved Windows window */
+      winAdjustXWindow (pWin, hwnd);
       return 0;
 
     case WM_SHOWWINDOW:
@@ -802,6 +809,10 @@
       if (!wParam)
 	return 0;
 
+#if CYGWINDOWING_DEBUG
+      ErrorF ("winTopLevelWindowProc - WM_SHOWWINDOW\n");
+#endif
+      
       /* Tell X to map the window */
       MapWindow (pWin, wClient(pWin));
 
@@ -825,10 +836,10 @@
 	    {
 	      /* Setup a rectangle with the X window position and size */
 	      SetRect (&rcNew,
-		       pWinPriv->iX,
-		       pWinPriv->iY,
-		       pWinPriv->iX + pWinPriv->iWidth,
-		       pWinPriv->iY + pWinPriv->iHeight);
+		       pDraw->x,
+		       pDraw->y,
+		       pDraw->x + pDraw->width,
+		       pDraw->y + pDraw->height);
 
 #if 0
 	      ErrorF ("winTopLevelWindowProc - (%d, %d)-(%d, %d)\n",
@@ -843,8 +854,8 @@
 				  WS_EX_APPWINDOW);
 
 	      /* Calculate position deltas */
-	      iDx = pWinPriv->iX - rcNew.left;
-	      iDy = pWinPriv->iY - rcNew.top;
+	      iDx = pDraw->x - rcNew.left;
+	      iDy = pDraw->y - rcNew.top;
 
 	      /* Calculate new rectangle */
 	      rcNew.left += iDx;
@@ -879,8 +890,8 @@
 	  
       /* Setup the Window Manager message */
       wmMsg.msg = WM_WM_MAP;
-      wmMsg.iWidth = pWinPriv->iWidth;
-      wmMsg.iHeight = pWinPriv->iHeight;
+      wmMsg.iWidth = pDraw->width;
+      wmMsg.iHeight = pDraw->height;
 
       /* Tell our Window Manager thread to map the window */
       if (fWMMsgInitialized)
@@ -896,120 +907,49 @@
       return ValidateSizing (hwnd, pWin, wParam, lParam);
 
     case WM_WINDOWPOSCHANGED:
-      {
-	LPWINDOWPOS pwindPos = (LPWINDOWPOS) lParam;
-
-	/* Bail if window z order was not changed */
-	if (pwindPos->flags & SWP_NOZORDER)
-	  break;
-
-#if CYGMULTIWINDOW_DEBUG
-	ErrorF ("winTopLevelWindowProc - hwndInsertAfter: %p\n",
-		pwindPos->hwndInsertAfter);
-#endif
-	
-#if 0
-	/* Pass the message to the root window */
-	SendMessage (hwndScreen, message, wParam, lParam);
-#endif
-	
-	if (s_pScreenPriv != NULL)
-	  s_pScreenPriv->fWindowOrderChanged = TRUE;
-      }
-      break;
-
-    case WM_SIZE:
-      /* see dix/window.c */
-
-#if CYGMULTIWINDOW_DEBUG
-      ErrorF ("winTopLevelWindowProc - WM_SIZE - %d ms\n", GetTickCount ());
-#endif
-
-      /* Branch on type of resizing occurring */
-      switch (wParam)
+      if (!( ((LPWINDOWPOS)lParam)->flags
+	     & SWP_NOZORDER ))
 	{
-	case SIZE_MINIMIZED:
-#if CYGMULTIWINDOW_DEBUG
-	  ErrorF ("\tSIZE_MINIMIZED\n");
+#if CYGWINDOWING_DEBUG
+	  ErrorF ("winTopLevelWindowProc - WM_WINDOWPOSCHANGED: "
+		  "Z order is changed\n");
 #endif
 	  if (s_pScreenPriv != NULL)
 	    s_pScreenPriv->fWindowOrderChanged = TRUE;
-	  break;
+	}
+      /*
+       * Pass the message to DefWindowProc to let the function
+       * break down WM_WINDOWPOSCHANGED to WM_MOVE and WM_SIZE.
+      */
+      break; 
 
-	case SIZE_RESTORED:
-	case SIZE_MAXIMIZED:
-#if CYGMULTIWINDOW_DEBUG
-	  ErrorF ("SIZE_RESTORED || SIZE_MAXIMIZED\n");
-#endif
-	  /* Break out if nothing to do */
-	  if (pWinPriv->iWidth == (short) LOWORD(lParam)
-	      && pWinPriv->iHeight == (short) HIWORD(lParam))
+    case WM_SIZE:
+      /* see dix/window.c */
+#if CYGWINDOWING_DEBUG
+      {
+	char buf[64];
+	switch (wParam)
+	  {
+	  case SIZE_MINIMIZED:
+	    strcpy(buf, "SIZE_MINIMIZED");
 	    break;
-	  
-	  /* Get the dimensions of the resized Windows window  */
-	  pWinPriv->iWidth = (short) LOWORD(lParam);
-	  pWinPriv->iHeight = (short) HIWORD(lParam);
-
-#if CYGMULTIWINDOW_DEBUG
-	  ErrorF ("\t(%d, %d)\n", pWinPriv->iWidth, pWinPriv->iHeight);
+	  case SIZE_MAXIMIZED:
+	    strcpy(buf, "SIZE_MAXIMIZED");
+	    break;
+	  case SIZE_RESTORED:
+	    strcpy(buf, "SIZE_RESTORED");
+	    break;
+	  default:
+	    strcpy(buf, "UNKNOWN_FLAG");
+	  }
+	ErrorF ("winTopLevelWindowProc - WM_SIZE to %dx%d (%s) - %d ms\n",
+		(int)LOWORD(lParam), (int)HIWORD(lParam), buf,
+		(int)(GetTickCount ()));
+      }
 #endif
-
-	  /*
-	   * If we're maximizing the window has been moved to upper left
-	   * of current screen.  Now it is safe for X to know about this.
-	   */
-	  if (wParam == SIZE_MAXIMIZED)
-	    {
-	      POINT		ptHome;
-
-	      /* Flag that we are being maximized and store info for restore */
-	      pWinPriv->fNeedRestore = TRUE;
-	      pWinPriv->ptRestore.x = pWinPriv->iX;
-	      pWinPriv->ptRestore.y = pWinPriv->iY;
-	     
-	      /* Get screen location of window root */
-	      ptHome.x = 0;
-	      ptHome.y = 0;
-	      ClientToScreen (hwnd, &ptHome);
-
-	      /* Map from screen (-X,-Y) to (0,0) root coords */
-	      winMoveXWindow (pWin,
-			      ptHome.x - wBorderWidth (pWin)
-			      - GetSystemMetrics (SM_XVIRTUALSCREEN),
-			      ptHome.y - wBorderWidth (pWin)
-			      - GetSystemMetrics (SM_YVIRTUALSCREEN));
-	    }
-	  else if (wParam == SIZE_RESTORED && pWinPriv->fNeedRestore)
-	    {
-	      /* If need restore and !maximized then move to cached position */
-	      WINDOWPLACEMENT windPlace;
-
-	      windPlace.length = sizeof (WINDOWPLACEMENT);
-
-	      GetWindowPlacement (hwnd, &windPlace);
-
-	      if (windPlace.showCmd != SW_MAXIMIZE
-		  && windPlace.showCmd != SW_SHOWMAXIMIZED)
-		{
-		  pWinPriv->fNeedRestore = FALSE;
-		  winMoveXWindow (pWin,
-				  pWinPriv->ptRestore.x  - wBorderWidth (pWin)
-				  - GetSystemMetrics (SM_XVIRTUALSCREEN),
-				  pWinPriv->ptRestore.y - wBorderWidth (pWin)
-				  - GetSystemMetrics (SM_YVIRTUALSCREEN));
-		}
-	    }
-
-	  /* Perform the resize and notify the X client */
-	  winResizeXWindow (pWin,
-			    (short) LOWORD(lParam),
-			    (short) HIWORD(lParam));
-	  break;
-
-	default:
-	  break;
-	}
-      return 0;
+      /* Adjust the X Window to the moved Windows window */
+      winAdjustXWindow (pWin, hwnd);
+      return 0; /* end of WM_SIZE handler */
 
     case WM_MOUSEACTIVATE:
 #if CYGMULTIWINDOW_DEBUG

Index: winscrinit.c
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winscrinit.c,v
retrieving revision 1.1.4.1.2.6
retrieving revision 1.1.4.1.2.7
diff -u -d -r1.1.4.1.2.6 -r1.1.4.1.2.7
--- a/winscrinit.c	8 Jan 2004 05:10:33 -0000	1.1.4.1.2.6
+++ b/winscrinit.c	21 Feb 2004 13:30:25 -0000	1.1.4.1.2.7
@@ -536,6 +536,9 @@
       WRAP(ChangeWindowAttributes);
       WRAP(ReparentWindow);
       WRAP(RestackWindow);
+      WRAP(ResizeWindow);
+      WRAP(MoveWindow);
+      WRAP(CopyWindow);
 #ifdef SHAPE
       WRAP(SetShape);
 #endif
@@ -549,6 +552,9 @@
       pScreen->UnrealizeWindow = winUnmapWindowMultiWindow;
       pScreen->ReparentWindow = winReparentWindowMultiWindow;
       pScreen->RestackWindow = winRestackWindowMultiWindow;
+      pScreen->ResizeWindow = winResizeWindowMultiWindow;
+      pScreen->MoveWindow = winMoveWindowMultiWindow;
+      pScreen->CopyWindow = winCopyWindowMultiWindow;
 #ifdef SHAPE
       pScreen->SetShape = winSetShapeMultiWindow;
 #endif

Index: winwindow.h
===================================================================
RCS file: /cvs/xorg/xc/programs/Xserver/hw/xwin/winwindow.h,v
retrieving revision 1.1.4.1.2.4
retrieving revision 1.1.4.1.2.5
diff -u -d -r1.1.4.1.2.4 -r1.1.4.1.2.5
--- a/winwindow.h	27 Jan 2004 05:39:29 -0000	1.1.4.1.2.4
+++ b/winwindow.h	21 Feb 2004 13:30:25 -0000	1.1.4.1.2.5
@@ -54,6 +54,7 @@
 #define WIN_NEEDMANAGE_PROP	"cyg_override_redirect_prop_rl"
 #define WIN_HWND_CACHE		"cyg_privmap_rl"
 #define CYGMULTIWINDOW_DEBUG    NO
+#define CYGWINDOWING_DEBUG	NO
 
 typedef struct _winPrivScreenRec *winPrivScreenPtr;
 
@@ -68,14 +69,7 @@
   HRGN			hRgn;
   HWND			hWnd;
   winPrivScreenPtr	pScreenPriv;
-  int			iX;
-  int			iY;
-  int			iWidth;
-  int			iHeight;
   Bool			fXKilled;
-  Bool                  fNeedRestore;
-  POINT                 ptRestore;
-  Bool                  fAlwaysOnTop;
 
   /* Privates used by primary fb DirectDraw server */
   LPDDSURFACEDESC	pddsdPrimary;





More information about the xorg-commit mailing list