forked from cztomczak/cefpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdpi_aware_win.pyx
More file actions
47 lines (40 loc) · 1.44 KB
/
dpi_aware_win.pyx
File metadata and controls
47 lines (40 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Copyright (c) 2014 CEF Python, see the Authors file.
# All rights reserved. Licensed under BSD 3-clause license.
# Project website: https://github.com/cztomczak/cefpython
include "cefpython.pyx"
class DpiAware:
@staticmethod
def GetSystemDpi():
# Win7 DPI (Control Panel > Appearance and Personalization > Display):
# text size Larger 150% => dpix/dpiy 144
# text size Medium 125% => dpix/dpiy 120
# text size Smaller 100% => dpix/dpiy 96
#
# dpix=96 zoomlevel=0.0
# dpix=120 zoomlevel=1.0
# dpix=144 zoomlevel=2.0
# dpix=72 zoomlevel=-1.0
#
# If DPI awareness wasn't yet enabled, then GetSystemDpi
# will always return a default 96 DPI.
cdef int dpix = 0
cdef int dpiy = 0
GetSystemDpi(&dpix, &dpiy)
return tuple(dpix, dpiy)
@staticmethod
def CalculateWindowSize(int width, int height):
# Calculation for DPI < 96 is not yet supported.
GetDpiAwareWindowSize(&width, &height)
return tuple(width, height)
@staticmethod
def IsProcessDpiAware():
return IsProcessDpiAware()
@staticmethod
def SetProcessDpiAware():
"""Deprecated."""
DpiAware.EnableHighDpiSupport()
@staticmethod
def EnableHighDpiSupport():
# This CEF function sets process to be DPI aware. This
# CEF func is also called in subprocesses.
CefEnableHighDPISupport()