Update: UltraVNC 1.4.3.6 and UltraVNC SC 1.4.3.6: viewtopic.php?t=37885
Important: Please update to latest version before to create a reply, a topic or an issue: viewtopic.php?t=37864

Join us on social networks and share our announcements:
- Website: https://uvnc.com/
- GitHub: https://github.com/ultravnc
- Mastodon: https://mastodon.social/@ultravnc
- Facebook: https://www.facebook.com/ultravnc1
- X/Twitter: https://twitter.com/ultravnc1
- Reddit community: https://www.reddit.com/r/ultravnc
- OpenHub: https://openhub.net/p/ultravnc

High DPI settings in Windows 10

Single Click discussions / bugs
Post Reply
kenjiuno
Posts: 5
Joined: 2016-03-30 04:46

High DPI settings in Windows 10

Post by kenjiuno »

Hi.

I have vnc screen update problem on High DPI enabled client.

I'm using setup created by,
- UltraVncSC update Feb 2015
- Same as pevious, but exe request UAC on start

The bottom-right part isn't updated correctly sometimes. Anyone has same problem?

[Refresh Screen] button works to recover broken part. But I'll have to keep pushing it...

kenjiuno
graham-h
Posts: 2
Joined: 2016-05-04 21:59

Re: High DPI settings in Windows 10

Post by graham-h »

Same issue here. Server is Win10, 1960x1080. Client is Win7, 1960x1080. Only the top left 1280x768 (approx) gets updated eg when closing a full-screen window on the server.
User avatar
Rudi De Vos
Admin & Developer
Admin & Developer
Posts: 6832
Joined: 2004-04-23 10:21
Contact:

Re: High DPI settings in Windows 10

Post by Rudi De Vos »

http://www.uvnc.com/downloads/single-cl ... loads.html
Experimental June 2015 win8 win10 updated, please test if scaling is better
graham-h
Posts: 2
Joined: 2016-05-04 21:59

Re: High DPI settings in Windows 10

Post by graham-h »

Rudi De Vos wrote:http://www.uvnc.com/downloads/single-cl ... loads.html
Experimental June 2015 win8 win10 updated, please test if scaling is better
Does not work. Client displays accept dialog then opens a blank window for a second or two then it disappears. On server, desktop background remains black.
User avatar
Rudi De Vos
Admin & Developer
Admin & Developer
Posts: 6832
Joined: 2004-04-23 10:21
Contact:

Re: High DPI settings in Windows 10

Post by Rudi De Vos »

I will check it
User avatar
Rudi De Vos
Admin & Developer
Admin & Developer
Posts: 6832
Joined: 2004-04-23 10:21
Contact:

Re: High DPI settings in Windows 10

Post by Rudi De Vos »

Please try again files (Experimental June 2015 win8 win10) updated.
tested on a vmware win10
kenjiuno
Posts: 5
Joined: 2016-03-30 04:46

Re: High DPI settings in Windows 10

Post by kenjiuno »

Hi,
Rudi De Vos wrote:Please try again files (Experimental June 2015 win8 win10) updated.
tested on a vmware win10
Thanks, I have tested Experimental June 2015 win8 win10 today and it works well on hi DPI client!
User avatar
ender
8
8
Posts: 13
Joined: 2014-01-19 23:16

Re: High DPI settings in Windows 10

Post by ender »

Can you publish the source code for June 2015 version (or at least a diff)?
User avatar
Rudi De Vos
Admin & Developer
Admin & Developer
Posts: 6832
Joined: 2004-04-23 10:21
Contact:

Re: High DPI settings in Windows 10

Post by Rudi De Vos »

goto
https://sourceforge.net/p/ultravnc/code ... ect%20Root
[r1036] by cyberfox123
dpi aware, was removed by mistake
2016-04-23 21:16:44 Tree

when you click on the link you get

Code: Select all

--- a/UltraVNC Project Root/UltraVNC/winvnc/winvnc/winvnc.cpp
+++ b/UltraVNC Project Root/UltraVNC/winvnc/winvnc/winvnc.cpp
@@ -215,12 +215,12 @@
 	// make vnc last service to stop
 	SetProcessShutdownParameters(0x100,false);
 	// handle dpi on aero
-	/*HMODULE hUser32 = LoadLibrary(_T("user32.dll"));
+	HMODULE hUser32 = LoadLibrary(_T("user32.dll"));
 	typedef BOOL (*SetProcessDPIAwareFunc)();
 	SetProcessDPIAwareFunc setDPIAware=NULL;
 	if (hUser32) setDPIAware = (SetProcessDPIAwareFunc)GetProcAddress(hUser32, "SetProcessDPIAware");
 	if (setDPIAware) setDPIAware();
-	if (hUser32) FreeLibrary(hUser32);*/
+	if (hUser32) FreeLibrary(hUser32);
User avatar
ender
8
8
Posts: 13
Joined: 2014-01-19 23:16

