xserver: Branch 'master' - 7 commits

Keith Packard keithp at kemper.freedesktop.org
Wed Nov 2 21:35:53 PDT 2011


 hw/xwin/InitOutput.c              |   66 ++++----------------------------------
 hw/xwin/XWin.exe.manifest         |    5 ++
 hw/xwin/ddraw.h                   |    2 -
 hw/xwin/win.h                     |    3 -
 hw/xwin/winclipboardwndproc.c     |   48 +--------------------------
 hw/xwin/winglobals.c              |    7 ----
 hw/xwin/winmonitors.c             |   28 ----------------
 hw/xwin/winmultiwindowwndproc.c   |    4 +-
 hw/xwin/winprocarg.c              |   32 ++++++++++++------
 hw/xwin/winwin32rootlesswndproc.c |    4 +-
 hw/xwin/winwndproc.c              |    4 +-
 xkb/ddxList.c                     |    8 +++-
 xkb/ddxLoad.c                     |    3 +
 13 files changed, 54 insertions(+), 160 deletions(-)

New commits:
commit 548c6fe044068ffba9b5306dc6b11f2ba22782a4
Merge: 3881b0b... ffe8ec8...
Author: Keith Packard <keithp at keithp.com>
Date:   Wed Nov 2 21:35:31 2011 -0700

    Merge remote-tracking branch 'jturney/master'

commit ffe8ec86db2655b2c83e5ae61521898140c855ac
Author: Colin Harrison <colin.harrison at virgin.net>
Date:   Sat Oct 8 15:05:22 2011 +0100

    hw/xwin: Fix a typo in ddraw.h
    
    Fix a (fortunately benign) typo in ddraw.h
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>

diff --git a/hw/xwin/ddraw.h b/hw/xwin/ddraw.h
index 2eb7c26..9d87b2b 100644
--- a/hw/xwin/ddraw.h
+++ b/hw/xwin/ddraw.h
@@ -1449,7 +1449,7 @@ DECLARE_INTERFACE_(IDirectDraw4,IUnknown)
 #define IDirectDraw4_GetAvailableVidMem(p,a,b,c) ICOM_CALL_(GetAvailableVidMem,p,(p,a,b,c))
 /*** IDirectDraw4 methods ***/
 #define IDirectDraw4_GetSurfaceFromDC(p,a,b)    ICOM_CALL_(GetSurfaceFromDC,p,(p,a,b))
-#define IDirectDraw4_RestoreAllSurfaces(pc)     ICOM_CALL_(RestoreAllSurfaces,p,(p))
+#define IDirectDraw4_RestoreAllSurfaces(p)      ICOM_CALL_(RestoreAllSurfaces,p,(p))
 #define IDirectDraw4_TestCooperativeLevel(p)    ICOM_CALL_(TestCooperativeLevel,p,(p))
 #define IDirectDraw4_GetDeviceIdentifier(p,a,b) ICOM_CALL_(GetDeviceIdentifier,p,(p,a,b))
 
commit 48fda3c52b41157313b7fd56d9f3fa3ad4166ed7
Author: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
Date:   Thu Feb 18 20:37:00 2010 -0600

    hw/xwin: Revert "Fix bug #5735, Serious flaw in CygwinX clipboard"
    
    This commit wreaks havoc with other programs which manage the clipboard,
    such as MS Office Clipboard or Win32 VNC viewers:
    
    http://sourceware.org/bugzilla/show_bug.cgi?id=9910
    
    This reverts commit 70ddd0f39d5118db72a1a4e473cbfb502f1ed9ec.
    
    Signed-off-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/winclipboardwndproc.c b/hw/xwin/winclipboardwndproc.c
index 9394b04..03da7f4 100644
--- a/hw/xwin/winclipboardwndproc.c
+++ b/hw/xwin/winclipboardwndproc.c
@@ -56,8 +56,6 @@ extern void		*g_pClipboardDisplay;
 extern Window		g_iClipboardWindow;
 extern Atom		g_atomLastOwnedSelection;
 
-/* BPS - g_hwndClipboard needed for X app->Windows paste fix */
-extern HWND		g_hwndClipboard;
 
 /* 
  * Local function prototypes
@@ -143,12 +141,6 @@ winProcessXEventsTimeout (HWND hwnd, int iWindow, Display *pDisplay,
  * Process a given Windows message
  */
 
