Skip to content

Commit

Permalink
#163:
Browse files Browse the repository at this point in the history
* add a new --dpi=VALUE command line option
* server defines the default value
* client can override this
* global default is 96
* remove --dpi from Xorg examples (since it doesn't work)
* when we apply the client's resource-manager values, we set/override the dpi
* when the client connects, we fake a "resource-manager" settings update as some clients never send this

git-svn-id: https://xpra.org/svn/Xpra/trunk@1262 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Aug 3, 2012
1 parent 29f0f13 commit 78c2686
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 9 deletions.
8 changes: 6 additions & 2 deletions src/etc/xpra/xpra.conf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ debug = no
# Default encoding:
encoding = png

# Default DPI:
dpi = 96

# Client window title:
title=@title@ on @client-machine@

Expand All @@ -49,6 +52,7 @@ pings = no

# Virtual display command:
# Old Xvfb option:
# xvfb=Xvfb -dpi 96 +extension Composite -screen 0 3840x2560x24+32 -nolisten tcp -noreset -auth $XAUTHORITY
# xvfb=Xvfb +extension Composite -screen 0 3840x2560x24+32 -nolisten tcp -noreset -auth $XAUTHORITY
# With Xorg 1.12 or newer and the dummy driver:
# xvfb=/usr/bin/Xorg-nosuid -dpi 96 -noreset -nolisten tcp +extension GLX +extension RANDR +extension RENDER -logfile ${HOME}/.xpra/Xorg.${DISPLAY}.log -config /etc/xpra/xorg.conf
# xvfb=/usr/bin/Xorg-nosuid -noreset -nolisten tcp +extension GLX +extension RANDR +extension RENDER -logfile ${HOME}/.xpra/Xorg.${DISPLAY}.log -config /etc/xpra/xorg.conf
xvfb=/usr/bin/Xorg-nosuid -noreset -nolisten tcp +extension GLX +extension RANDR +extension RENDER -logfile ${HOME}/.xpra/Xorg.${DISPLAY}.log -config /etc/xpra/xorg.conf
7 changes: 5 additions & 2 deletions src/etc/xpra/xpra.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ debug = no
# Default encoding:
encoding = png

# Default DPI:
dpi = 96

# Client window title:
title=@title@ on @client-machine@

Expand All @@ -49,6 +52,6 @@ pings = no

# Virtual display command:
# Old Xvfb option:
# xvfb=Xvfb -dpi 96 +extension Composite -screen 0 3840x2560x24+32 -nolisten tcp -noreset -auth $XAUTHORITY
# xvfb=Xvfb +extension Composite -screen 0 3840x2560x24+32 -nolisten tcp -noreset -auth $XAUTHORITY
# With Xorg 1.12 or newer and the dummy driver:
# xvfb=/usr/bin/Xorg-nosuid -dpi 96 -noreset -nolisten tcp +extension GLX +extension RANDR +extension RENDER -logfile ${HOME}/.xpra/Xorg.${DISPLAY}.log -config /etc/xpra/xorg.conf
# xvfb=/usr/bin/Xorg-nosuid -noreset -nolisten tcp +extension GLX +extension RANDR +extension RENDER -logfile ${HOME}/.xpra/Xorg.${DISPLAY}.log -config /etc/xpra/xorg.conf
2 changes: 1 addition & 1 deletion src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def pkgconfig(*packages_options, **ekw):
print("found valid Xorg server version %s" % v_str)
print("enabling Xdummy in config file")
f = open("etc/xpra/xpra.conf", mode='a')
f.write("xvfb=/usr/bin/Xorg-nosuid -dpi 96 -noreset -nolisten tcp "+
f.write("xvfb=/usr/bin/Xorg-nosuid -noreset -nolisten tcp "+
"+extension GLX +extension RANDR +extension RENDER "+
"-logfile ${HOME}/.xpra/Xorg.${DISPLAY}.log -config /etc/xpra/xorg.conf")
f.close()
Expand Down
2 changes: 1 addition & 1 deletion src/tests/wimpiggy/test_prop.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#@PydevCodeAnalysisIgnore

from wimpiggy.test import *
from tests.wimpiggy import *
import struct
import gtk
import cairo
Expand Down
10 changes: 10 additions & 0 deletions src/xpra.1
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ xpra \- viewer for remote, persistent X applications
[\fB\-\-no\-pulseaudio\fP]
[\fB\-\-bind\-tcp=[HOST]:PORT\fP]
[\fB\-\-password\-file=filename\fP]
[\fB\-\-dpi=VALUE\fP]
[\fB\-\-socket\-dir=DIR\fP]
.HP
\fBxpra\fP \fBattach\fP
Expand All @@ -45,6 +46,7 @@ xpra \- viewer for remote, persistent X applications
[\fB\-\-tray\-icon=filename\fP]
[\fB\-\-ssh=CMD\fP] [\fB\-\-remote\-xpra=CMD\fP]
[\fB\-\-password\-file=filename\fP]
[\fB\-\-dpi=VALUE\fP]
[\fB\-\-socket\-dir=DIR\fP]
[\fB\-\-mmap\-group\fP]
[\fB\-\-enable\-pings\fP]
Expand Down Expand Up @@ -347,12 +349,20 @@ and is a major security risk (especially when passing 0.0.0.0)!
Anyone at all may connect to this port and access your session.
Use it only if you have special needs, and understand the consequences
of your actions.

.SS Options for start, upgrade and attach
.TP
\fB\-\-password\-file\fP=\fIFILENAME\fP
This allows sessions to be secured with a password stored in a text
file. You should use this if you use the \fB\-\-bind-\-tcp\fP option.
If this is used on the server, it will reject any client connections
that do not provide the same password value.
[\fB\-\-dpi=VALUE\fP]
The 'dots per inch' value that client applications should try to honour.
This numeric value should be in the range 10 to 500 to be useful.
Many applications will only read this value when starting up,
so connecting to an existing session started with a different DPI
value may not have the desired effect.

.SS Options for attach
.TP
Expand Down
2 changes: 2 additions & 0 deletions src/xpra/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def __init__(self, conn, opts):
""" jpegquality was not set, use a better start value """
self.jpegquality = 50

self.dpi = int(opts.dpi)
self.mmap_enabled = False
self.server_start_time = -1
self.server_platform = ""
Expand Down Expand Up @@ -512,6 +513,7 @@ def make_hello(self, challenge_response=None):
capabilities["mmap_token"] = self.mmap_token
capabilities["randr_notify"] = True
capabilities["compressible_cursors"] = True
capabilities["dpi"] = self.dpi
#these should be turned into options:
capabilities["cursors"] = True
capabilities["bell"] = True
Expand Down
2 changes: 2 additions & 0 deletions src/xpra/scripts/client_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def default_bool(varname, default_value):
xpra_opts.keyboard_sync = default_bool("keyboard-sync", True)
xpra_opts.compression_level = default_int("compression", 3)
xpra_opts.send_pings = default_bool("pings", False)
xpra_opts.dpi = default_int("dpi", 96)
#these would need testing/work:
xpra_opts.auto_refresh_delay = 0.0
xpra_opts.max_bandwidth = 0.0
Expand Down Expand Up @@ -418,6 +419,7 @@ def connect_tcp(self):
opts.mmap = xpra_opts.mmap
opts.keyboard_sync = xpra_opts.keyboard_sync
opts.send_pings = xpra_opts.send_pings
opts.dpi = xpra_opts.dpi

import logging
logging.root.setLevel(logging.INFO)
Expand Down
15 changes: 15 additions & 0 deletions src/xpra/scripts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ def bool_default(varname, default_value):
return False
print("invalid value for '%s': %s, using default value %s instead" % (varname, v, default_value))
return default_value
def int_default(varname, default_value):
v = defaults.get(varname)
if not v:
return default_value
try:
return int(v)
except:
return default_value

if XPRA_LOCAL_SERVERS_SUPPORTED:
start_str = "\t%prog start DISPLAY\n"
Expand Down Expand Up @@ -291,6 +299,9 @@ def bool_default(varname, default_value):
group.add_option("--password-file", action="store",
dest="password_file", default=None,
help="The file containing the password required to connect (useful to secure TCP mode)")
group.add_option("--dpi", action="store",
dest="dpi", default=int_default("dpi", 96),
help="The 'dots per inch' value that client applications should try to honour (default: %s)")
default_socket_dir = defaults.get("socket-dir")
default_socket_dir_str = default_socket_dir or "$XPRA_SOCKET_DIR or '~/.xpra'"
group.add_option("--socket-dir", action="store",
Expand Down Expand Up @@ -327,6 +338,10 @@ def bool_default(varname, default_value):
#the option is not shown to the user as it is not available
options.jpegquality = 80
options.max_bandwidth = 0
try:
int(options.dpi)
except Exception, e:
parser.error("invalid dpi: %s" % e)

if not args:
parser.error("need a mode")
Expand Down
42 changes: 39 additions & 3 deletions src/xpra/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ def __init__(self, clobber, sockets, opts):
xpra.__version__)
add_event_receiver(root, self)

self.default_dpi = int(opts.dpi)
self.dpi = self.default_dpi

# This must happen early, before loading in windows at least:
self._protocol = None
self._potential_protocols = []
Expand Down Expand Up @@ -1094,6 +1097,11 @@ def _process_hello(self, proto, packet):
self.reset_statistics()
self.encodings = capabilities.get("encodings", [])
self._set_encoding(capabilities.get("encoding", None), None)
self.dpi = capabilities.get("dpi", self.default_dpi)
if self.dpi>0:
#some non-posix clients never send us 'resource-manager' settings
#so just use a fake one to ensure the dpi gets applied:
self.update_server_settings({'resource-manager' : ""})
#mmap:
self.close_mmap()
mmap_file = capabilities.get("mmap_file")
Expand Down Expand Up @@ -1368,14 +1376,42 @@ def _process_keyboard_sync_enabled_status(self, proto, packet):
log("toggled keyboard-sync to %s", self.keyboard_sync)

def _process_server_settings(self, proto, packet):
settings = packet[1]
self.update_server_settings(packet[1])

def update_server_settings(self, settings):
old_settings = dict(self._settings)
log("server_settings: old=%s, updating with=%s", old_settings, settings)
self._settings.update(settings)
root = gtk.gdk.get_default_root_window()
for k, v in settings.items():
#cook the "resource-manager" value to add the DPI:
if k == "resource-manager" and self.dpi>0:
value = v.decode("utf-8")
#parse the resources into a dict:
values={}
options = value.split("\n")
for option in options:
if not option:
continue
parts = option.split(":\t")
if len(parts)!=2:
continue
values[parts[0]] = parts[1]
values["Xft.dpi"] = self.dpi
log("server_settings: resource-manager values=%s", values)
#convert the dict back into a resource string:
value = u''
for vk, vv in values.items():
value += "%s:\t%s\n" % (vk, vv)
value += '\n'
#record the actual value used
self._settings["resource-manager"] = value
v = value.encode("utf-8")

if k not in old_settings or v != old_settings[k]:
def root_set(p):
prop_set(gtk.gdk.get_default_root_window(),
p, "latin1", v.decode("utf-8"))
log("server_settings: setting %s to %s", p, v)
prop_set(root, p, "latin1", v.decode("utf-8"))
if k == "xsettings-blob":
self._xsettings_manager = XSettingsManager(v)
elif k == "resource-manager":
Expand Down
7 changes: 7 additions & 0 deletions src/xpra/xposix/xsettings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# This file is part of Parti.
# Copyright (C) 2010-2012 Antoine Martin <antoine@devloop.org.uk>
# Copyright (C) 2008 Nathaniel Smith <njs@pobox.com>
# Parti is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

import gobject
import gtk
from wimpiggy.error import *
Expand All @@ -13,6 +19,7 @@
from wimpiggy.log import Logger
log = Logger()


class XSettingsManager(object):
def __init__(self, settings_blob):
self._selection = ManagerSelection(gtk.gdk.display_get_default(),
Expand Down

0 comments on commit 78c2686

Please sign in to comment.