Re: High DPI settings in Windows 10

Post by ender »

That doesn't seem to apply to the SC's winvnc.cpp directly, though AFAIK, you should get the same effect by declaring <dpiAware>true</dpiAware> in the manifest, right? I already do that in my modification, and while it solves most problems with DPI, I still sometimes encounter one of the two problems:
  • right and bottom part of the screen not updating
  • mouse being offset from the viewer's position
I'm not entirely sure how either of these problems happen, though at least the first one can be triggered by switching from 100 to 125% DPI in Windows 10, and running SC immediately afterwards, without logging out and back in first (however, this is just a reproduction of the problem - I'm fairly certain that the clients where I regularly encounter this don't trigger it this way).
I've got no idea how to reproduce the mouse offset though.
User avatar
Rudi De Vos
Admin & Developer
Admin & Developer
Posts: 6832
Joined: 2004-04-23 10:21
Contact:

Re: High DPI settings in Windows 10

Post by Rudi De Vos »

SC... didn't see that one.
Sc used an old method to handle dpi using the g_dpi.
The new setdpiaware work a lot better, but then you need to remove the old method
Search in code for g_dpi and that are the spots that need to be replaced , see diff

-------------------------diff------------------------

Code: Select all

Index: winvnc/winvnc/black_layered.cpp
===================================================================
--- winvnc/winvnc/black_layered.cpp	(revision 2)
+++ winvnc/winvnc/black_layered.cpp	(working copy)
@@ -25,7 +25,7 @@
 
 int wd=0;
 int ht=0;