-/* BPS - Define our own message, which we'll post to ourselves to facilitate
- * resetting the delayed rendering mechanism after each paste from X app to
- * Windows app. TODO - Perhaps move to win.h with the other WM_USER messages.
- */
-#define WM_USER_PASTE_COMPLETE		(WM_USER + 1003)
-
 LRESULT CALLBACK
 winClipboardWindowProc (HWND hwnd, UINT message, 
 			WPARAM wParam, LPARAM lParam)
@@ -343,6 +335,8 @@ winClipboardWindowProc (HWND hwnd, UINT message,
 	     * previous XSetSelectionOwner messages.
 	     */
 	    XSync (pDisplay, FALSE);
+
+            winDebug("winClipboardWindowProc - XSync done.\n");
 	    
 	    /* Release PRIMARY selection if owned */
 	    iReturn = XGetSelectionOwner (pDisplay, XA_PRIMARY);
@@ -540,13 +534,6 @@ winClipboardWindowProc (HWND hwnd, UINT message,
             ErrorF("winClipboardWindowProc - timed out waiting for WIN_XEVENTS_NOTIFY\n");
 	  }
 
-	/* BPS - Post ourselves a user message whose handler will reset the
-	 * delayed rendering mechanism after the paste is complete. This is
-	 * necessary because calling SetClipboardData() with a NULL argument
-	 * here will cause the data we just put on the clipboard to be lost!
-	 */
-	PostMessage(g_hwndClipboard, WM_USER_PASTE_COMPLETE, 0, 0);
-
 	/* Special handling for WM_RENDERALLFORMATS */
 	if (message == WM_RENDERALLFORMATS)
 	  {
@@ -564,37 +551,6 @@ winClipboardWindowProc (HWND hwnd, UINT message,
 	winDebug ("winClipboardWindowProc - WM_RENDER*FORMAT - Returning.\n");
 	return 0;
       }
-    /* BPS - This WM_USER message is posted by us. It gives us the opportunity
-     * to reset the delayed rendering mechanism after each and every paste
-     * from an X app to a Windows app. Without such a mechanism, subsequent
-     * changes of selection in the X app owning the selection are not
-     * reflected in pastes into Windows apps, since Windows won't send us the
-     * WM_RENDERFORMAT message unless someone has set changed data (or NULL)
-     * on the clipboard. */
-    case WM_USER_PASTE_COMPLETE:
-      {
-	if (hwnd != GetClipboardOwner ())
-	  /* In case we've lost the selection since posting the message */
-	  return 0;
-	winDebug ("winClipboardWindowProc - WM_USER_PASTE_COMPLETE\n");
-
-	/* Set up for another delayed rendering callback */
-	OpenClipboard (g_hwndClipboard);
-
-	/* Take ownership of the Windows clipboard */
-	EmptyClipboard ();
-
-	/* Advertise Unicode if we support it */
-	if (g_fUnicodeSupport)
-	  SetClipboardData (CF_UNICODETEXT, NULL);
-
-	/* Always advertise regular text */
-	SetClipboardData (CF_TEXT, NULL);
-
-	/* Release the clipboard */
-	CloseClipboard ();
-      }
-      return 0;
     }
 
   /* Let Windows perform default processing for unhandled messages */
commit 3ead1d810b0e157078db39712e02ea6dc85216d8
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Sun Jul 3 19:10:52 2011 +0100

    hw/xwin: Stop pretending we work on NT4
    
    We already link directly to some functions not available in NT4, so stop
    pretending we will work on NT4 and link directly to EnumDisplayMonitors()
    and SHGetFolderPath()
    
    Also remove mentions of NT4 & Win95 from error messages
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 67961b7..7704392 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -588,34 +588,17 @@ winFixupPaths (void)
     }
     if (getenv("HOME") == NULL)
     {
-        HMODULE shfolder;
-        SHGETFOLDERPATHPROC shgetfolderpath = NULL;
         char buffer[MAX_PATH + 5];
         strncpy(buffer, "HOME=", 5);
 
-        /* Try to load SHGetFolderPath from shfolder.dll and shell32.dll */
-        
-        shfolder = LoadLibrary("shfolder.dll");
-        /* fallback to shell32.dll */
-        if (shfolder == NULL)
-            shfolder = LoadLibrary("shell32.dll");
-
-        /* resolve SHGetFolderPath */
-        if (shfolder != NULL)
-            shgetfolderpath = (SHGETFOLDERPATHPROC)GetProcAddress(shfolder, "SHGetFolderPathA");
-
         /* query appdata directory */
-        if (shgetfolderpath &&
-                shgetfolderpath(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, NULL, 0, 
-                    buffer + 5) == 0)
-        { 
+        if (SHGetFolderPathA(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, NULL, 0, buffer + 5) == 0)
+        {
             putenv(buffer);
         } else
         {
             winMsg (X_ERROR, "Can not determine HOME directory\n");
-        } 
-        if (shfolder != NULL)
-            FreeLibrary(shfolder);
+        }
     }
     if (!g_fLogFileChanged) {
         static char buffer[MAX_PATH];
@@ -825,10 +808,10 @@ winUseMsg (void)
 	  "\theight and initial position for that screen. Additionally\n"
 	  "\ta monitor number can be specified to start the server on,\n"
 	  "\tat which point, all coordinates become relative to that\n"
-      "\tmonitor (Not for Windows NT4 and 95). Examples:\n"
-      "\t -screen 0 800x600+100+100 at 2 ; 2nd monitor offset 100,100 size 800x600\n"
-      "\t -screen 0 1024x768 at 3        ; 3rd monitor size 1024x768\n"
-      "\t -screen 0 @1 ; on 1st monitor using its full resolution (the default)\n");
+	  "\tmonitor. Examples:\n"
+	  "\t -screen 0 800x600+100+100 at 2 ; 2nd monitor offset 100,100 size 800x600\n"
+	  "\t -screen 0 1024x768 at 3        ; 3rd monitor size 1024x768\n"
+	  "\t -screen 0 @1 ; on 1st monitor using its full resolution (the default)\n");
 
   ErrorF ("-silent-dup-error\n"
 	  "\tIf another instance of " EXECUTABLE_NAME " with the same display number is running\n"
diff --git a/hw/xwin/winmonitors.c b/hw/xwin/winmonitors.c
index a9d46f9..967ae6d 100644
--- a/hw/xwin/winmonitors.c
+++ b/hw/xwin/winmonitors.c
@@ -53,30 +53,8 @@ wBOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _d
   return TRUE;
 }
 
