Skip to content

Commit

Permalink
add support for choosing what to do with input methods: current behav…
Browse files Browse the repository at this point in the history
…iour remains the default, but we can now also "keep" the current environment settings, or set new values ("SCIM", "IBus", etc)

git-svn-id: https://xpra.org/svn/Xpra/trunk@7272 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Aug 13, 2014
1 parent b0cd9dc commit 4a93537
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 10 deletions.
11 changes: 11 additions & 0 deletions src/etc/xpra/xpra.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,17 @@ log-file = $DISPLAY.log
# Publish sessions:
mdns = yes

# Input methods
# To disable input method completely:
#input-method=none
# To keep the environment unchanged:
#input-method=keep
# Other possible options:
#input-method=IBus
#input-method=SCIM
#input-method=uim
input-method=none

# Start a pulseaudio server with each session:
pulseaudio = yes

Expand Down
28 changes: 28 additions & 0 deletions src/man/xpra.1
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ xpra \- viewer for remote, persistent X applications
[\fB\-\-password\-file\fP=\fIFILENAME\fP]
[\fB\-\-clipboard\-filter\-file\fP=\fIFILENAME\fP]
[\fB\-\-dpi\fP=\fIVALUE\fP]
[\fB\-\-input\-method\fP=\fIMETHOD\fP]
[\fB\-\-socket\-dir\fP=\fIDIR\fP]
[\fB\-\-tcp\-proxy\fP=\fIHOST:PORT\fP]
.HP
Expand Down Expand Up @@ -650,6 +651,33 @@ System notifications require the xpra server to have its own instance
of a dbus daemon, if it is missing a warning will be printed on
startup. This switch disables the feature entirely, and avoids
the warning.
.TP
\fB\-\-input\-method\fP=\fIMETHOD\fP
Specify which input method to configure.
This sets a number of environment variables which should be
honoured by applications started with the \fBstart\-child\fP option.

.br
The following \fIMETHOD\fPs are currently supported:
.RS
.IP \fBnone\fP
Disable input methods completely and prevent it from
interfering with keyboard input. This is the default.
.IP \fBkeep\fP
Keeps the environment unchanged. You are responsible for ensuring
it is correct.
.IP \fBxim\fP
Enables the X Input Method.
.IP \fBIBus\fP
Enables the Intelligent Input Bus.
.IP \fBSCIM\fP
Enables the Smart Common Input Method.
.IP \fBuim\fP
Enables the Universal Input Method.
.RE
.PP
Any other value will also be set up, but will trigger a warning.

.TP
\fB\-\-xsettings\fP or \fB\-\-no\-xsettings\fP
Enable or disable xsettings synchronization. Xsettings are only forwarded
Expand Down
2 changes: 2 additions & 0 deletions src/xpra/scripts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ def read_xpra_defaults():
"display" : str,
"tcp-proxy" : str,
"debug" : str,
"input-method" : str,
#int options:
"quality" : int,
"min-quality" : int,
Expand Down Expand Up @@ -354,6 +355,7 @@ def get_defaults():
"display" : "",
"tcp-proxy" : "",
"debug" : "",
"input-method" : "none",
"quality" : 0,
"min-quality" : 30,
"speed" : 0,
Expand Down
3 changes: 3 additions & 0 deletions src/xpra/scripts/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,9 @@ def do_parse_cmdline(cmdline, defaults):
group.add_option("--password-file", action="store",
dest="password_file", default=defaults.password_file,
help="The file containing the password required to connect (useful to secure TCP mode)")
group.add_option("--input-method", action="store",
dest="input_method", default=defaults.input_method,
help="Which X11 input method to configure for client applications started with start-child (default: %default, options: none, keep, xim, IBus, SCIM, uim)")
group.add_option("--dpi", action="store",
dest="dpi", default=defaults.dpi,
help="The 'dots per inch' value that client applications should try to honour (default: %default)")
Expand Down
48 changes: 38 additions & 10 deletions src/xpra/scripts/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import time
import traceback

from xpra.scripts.main import TCP_NODELAY
from xpra.scripts.main import TCP_NODELAY, warn
from xpra.dotxpra import DotXpra, ServerSockInUse

o0117 = 79
Expand Down Expand Up @@ -479,17 +479,44 @@ def unsetenv(*varnames):
#"XDG_RUNTIME_DIR",
"QT_GRAPHICSSYSTEM_CHECKED",
)
#force 'simple' / 'xim', as 'ibus' 'immodule' breaks keyboard handling
#unless its daemon is also running - and we don't know if it is..
#this should override any XSETTINGS too.

def configure_imsettings_env(input_method):
im = (input_method or "").lower()
if im in ("none", "no"):
#the default: set DISABLE_IMSETTINGS=1, fallback to xim
#that's because the 'ibus' 'immodule' breaks keyboard handling
#unless its daemon is also running - and we don't know if it is..
imsettings_env(True, "xim", "xim", "none", "")
elif im=="keep":
#do nothing and keep whatever is already set, hoping for the best
pass
elif im in ("xim", "IBus", "SCIM", "uim"):
#ie: (False, "ibus", "ibus", "IBus", "@im=ibus")
imsettings_env(True, im.lower(), im.lower(), im, "@im=%s" % im.lower())
else:
v = imsettings_env(True, im.lower(), im.lower(), im, "@im=%s" % im.lower())
warn("using input method settings: %s" % str(v))
warn("unknown input method specified: %s" % input_method)
warn(" if it is correct, you may want to file a bug to get it recognized")

def imsettings_env(disabled, gtk_im_module, qt_im_module, imsettings_module, xmodifiers):
#for more information, see imsettings:
#https://code.google.com/p/imsettings/source/browse/trunk/README
os.environ.update({
"DISABLE_IMSETTINGS" : "true",
"GTK_IM_MODULE" : "xim", #or "gtk-im-context-simple"?
"QT_IM_MODULE" : "xim", #or "simple"?
"IMSETTINGS_MODULE" : "none", #or "xim"?
"XMODIFIERS" : ""}) #oe "@im=none"
if disabled is True:
os.environ["DISABLE_IMSETTINGS"] = "1" #this should override any XSETTINGS too
elif disabled is False and ("DISABLE_IMSETTINGS" in os.environ):
del os.environ["DISABLE_IMSETTINGS"]
v = {
"GTK_IM_MODULE" : gtk_im_module, #or "gtk-im-context-simple"?
"QT_IM_MODULE" : qt_im_module, #or "simple"?
"IMSETTINGS_MODULE" : imsettings_module, #or "xim"?
"XMODIFIERS" : xmodifiers,
#not really sure what to do with those:
#"IMSETTINGS_DISABLE_DESKTOP_CHECK" : "true", #
#"IMSETTINGS_INTEGRATE_DESKTOP" : "no"} #we're not a real desktop
}
os.environ.update(v)
return v

def start_pulseaudio(child_reaper, pulseaudio_command):
from xpra.log import Logger
Expand Down Expand Up @@ -828,6 +855,7 @@ def run_server(error_cb, opts, mode, xpra_file, extra_args):
if display_name[0] != 'S':
os.environ["DISPLAY"] = display_name
sanitize_env()
configure_imsettings_env(opts.input_method)

# Start the Xvfb server first to get the display_name if needed
xvfb = None
Expand Down

0 comments on commit 4a93537

Please sign in to comment.