Ejemplo n.º 1
0
        if len(bytes) < width * height * 4:
            log.warn("Corrupt _NET_WM_ICON")
            return None
    except Exception, e:
        log.warn("Weird corruption in _NET_WM_ICON: %s", e)
        return None
    # Cairo wants a native-endian array here, and since the icon is
    # transmitted as CARDINALs, that's what we get. It might seem more
    # sensible to use ImageSurface.create_for_data (at least it did to me!)
    # but then you end up with a surface that refers to the memory you pass in
    # directly, and also .get_data() doesn't work on it, and it breaks the
    # test suite and blah. This at least works, as odd as it is:
    surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
    # old versions of cairo do not have this method, just ignore it
    if not hasattr(surf, "get_data"):
        log.warn("Your Cairo is too old! Carrying on as best I can, "
                 "but don't expect a miracle")
        return None
    surf.get_data()[:] = bytes
    # Cairo uses premultiplied alpha. EWMH actually doesn't specify what it
    # uses, but apparently the de-facto standard is non-premultiplied. (At
    # least that's what Compiz's sources say.)
    premultiply_argb_in_place(surf.get_data())
    return (width * height, surf)

# This returns a cairo ImageSurface which contains the largest icon defined in
# a _NET_WM_ICON property.
def NetWMIcons(disp, data):
    icons = []
    stream = StringIO(data)
    while True:
        size_image = _read_image(disp, stream)
Ejemplo n.º 2
0
# 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)
Ejemplo n.º 3
0
 #figure out the maximum actual desktop size and use it to
 #calculate the maximum size of a packet (a full screen update packet)
 self.server_actual_desktop_size = capabilities.get(
     "actual_desktop_size")
 log("server actual desktop size=%s", self.server_actual_desktop_size)
 self.set_max_packet_size()
 self.server_max_desktop_size = capabilities.get("max_desktop_size")
 server_desktop_size = capabilities.get("desktop_size")
 log("server desktop size=%s", server_desktop_size)
 assert server_desktop_size
 avail_w, avail_h = server_desktop_size
 root_w, root_h = get_root_size()
 if avail_w < root_w or avail_h < root_h:
     log.warn("Server's virtual screen is too small -- "
              "(server: %sx%s vs. client: %sx%s)\n"
              "You may see strange behavior.\n"
              "Please see "
              "https://www.xpra.org/trac/ticket/10" %
              (avail_w, avail_h, root_w, root_h))
 self.server_randr = capabilities.get("resize_screen", False)
 log.debug("server has randr: %s", self.server_randr)
 if self.server_randr and not is_gtk3():
     display = gdk.display_get_default()
     i = 0
     while i < display.get_n_screens():
         screen = display.get_screen(i)
         screen.connect("size-changed", self._screen_size_changed)
         i += 1
 e = capabilities.get("encoding")
 if e and e != self.encoding:
     log.debug("server is using %s encoding" % e)
     self.encoding = e
Ejemplo n.º 4
0
     log.warn("glib is missing, cannot set the application name, please install glib's python bindings: %s", e)
 #figure out the maximum actual desktop size and use it to
 #calculate the maximum size of a packet (a full screen update packet)
 self.server_actual_desktop_size = capabilities.get("actual_desktop_size")
 log("server actual desktop size=%s", self.server_actual_desktop_size)
 self.set_max_packet_size()
 self.server_max_desktop_size = capabilities.get("max_desktop_size")
 server_desktop_size = capabilities.get("desktop_size")
 log("server desktop size=%s", server_desktop_size)
 assert server_desktop_size
 avail_w, avail_h = server_desktop_size
 root_w, root_h = get_root_size()
 if avail_w<root_w or avail_h<root_h:
     log.warn("Server's virtual screen is too small -- "
              "(server: %sx%s vs. client: %sx%s)\n"
              "You may see strange behavior.\n"
              "Please see "
              "https://www.xpra.org/trac/ticket/10"
              % (avail_w, avail_h, root_w, root_h))
 self.server_randr = capabilities.get("resize_screen", False)
 log.debug("server has randr: %s", self.server_randr)
 if self.server_randr and not is_gtk3():
     display = gdk.display_get_default()
     i=0
     while i<display.get_n_screens():
         screen = display.get_screen(i)
         screen.connect("size-changed", self._screen_size_changed)
         i += 1
 e = capabilities.get("encoding")
 if e and e!=self.encoding:
     log.debug("server is using %s encoding" % e)
     self.encoding = e
Ejemplo n.º 5
0
        if len(bytes) < width * height * 4:
            log.warn("Corrupt _NET_WM_ICON")
            return None
    except Exception, e:
        log.warn("Weird corruption in _NET_WM_ICON: %s", e)
        return None
    # Cairo wants a native-endian array here, and since the icon is
    # transmitted as CARDINALs, that's what we get. It might seem more
    # sensible to use ImageSurface.create_for_data (at least it did to me!)
    # but then you end up with a surface that refers to the memory you pass in
    # directly, and also .get_data() doesn't work on it, and it breaks the
    # test suite and blah. This at least works, as odd as it is:
    surf = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
    # old versions of cairo do not have this method, just ignore it
    if not hasattr(surf, "get_data"):
        log.warn("Your Cairo is too old! Carrying on as best I can, "
                 "but don't expect a miracle")
        return None
    surf.get_data()[:] = bytes
    # Cairo uses premultiplied alpha. EWMH actually doesn't specify what it
    # uses, but apparently the de-facto standard is non-premultiplied. (At
    # least that's what Compiz's sources say.)
    premultiply_argb_in_place(surf.get_data())
    return (width * height, surf)


