xserver: Branch 'master' - 10 commits

Jon TURNEY jturney at kemper.freedesktop.org
Wed May 27 06:20:07 PDT 2009


 hw/xwin/InitInput.c              |   10 ---
 hw/xwin/win.h                    |    1 
 hw/xwin/winclipboardwndproc.c    |   26 ++++----
 hw/xwin/winclipboardxevents.c    |   53 +++++++++++++----
 hw/xwin/windialogs.c             |  116 ++++++++++++++++-----------------------
 hw/xwin/winmouse.c               |    1 
 hw/xwin/winmultiwindowicons.c    |   54 ++++++++----------
 hw/xwin/winmultiwindowwm.c       |    2 
 hw/xwin/winmultiwindowwndproc.c  |   25 +++++---
 hw/xwin/winprefs.c               |   35 +++++------
 hw/xwin/winprocarg.c             |    6 +-
 hw/xwin/winwin32rootlesswindow.c |    8 +-
 12 files changed, 167 insertions(+), 170 deletions(-)

New commits:
commit 996357e905c1082479bb238110b93bc170b8cb84
Author: Joe Krahn <jkrahn at nc.rr.com>
Date:   Tue Jan 20 17:22:37 2009 +0000

    Cygwin/X: Update icons directly, rather than modifying the window's class
    
    Update icons directly to windows rather than modifying
    the window's class.  Respect custom icons overriden via
    the configuration file.
    
    fd.o bugzilla #4491
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>

diff --git a/hw/xwin/winmultiwindowicons.c b/hw/xwin/winmultiwindowicons.c
index 88416bb..8200aad 100644
--- a/hw/xwin/winmultiwindowicons.c
+++ b/hw/xwin/winmultiwindowicons.c
@@ -364,43 +364,37 @@ void
 winUpdateIcon (Window id)
 {
   WindowPtr		pWin;
-  HICON			hIcon, hiconOld;
+  HICON			hIcon, hIconSmall=NULL, hIconOld;
 
   pWin = (WindowPtr) LookupIDByType (id, RT_WINDOW);
   if (!pWin) return;
-  hIcon = winOverrideIcon ((unsigned long)pWin);
+  winWindowPriv(pWin);
+  if (pWinPriv->hWnd) {
+    hIcon = winOverrideIcon ((unsigned long)pWin);
+    if (!hIcon) {
+      hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXICON));
+      if (!hIcon) {
+        hIcon = g_hIconX;
+        hIconSmall = g_hSmallIconX;
+      } else {
+        /* Leave undefined if not found */
+        hIconSmall = winXIconToHICON (pWin, GetSystemMetrics(SM_CXSMICON));
+      }
+    }
 
-  if (!hIcon)
-    hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXICON));
+    /* Set the large icon */
+    hIconOld = (HICON) SendMessage (pWinPriv->hWnd,
+                     WM_SETICON, ICON_BIG, (LPARAM) hIcon);
 
-  if (hIcon)
-    {
-      winWindowPriv(pWin);
+    /* Delete the icon if its not the default */
+    winDestroyIcon(hIconOld);
 
-      if (pWinPriv->hWnd)
-	{
-	  hiconOld = (HICON) SetClassLong (pWinPriv->hWnd,
-					   GCL_HICON,
-					   (int) hIcon);
-	  
-	  /* Delete the icon if its not the default */
-	  winDestroyIcon(hiconOld);
-	}
-    }
- 
-  hIcon = winXIconToHICON (pWin, GetSystemMetrics(SM_CXSMICON));
-  if (hIcon)
-    {
-      winWindowPriv(pWin);
+    /* Same for the small icon */
+    hIconOld = (HICON) SendMessage (pWinPriv->hWnd,
+                    WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall);
+    winDestroyIcon(hIconOld);
 
-      if (pWinPriv->hWnd)
-	{
-	  hiconOld = (HICON) SetClassLong (pWinPriv->hWnd,
-					   GCL_HICONSM,
-					   (int) hIcon);
-	  winDestroyIcon (hiconOld);
-	}
-    }
+  }
 }
 
 void winInitGlobalIcons (void)