-CDPI g_dpi;
+//CDPI g_dpi;
 
 HBITMAP
     DoGetBkGndBitmap2(
Index: winvnc/winvnc/vncclient.cpp
===================================================================
--- winvnc/winvnc/vncclient.cpp	(revision 4)
+++ winvnc/winvnc/vncclient.cpp	(working copy)
@@ -60,7 +60,7 @@
 #include "shlobj.h"
 int getinfo(char mytext[1024]);
 #include "dpi.h"
-extern CDPI g_dpi;
+//extern CDPI g_dpi;
 // #include "rfb.h"
 
 #include "localization.h" // Act : add localization on messages
@@ -1361,10 +1361,10 @@
 							{
 								INPUT evt;
 								evt.type = INPUT_MOUSE;
-								msg.pe.x=msg.pe.x-g_dpi.ScaledScreenVirtualX();
-								msg.pe.y=msg.pe.y-g_dpi.ScaledScreenVirtualY();
-								evt.mi.dx = (msg.pe.x * 65535) / (g_dpi.ScaledScreenVirtualWidth()-1);
-								evt.mi.dy = (msg.pe.y* 65535) / (g_dpi.ScaledScreenVirtualHeight()-1);
+								msg.pe.x=msg.pe.x-GetSystemMetrics(SM_XVIRTUALSCREEN);//g_dpi.ScaledScreenVirtualX();
+								msg.pe.y=msg.pe.y-GetSystemMetrics(SM_YVIRTUALSCREEN);//g_dpi.ScaledScreenVirtualY();
+								evt.mi.dx = (msg.pe.x * 65535) / (GetSystemMetrics(SM_CXVIRTUALSCREEN)-1);//g_dpi.ScaledScreenVirtualWidth()-1);
+								evt.mi.dy = (msg.pe.y* 65535) / (GetSystemMetrics(SM_CYVIRTUALSCREEN)-1);//(g_dpi.ScaledScreenVirtualHeight()-1);
 								evt.mi.dwFlags = flags | MOUSEEVENTF_VIRTUALDESK;
 								evt.mi.dwExtraInfo = 0;
 								evt.mi.mouseData = wheel_movement;
@@ -1374,8 +1374,8 @@
 							else
 							{
 								POINT cursorPos; GetCursorPos(&cursorPos);
-								cursorPos.x=g_dpi.UnscaleX(cursorPos.x);
-								cursorPos.y=g_dpi.UnscaleY(cursorPos.y);
+								cursorPos.x=cursorPos.x;//g_dpi.UnscaleX(cursorPos.x);
+								cursorPos.y=cursorPos.y;//g_dpi.UnscaleY(cursorPos.y);
 								ULONG oldSpeed, newSpeed = 10;
 								ULONG mouseInfo[3];
 								if (flags & MOUSEEVENTF_MOVE)
Index: winvnc/winvnc/vncdesktop.cpp
===================================================================
--- winvnc/winvnc/vncdesktop.cpp	(revision 3)
+++ winvnc/winvnc/vncdesktop.cpp	(working copy)
@@ -51,7 +51,7 @@
 #include "dpi.h"
 #include <algorithm>
 #include <Commctrl.h>
-extern CDPI g_dpi;
+//extern CDPI g_dpi;
 bool w8OK = false;
 
 // Constants
@@ -1838,8 +1838,8 @@
 	// Get the cursor position
 	if (!GetCursorPos(&CursorPos))
 		return;
-	CursorPos.x=g_dpi.UnscaleX(CursorPos.x);
-	CursorPos.y=g_dpi.UnscaleY(CursorPos.y);
+	CursorPos.x=CursorPos.x;//g_dpi.UnscaleX(CursorPos.x);
+	CursorPos.y=CursorPos.y;//g_dpi.UnscaleY(CursorPos.y);
 	//vnclog.Print(LL_INTINFO, VNCLOG("CursorPos %i %i\n"),CursorPos.x, CursorPos.y);
 	// Translate position for hotspot
 	if (GetIconInfo(m_hcursor, &IconInfo))
Index: winvnc/winvnc/vncdesktopthread.cpp
===================================================================
--- winvnc/winvnc/vncdesktopthread.cpp	(revision 4)
+++ winvnc/winvnc/vncdesktopthread.cpp	(working copy)
@@ -7,6 +7,8 @@
 extern bool w8OK;
 void testBench();
 
+int skip_counter=0;
+
 inline bool
 ClipRect(int *x, int *y, int *w, int *h,
 	    int cx, int cy, int cw, int ch) {
@@ -693,8 +695,9 @@
 									m_desktop->SWinit();
 									m_desktop->GetQuarterSize();
 									GetCursorPos(&CursorPos);
-									CursorPos.x=g_dpi.UnscaleX(CursorPos.x);
-									CursorPos.y=g_dpi.UnscaleY(CursorPos.y);
+										GetCursorPos(&CursorPos);
+									CursorPos.x=CursorPos.x;//g_dpi.UnscaleX(CursorPos.x);
+									CursorPos.y=CursorPos.y;//g_dpi.UnscaleY(CursorPos.y);
 									CursorPos.x -= m_desktop->m_ScreenOffsetx;
 									CursorPos.y -= m_desktop->m_ScreenOffsety;
 									m_desktop->m_cursorpos.tl = CursorPos;
@@ -899,10 +902,17 @@
 
 					DWORD lTime = timeGetTime();
 
-					if (cursormoved && !w8OK)
-					{
-						m_lLastMouseMoveTime = lTime;
-					}
+					if (cursormoved && !w8OK) m_lLastMouseMoveTime = lTime;
+					//{
+					//	skip_counter++;
+					//	if (skip_counter!=5) m_lLastMouseMoveTime = lTime;
+					//	if (skip_counter==5) skip_counter=0;
+					//}
+					//else if (cursormoved && !w8OK)
+					//{
+					//	m_lLastMouseMoveTime = lTime;
+					//}
+
 					m_desktop->m_buffer.SetAccuracy(m_desktop->m_server->TurboMode() ? 8 : 4);
 
 					if (m_desktop->m_server->PollFullScreen())
@@ -944,8 +954,8 @@
 						POINT mousepos;
 						if (GetCursorPos(&mousepos))
 						{
-							mousepos.x=g_dpi.UnscaleX(mousepos.x);
-							mousepos.y=g_dpi.UnscaleY(mousepos.y);
+							mousepos.x=mousepos.x;//g_dpi.UnscaleX(mousepos.x);
+							mousepos.y=mousepos.y;//g_dpi.UnscaleY(mousepos.y);
 							// Find the window under the mouse
 							HWND hwnd = WindowFromPoint(mousepos);
 							if (hwnd != NULL)
Index: winvnc/winvnc/vncMultiMonitor.cpp
===================================================================
--- winvnc/winvnc/vncMultiMonitor.cpp	(revision 2)
+++ winvnc/winvnc/vncMultiMonitor.cpp	(working copy)
@@ -20,7 +20,7 @@
 #include "TextChat.h" // sf@2002
 #include "vncdesktopthread.h"
 #include "dpi.h"
-extern CDPI g_dpi;
+//extern CDPI g_dpi;
 
 typedef BOOL (WINAPI* pEnumDisplayDevices)(PVOID,DWORD,PVOID,DWORD);
 
@@ -53,11 +53,11 @@
 	mymonitor[1].Depth=devMode.dmBitsPerPel;
   }
 	///
-    g_dpi.Invalidate();
-    mymonitor[2].offsetx=g_dpi.ScaledScreenVirtualX();
-    mymonitor[2].offsety=g_dpi.ScaledScreenVirtualY();
-    mymonitor[2].Width=g_dpi.ScaledScreenVirtualWidth();
-    mymonitor[2].Height=g_dpi.ScaledScreenVirtualHeight();
+    //g_dpi.Invalidate();
+    mymonitor[2].offsetx=GetSystemMetrics(SM_XVIRTUALSCREEN);//g_dpi.ScaledScreenVirtualX();
+    mymonitor[2].offsety=GetSystemMetrics(SM_YVIRTUALSCREEN);//g_dpi.ScaledScreenVirtualY();
+    mymonitor[2].Width=GetSystemMetrics(SM_CXVIRTUALSCREEN);//g_dpi.ScaledScreenVirtualWidth();
+    mymonitor[2].Height=GetSystemMetrics(SM_CYVIRTUALSCREEN);//g_dpi.ScaledScreenVirtualHeight();
 	mymonitor[2].Depth=mymonitor[0].Depth;//depth primary monitor is used
 
 }
Index: winvnc/winvnc/vncserver.cpp
===================================================================
--- winvnc/winvnc/vncserver.cpp	(revision 3)
+++ winvnc/winvnc/vncserver.cpp	(working copy)
@@ -46,7 +46,7 @@
 bool g_Server_running;
 extern bool g_Desktop_running;
 #include "dpi.h"
-extern CDPI g_dpi;
+//extern CDPI g_dpi;
 // vncServer::UpdateTracker routines
 
 void
@@ -1221,9 +1221,10 @@
 		}
 		else
 		{
-			scrinfo.framebufferWidth = g_dpi.UnscaleX(GetDeviceCaps(hrootdc, HORZRES));
-			scrinfo.framebufferHeight = g_dpi.UnscaleY(GetDeviceCaps(hrootdc, VERTRES));
+			scrinfo.framebufferWidth = GetDeviceCaps(hrootdc, HORZRES);//g_dpi.UnscaleX(GetDeviceCaps(hrootdc, HORZRES));
+			scrinfo.framebufferHeight = GetDeviceCaps(hrootdc, VERTRES);//g_dpi.UnscaleY(GetDeviceCaps(hrootdc, VERTRES));
 
+
 			HBITMAP membitmap = CreateCompatibleBitmap(hrootdc, scrinfo.framebufferWidth, scrinfo.framebufferHeight);
 			if (membitmap == NULL) {
 				scrinfo.framebufferWidth = 0;
Index: winvnc/winvnc/winvnc.cpp
===================================================================
--- winvnc/winvnc/winvnc.cpp	(revision 2)
+++ winvnc/winvnc/winvnc.cpp	(working copy)
@@ -585,6 +585,13 @@
 	GetVersionEx(&OSversion);
 	if (OSversion.dwMajorVersion==6 && OSversion.dwMinorVersion>=2) OS_WIN8=true;
 
+	HMODULE hUser32 = LoadLibrary("user32.dll");
+	typedef BOOL (*SetProcessDPIAwareFunc)();
+	SetProcessDPIAwareFunc setDPIAware=NULL;
+	if (hUser32) setDPIAware = (SetProcessDPIAwareFunc)GetProcAddress(hUser32, "SetProcessDPIAware");
+	if (setDPIAware) setDPIAware();
+	if (hUser32) FreeLibrary(hUser32);
+
 #ifdef NOTUSED
 	//Create_savemode_reg();
 	if (GetSystemMetrics(SM_CLEANBOOT) != 0)
User avatar
ender
8
8
Posts: 13
Joined: 2014-01-19 23:16

Re: High DPI settings in Windows 10

Post by ender »

Any chance you could upload the source code for the latest SingleClick? I tried applying the patch from the above message, but it doesn't apply cleanly to Z_SC_2015(Feb).zip source (there are eg. references to w8ok in the patch that aren't in the original files).
User avatar
Rudi De Vos
Admin & Developer
Admin & Developer
Posts: 6832
Joined: 2004-04-23 10:21
Contact:

Re: High DPI settings in Windows 10

Post by Rudi De Vos »

Current working on a winvnc win10 update, after that SC wil also be updated.
The w8 parts had to many bugs and gonna be replaced by the same code as winvnc
Post Reply