Skip to content

Commit

Permalink
#56 honour dpi when setting initial resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
totaam committed Dec 7, 2022
1 parent a0b1ae7 commit bee5259
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion xpra/x11/desktop/desktop_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def server_init(self):
log.warn(" using %r", res[0])
res = (res[0], )
with xlog:
set_initial_resolution(res)
set_initial_resolution(res, self.dpi or self.default_dpi)


def configure_best_screen_size(self):
Expand Down
2 changes: 1 addition & 1 deletion xpra/x11/desktop/monitor_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def server_init(self):
return
res = self.initial_resolutions or get_desktop_vfb_resolutions(default_refresh_rate=self.refresh_rate)
with xlog:
set_initial_resolution(res)
set_initial_resolution(res, self.dpi or self.default_dpi)


def get_server_mode(self):
Expand Down
2 changes: 1 addition & 1 deletion xpra/x11/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def server_init(self):
from xpra.x11.vfb_util import set_initial_resolution, parse_env_resolutions
DEFAULT_VFB_RESOLUTIONS = parse_env_resolutions(default_refresh_rate=self.refresh_rate)
with xlog:
set_initial_resolution(self.initial_resolutions or DEFAULT_VFB_RESOLUTIONS)
set_initial_resolution(self.initial_resolutions or DEFAULT_VFB_RESOLUTIONS, self.dpi or self.default_dpi)

def validate(self):
if not X11Window.displayHasXComposite():
Expand Down
7 changes: 6 additions & 1 deletion xpra/x11/vfb_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def kill_xvfb(xvfb_pid):
os.unlink(xauthority)


def set_initial_resolution(resolutions):
def set_initial_resolution(resolutions, dpi=0):
try:
log = get_vfb_logger()
log("set_initial_resolution(%s)", resolutions)
Expand All @@ -378,10 +378,15 @@ def set_initial_resolution(resolutions):
if not (isinstance(v, int) for v in res):
raise ValueError(f"resolution values must be ints, found: {res} ({csv(type(v) for v in res)})")
w, h, hz = res
mdpi = dpi or 96
def rdpi(v):
return round(v * 25.4 / mdpi)
monitors[i] = {
"name" : f"VFB-{i}",
"primary" : i==0,
"geometry" : (x, y, w, h),
"width-mm" : rdpi(w),
"height-mm" : rdpi(h),
"refresh-rate" : hz*1000,
"automatic" : True,
}
Expand Down

0 comments on commit bee5259

Please sign in to comment.