diff --git a/hw/xwin/winprefs.c b/hw/xwin/winprefs.c
index 8152064..fe49ae2 100644
--- a/hw/xwin/winprefs.c
+++ b/hw/xwin/winprefs.c
@@ -189,35 +189,28 @@ ReloadEnumWindowsProc (HWND hwnd, LPARAM lParam)
   /* It's our baby, either clean or dirty it */
   if (lParam==FALSE) 
     {
-      hicon = (HICON)GetClassLong(hwnd, GCL_HICON);
+      /* Reset the window's icon to undefined. */
+      hicon = (HICON)SendMessage(hwnd, WM_SETICON, ICON_BIG, 0);
 
-      /* Unselect any icon in the class structure */
-      SetClassLong (hwnd, GCL_HICON, (LONG)LoadIcon (NULL, IDI_APPLICATION));
-
-      /* If it's generated on-the-fly, get rid of it, will regen */
+      /* If the old icon is generated on-the-fly, get rid of it, will regen */
       winDestroyIcon (hicon);
-     
-      hicon = (HICON)GetClassLong(hwnd, GCL_HICONSM);
-
-      /* Unselect any icon in the class structure */
-      SetClassLong (hwnd, GCL_HICONSM, 0);
 
-      /* If it's generated on-the-fly, get rid of it, will regen */
+      /* Same for the small icon */
+      hicon = (HICON)SendMessage(hwnd, WM_SETICON, ICON_SMALL, 0);
       winDestroyIcon (hicon);
-      
-      /* Remove any menu additions, use bRevert flag */
+
+      /* Remove any menu additions; bRevert=TRUE destroys any modified menus */
       GetSystemMenu (hwnd, TRUE);
       
-      /* This window is now clean of our taint */
+      /* This window is now clean of our taint (but with undefined icons) */
     }
   else
     {
-      /* Make the icon default, dynamic, or from xwinrc */
-      SetClassLong (hwnd, GCL_HICON, (LONG)g_hIconX);
-      SetClassLong (hwnd, GCL_HICONSM, (LONG)g_hSmallIconX);
+      /* winUpdateIcon() will set the icon default, dynamic, or from xwinrc */
       wid = (Window)GetProp (hwnd, WIN_WID_PROP);
       if (wid)
 	winUpdateIcon (wid);
+
       /* Update the system menu for this window */
       SetupSysMenu ((unsigned long)hwnd);
 
@@ -241,8 +234,12 @@ ReloadPrefs (void)
   int i;
 
 #ifdef XWIN_MULTIWINDOW
-  /* First, iterate over all windows replacing their icon with system */
-  /* default one and deleting any custom system menus                 */
+  /* First, iterate over all windows, deleting their icons and custom menus.
+   * This is really only needed because winDestroyIcon() will try to
+   * destroy the old global icons, which will have changed.
+   * It is probably better to set a windows USER_DATA to flag locally defined
+   * icons, and use that to accurately know when to destroy old icons.
+   */
   EnumThreadWindows (g_dwCurrentThreadID, ReloadEnumWindowsProc, FALSE);
 #endif
   
diff --git a/hw/xwin/winwin32rootlesswindow.c b/hw/xwin/winwin32rootlesswindow.c
index 3f521d6..2b2f630 100755
--- a/hw/xwin/winwin32rootlesswindow.c
+++ b/hw/xwin/winwin32rootlesswindow.c
@@ -177,12 +177,12 @@ winMWExtWMUpdateIcon (Window id)
 
       if (pRLWinPriv->hWnd)
 	{
-	  hiconOld = (HICON) SetClassLong (pRLWinPriv->hWnd,
-					   GCL_HICON,
-					   (int) hIcon);
-	  
+
+          hiconOld = (HICON) SendMessage (pRLWinPriv->hWnd,
+                     WM_SETICON, ICON_BIG, (LPARAM) hIcon);
           winDestroyIcon(hiconOld);
 	}
+      hIcon=NULL;
     }
 }
 
commit 9955252564922e7e8702dfb6eab52c75605a4a22
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Mon Jan 5 17:55:58 2009 +0000

    Cygwin/X: Remove unused TimeSinceLastInputEvent()
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>

diff --git a/hw/xwin/InitInput.c b/hw/xwin/InitInput.c
index 76c1715..2eaa024 100644
--- a/hw/xwin/InitInput.c
+++ b/hw/xwin/InitInput.c
@@ -48,7 +48,6 @@ DISPATCH_PROC(winProcSetSelectionOwner);
  * Local global declarations
  */
 
-CARD32				g_c32LastInputEventTime = 0;
 DeviceIntPtr g_pwinPointer;
 DeviceIntPtr g_pwinKeyboard;
 
@@ -110,15 +109,6 @@ void DDXRingBell(int volume, int pitch, int duration)
 }
 
 
