xpra icon
Bug tracker and wiki

This bug tracker and wiki are being discontinued
please use https://github.com/Xpra-org/xpra instead.


Ticket #279: transparency.patch

File transparency.patch, 7.7 KB (added by Antoine Martin, 9 years ago)

adds basics for supporting transparency

  • wimpiggy/window.py

     
    577577
    578578        # We enable PROPERTY_CHANGE_MASK so that we can call
    579579        # x11_get_server_time on this window.
     580        visual = None
     581        colormap = None
     582        if self.is_tray() or True:
     583            screen = self.parking_window.get_screen()
     584            visual = screen.get_rgba_visual()
     585            colormap = screen.get_rgba_colormap()
     586        if visual is None:
     587            visual = self.parking_window.get_visual()
     588        if colormap is None:
     589            colormap = self.parking_window.get_colormap()
     590        log.info("window.setup() using visual=%s, colormap=%s", visual, colormap)
     591        for a in ("bits_per_rgb", "colormap_size", "depth", "type"):
     592            log.info("visual.%s: %s", a, getattr(visual, a))
     593
    580594        self.corral_window = gtk.gdk.Window(self.parking_window,
    581595                                            width=100,
    582596                                            height=100,
     597                                            visual=visual,
     598                                            colormap=colormap,
    583599                                            window_type=gtk.gdk.WINDOW_CHILD,
    584600                                            wclass=gtk.gdk.INPUT_OUTPUT,
    585601                                            event_mask=gtk.gdk.PROPERTY_CHANGE_MASK,
  • xpra/pixbuf_to_rgb.py

     
    3434    if not colormap:
    3535        log.error("get_rgb_rawdata(..) no colormap for RGB pixbuf %sx%s", width, height)
    3636        return None
    37     pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height)
     37    depth = pixmap.get_depth()
     38    has_alpha = depth==32
     39    pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, has_alpha, 8, width, height)
    3840    pixbuf.get_from_drawable(pixmap, colormap, x, y, 0, 0, width, height)
    39     if logger:
    40         logger("get_rgb_rawdata(..) pixbuf.get_from_drawable took %s ms, visual depth=%s",
     41    #if logger:
     42    log.info("get_rgb_rawdata(..) pixbuf.get_from_drawable took %s ms, visual depth=%s",
    4143             int(1000*(time.time()-start)), colormap.get_visual().depth)
    4244    raw_data = pixbuf.get_pixels()
    4345    rowstride = pixbuf.get_rowstride()
    44     return (damage_time, process_damage_time, wid, x, y, width, height, encoding, raw_data, rowstride, sequence, options)
     46    return (damage_time, process_damage_time, wid, x, y, width, height, depth, encoding, raw_data, rowstride, sequence, options)
  • xpra/server.py

     
    605605            import Image
    606606            image = Image.new("RGBA", (width, height))
    607607            for wid, x, y, w, h, pixmap in reversed(regions):
    608                 _, _, wid, _, _, w, h, _, raw_data, rowstride, _, _ = get_rgb_rawdata(0, 0, wid, pixmap, 0, 0, w, h, "rgb24", -1, None, logger=log.debug)
     608                _, _, wid, _, _, w, h, depth, _, raw_data, rowstride, _, _ = get_rgb_rawdata(0, 0, wid, pixmap, 0, 0, w, h, "rgb24", -1, None, logger=log.debug)
    609609                window_image = Image.fromstring("RGB", (w, h), raw_data, "raw", "RGB", rowstride)
    610610                tx = x-minx
    611611                ty = y-miny
  • xpra/window_source.py

     
    763763
    764764        sequence = self._sequence + 1
    765765        if self.is_cancelled(sequence):
    766             debug("get_window_pixmap: dropping damage request with sequence=%s", sequence)
     766            debug("process_damage_region: dropping damage request with sequence=%s", sequence)
    767767            return
    768768        pixmap = window.get_property("client-contents")
    769769        if pixmap is None:
    770             debug("get_window_pixmap: pixmap is None for window %s, wid=%s", window, self.wid)
     770            debug("process_damage_region: pixmap is None for window %s, wid=%s", window, self.wid)
    771771            return
     772        log.info("process_damage_region: wid=%s, pixmap depth: %s", self.wid, pixmap.get_depth())
     773        log.info("process_damage_region: colormap: %s", pixmap.get_colormap())
     774        log.info("process_damage_region: visual: %s", pixmap.get_visual())
     775        for a in ("bits_per_rgb", "colormap_size", "depth", "type"):
     776            log.info("process_damage_region: visual.%s: %s", a, getattr(pixmap.get_visual(), a))
     777        depth = pixmap.get_visual().depth
     778
    772779        process_damage_time = time.time()
    773780        data = get_rgb_rawdata(damage_time, process_damage_time, self.wid, pixmap, x, y, w, h, coding, sequence, options, logger=rgblog)
    774781        if not data or self.is_cancelled(sequence):
     
    897904        if self._damage_delayed is not None and self._damage_delayed_expired:
    898905            gobject.idle_add(self.may_send_delayed)
    899906
    900     def make_data_packet(self, damage_time, process_damage_time, wid, x, y, w, h, coding, rgbdata, rowstride, sequence, options):
     907    def make_data_packet(self, damage_time, process_damage_time, wid, x, y, w, h, depth, coding, rgbdata, rowstride, sequence, options):
    901908        """
    902909            Picture encoding - non-UI thread.
    903910            Converts a damage item picked from the 'damage_data_queue'
     
    925932        #if client supports delta pre-compression for this encoding, use it if we can:
    926933        delta = -1
    927934        if coding in self.supports_delta and self.last_pixmap_data is not None:
    928             lw, lh, lcoding, lsequence, ldata = self.last_pixmap_data
    929             if lw==w and lh==h and lcoding==coding and len(ldata)==len(rgbdata):
     935            lw, lh, ldepth, lcoding, lsequence, ldata = self.last_pixmap_data
     936            if lw==w and lh==h and ldepth==depth and lcoding==coding and len(ldata)==len(rgbdata):
    930937                #xor with the last frame:
    931938                delta = lsequence
    932939                data = xor_str(rgbdata, ldata)
    933940
    934941        if coding in ("jpeg", "png"):
    935             data, client_options = self.PIL_encode(w, h, coding, data, rowstride, options)
     942            data, client_options = self.PIL_encode(w, h, depth, coding, data, rowstride, options)
    936943        elif coding=="x264":
    937944            #x264 needs sizes divisible by 2:
    938945            w = w & 0xFFFE
     
    958965        if delta>=0:
    959966            client_options["delta"] = delta
    960967        if coding in self.supports_delta:
    961             self.last_pixmap_data = w, h, coding, sequence, rgbdata
     968            self.last_pixmap_data = w, h, coding, depth, sequence, rgbdata
    962969            client_options["store"] = sequence
    963970        #actual network packet:
    964971        packet = ["draw", wid, x, y, w, h, coding, data, self._damage_packet_sequence, rowstride, client_options]
     
    9931000        #won't decompress it (leave it to the client's draw thread)
    9941001        return Compressed("rgb24", zlib.data), {"zlib" : zlib.level}
    9951002
    996     def PIL_encode(self, w, h, coding, data, rowstride, options):
    997         assert coding in ENCODINGS
     1003    def PIL_encode(self, w, h, depth, coding, data, rowstride, options):
     1004        assert coding in ENCODINGS, "%s is not supported!" % coding
    9981005        import Image
    999         im = Image.fromstring("RGB", (w, h), data, "raw", "RGB", rowstride)
     1006        log.info("PIL encode: %s bits, %sx%s, rowstride=%s", depth, w, h, rowstride)
     1007        if depth==32:
     1008            im = Image.fromstring("RGBA", (w, h), data, "raw", "RGBA", rowstride)
     1009        else:
     1010            im = Image.fromstring("RGB", (w, h), data, "raw", "RGB", rowstride)
    10001011        buf = StringIO()
    10011012        client_options = {}
    10021013        if coding=="jpeg":