-typedef WINAPI wBOOL (*ENUMDISPLAYMONITORSPROC)(HDC,LPCRECT,MONITORENUMPROC,LPARAM);
-ENUMDISPLAYMONITORSPROC _EnumDisplayMonitors;
-
-wBOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data);
-
 Bool QueryMonitor(int index, struct GetMonitorInfoData *data)
 {
-    /* Load EnumDisplayMonitors from DLL */
-    HMODULE user32;
-    FARPROC func;
-    user32 = LoadLibrary("user32.dll");
-    if (user32 == NULL)
-    {
-        winW32Error(2, "Could not open user32.dll");
-        return FALSE;
-    }
-    func = GetProcAddress(user32, "EnumDisplayMonitors");
-    if (func == NULL)
-    {
-        winW32Error(2, "Could not resolve EnumDisplayMonitors: ");
-        return FALSE;
-    }
-    _EnumDisplayMonitors = (ENUMDISPLAYMONITORSPROC)func;
-
     /* prepare data */
     if (data == NULL)
         return FALSE;
@@ -84,9 +62,5 @@ Bool QueryMonitor(int index, struct GetMonitorInfoData *data)
     data->requestedMonitor = index;
 
     /* query information */
-    _EnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) data);
-
-    /* cleanup */
-    FreeLibrary(user32);
-    return TRUE;
+    return EnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) data);
 }
diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c
index 0c24b08..2b6949e 100644
--- a/hw/xwin/winprocarg.c
+++ b/hw/xwin/winprocarg.c
@@ -326,8 +326,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
         struct GetMonitorInfoData data;
         if (!QueryMonitor(iMonitor, &data))
         {
-            ErrorF ("ddxProcessArgument - screen - "
-                    "Querying monitors is not supported on NT4 and Win95\n");
+            ErrorF ("ddxProcessArgument - screen - Querying monitors failed\n");
         } else if (data.bMonitorSpecifiedExists == TRUE) 
         {
 		  winErrorFVerb(2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);
@@ -383,8 +382,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
           struct GetMonitorInfoData data;
           if (!QueryMonitor(iMonitor, &data))
           {
-              ErrorF ("ddxProcessArgument - screen - "
-                      "Querying monitors is not supported on NT4 and Win95\n");
+              ErrorF ("ddxProcessArgument - screen - Querying monitors failed\n");
           } else if (data.bMonitorSpecifiedExists == TRUE) 
           {
 			g_ScreenInfo[nScreenNum].iMonitor = iMonitor;
@@ -411,8 +409,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
         struct GetMonitorInfoData data;
         if (!QueryMonitor(iMonitor, &data))
         {
-		  ErrorF ("ddxProcessArgument - screen - "
-                  "Querying monitors is not supported on NT4 and Win95\n");
+		  ErrorF ("ddxProcessArgument - screen - Querying monitors failed\n");
         } else if (data.bMonitorSpecifiedExists == TRUE) 
         {
 		  winErrorFVerb (2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);
commit f6529a05a2f087cb57a7fe84f226fef3780728d0
Author: Colin Harrison <colin.harrison at virgin.net>
Date:   Sat Oct 8 14:39:07 2011 +0100

    Xming: Always remove temporary file used when invoking xkbcomp on Win32
    
    When built for native Win32, pipe() & fork() aren't available, so we
    use a tempoary file and system() to invoke xkbcomp
    
    Ensure the temporary file is always removed. It was only being removed
    on most errors, not on success :S
    
    Also fix a couple of warnings which occur when built with WIN32 defined
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Jon TURNEY <jon.turney at dronecode.org.uk>

diff --git a/xkb/ddxList.c b/xkb/ddxList.c
index 7de8efc..e599f91 100644
--- a/xkb/ddxList.c
+++ b/xkb/ddxList.c
@@ -44,7 +44,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 #ifdef WIN32
 /* from ddxLoad.c */
-extern const char* Win32TempDir();
+extern const char* Win32TempDir(void);
 extern int Win32System(const char *cmdline);
 #undef System
 #define System Win32System
@@ -126,10 +126,11 @@ XkbDDXListComponent(	DeviceIntPtr 		dev,
 char 	*file,*map,*tmp,*buf=NULL;
 FILE 	*in;
 Status	status;
-int	rval;
 Bool	haveDir;
 #ifdef WIN32
 char	tmpname[PATH_MAX];
+#else
+int	rval;
 #endif
 
     if ((list->pattern[what]==NULL)||(list->pattern[what][0]=='\0'))
@@ -223,6 +224,9 @@ char	tmpname[PATH_MAX];
     buf = malloc(PATH_MAX * sizeof(char));
     if (!buf) {
         fclose(in);
+#ifdef WIN32
+        unlink(tmpname);
+#endif
         return BadAlloc;
     }
     while ((status==Success)&&((tmp=fgets(buf,PATH_MAX,in))!=NULL)) {
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index e102035..219d39c 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -267,6 +267,9 @@ XkbDDXCompileKeymapByNames(	XkbDescPtr		xkb,
 		nameRtrn[nameRtrnLen-1]= '\0';
 	    }
             free(buf);
+#ifdef WIN32
+	    unlink(tmpname);
+#endif
 	    return TRUE;
 	}
 	else
commit ee1985386700288af1a8b1789dcad0d7d9c97393
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Sat Apr 16 23:28:45 2011 +0100

    hw/xwin: Link directly to TrackMouseEvent()
    
    TrackMouseEvent has existed in user32 since at least NT4, so
    don't bother with jumping through all the ancient compatibility hoops
    of finding if _TrackMouseEvent() exists in comctl32 so it can check
    if TrackMouseEvent() exists in user32 to see if it needs to emulate
    it...
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 4fe5053..67961b7 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -70,12 +70,6 @@ extern HWND			g_hwndClipboard;
 extern Bool			g_fClipboard;
 #endif
 
-
-/*
-  module handle for dynamically loaded comctl32 library
-*/
-static HMODULE g_hmodCommonControls = NULL;
-
 /*
  * Function prototypes
  */
@@ -235,14 +229,6 @@ ddxGiveUp (enum ExitCode error)
    * we are guaranteed to not need the DirectDraw functions.
    */
   winReleaseDDProcAddresses();
-
-  /* Unload our TrackMouseEvent function pointer */
-  if (g_hmodCommonControls != NULL)
-    {
-      FreeLibrary (g_hmodCommonControls);
-      g_hmodCommonControls = NULL;
-      g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
-    }
   
   /* Free concatenated command line */
   free(g_pszCommandLine);
@@ -979,27 +965,6 @@ InitOutput (ScreenInfo *screenInfo, int argc, char *argv[])
   /* Detect supported engines */
   winDetectSupportedEngines ();
 
-  /* Load common controls library */
-  g_hmodCommonControls = LoadLibraryEx ("comctl32.dll", NULL, 0);
-
-  /* Load TrackMouseEvent function pointer */  
-  g_fpTrackMouseEvent = GetProcAddress (g_hmodCommonControls,
-					 "_TrackMouseEvent");
-  if (g_fpTrackMouseEvent == NULL)
-    {
-      winErrorFVerb (1, "InitOutput - Could not get pointer to function\n"
-	      "\t_TrackMouseEvent in comctl32.dll.  Try installing\n"
-	      "\tInternet Explorer 3.0 or greater if you have not\n"
-	      "\talready.\n");
-
-      /* Free the library since we won't need it */
-      FreeLibrary (g_hmodCommonControls);
-      g_hmodCommonControls = NULL;
-
-      /* Set function pointer to point to no operation function */
-      g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
-    }
-
   /* Store the instance handle */
   g_hInstance = GetModuleHandle (NULL);
 
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 445bcab..e2e946f 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -673,7 +673,6 @@ extern DeviceIntPtr             g_pwinKeyboard;
 
 extern FARPROC			g_fpDirectDrawCreate;
 extern FARPROC			g_fpDirectDrawCreateClipper;
-extern FARPROC			g_fpTrackMouseEvent;
 
 
 /*
diff --git a/hw/xwin/winglobals.c b/hw/xwin/winglobals.c
index 2909f37..631f12e 100644
--- a/hw/xwin/winglobals.c
+++ b/hw/xwin/winglobals.c
@@ -78,13 +78,6 @@ Bool		g_fSoftwareCursor = FALSE;
 Bool		g_fSilentDupError = FALSE;
 Bool            g_fNativeGl = FALSE;
 
-/*
- * Global variables for dynamically loaded libraries and
- * their function pointers
- */
-
-FARPROC		g_fpTrackMouseEvent = (FARPROC) (void (*)(void))NoopDDA;
-
 
 #ifdef XWIN_CLIPBOARD
 /*
diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c
index fb1938b..3d23e97 100644
--- a/hw/xwin/winmultiwindowwndproc.c
+++ b/hw/xwin/winmultiwindowwndproc.c
@@ -549,8 +549,8 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
 	  tme.hwndTrack = hwnd;
 
 	  /* Call the tracking function */
-	  if (!(*g_fpTrackMouseEvent) (&tme))
-	    ErrorF ("winTopLevelWindowProc - _TrackMouseEvent failed\n");
+	  if (!TrackMouseEvent(&tme))
+	    ErrorF ("winTopLevelWindowProc - TrackMouseEvent failed\n");
 
 	  /* Flag that we are tracking now */
 	  s_fTracking = TRUE;
diff --git a/hw/xwin/winwin32rootlesswndproc.c b/hw/xwin/winwin32rootlesswndproc.c
index 21506df..c60a76c 100644
--- a/hw/xwin/winwin32rootlesswndproc.c
+++ b/hw/xwin/winwin32rootlesswndproc.c
@@ -547,8 +547,8 @@ winMWExtWMWindowProc (HWND hwnd, UINT message,
 	  tme.hwndTrack = hwnd;
 
 	  /* Call the tracking function */
-	  if (!(*g_fpTrackMouseEvent) (&tme))
-	    ErrorF ("winMWExtWMWindowProc - _TrackMouseEvent failed\n");
+	  if (!TrackMouseEvent(&tme))
+	    ErrorF ("winMWExtWMWindowProc - TrackMouseEvent failed\n");
 
 	  /* Flag that we are tracking now */
 	  s_fTracking = TRUE;
diff --git a/hw/xwin/winwndproc.c b/hw/xwin/winwndproc.c
index bccd6f9..a89857a 100644
--- a/hw/xwin/winwndproc.c
+++ b/hw/xwin/winwndproc.c
@@ -776,8 +776,8 @@ winWindowProc (HWND hwnd, UINT message,
 	  tme.hwndTrack = hwnd;
 
 	  /* Call the tracking function */
-	  if (!(*g_fpTrackMouseEvent) (&tme))
-	    ErrorF ("winWindowProc - _TrackMouseEvent failed\n");
+	  if (!TrackMouseEvent(&tme))
+	    ErrorF ("winWindowProc - TrackMouseEvent failed\n");
 
 	  /* Flag that we are tracking now */
 	  s_fTracking = TRUE;
commit e2e6fab1efa6895256ac0ed4d5b054a88ad18077
Author: Jon TURNEY <jon.turney at dronecode.org.uk>
Date:   Tue Mar 23 04:45:37 2010 -0500

    Cygwin/X: Make default DPI match native DPI
    
    Make the default DPI match the current Windows DPI setting. If that
    setting can't be retrieved, change the fallback DPI value from 75 dpi
    to 96 dpi.
    
    Mark the application as dpiAware in the manifest, which prevents
    dpi virtualization for high (>96) dpi values on Vista and later.
    
    Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
    Signed-off-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
    Reviewed-by: Colin Harrison <colin.harrison at virgin.net>

diff --git a/hw/xwin/XWin.exe.manifest b/hw/xwin/XWin.exe.manifest
index 221150d..a0d4d7d 100755
--- a/hw/xwin/XWin.exe.manifest
+++ b/hw/xwin/XWin.exe.manifest
@@ -13,4 +13,9 @@
 	     />
 	   </dependentAssembly>
 	</dependency>
+	<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
+	   <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
+	     <dpiAware>true</dpiAware>
+	   </asmv3:windowsSettings>
+	</asmv3:application>
 </assembly>
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 9bee9b6..445bcab 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -64,7 +64,7 @@
 #define WIN_DEFAULT_BLACKPIXEL			0
 #define WIN_DEFAULT_LINEBIAS			0
 #define WIN_DEFAULT_E3B_TIME			50 /* milliseconds */
-#define WIN_DEFAULT_DPI				75
+#define WIN_DEFAULT_DPI				96
 #define WIN_DEFAULT_REFRESH			0
 #define WIN_DEFAULT_WIN_KILL			TRUE
 #define WIN_DEFAULT_UNIX_KILL			FALSE
diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c
index ddfe1f5..0c24b08 100644
--- a/hw/xwin/winprocarg.c
+++ b/hw/xwin/winprocarg.c
@@ -88,12 +88,27 @@ winInitializeScreenDefaults(void)
   dwWidth = GetSystemMetrics (SM_CXSCREEN);
   dwHeight = GetSystemMetrics (SM_CYSCREEN);
 
-  winErrorFVerb (2, "winInitializeScreenDefaults - w %d h %d\n",
-	  (int) dwWidth, (int) dwHeight);
+  winErrorFVerb(2, "winInitializeScreenDefaults - primary monitor w %d h %d\n", (int) dwWidth, (int) dwHeight);
 
-  /* Set a default DPI, if no parameter was passed */
+  /* Set a default DPI, if no '-dpi' option was used */
   if (monitorResolution == 0)
-    monitorResolution = WIN_DEFAULT_DPI;
+    {
+      HDC hdc = GetDC(NULL);
+      if (hdc)
+        {
+          int dpiX = GetDeviceCaps(hdc, LOGPIXELSX);
+          int dpiY = GetDeviceCaps(hdc, LOGPIXELSY);
+
+          winErrorFVerb(2, "winInitializeDefaultScreens - native DPI x %d y %d\n", dpiX, dpiY);
+          monitorResolution = dpiY;
+          ReleaseDC(NULL, hdc);
+        }
+      else
+        {
+          winErrorFVerb(1, "winInitializeDefaultScreens - Failed to retrieve native DPI, falling back to default of %d DPI\n", WIN_DEFAULT_DPI);
+          monitorResolution = WIN_DEFAULT_DPI;
+        }
+    }
 
   defaultScreenInfo.iMonitor = 1;
   defaultScreenInfo.dwWidth  = dwWidth;


More information about the xorg-commit mailing list