-int
-TimeSinceLastInputEvent ()
-{
-  if (g_c32LastInputEventTime == 0)
-    g_c32LastInputEventTime = GetTickCount ();
-  return GetTickCount () - g_c32LastInputEventTime;
-}
-
-
 /* See Porting Layer Definition - p. 17 */
 void
 InitInput (int argc, char *argv[])
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 8005d5b..9009df2 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -636,7 +636,6 @@ extern DevPrivateKey		g_iGCPrivateKey;
 extern DevPrivateKey		g_iPixmapPrivateKey;
 extern DevPrivateKey		g_iWindowPrivateKey;
 extern unsigned long		g_ulServerGeneration;
-extern CARD32			g_c32LastInputEventTime;
 extern DWORD			g_dwEnginesSupported;
 extern HINSTANCE		g_hInstance;
 extern int                      g_copyROP[];
diff --git a/hw/xwin/winmouse.c b/hw/xwin/winmouse.c
index 188126b..9cfc945 100644
--- a/hw/xwin/winmouse.c
+++ b/hw/xwin/winmouse.c
@@ -354,7 +354,6 @@ winMouseButtonsHandle (ScreenPtr pScreen,
 void winEnqueueMotion(int x, int y)
 {
   miPointerSetPosition(g_pwinPointer, &x, &y);
-  g_c32LastInputEventTime = GetTickCount();
 
   int i, nevents;
   int valuators[2];
commit 966c8fccf16e77c8f459b4b175718323f2ec5d58
Author: Colin Harrison <colin.harrison at virgin.net>
Date:   Mon Jan 5 18:04:42 2009 +0000

    Xming: Fix some log spam
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>

diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c
index ea9dfca..194dbf6 100644
--- a/hw/xwin/winmultiwindowwm.c
+++ b/hw/xwin/winmultiwindowwm.c
@@ -1359,7 +1359,9 @@ winMultiWindowXMsgProcErrorHandler (Display *pDisplay, XErrorEvent *pErr)
 		 pErr->error_code,
 		 pszErrorMsg,
 		 sizeof (pszErrorMsg));
+#if CYGMULTIWINDOW_DEBUG
   ErrorF ("winMultiWindowXMsgProcErrorHandler - ERROR: %s\n", pszErrorMsg);
+#endif
   
   return 0;
 }
commit d190a27a33ab8c198568baf184fad14df57e24ad
Author: Colin Harrison <colin.harrison at virgin.net>
Date:   Thu Jan 29 11:00:49 2009 +0000

    Xming: Various tidy ups in winClipboardFlushXEvents()
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>