# This returns a cairo ImageSurface which contains the largest icon defined in
# a _NET_WM_ICON property.
def NetWMIcons(disp, data):
    icons = []
    stream = StringIO(data)
    while True:
Ejemplo n.º 6
0
# 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)
Ejemplo n.º 7
0
    glGenTextures, glDisable, \
    glBindTexture, glPixelStorei, glEnable, glBegin, glFlush, \
    glTexParameteri, \
    glTexImage2D, \
    glMultiTexCoord2i, \
    glTexCoord2i, glVertex2i, glEnd, \
    glClear, glClearColor
from OpenGL.GL.ARB.texture_rectangle import GL_TEXTURE_RECTANGLE_ARB
from OpenGL.GL.ARB.vertex_program import glGenProgramsARB, \
    glBindProgramARB, glProgramStringARB, GL_PROGRAM_ERROR_STRING_ARB, GL_PROGRAM_FORMAT_ASCII_ARB
from OpenGL.GL.ARB.fragment_program import GL_FRAGMENT_PROGRAM_ARB
from OpenGL.GL.ARB.framebuffer_object import GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, glGenFramebuffers, glBindFramebuffer, glFramebufferTexture2D
try:
    from OpenGL.GL.KHR.debug import GL_DEBUG_OUTPUT, GL_DEBUG_OUTPUT_SYNCHRONOUS, glDebugMessageControl, glDebugMessageCallback, glInitDebugKHR
except ImportError:
    log.warn("Unable to import GL_KHR_debug OpenGL extension. Debug output will be more limited.")
    GL_DEBUG_OUTPUT = None
try:
    from OpenGL.GL.GREMEDY.string_marker import glInitStringMarkerGREMEDY, glStringMarkerGREMEDY
    from OpenGL.GL.GREMEDY.frame_terminator import glInitFrameTerminatorGREMEDY, glFrameTerminatorGREMEDY
    from OpenGL.GL import GLDEBUGPROC #@UnresolvedImport
    def py_gl_debug_callback(source, error_type, error_id, severity, length, message, param):
        log.error("src %x type %x id %x severity %x length %d message %s", source, error_type, error_id, severity, length, message)
    gl_debug_callback = GLDEBUGPROC(py_gl_debug_callback)
except ImportError:
    # This is normal- GREMEDY_string_marker is only available with OpenGL debuggers
    gl_debug_callback = None
    glInitStringMarkerGREMEDY = None
    glStringMarkerGREMEDY = None
    glInitFrameTerminatorGREMEDY = None
    glFrameTerminatorGREMEDY = None
Ejemplo n.º 8
0
    glBindTexture, glPixelStorei, glEnable, glBegin, glFlush, \
    glTexParameteri, \
    glTexImage2D, \
    glMultiTexCoord2i, \
    glTexCoord2i, glVertex2i, glEnd, \
    glClear, glClearColor
from OpenGL.GL.ARB.texture_rectangle import GL_TEXTURE_RECTANGLE_ARB
from OpenGL.GL.ARB.vertex_program import glGenProgramsARB, \
    glBindProgramARB, glProgramStringARB, GL_PROGRAM_ERROR_STRING_ARB, GL_PROGRAM_FORMAT_ASCII_ARB
from OpenGL.GL.ARB.fragment_program import GL_FRAGMENT_PROGRAM_ARB
from OpenGL.GL.ARB.framebuffer_object import GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, glGenFramebuffers, glBindFramebuffer, glFramebufferTexture2D
try:
    from OpenGL.GL.KHR.debug import GL_DEBUG_OUTPUT, GL_DEBUG_OUTPUT_SYNCHRONOUS, glDebugMessageControl, glDebugMessageCallback, glInitDebugKHR
except ImportError:
    log.warn(
        "Unable to import GL_KHR_debug OpenGL extension. Debug output will be more limited."
    )
    GL_DEBUG_OUTPUT = None
try:
    from OpenGL.GL.GREMEDY.string_marker import glInitStringMarkerGREMEDY, glStringMarkerGREMEDY
    from OpenGL.GL.GREMEDY.frame_terminator import glInitFrameTerminatorGREMEDY, glFrameTerminatorGREMEDY
    from OpenGL.GL import GLDEBUGPROC  #@UnresolvedImport

    def py_gl_debug_callback(source, error_type, error_id, severity, length,
                             message, param):
        log.error("src %x type %x id %x severity %x length %d message %s",
                  source, error_type, error_id, severity, length, message)

    gl_debug_callback = GLDEBUGPROC(py_gl_debug_callback)
except ImportError:
    # This is normal- GREMEDY_string_marker is only available with OpenGL debuggers