class ChildReaper(object): def __init__(self, quit_cb, children_pids={}): self._quit = quit_cb self._children_pids = children_pids self._dead_pids = set() from wimpiggy.log import Logger self._logger = Logger() def check(self): if self._children_pids: pids = set(self._children_pids.keys()) if pids.issubset(self._dead_pids): self._quit() def sigchld(self, signum, frame): self.reap() def add_dead_pid(self, pid): if pid not in self._dead_pids: cmd = self._children_pids.get(pid) if cmd: self._logger.info("child '%s' with pid %s has terminated", cmd, pid) self._dead_pids.add(pid) self.check() def reap(self): while True: try: pid, _ = os.waitpid(-1, os.WNOHANG) except OSError: break if pid == 0: break self.add_dead_pid(pid)
def handshake_complete(*args): from wimpiggy.log import Logger log = Logger() if mode=="detach": log.info("handshake-complete: detaching") app.quit(0) elif mode=="attach": log.info("Attached to %s (press Control-C to detach)\n" % conn.target)
def handshake_complete(*args): from wimpiggy.log import Logger log = Logger() if mode == "detach": log.info("handshake-complete: detaching") app.quit(0) elif mode == "attach": log.info("Attached to %s (press Control-C to detach)\n" % target)
# This file is part of Parti. # Copyright (C) 2010 Nathaniel Smith <*****@*****.**> # Copyright (C) 2011-2013 Antoine Martin <*****@*****.**> # Parti is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. # Platform-specific code for Win32 -- the parts that may import gtk. import os.path from xpra.platform.client_extras_base import ClientExtrasBase from xpra.platform.clipboard_base import DefaultClipboardProtocolHelper from xpra.keys import get_gtk_keymap from xpra.platform.keyboard_layouts import WIN32_LAYOUTS from wimpiggy.log import Logger log = Logger() from wimpiggy.gobject_compat import import_gdk gdk = import_gdk() class ClientExtras(ClientExtrasBase): def __init__(self, client, opts, conn): ClientExtrasBase.__init__(self, client, opts, conn) try: from xpra.platform.gdk_clipboard import TranslatedClipboardProtocolHelper self.setup_clipboard_helper(TranslatedClipboardProtocolHelper) except ImportError, e: log.error( "GDK Translated Clipboard failed to load: %s - using default fallback", e)
from cStringIO import StringIO import gtk.gdk import cairo from wimpiggy.lowlevel import ( XGetWindowProperty, #@UnresolvedImport XChangeProperty, #@UnresolvedImport NoSuchProperty, #@UnresolvedImport PropertyError, #@UnresolvedImport get_xatom, get_pyatom, #@UnresolvedImport get_xwindow, get_pywindow, #@UnresolvedImport const, #@UnresolvedImport premultiply_argb_in_place #@UnresolvedImport ) from wimpiggy.error import trap, XError from wimpiggy.log import Logger log = Logger() def unsupported(*args): raise Exception("unsupported") def _force_length(name, data, length, noerror_length=None): if len(data)==length: return data if len(data)!=noerror_length: log.warn("Odd-lengthed property %s: wanted %s bytes, got %s: %r" % (name, length, len(data), data)) # Zero-pad data data += "\0" * length return data[:length] class WMSizeHints(object):
def run_server(parser, opts, mode, xpra_file, extra_args): if len(extra_args) != 1: parser.error("need exactly 1 extra argument") assert mode in ("start", "upgrade", "shadow") upgrading = mode == "upgrade" shadowing = mode == "shadow" display_name = extra_args.pop(0) if display_name.startswith(":") and not shadowing: n = display_name[1:] p = n.find(".") if p>0: n = n[:p] try: dno = int(n) if dno>=0 and dno<10: sys.stderr.write("WARNING: low display number: %s\n" % dno) sys.stderr.write("You are attempting to run the xpra server against what seems to be a default X11 display '%s'.\n" % display_name) sys.stderr.write("This is generally not what you want.\n") sys.stderr.write("You should probably use a higher display number just to avoid any confusion (and also this warning message).\n") except: pass if opts.exit_with_children and not opts.children: sys.stderr.write("--exit-with-children specified without any children to spawn; exiting immediately") return 1 atexit.register(run_cleanups) signal.signal(signal.SIGINT, deadly_signal) signal.signal(signal.SIGTERM, deadly_signal) from xpra.scripts.main import get_default_socket_dir dotxpra = DotXpra(opts.sockdir or get_default_socket_dir()) # This used to be given a display-specific name, but now we give it a # single fixed name and if multiple servers are started then the last one # will clobber the rest. This isn't great, but the tradeoff is that it # makes it possible to use bare 'ssh:hostname' display names and # autodiscover the proper numeric display name when only one xpra server # is running on the remote host. Might need to revisit this later if # people run into problems or autodiscovery turns out to be less useful # than expected. scriptpath = os.path.join(dotxpra.confdir(), "run-xpra") # Save the starting dir now, because we'll lose track of it when we # daemonize: starting_dir = os.getcwd() # Daemonize: if opts.daemon: logpath = dotxpra.log_path(display_name) + ".log" sys.stderr.write("Entering daemon mode; " + "any further errors will be reported to:\n" + (" %s\n" % logpath)) # Do some work up front, so any errors don't get lost. if os.path.exists(logpath): os.rename(logpath, logpath + ".old") logfd = os.open(logpath, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, o0666) assert logfd > 2 os.chdir("/") if os.fork(): os._exit(0) os.setsid() if os.fork(): os._exit(0) close_all_fds(exceptions=[logfd]) fd0 = os.open("/dev/null", os.O_RDONLY) if fd0 != 0: os.dup2(fd0, 0) os.close(fd0) os.dup2(logfd, 1) os.dup2(logfd, 2) os.close(logfd) # Make these line-buffered: sys.stdout = os.fdopen(1, "w", 1) sys.stderr = os.fdopen(2, "w", 1) # Write out a shell-script so that we can start our proxy in a clean # environment: scriptfile = open(scriptpath, "w") # Unix is a little silly sometimes: umask = os.umask(0) os.umask(umask) if hasattr(os, "fchmod"): os.fchmod(scriptfile.fileno(), o0700 & ~umask) else: os.chmod(scriptpath, o0700 & ~umask) scriptfile.write(xpra_runner_shell_script(xpra_file, starting_dir, opts.sockdir)) scriptfile.close() from wimpiggy.log import Logger log = Logger() # Initialize the sockets before the display, # That way, errors won't make us kill the Xvfb # (which may not be ours to kill at that point) sockets = [] if opts.bind_tcp: try: tcp_socket = create_tcp_socket(parser, opts.bind_tcp) sockets.append(tcp_socket) def cleanup_tcp_socket(): log.info("closing tcp socket %s", opts.bind_tcp) try: tcp_socket.close() except: pass _cleanups.append(cleanup_tcp_socket) except Exception, e: log.error("cannot start - failed to create tcp socket at %s: %s" % (opts.bind_tcp, e)) return 1
def err(*msg): """ log an error message and return None """ from wimpiggy.log import Logger log = Logger() log.error(*msg) return None
# This file is part of Parti. # Copyright (C) 2011-2013 Antoine Martin <*****@*****.**> # Parti is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. from wimpiggy.log import Logger log = Logger() try: from xpra.xor.cyxor import xor_str #@UnresolvedImport log("cyxor loaded") except ImportError, e: log("cyxor not present") try: from xpra.xor.numpyxor import xor_str log("numpyxor loaded") except ImportError, e: log("numpyxor not present") assert bytearray is not None, "your python version lacks bytearray, you must install numpy or compile the xpra.xor.cyxor module" log.warn("using python xor fallback (much slower)") def xor_str(a, b): assert len(a)==len(b), "cannot xor strings of different lengths (pyxor)" c = bytearray("\0"*len(a)) for i in range(len(a)): c[i] = ord(a[i])^ord(b[i]) return str(c)
# This file is part of Parti. # Copyright (C) 2011, 2012 Antoine Martin <*****@*****.**> # 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 os import re import subprocess import time from wimpiggy.error import trap from wimpiggy.lowlevel import set_xmodmap, parse_keycode, parse_keysym, get_keycodes, parse_modifier, get_minmax_keycodes #@UnresolvedImport from wimpiggy.log import Logger log = Logger() def signal_safe_exec(cmd, stdin): """ this is a bit of a hack, the problem is that we won't catch SIGCHLD at all while this command is running! """ import signal try: oldsignal = signal.signal(signal.SIGCHLD, signal.SIG_DFL) process = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out,err) = process.communicate(stdin) code = process.poll() l=log.debug if code!=0: l=log.error l("signal_safe_exec(%s,%s) stdout='%s'", cmd, stdin, out) l("signal_safe_exec(%s,%s) stderr='%s'", cmd, stdin, err) return code
if sys.version_info[:2]>=(2,5): def unpack_header(buf): return struct.unpack_from('!cBBBL', buf) else: def unpack_header(buf): return struct.unpack('!cBBBL', "".join(buf)) try: from queue import Queue #@UnresolvedImport @UnusedImport (python3) except: from Queue import Queue #@Reimport from threading import Lock from wimpiggy.log import Logger log = Logger() from xpra.daemon_thread import make_daemon_thread from xpra.bencode import bencode, bdecode rencode_dumps, rencode_loads, rencode_version = None, None, None try: try: from xpra.rencode import dumps as rencode_dumps #@UnresolvedImport from xpra.rencode import loads as rencode_loads #@UnresolvedImport from xpra.rencode import __version__ rencode_version = __version__ log("found rencode version %s", rencode_version) except ImportError: log.error("rencode load error", exc_info=True) except Exception, e: log.error("xpra.rencode is missing: %s", e)
# This file is part of Parti. # Copyright (C) 2011-2013 Antoine Martin <*****@*****.**> # Parti is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. from wimpiggy.log import Logger log = Logger() try: from xpra.xor.cyxor import xor_str #@UnresolvedImport log("cyxor loaded") except ImportError, e: log("cyxor not present") try: from xpra.xor.numpyxor import xor_str log("numpyxor loaded") except ImportError, e: log("numpyxor not present") assert bytearray is not None, "your python version lacks bytearray, you must install numpy or compile the xpra.xor.cyxor module" log.warn("using python xor fallback (much slower)") def xor_str(a, b): assert len(a) == len( b), "cannot xor strings of different lengths (pyxor)" c = bytearray("\0" * len(a)) for i in range(len(a)): c[i] = ord(a[i]) ^ ord(b[i]) return str(c)
# This file is part of Parti. # Copyright (C) 2011, 2012 Antoine Martin <*****@*****.**> # 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 os import re import subprocess import time from wimpiggy.error import trap from wimpiggy.lowlevel import set_xmodmap, parse_keycode, parse_keysym, get_keycodes, parse_modifier, get_minmax_keycodes #@UnresolvedImport from wimpiggy.log import Logger log = Logger() def signal_safe_exec(cmd, stdin): """ this is a bit of a hack, the problem is that we won't catch SIGCHLD at all while this command is running! """ import signal try: oldsignal = signal.signal(signal.SIGCHLD, signal.SIG_DFL) process = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = process.communicate(stdin) code = process.poll() l = log.debug if code != 0: l = log.error
# This file is part of Parti. # Copyright (C) 2010 Nathaniel Smith <*****@*****.**> # Copyright (C) 2011-2013 Antoine Martin <*****@*****.**> # Parti is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. # Platform-specific code for Win32 -- the parts that may import gtk. import os.path from xpra.platform.client_extras_base import ClientExtrasBase from xpra.platform.clipboard_base import DefaultClipboardProtocolHelper from xpra.keys import get_gtk_keymap from xpra.platform.keyboard_layouts import WIN32_LAYOUTS from wimpiggy.log import Logger log = Logger() from wimpiggy.gobject_compat import import_gdk gdk = import_gdk() class ClientExtras(ClientExtrasBase): def __init__(self, client, opts, conn): ClientExtrasBase.__init__(self, client, opts, conn) try: from xpra.platform.gdk_clipboard import TranslatedClipboardProtocolHelper self.setup_clipboard_helper(TranslatedClipboardProtocolHelper) except ImportError, e: log.error("GDK Translated Clipboard failed to load: %s - using default fallback", e) self.setup_clipboard_helper(DefaultClipboardProtocolHelper) self.setup_exit_handler(True)
def __init__(self, quit_cb, children_pids={}): self._quit = quit_cb self._children_pids = children_pids self._dead_pids = set() from wimpiggy.log import Logger self._logger = Logger()
# This file is part of Parti. # Copyright (C) 2011, 2012 Antoine Martin <*****@*****.**> # 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 os import re import subprocess from wimpiggy.error import trap from wimpiggy.lowlevel import set_xmodmap, parse_keysym, parse_modifier, get_minmax_keycodes #@UnresolvedImport from wimpiggy.log import Logger log = Logger() def signal_safe_exec(cmd, stdin): """ this is a bit of a hack, the problem is that we won't catch SIGCHLD at all while this command is running! """ import signal try: oldsignal = signal.signal(signal.SIGCHLD, signal.SIG_DFL) process = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out,err) = process.communicate(stdin) code = process.poll() l=log.debug if code!=0: l=log.error l("signal_safe_exec(%s,%s) stdout='%s'", cmd, stdin, out) l("signal_safe_exec(%s,%s) stderr='%s'", cmd, stdin, err) return code finally:
# This file is part of Parti. # Copyright (C) 2013 Serviware (Arthur Huillet, <*****@*****.**>) # Copyright (C) 2012, 2013 Antoine Martin <*****@*****.**> # Parti is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. #only works with gtk2: from gtk import gdk assert gdk import gtk.gdkgl, gtk.gtkgl #@UnresolvedImport assert gtk.gdkgl is not None and gtk.gtkgl is not None import gobject import os from wimpiggy.log import Logger log = Logger() debug = log.debug if os.environ.get("XPRA_OPENGL_DEBUG", "0")=="1": debug = log.info from xpra.gl.gl_check import get_DISPLAY_MODE from xpra.codec_constants import YUV420P, YUV422P, YUV444P, get_subsampling_divs from xpra.gl.gl_colorspace_conversions import GL_COLORSPACE_CONVERSIONS from xpra.window_backing import PixmapBacking, fire_paint_callbacks from OpenGL.GL import GL_PROJECTION, GL_MODELVIEW, \ GL_UNPACK_ROW_LENGTH, GL_UNPACK_ALIGNMENT, \ GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_FILTER, GL_NEAREST, \ GL_UNSIGNED_BYTE, GL_LUMINANCE, GL_RGB, GL_LINEAR, \ GL_TEXTURE0, GL_TEXTURE1, GL_TEXTURE2, GL_QUADS, GL_COLOR_BUFFER_BIT, \ GL_DONT_CARE, GL_TRUE,\ glActiveTexture, glTexSubImage2D, \
#!/usr/bin/env python # This file is part of Parti. # Copyright (C) 2010-2013 Antoine Martin <*****@*****.**> # 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 sys, os import gobject from xpra.sound.sound_pipeline import SoundPipeline, debug from xpra.sound.pulseaudio_util import has_pa from xpra.sound.gstreamer_util import plugin_str, get_decoder_parser, MP3, CODECS, gst from wimpiggy.util import one_arg_signal, no_arg_signal from wimpiggy.log import Logger log = Logger() SINKS = ["autoaudiosink"] DEFAULT_SINK = SINKS[0] if has_pa(): SINKS.append("pulsesink") if sys.platform.startswith("darwin"): SINKS.append("osxaudiosink") DEFAULT_SINK = "osxaudiosink" elif sys.platform.startswith("win"): SINKS.append("directsoundsink") DEFAULT_SINK = "directsoundsink" if os.name == "posix": SINKS += ["alsasink", "osssink", "oss4sink", "jackaudiosink"] GST_QUEUE_NO_LEAK = 0 GST_QUEUE_LEAK_UPSTREAM = 1
# This file is part of Parti. # Copyright (C) 2013 Serviware (Arthur Huillet, <*****@*****.**>) # Copyright (C) 2012, 2013 Antoine Martin <*****@*****.**> # Parti is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. #only works with gtk2: from gtk import gdk assert gdk import gtk.gdkgl, gtk.gtkgl #@UnresolvedImport assert gtk.gdkgl is not None and gtk.gtkgl is not None import gobject import os from wimpiggy.log import Logger log = Logger() debug = log.debug if os.environ.get("XPRA_OPENGL_DEBUG", "0") == "1": debug = log.info from xpra.gl.gl_check import get_DISPLAY_MODE from xpra.codec_constants import YUV420P, YUV422P, YUV444P, get_subsampling_divs from xpra.gl.gl_colorspace_conversions import GL_COLORSPACE_CONVERSIONS from xpra.window_backing import PixmapBacking, fire_paint_callbacks from OpenGL.GL import GL_PROJECTION, GL_MODELVIEW, \ GL_UNPACK_ROW_LENGTH, GL_UNPACK_ALIGNMENT, \ GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_FILTER, GL_NEAREST, \ GL_UNSIGNED_BYTE, GL_LUMINANCE, GL_RGB, GL_LINEAR, \ GL_TEXTURE0, GL_TEXTURE1, GL_TEXTURE2, GL_QUADS, GL_COLOR_BUFFER_BIT, \ GL_DONT_CARE, GL_TRUE,\ glActiveTexture, glTexSubImage2D, \
def run_server(parser, opts, mode, xpra_file, extra_args): if len(extra_args) != 1: parser.error("need exactly 1 extra argument") assert mode in ("start", "upgrade", "shadow") upgrading = mode == "upgrade" shadowing = mode == "shadow" display_name = extra_args.pop(0) if display_name.startswith(":") and not shadowing: n = display_name[1:] p = n.find(".") if p > 0: n = n[:p] try: dno = int(n) if dno >= 0 and dno < 10: sys.stderr.write("WARNING: low display number: %s\n" % dno) sys.stderr.write( "You are attempting to run the xpra server against what seems to be a default X11 display '%s'.\n" % display_name) sys.stderr.write("This is generally not what you want.\n") sys.stderr.write( "You should probably use a higher display number just to avoid any confusion (and also this warning message).\n" ) except: pass if opts.exit_with_children and not opts.children: sys.stderr.write( "--exit-with-children specified without any children to spawn; exiting immediately" ) return 1 atexit.register(run_cleanups) signal.signal(signal.SIGINT, deadly_signal) signal.signal(signal.SIGTERM, deadly_signal) from xpra.scripts.main import get_default_socket_dir dotxpra = DotXpra(opts.sockdir or get_default_socket_dir()) # This used to be given a display-specific name, but now we give it a # single fixed name and if multiple servers are started then the last one # will clobber the rest. This isn't great, but the tradeoff is that it # makes it possible to use bare 'ssh:hostname' display names and # autodiscover the proper numeric display name when only one xpra server # is running on the remote host. Might need to revisit this later if # people run into problems or autodiscovery turns out to be less useful # than expected. scriptpath = os.path.join(dotxpra.confdir(), "run-xpra") # Save the starting dir now, because we'll lose track of it when we # daemonize: starting_dir = os.getcwd() # Daemonize: if opts.daemon: logpath = dotxpra.log_path(display_name) + ".log" sys.stderr.write("Entering daemon mode; " + "any further errors will be reported to:\n" + (" %s\n" % logpath)) # Do some work up front, so any errors don't get lost. if os.path.exists(logpath): os.rename(logpath, logpath + ".old") logfd = os.open(logpath, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, o0666) assert logfd > 2 os.chdir("/") if os.fork(): os._exit(0) os.setsid() if os.fork(): os._exit(0) close_all_fds(exceptions=[logfd]) fd0 = os.open("/dev/null", os.O_RDONLY) if fd0 != 0: os.dup2(fd0, 0) os.close(fd0) os.dup2(logfd, 1) os.dup2(logfd, 2) os.close(logfd) # Make these line-buffered: sys.stdout = os.fdopen(1, "w", 1) sys.stderr = os.fdopen(2, "w", 1) # Write out a shell-script so that we can start our proxy in a clean # environment: scriptfile = open(scriptpath, "w") # Unix is a little silly sometimes: umask = os.umask(0) os.umask(umask) if hasattr(os, "fchmod"): os.fchmod(scriptfile.fileno(), o0700 & ~umask) else: os.chmod(scriptpath, o0700 & ~umask) scriptfile.write( xpra_runner_shell_script(xpra_file, starting_dir, opts.sockdir)) scriptfile.close() from wimpiggy.log import Logger log = Logger() # Initialize the sockets before the display, # That way, errors won't make us kill the Xvfb # (which may not be ours to kill at that point) sockets = [] if opts.bind_tcp: try: tcp_socket = create_tcp_socket(parser, opts.bind_tcp) sockets.append(tcp_socket) def cleanup_tcp_socket(): log.info("closing tcp socket %s", opts.bind_tcp) try: tcp_socket.close() except: pass _cleanups.append(cleanup_tcp_socket) except Exception, e: log.error("cannot start - failed to create tcp socket at %s: %s" % (opts.bind_tcp, e)) return 1
#!/usr/bin/env python # This file is part of Parti. # Copyright (C) 2010-2013 Antoine Martin <*****@*****.**> # 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 sys, os import gobject from xpra.sound.sound_pipeline import SoundPipeline, debug from xpra.sound.pulseaudio_util import has_pa from xpra.sound.gstreamer_util import plugin_str, get_decoder_parser, MP3, CODECS, gst from wimpiggy.util import one_arg_signal, no_arg_signal from wimpiggy.log import Logger log = Logger() SINKS = ["autoaudiosink"] DEFAULT_SINK = SINKS[0] if has_pa(): SINKS.append("pulsesink") if sys.platform.startswith("darwin"): SINKS.append("osxaudiosink") DEFAULT_SINK = "osxaudiosink" elif sys.platform.startswith("win"): SINKS.append("directsoundsink") DEFAULT_SINK = "directsoundsink" if os.name=="posix": SINKS += ["alsasink", "osssink", "oss4sink", "jackaudiosink"] GST_QUEUE_NO_LEAK = 0 GST_QUEUE_LEAK_UPSTREAM = 1
import cairo from wimpiggy.lowlevel import ( XGetWindowProperty, #@UnresolvedImport XChangeProperty, #@UnresolvedImport NoSuchProperty, #@UnresolvedImport PropertyError, #@UnresolvedImport get_xatom, get_pyatom, #@UnresolvedImport get_xwindow, get_pywindow, #@UnresolvedImport const, #@UnresolvedImport premultiply_argb_in_place #@UnresolvedImport ) from wimpiggy.error import trap, XError from wimpiggy.log import Logger log = Logger() def unsupported(*args): raise Exception("unsupported") def _force_length(data, length): if len(data) != length: log.warn("Odd-lengthed prop, wanted %s bytes, got %s: %r" % (length, len(data), data)) # Zero-pad data data += "\0" * length return data[:length]
# later version. See the file COPYING for details. import gtk import gobject import cairo import re import os import time from collections import deque from wimpiggy.util import (n_arg_signal, gtk_main_quit_really, gtk_main_quit_on_fatal_exceptions_enable) from wimpiggy.log import Logger log = Logger() from xpra.client_base import XpraClientBase from xpra.keys import mask_to_names, DEFAULT_MODIFIER_MEANINGS, DEFAULT_MODIFIER_NUISANCE, DEFAULT_MODIFIER_IGNORE_KEYNAMES from xpra.platform.gui import ClientExtras from xpra.scripts.main import ENCODINGS from xpra.version_util import is_compatible_with def nn(x): if x is None: return "" return x class ClientWindow(gtk.Window): def __init__(self, client, wid, x, y, w, h, metadata, override_redirect): if override_redirect:
if sys.version_info[:2]>=(2,5): def unpack_header(buf): return struct.unpack_from('!cBBBL', buf) else: def unpack_header(buf): return struct.unpack('!cBBBL', "".join(buf)) try: from queue import Queue #@UnresolvedImport @UnusedImport (python3) except: from Queue import Queue #@Reimport from threading import Lock from wimpiggy.log import Logger log = Logger() from xpra.daemon_thread import make_daemon_thread from xpra.bytestreams import untilConcludes from xpra.bencode import bencode, bdecode rencode_dumps, rencode_loads = None, None try: try: from xpra.rencode import dumps as rencode_dumps #@UnresolvedImport from xpra.rencode import loads as rencode_loads #@UnresolvedImport except ImportError: pass except Exception, e: log.error("xpra.rencode is missing: %s", e) has_rencode = rencode_dumps is not None and rencode_loads is not None use_rencode = has_rencode and not os.environ.get("XPRA_USE_BENCODER", "0")=="1"
#!/usr/bin/env python # This file is part of Parti. # Copyright (C) 2010-2013 Antoine Martin <*****@*****.**> # 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 sys, os import gobject gobject.threads_init() from xpra.sound.sound_pipeline import SoundPipeline, debug from xpra.sound.pulseaudio_util import has_pa from xpra.sound.gstreamer_util import plugin_str, get_encoders, MP3, CODECS from wimpiggy.util import n_arg_signal from wimpiggy.log import Logger log = Logger() SOURCES = ["autoaudiosrc"] if has_pa(): SOURCES.append("pulsesrc") if sys.platform.startswith("darwin"): SOURCES.append("osxaudiosrc") elif sys.platform.startswith("win"): SOURCES.append("directsoundsrc") if os.name=="posix": SOURCES += ["alsasrc", "jackaudiosrc", "osssrc", "oss4src", "osxaudiosrc", "jackaudiosrc"] SOURCES.append("audiotestsrc")
#!/usr/bin/env python # This file is part of Parti. # Copyright (C) 2010-2013 Antoine Martin <*****@*****.**> # 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 sys, os import gobject gobject.threads_init() from xpra.sound.sound_pipeline import SoundPipeline, debug from xpra.sound.pulseaudio_util import has_pa from xpra.sound.gstreamer_util import plugin_str, get_encoders, MP3, CODECS from wimpiggy.util import n_arg_signal from wimpiggy.log import Logger log = Logger() SOURCES = ["autoaudiosrc"] if has_pa(): SOURCES.append("pulsesrc") if sys.platform.startswith("darwin"): SOURCES.append("osxaudiosrc") elif sys.platform.startswith("win"): SOURCES.append("directsoundsrc") if os.name == "posix": SOURCES += [ "alsasrc", "jackaudiosrc", "osssrc", "oss4src", "osxaudiosrc", "jackaudiosrc" ] SOURCES.append("audiotestsrc")
def unpack_header(buf): return struct.unpack_from('!cBBBL', buf) else: def unpack_header(buf): return struct.unpack('!cBBBL', "".join(buf)) try: from queue import Queue #@UnresolvedImport @UnusedImport (python3) except: from Queue import Queue #@Reimport from threading import Lock from wimpiggy.log import Logger log = Logger() from xpra.daemon_thread import make_daemon_thread from xpra.bytestreams import untilConcludes from xpra.bencode import bencode, bdecode rencode_dumps, rencode_loads = None, None try: try: from xpra.rencode import dumps as rencode_dumps #@UnresolvedImport from xpra.rencode import loads as rencode_loads #@UnresolvedImport except ImportError: pass except Exception, e: log.error("xpra.rencode is missing: %s", e) has_rencode = rencode_dumps is not None and rencode_loads is not None use_rencode = has_rencode and not os.environ.get("XPRA_USE_BENCODER",
# later version. See the file COPYING for details. import os import re import subprocess from wimpiggy.error import trap from wimpiggy.lowlevel import (set_xmodmap, #@UnresolvedImport parse_keysym, #@UnresolvedImport parse_modifier, #@UnresolvedImport get_minmax_keycodes, #@UnresolvedImport ungrab_all_keys, #@UnresolvedImport unpress_all_keys, #@UnresolvedImport get_keycode_mappings) #@UnresolvedImport from wimpiggy.log import Logger log = Logger() debug = log.info debug = log.debug verbose = log.debug def signal_safe_exec(cmd, stdin): """ this is a bit of a hack, the problem is that we won't catch SIGCHLD at all while this command is running! """ import signal try: oldsignal = signal.signal(signal.SIGCHLD, signal.SIG_DFL) process = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out,err) = process.communicate(stdin) code = process.poll()
# This file is part of Parti. # Copyright (C) 2012 Serviware (Arthur Huillet, <*****@*****.**>) # Copyright (C) 2012 Antoine Martin <*****@*****.**> # Parti is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. from wimpiggy.log import Logger log = Logger() from xpra.client_window import ClientWindow, queue_draw from xpra.scripts.main import ENCODINGS import gtk.gdkgl, gtk.gtkgl #@UnresolvedImport assert gtk.gdkgl is not None and gtk.gtkgl is not None from OpenGL.GL import GL_VERSION, GL_PROJECTION, GL_MODELVIEW, GL_VERTEX_ARRAY, \ GL_TEXTURE_COORD_ARRAY, GL_FRAGMENT_PROGRAM_ARB, \ GL_PROGRAM_ERROR_STRING_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, \ GL_TEXTURE_RECTANGLE_ARB, GL_UNPACK_ROW_LENGTH, \ GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_FILTER, GL_NEAREST, \ GL_UNSIGNED_BYTE, GL_RGB, GL_LUMINANCE, GL_LINEAR, \ GL_TEXTURE0, GL_TEXTURE1, GL_TEXTURE2, GL_QUADS, \ glActiveTexture, \ glGetString, glViewport, glMatrixMode, glLoadIdentity, glOrtho, \ glEnableClientState, glDisable, glGenTextures, \ glBindTexture, glPixelStorei, glEnable, glBegin, \ glTexParameteri, glVertexPointeri, glTexCoordPointeri, \ glTexImage2D, glTexSubImage2D, \ glDrawArrays, glMultiTexCoord2i, \ glVertex2i, glEnd
y = int(y/ratio) cursor = gdk.Cursor(gdk.display_get_default(), pixbuf, x, y) for gtkwindow in gtkwindows: gtkwindow.get_window().set_cursor(cursor) import sys import os import time import ctypes from wimpiggy.util import (n_arg_signal, gtk_main_quit_really, gtk_main_quit_on_fatal_exceptions_enable) from wimpiggy.log import Logger log = Logger() from xpra import __version__ from xpra.deque import maxdeque from xpra.client_base import XpraClientBase from xpra.keys import mask_to_names, DEFAULT_MODIFIER_MEANINGS, DEFAULT_MODIFIER_NUISANCE, DEFAULT_MODIFIER_IGNORE_KEYNAMES from xpra.platform.gui import ClientExtras from xpra.scripts.main import ENCODINGS from xpra.version_util import add_gtk_version_info from xpra.client_window import ClientWindow ClientWindowClass = ClientWindow #the GL backend only works with gtk2 USE_OPENGL = False if USE_OPENGL and not is_gtk3(): try:
# later version. See the file COPYING for details. import os import re from wimpiggy.error import trap from wimpiggy.lowlevel import ( set_xmodmap, #@UnresolvedImport parse_keysym, #@UnresolvedImport parse_modifier, #@UnresolvedImport get_minmax_keycodes, #@UnresolvedImport ungrab_all_keys, #@UnresolvedImport unpress_all_keys, #@UnresolvedImport get_keycode_mappings) #@UnresolvedImport from wimpiggy.log import Logger log = Logger() KEYBOARD_DEBUG = os.environ.get("XPRA_KEYBOARD_DEBUG", "0") == "1" if KEYBOARD_DEBUG: debug = log.info else: debug = log.debug KEYBOARD_VERBOSE = os.environ.get("XPRA_KEYBOARD_DEBUG", "0") == "2" if KEYBOARD_VERBOSE: verbose = log.info else: verbose = log.debug def exec_keymap_command(args, stdin=None): try:
cursor = gdk.Cursor(gdk.display_get_default(), pixbuf, x, y) for gtkwindow in gtkwindows: gtkwindow.get_window().set_cursor(cursor) import sys import os import time import ctypes from wimpiggy.util import (n_arg_signal, gtk_main_quit_really, gtk_main_quit_on_fatal_exceptions_enable) from wimpiggy.log import Logger log = Logger() from xpra.deque import maxdeque from xpra.client_base import XpraClientBase from xpra.keys import mask_to_names, DEFAULT_MODIFIER_MEANINGS, DEFAULT_MODIFIER_NUISANCE, DEFAULT_MODIFIER_IGNORE_KEYNAMES from xpra.platform.gui import ClientExtras from xpra.scripts.main import ENCODINGS from xpra.version_util import add_gtk_version_info from xpra.client_window import ClientWindow ClientWindowClass = ClientWindow #the GL backend only works with gtk2 USE_OPENGL = False if USE_OPENGL and not is_gtk3(): try:
# This file is part of Parti. # Copyright (C) 2012 Serviware (Arthur Huillet, <*****@*****.**>) # Copyright (C) 2012 Antoine Martin <*****@*****.**> # Parti is released under the terms of the GNU GPL v2, or, at your option, any # later version. See the file COPYING for details. from wimpiggy.log import Logger log = Logger() from xpra.client_window import ClientWindow, queue_draw from xpra.scripts.main import ENCODINGS import gtk.gdkgl, gtk.gtkgl #@UnresolvedImport assert gtk.gdkgl is not None and gtk.gtkgl is not None from OpenGL.GL import GL_VERSION, GL_PROJECTION, GL_MODELVIEW, GL_VERTEX_ARRAY, \ GL_TEXTURE_COORD_ARRAY, GL_FRAGMENT_PROGRAM_ARB, \ GL_PROGRAM_ERROR_STRING_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, \ GL_TEXTURE_RECTANGLE_ARB, GL_UNPACK_ROW_LENGTH, \ GL_TEXTURE_MAG_FILTER, GL_TEXTURE_MIN_FILTER, GL_NEAREST, \ GL_UNSIGNED_BYTE, GL_RGB, GL_LUMINANCE, GL_LINEAR, \ GL_TEXTURE0, GL_TEXTURE1, GL_TEXTURE2, GL_QUADS, \ glActiveTexture, \ glGetString, glViewport, glMatrixMode, glLoadIdentity, glOrtho, \ glEnableClientState, glDisable, glGenTextures, \ glBindTexture, glPixelStorei, glEnable, glBegin, \ glTexParameteri, glVertexPointeri, glTexCoordPointeri, \ glTexImage2D, glTexSubImage2D, \ glDrawArrays, glMultiTexCoord2i, \ glVertex2i, glEnd from OpenGL.GL.ARB.vertex_program import glGenProgramsARB, glBindProgramARB, glProgramStringARB
import gobject import gtk from wimpiggy.error import * from wimpiggy.util import no_arg_signal, one_arg_signal from wimpiggy.selection import ManagerSelection from wimpiggy.prop import prop_set, prop_get from wimpiggy.lowlevel import (myGetSelectionOwner, const, get_pywindow, add_event_receiver, remove_event_receiver, get_xatom) from wimpiggy.log import Logger log = Logger() class XSettingsManager(object): def __init__(self, settings_blob): self._selection = ManagerSelection(gtk.gdk.display_get_default(), "_XSETTINGS_S0") # Technically I suppose ICCCM says we should use FORCE, but it's not # like a window manager where you have to wait for the old wm to clean # things up before you can do anything... as soon as the selection is # gone, the settings are gone. (Also, if we're stealing from # ourselves, we probably don't clean up the window properly.) self._selection.acquire(self._selection.FORCE_AND_RETURN) self._window = self._selection.window() self._set_blob_in_place(settings_blob) # This is factored out as a separate function to make it easier to test # XSettingsWatcher: def _set_blob_in_place(self, settings_blob): prop_set(self._window, "_XSETTINGS_SETTINGS", "xsettings-settings", settings_blob)
def unpack_header(buf): return struct.unpack_from('!cBBBL', buf) else: def unpack_header(buf): return struct.unpack('!cBBBL', "".join(buf)) try: from queue import Queue #@UnresolvedImport @UnusedImport (python3) except: from Queue import Queue #@Reimport from threading import Lock from wimpiggy.log import Logger log = Logger() from xpra.daemon_thread import make_daemon_thread from xpra.bencode import bencode, bdecode rencode_dumps, rencode_loads, rencode_version = None, None, None try: try: from xpra.rencode import dumps as rencode_dumps #@UnresolvedImport from xpra.rencode import loads as rencode_loads #@UnresolvedImport from xpra.rencode import __version__ rencode_version = __version__ log("found rencode version %s", rencode_version) except ImportError: log.error("rencode load error", exc_info=True) except Exception, e: log.error("xpra.rencode is missing: %s", e)