diff --git a/hw/xwin/winclipboardxevents.c b/hw/xwin/winclipboardxevents.c
index 0a64ba6..ec40814 100644
--- a/hw/xwin/winclipboardxevents.c
+++ b/hw/xwin/winclipboardxevents.c
@@ -311,6 +311,7 @@ winClipboardFlushXEvents (HWND hwnd,
 
 	  /* Initialize the text property */
 	  xtpText.value = NULL;
+	  xtpText.nitems = 0;
 
 	  /* Create the text property from the text list */
 	  if (fUseUnicode)
@@ -371,10 +372,13 @@ winClipboardFlushXEvents (HWND hwnd,
 	  /* Release the clipboard data */
 	  GlobalUnlock (hGlobal);
 	  pszGlobalData = NULL;
+	  fCloseClipboard = FALSE;
+	  CloseClipboard ();
 
 	  /* Clean up */
 	  XFree (xtpText.value);
 	  xtpText.value = NULL;
+	  xtpText.nitems = 0;
 
 	  /* Setup selection notify event */
 	  eventSelection.type = SelectionNotify;
@@ -405,7 +409,11 @@ winClipboardFlushXEvents (HWND hwnd,
 	winClipboardFlushXEvents_SelectionRequest_Done:
 	  /* Free allocated resources */
 	  if (xtpText.value)
+	  {
 	    XFree (xtpText.value);
+	    xtpText.value = NULL;
+	    xtpText.nitems = 0;
+	  }
 	  if (pszConvertData)
 	    free (pszConvertData);
 	  if (hGlobal && pszGlobalData)
@@ -446,7 +454,10 @@ winClipboardFlushXEvents (HWND hwnd,
 
 	  /* Close clipboard if it was opened */
 	  if (fCloseClipboard)
+	  {
+	    fCloseClipboard = FALSE;
 	    CloseClipboard ();
+	  }
 	  break;
 
 
@@ -628,6 +639,7 @@ winClipboardFlushXEvents (HWND hwnd,
 	      /* Conversion succeeded or some unconvertible characters */
 	      if (ppszTextList != NULL)
 		{
+		  iReturnDataLen = 0;
 		  for (i = 0; i < iCount; i++)
 		    {
 		      iReturnDataLen += strlen(ppszTextList[i]);
@@ -673,6 +685,7 @@ winClipboardFlushXEvents (HWND hwnd,
 	  ppszTextList = NULL;
 	  XFree (xtpText.value);
 	  xtpText.value = NULL;
+	  xtpText.nitems = 0;
 
 	  /* Convert the X clipboard string to DOS format */
 	  winClipboardUNIXtoDOS (&pszReturnData, strlen (pszReturnData));
@@ -786,7 +799,11 @@ winClipboardFlushXEvents (HWND hwnd,
 	  if (ppszTextList)
 	    XFreeStringList (ppszTextList);
 	  if (xtpText.value)
+	  {
 	    XFree (xtpText.value);
+	    xtpText.value = NULL;
+	    xtpText.nitems = 0;
+	  }
 	  if (pszConvertData)
 	    free (pszConvertData);
 	  if (pwszUnicodeStr)
commit fbe9ed27b1c2f932a74aa6ced134ecec021a3fc1
Author: Colin Harrison <colin.harrison at virgin.net>
Date:   Thu Jan 29 10:55:38 2009 +0000

    Xming: Avoid log spam if a windows application won't provide CF_UNICODETEXT clipboard format
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>

diff --git a/hw/xwin/winclipboardxevents.c b/hw/xwin/winclipboardxevents.c
index ab8d5e4..0a64ba6 100644
--- a/hw/xwin/winclipboardxevents.c
+++ b/hw/xwin/winclipboardxevents.c
@@ -191,8 +191,13 @@ winClipboardFlushXEvents (HWND hwnd,
 	  if (fUseUnicode
 	      && !IsClipboardFormatAvailable (CF_UNICODETEXT))
 	    {
-	      ErrorF ("winClipboardFlushXEvents - CF_UNICODETEXT is not "
-		      "available from Win32 clipboard.  Aborting.\n");
+	      static int count; /* Hack to stop acroread spamming the log */
+	      static HWND lasthwnd; /* I've not seen any other client get here repeatedly? */
+	      if (hwnd != lasthwnd) count = 0;
+	      count++;
+	      if (count < 6) ErrorF ("winClipboardFlushXEvents - CF_UNICODETEXT is not "
+		      "available from Win32 clipboard.  Aborting %d.\n", count);
+	      lasthwnd = hwnd;
 
 	      /* Abort */
 	      fAbort = TRUE;
commit 71ba9856a4f01aa7a42f1178c8da98a2e5ac23ae
Author: Colin Harrison <colin.harrison at virgin.net>
Date:   Tue Feb 3 15:52:11 2009 +0000

    Xming: Cache atom lookups in clipboard integration code
    
    Cache the CLIPBOARD atom lookups in winClipboardWindowProc()
    Cache atom lookups in winClipboardFlushXEvents()
    Recache on server regeneration
    
    Copyright (C) Colin Harrison 2005-2008
    http://www.straightrunning.com/XmingNotes/
    http://sourceforge.net/projects/xming/
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>

diff --git a/hw/xwin/winclipboardwndproc.c b/hw/xwin/winclipboardwndproc.c
index 04c0c58..65faedf 100644
--- a/hw/xwin/winclipboardwndproc.c
+++ b/hw/xwin/winclipboardwndproc.c
@@ -36,6 +36,7 @@
 #include <sys/types.h>
 #include <sys/time.h>
 #include "winclipboard.h"
+#include "misc.h"
 
 extern void		winFixClipboardChain();
 
@@ -261,6 +262,8 @@ winClipboardWindowProc (HWND hwnd, UINT message,
 
     case WM_DRAWCLIPBOARD:
       {
+	static Atom atomClipboard;
+	static int generation;
 	static Bool s_fProcessingDrawClipboard = FALSE;
 	Display	*pDisplay = g_pClipboardDisplay;
 	Window	iWindow = g_iClipboardWindow;
@@ -268,6 +271,12 @@ winClipboardWindowProc (HWND hwnd, UINT message,
 
 	winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD: Enter\n");
 
+	if (generation != serverGeneration)
+          {
+            generation = serverGeneration;
+            atomClipboard = XInternAtom (pDisplay, "CLIPBOARD", False);
+          }
+
 	/*
 	 * We've occasionally seen a loop in the clipboard chain.
 	 * Try and fix it on the first hint of recursion.
@@ -355,17 +364,13 @@ winClipboardWindowProc (HWND hwnd, UINT message,
 
 	    /* Release CLIPBOARD selection if owned */
 	    iReturn = XGetSelectionOwner (pDisplay,
-					  XInternAtom (pDisplay,
-						       "CLIPBOARD",
-						       False));
+					  atomClipboard);
 	    if (iReturn == g_iClipboardWindow)
 	      {
 		winDebug ("winClipboardWindowProc - WM_DRAWCLIPBOARD - "
 			"CLIPBOARD selection is owned by us.\n");
 		XSetSelectionOwner (pDisplay,
-				    XInternAtom (pDisplay,
-						 "CLIPBOARD",
-						 False),
+				    atomClipboard,
 				    None,
 				    CurrentTime);
 	      }
@@ -399,17 +404,12 @@ winClipboardWindowProc (HWND hwnd, UINT message,
 	
 	/* Reassert ownership of the CLIPBOARD */	  
 	iReturn = XSetSelectionOwner (pDisplay,
-				      XInternAtom (pDisplay,
-						   "CLIPBOARD",
-						   False),
+				      atomClipboard,
 				      iWindow,
 				      CurrentTime);
 
 	if (iReturn == BadAtom || iReturn == BadWindow ||
-	    XGetSelectionOwner (pDisplay,
-                                XInternAtom (pDisplay,
-                                             "CLIPBOARD",
-                                             False)) != iWindow)
+	    XGetSelectionOwner (pDisplay, atomClipboard) != iWindow)
 	  {
 	    winErrorFVerb (1, "winClipboardWindowProc - WM_DRAWCLIPBOARD - "
 		    "Could not reassert ownership of CLIPBOARD\n");
diff --git a/hw/xwin/winclipboardxevents.c b/hw/xwin/winclipboardxevents.c
index 95e86b1..ab8d5e4 100644
--- a/hw/xwin/winclipboardxevents.c
+++ b/hw/xwin/winclipboardxevents.c
@@ -34,6 +34,7 @@
 #include <xwin-config.h>
 #endif
 #include "winclipboard.h"
+#include "misc.h"
 
 
 /*
@@ -53,18 +54,20 @@ winClipboardFlushXEvents (HWND hwnd,
 			  Display *pDisplay,
 			  Bool fUseUnicode)
 {
-  Atom			atomLocalProperty = XInternAtom (pDisplay,
-							 WIN_LOCAL_PROPERTY,
-							 False);
-  Atom			atomUTF8String = XInternAtom (pDisplay,
-						      "UTF8_STRING",
-						      False);
-  Atom			atomCompoundText = XInternAtom (pDisplay,
-							"COMPOUND_TEXT",
-							False);
-  Atom			atomTargets = XInternAtom (pDisplay,
-						   "TARGETS",
-						   False);
+  static Atom atomLocalProperty;
+  static Atom atomCompoundText;
+  static Atom atomUTF8String;
+  static Atom atomTargets;
+  static int generation;
+
+  if (generation != serverGeneration)
+    {
+      generation = serverGeneration;
+      atomLocalProperty = XInternAtom (pDisplay, WIN_LOCAL_PROPERTY, False);
+      atomUTF8String = XInternAtom (pDisplay, "UTF8_STRING", False);
+      atomCompoundText = XInternAtom (pDisplay, "COMPOUND_TEXT", False);
+      atomTargets = XInternAtom (pDisplay, "TARGETS", False);
+    }
 
   /* Process all pending events */
   while (XPending (pDisplay))
commit 4ec110327bdc4f2617cd6116539812d7ef96b24e
Author: Colin Harrison <colin.harrison at virgin.net>
Date:   Sun Jan 4 18:29:49 2009 +0000

    Xming: Prevent the mouse wheel from stalling when another window is minimized.
    
    Fix internal WM to prevent the mouse wheel from stalling when another window is minimized.
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>

diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c
index 0dd8885..becae29 100644
--- a/hw/xwin/winmultiwindowwndproc.c
+++ b/hw/xwin/winmultiwindowwndproc.c
@@ -786,6 +786,10 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
 	    if (!pWin || !pWin->overrideRedirect) /* for OOo menus */
 	      winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg);
 	}
+      /* Prevent the mouse wheel from stalling when another window is minimized */
+      if (HIWORD(wParam) == 0 && LOWORD(wParam) == WA_ACTIVE &&
+	  (HWND)lParam != NULL && (HWND)lParam != (HWND)GetParent(hwnd))
+	SetFocus(hwnd);
       return 0;
 
     case WM_ACTIVATEAPP:
commit 888e6961a4ee76d05d212cfb946f089caafb3f69
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Wed Jan 7 18:29:16 2009 +0000

    Cygwin/X: Correctly allow for the native window frame width in ValidateSizing()
    
    Fix internal WM to correctly calculate the native window border when validating window sizing
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>

diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c
index b5e789c..0dd8885 100644
--- a/hw/xwin/winmultiwindowwndproc.c
+++ b/hw/xwin/winmultiwindowwndproc.c
@@ -207,6 +207,8 @@ ValidateSizing (HWND hwnd, WindowPtr pWin,
   WinXSizeHints sizeHints;
   RECT *rect;
   int iWidth, iHeight;
+  RECT rcClient, rcWindow;
+  int iBorderWidthX, iBorderWidthY;
 
   /* Invalid input checking */
   if (pWin==NULL || lParam==0)
@@ -228,19 +230,20 @@ ValidateSizing (HWND hwnd, WindowPtr pWin,
   iWidth = rect->right - rect->left;
   iHeight = rect->bottom - rect->top;
 
-  /* Now remove size of any borders */
-  iWidth -= 2 * GetSystemMetrics(SM_CXSIZEFRAME);
-  iHeight -= (GetSystemMetrics(SM_CYCAPTION)
-	      + 2 * GetSystemMetrics(SM_CYSIZEFRAME));
-	      
+  /* Now remove size of any borders and title bar */
+  GetClientRect(hwnd, &rcClient);
+  GetWindowRect(hwnd, &rcWindow);
+  iBorderWidthX = (rcWindow.right - rcWindow.left) - (rcClient.right - rcClient.left);
+  iBorderWidthY = (rcWindow.bottom - rcWindow.top) - (rcClient.bottom - rcClient.top);
+  iWidth -= iBorderWidthX;
+  iHeight -= iBorderWidthY;
 
   /* Constrain the size to legal values */
   ConstrainSize (sizeHints, &iWidth, &iHeight);
 
-  /* Add back the borders */
-  iWidth += 2 * GetSystemMetrics(SM_CXSIZEFRAME);
-  iHeight += (GetSystemMetrics(SM_CYCAPTION)
-	      + 2 * GetSystemMetrics(SM_CYSIZEFRAME));
+  /* Add back the size of borders and title bar */
+  iWidth += iBorderWidthX;
+  iHeight += iBorderWidthY;
 
   /* Adjust size according to where we're dragging from */
   switch(wParam) {
commit a72865868f03b675f86990476fcee601822894b3
Author: Joe Krahn <jkrahn at nc.rr.com>
Date:   Tue Jan 20 17:09:43 2009 +0000

    Cygwin/X: Consolidate dialog initialization in winInitDialog()
    
    Changed windialogs.c to set icons via window properties rather than class
    properties, and use LoadImage() for small icons, because LoadIcon() can only open
    large icons. Since this code is redundant across the dialogs, I put it in the
    winCenterDialog function, along with a few other redundant instructions, and
    renamed in winInitDialog().
    
    Also, don't bogusly put our dialogs at the center of the virtual desktop if we
    are on a multimonitor system (this causes the dialog to end up split across two
    monitors in a dual-monitor side-by-side setup)
    
    Corrections to use HWND_TOPMOST instead of HWND_TOP and not to use SWP_NOZORDER
    from Colin Harrison
    
    fd.o bugzilla #4491
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>

diff --git a/hw/xwin/windialogs.c b/hw/xwin/windialogs.c
index ab06b0d..274c046 100755
--- a/hw/xwin/windialogs.c
+++ b/hw/xwin/windialogs.c
@@ -181,32 +181,64 @@ winUnoverrideURLButton (HWND hwnd, int id)
 
 /*
  * Center a dialog window in the desktop window
+ * and set small and large icons to X icons.
  */
 
 static void
-winCenterDialog (HWND hwndDlg)
+winInitDialog (HWND hwndDlg)
 {
   HWND hwndDesk; 
-  RECT rc, rcDlg, rcDesk; 
+  RECT rc, rcDlg, rcDesk;
+  HICON hIcon, hIconSmall;
  
   hwndDesk = GetParent (hwndDlg);
   if (!hwndDesk || IsIconic (hwndDesk))
     hwndDesk = GetDesktopWindow (); 
   
-  GetWindowRect (hwndDesk, &rcDesk); 
-  GetWindowRect (hwndDlg, &rcDlg); 
-  CopyRect (&rc, &rcDesk); 
-  
-  OffsetRect (&rcDlg, -rcDlg.left, -rcDlg.top); 
-  OffsetRect (&rc, -rc.left, -rc.top); 
-  OffsetRect (&rc, -rcDlg.right, -rcDlg.bottom); 
-  
-  SetWindowPos (hwndDlg, 
-		HWND_TOP, 
-		rcDesk.left + (rc.right / 2), 
-		rcDesk.top + (rc.bottom / 2), 
+  /* Remove minimize and maximize buttons */
+  SetWindowLong (hwndDlg, GWL_STYLE,
+		 GetWindowLong (hwndDlg, GWL_STYLE)
+		 & ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
+
+  /* Set Window not to show in the task bar */
+  SetWindowLong (hwndDlg, GWL_EXSTYLE,
+		 GetWindowLong (hwndDlg, GWL_EXSTYLE) & ~WS_EX_APPWINDOW );
+
+  /* Center dialog window in the screen. Not done for multi-monitor systems, where
+   * it is likely to end up split across the screens. In that case, it appears
+   * near the Tray icon.
+   */
+  if (GetSystemMetrics(SM_CMONITORS)>1) {
+    /* Still need to refresh the frame change. */
+    SetWindowPos (hwndDlg, HWND_TOPMOST, 0,0,0,0,
+		SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
+  } else {
+    GetWindowRect (hwndDesk, &rcDesk);
+    GetWindowRect (hwndDlg, &rcDlg);
+    CopyRect (&rc, &rcDesk);
+
+    OffsetRect (&rcDlg, -rcDlg.left, -rcDlg.top);
+    OffsetRect (&rc, -rc.left, -rc.top);
+    OffsetRect (&rc, -rcDlg.right, -rcDlg.bottom);
+
+    SetWindowPos (hwndDlg,
+		HWND_TOPMOST,
+		rcDesk.left + (rc.right / 2),
+		rcDesk.top + (rc.bottom / 2),
 		0, 0,
-		SWP_NOSIZE | SWP_NOZORDER); 
+		SWP_NOSIZE | SWP_FRAMECHANGED);
+  }
+
+  /* Set icon to standard app icon */
+  hIcon = LoadIcon (g_hInstance, MAKEINTRESOURCE(IDI_XWIN));
+  hIconSmall = LoadImage (g_hInstance,
+                        MAKEINTRESOURCE(IDI_XWIN), IMAGE_ICON,
+                        GetSystemMetrics(SM_CXSMICON),
+                        GetSystemMetrics(SM_CYSMICON),
+                        LR_SHARED);
+
+  PostMessage (hwndDlg, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
+  PostMessage (hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) hIconSmall);
 }
 
 
@@ -271,15 +303,6 @@ winDisplayExitDialog (winPrivScreenPtr pScreenPriv)
 				  winExitDlgProc,
 				  (int) pScreenPriv);
 
-  /* Drop minimize and maximize buttons */
-  SetWindowLong (g_hDlgExit, GWL_STYLE,
-		 GetWindowLong (g_hDlgExit, GWL_STYLE)
-		 & ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
-  SetWindowLong (g_hDlgExit, GWL_EXSTYLE,
-		 GetWindowLong (g_hDlgExit, GWL_EXSTYLE) & ~WS_EX_APPWINDOW );
-  SetWindowPos (g_hDlgExit, HWND_TOPMOST, 0, 0, 0, 0,
-		SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE); 
- 
   /* Show the dialog box */
   ShowWindow (g_hDlgExit, SW_SHOW);
   
@@ -314,14 +337,7 @@ winExitDlgProc (HWND hDialog, UINT message,
 	/* Store pointers to private structures for future use */
 	s_pScreenPriv = (winPrivScreenPtr) lParam;
 	
-	winCenterDialog (hDialog);
-	
-	/* Set icon to standard app icon */
-	PostMessage (hDialog,
-		     WM_SETICON,
-		     ICON_SMALL,
-		     (LPARAM) LoadIcon (g_hInstance,
-					MAKEINTRESOURCE(IDI_XWIN)));
+	winInitDialog (hDialog);
 
 	/* Format the connected clients string */
 	pszConnectedClients = Xprintf (CONNECTED_CLIENTS_FORMAT,
@@ -413,17 +429,6 @@ winDisplayDepthChangeDialog (winPrivScreenPtr pScreenPriv)
 					 pScreenPriv->hwndScreen,
 					 winChangeDepthDlgProc,
 					 (int) pScreenPriv);
- 
-  /* Drop minimize and maximize buttons */
-  SetWindowLong (g_hDlgDepthChange, GWL_STYLE,
-		 GetWindowLong (g_hDlgDepthChange, GWL_STYLE)
-		 & ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
-  SetWindowLong (g_hDlgDepthChange, GWL_EXSTYLE,
-		 GetWindowLong (g_hDlgDepthChange, GWL_EXSTYLE)
-		 & ~WS_EX_APPWINDOW );
-  SetWindowPos (g_hDlgDepthChange, 0, 0, 0, 0, 0,
-		SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER | SWP_NOSIZE); 
-
   /* Show the dialog box */
   ShowWindow (g_hDlgDepthChange, SW_SHOW);
   
@@ -480,13 +485,7 @@ winChangeDepthDlgProc (HWND hwndDialog, UINT message,
 	      s_pScreenPriv->dwLastWindowsBitsPixel);
 #endif
       
-      winCenterDialog( hwndDialog );
-
-      /* Set icon to standard app icon */
-      PostMessage (hwndDialog,
-		   WM_SETICON,
-		   ICON_SMALL,
-		   (LPARAM) LoadIcon (g_hInstance, MAKEINTRESOURCE(IDI_XWIN)));
+      winInitDialog( hwndDialog );
 
       return TRUE;
 
@@ -572,15 +571,6 @@ winDisplayAboutDialog (winPrivScreenPtr pScreenPriv)
 				   winAboutDlgProc,
 				   (int) pScreenPriv);
  
-  /* Drop minimize and maximize buttons */
-  SetWindowLong (g_hDlgAbout, GWL_STYLE,
-		 GetWindowLong (g_hDlgAbout, GWL_STYLE)
-		 & ~(WS_MAXIMIZEBOX | WS_MINIMIZEBOX));
-  SetWindowLong (g_hDlgAbout, GWL_EXSTYLE,
-		 GetWindowLong (g_hDlgAbout, GWL_EXSTYLE) & ~WS_EX_APPWINDOW);
-  SetWindowPos (g_hDlgAbout, 0, 0, 0, 0, 0,
-		SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE); 
-
   /* Show the dialog box */
   ShowWindow (g_hDlgAbout, SW_SHOW);
 
@@ -622,13 +612,7 @@ winAboutDlgProc (HWND hwndDialog, UINT message,
       s_pScreenInfo = s_pScreenPriv->pScreenInfo;
       s_pScreen = s_pScreenInfo->pScreen;
 
-      winCenterDialog (hwndDialog);
-
-      /* Set icon to standard app icon */
-      PostMessage (hwndDialog,
-		   WM_SETICON,
-		   ICON_SMALL,
-		   (LPARAM) LoadIcon (g_hInstance, MAKEINTRESOURCE(IDI_XWIN)));
+      winInitDialog (hwndDialog);
 
       /* Override the URL buttons */
       winOverrideURLButton (hwndDialog, ID_ABOUT_CHANGELOG);
commit d053c3b35f730fdaddd22f841dbd8ed6c9a07ba0
Author: Colin Harrison <colin.harrison at virgin.net>
Date:   Sun Nov 2 20:46:40 2008 +0000

    Xming: Slightly adjust the formatting of the logged command line
    
    Copyright (C) Colin Harrison 2005-2008
    http://www.straightrunning.com/XmingNotes/
    http://sourceforge.net/projects/xming/
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>

diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c
index 38ee9a2..f20598d 100755
--- a/hw/xwin/winprocarg.c
+++ b/hw/xwin/winprocarg.c
@@ -1448,13 +1448,13 @@ winLogCommandLine (int argc, char *argv[])
   for (i = 0, iCurrLen = 0; i < argc; ++i)
     if (argv[i])
       {
-	/* Add a character for lines that overflow */
+	/* Adds two characters for lines that overflow */
 	if ((strlen (argv[i]) < CHARS_PER_LINE
 	    && iCurrLen + strlen (argv[i]) > CHARS_PER_LINE)
 	    || strlen (argv[i]) > CHARS_PER_LINE)
 	  {
 	    iCurrLen = 0;
-	    ++iSize;
+	    iSize += 2;
 	  }
 	
 	/* Add space for item and trailing space */
@@ -1484,7 +1484,7 @@ winLogCommandLine (int argc, char *argv[])
 	iCurrLen = 0;
 	
 	/* Add line break if it fits */
-	strncat (g_pszCommandLine, "\n", iSize - strlen (g_pszCommandLine));
+	strncat (g_pszCommandLine, "\n ", iSize - strlen (g_pszCommandLine));
       }
       
       strncat (g_pszCommandLine, argv[i], iSize - strlen (g_pszCommandLine));


More information about the xorg-commit mailing list