Skip to content

Commit

Permalink
#976: re-apply dpi settings when we scaleup or scaledown:
Browse files Browse the repository at this point in the history
* pass new dpi settings to the server via the desktop_size packet
* if the values have changed, fire dpi_changed which re-applies the xsettings

git-svn-id: https://xpra.org/svn/Xpra/trunk@10953 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Oct 22, 2015
1 parent 88f9ac1 commit 59f05b0
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 16 deletions.
44 changes: 28 additions & 16 deletions src/xpra/client/ui_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,15 @@ def update_screen_size(self):
ndesktops = get_number_of_desktops()
desktop_names = get_desktop_names()
screenlog("update_screen_size() sizes=%s, %s desktops: %s", sss, ndesktops, desktop_names)
screen_settings = (root_w, root_h, sss, ndesktops, desktop_names, u_root_w, u_root_h)
if self.dpi>0:
#use command line value supplied, but scale it:
xdpi = self.cx(self.cy(2.0*self.dpi))
ydpi = xdpi
else:
#not supplied, use platform detection code:
xdpi = self.cx(get_xdpi())
ydpi = self.cy(get_ydpi())
screen_settings = (root_w, root_h, sss, ndesktops, desktop_names, u_root_w, u_root_h, xdpi, ydpi)
screenlog("update_screen_size() new settings=%s", screen_settings)
screenlog("update_screen_size() current settings=%s", self._last_screen_settings)
if self._last_screen_settings==screen_settings:
Expand Down Expand Up @@ -1178,7 +1186,25 @@ def roundfloat(v):
root_w, root_h = u_root_w, u_root_h
sss = ss
capabilities["screen_sizes"] = sss
self._last_screen_settings = (root_w, root_h, sss, ndesktops, desktop_names, u_root_w, u_root_h)
#command line (or config file) override supplied:
if self.dpi>0:
#scale it:
dpi = self.cx(self.cy(2.0*self.dpi))
xdpi = self.cx(dpi)
ydpi = self.cy(dpi)
else:
#not supplied, use platform detection code:
xdpi = self.cx(get_xdpi())
ydpi = self.cy(get_ydpi())
dpi = int((xdpi+ydpi+0.5)/2.0)
#platforms may also provide per-axis dpi (later win32 versions do)
capabilities.update({
"dpi.x" : xdpi,
"dpi.y" : ydpi,
})
capabilities["dpi"] = dpi
self._last_screen_settings = (root_w, root_h, sss, ndesktops, desktop_names, u_root_w, u_root_h, xdpi, ydpi)

if self.keyboard_helper:
key_repeat = self.keyboard_helper.keyboard.get_keyboard_repeat()
if key_repeat:
Expand Down Expand Up @@ -1273,19 +1299,6 @@ def roundfloat(v):
"transparency" : self.has_transparency(),
"rgb24zlib" : True,
})
#command line (or config file) override supplied:
dpi = self.dpi
if self.dpi<=0:
#not supplied, use platform detection code:
xdpi = self.cx(get_xdpi())
ydpi = self.cy(get_ydpi())
dpi = int((xdpi+ydpi+0.5)/2.0)
#platforms may also provide per-axis dpi (later win32 versions do)
capabilities.update({
"dpi.x" : xdpi,
"dpi.y" : ydpi,
})
capabilities["dpi"] = dpi
capabilities["antialias"] = get_antialias_info()
capabilities["cursor.size"] = int(2*get_cursor_size()/(self.xscale+self.yscale))
#generic rgb compression flags:
Expand Down Expand Up @@ -1585,7 +1598,6 @@ def parse_server_capabilities(self):
self.change_min_quality = c.boolget("change-min-quality")
self.change_speed = c.boolget("change-speed")
self.change_min_speed = c.boolget("change-min-speed")
self.xsettings_tuple = c.boolget("xsettings-tuple")
if self.mmap_enabled:
log.info("mmap is enabled using %sB area in %s", std_unit(self.mmap_size, unit=1024), self.mmap_filename)
#the server will have a handle on the mmap file by now, safe to delete:
Expand Down
11 changes: 11 additions & 0 deletions src/xpra/server/server_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1795,6 +1795,14 @@ def _process_desktop_size(self, proto, packet):
if ss is None:
return
ss.desktop_size = (width, height)
if len(packet)>=10:
#added in 0.16 for scaled client displays:
xdpi, ydpi = packet[8:10]
if xdpi!=self.xdpi or ydpi!=self.ydpi:
self.xdpi, self.ydpi = xdpi, ydpi
screenlog("new dpi: %ix%i", self.xdpi, self.ydpi)
self.dpi = int((self.xdpi + self.ydpi + 0.5)//2)
self.dpi_changed()
if len(packet)>=8:
#added in 0.16 for scaled client displays:
ss.desktop_size_unscaled = packet[6:8]
Expand All @@ -1812,6 +1820,9 @@ def _process_desktop_size(self, proto, packet):
log_screen_sizes(width, height, ss.screen_sizes)
self.calculate_workarea(width, height)

def dpi_changed(self):
pass

def calculate_desktops(self):
count = 1
for ss in self._server_sources.values():
Expand Down
5 changes: 5 additions & 0 deletions src/xpra/x11/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,11 @@ def _get_antialias_hintstyle(self, antialias):
return "hintnone"


def dpi_changed(self):
#re-apply the same settings, which will apply the new dpi override to it:
self.update_server_settings(self._settings)


def init_all_server_settings(self):
settingslog("init_all_server_settings() dpi=%i, default_dpi=%i", self.dpi, self.default_dpi)
#almost like update_all, except we use the default_dpi,
Expand Down

0 comments on commit 59f05b0

Please sign in to comment.