Skip to content

Commit

Permalink
* fix SetProcessDpiAwareness call by using the totally undocumented S…
Browse files Browse the repository at this point in the history
…etProcessDpiAwarenessInternal

* replace SetProcessDPIAware code to use the function from windll.user32 directly (no need for defining a prototype)

git-svn-id: https://xpra.org/svn/Xpra/trunk@11151 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Nov 8, 2015
1 parent 706a47b commit 7faca89
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions src/xpra/platform/win32/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,9 @@ def do_init():
screenlog.warn("SetProcessDPIAware not set due to environment override")
return
try:
from ctypes import WINFUNCTYPE
from ctypes.wintypes import BOOL, UINT
except Exception as e:
screenlog.error("Error setting DPI: %s", e)
return
try:
prototype = WINFUNCTYPE(BOOL)
SetProcessDPIAware = prototype(("SetProcessDPIAware", windll.user32))
dpi_set = SetProcessDPIAware()
screenlog("SetProcessDPIAware()=%s", dpi_set)
SetProcessDPIAware = windll.user32.SetProcessDPIAware
dpiaware = SetProcessDPIAware()
screenlog("SetProcessDPIAware: %s()=%s", SetProcessDPIAware, dpiaware)
except Exception as e:
screenlog("SetProcessDPIAware() failed: %s", e)
if DPI_AWARENESS<=0:
Expand All @@ -76,13 +69,12 @@ def do_init():
Process_DPI_Unaware = 0
Process_Per_Monitor_DPI_Aware = 2
assert DPI_AWARENESS in (Process_System_DPI_Aware, Process_DPI_Unaware, Process_Per_Monitor_DPI_Aware)
prototype = WINFUNCTYPE(BOOL, UINT)
SetProcessDPIAwareness = prototype(("SetProcessDPIAwareness", windll.user32))
dpi_set = SetProcessDPIAwareness(UINT(DPI_AWARENESS))
screenlog("SetProcessDPIAwareness(%s)=%s", DPI_AWARENESS, dpi_set)
SetProcessDpiAwarenessInternal = windll.user32.SetProcessDpiAwarenessInternal
dpiawareness = SetProcessDpiAwarenessInternal(DPI_AWARENESS)
screenlog("SetProcessDPIAwareness: %s(%s)=%s", SetProcessDpiAwarenessInternal, DPI_AWARENESS, dpiawareness)
except Exception as e:
screenlog("SetProcessDPIAwareness(%s) failed: %s", DPI_AWARENESS, e)
screenlog(" (not available on MS Windows before version 8)")
screenlog("SetProcessDpiAwarenessInternal(%s) failed: %s", DPI_AWARENESS, e)
screenlog(" (not available on MS Windows before version 8.1)")


def get_native_notifier_classes():
Expand Down

0 comments on commit 7faca89

Please sign in to comment.