xpra icon
Bug tracker and wiki

Ticket #475: xshm-single.patch

File xshm-single.patch, 2.8 KB (added by Antoine Martin, 7 years ago)

forces us to not use more than one XShm mapping per window

  • xpra/x11/gtk_x11/composite.py

     
    113113        if not self._use_shm or not CompositeHelper.XShmEnabled:
    114114            return None
    115115        if self._shm_handle and self._shm_handle.get_size()!=self._window.get_size():
    116             #size has changed!
    117             #make sure the current wrapper gets garbage collected:
     116            #size has changed, close the current XShm wrapper:
    118117            self._shm_handle.cleanup()
    119             self._shm_handle = None
     118        if self._shm_handle and self._shm_handle.is_closed():
     119            if self._shm_handle.is_freed():
     120                #safe to create a new handle:
     121                self._shm_handle = None
     122            else:
     123                #we must wait for the current XShm wrapper to be freed
     124                #before we can create a new one
     125                return None
    120126        if self._shm_handle is None:
    121127            #make a new one:
    122128            self._shm_handle = XImage.get_XShmWrapper(get_xwindow(self._window))
  • xpra/x11/bindings/ximage.pyx

     
    351351    cdef XImage *image
    352352    cdef int ref_count
    353353    cdef Bool closed
     354    cdef Bool freed
    354355
    355356    cdef init(self, Display *display, Window xwindow, Visual *visual, int width, int height, int depth):
    356357        self.display = display
     
    444445        xshm_debug("XShmWrapper.__dealloc__() self=%s", self)
    445446        self.cleanup()
    446447
     448    def is_closed(self):
     449        return self.closed
     450
     451    def is_freed(self):
     452        return self.freed
     453
    447454    def cleanup(self):
    448455        #ok, we want to free resources... problem is,
    449456        #we may have handed out some XShmImageWrappers
     
    452459        #and rely on them telling us via the free_image callback.
    453460        xshm_debug("XShmWrapper.cleanup() ref_count=%s", self.ref_count)
    454461        self.closed = True
    455         if self.ref_count==0:
     462        if self.ref_count==0 and not self.freed:
    456463            self.free()
    457464
    458465    def free_image(self):                               #@DuplicatedSignature
    459466        self.ref_count -= 1
    460467        xshm_debug("XShmWrapper.free_image() closed=%s, new ref_count=%s", self.closed, self.ref_count)
    461468        if self.closed and self.ref_count==0:
     469            assert not self.freed
    462470            self.free()
    463471
    464472    def free(self):                                     #@DuplicatedSignature
     
    476484            shmdt(self.shminfo.shmaddr)
    477485            self.shminfo.shmaddr = <char *> -1
    478486            self.shminfo.shmid = -1
     487        self.freed = True
    479488
    480489
    481490cdef class XShmImageWrapper(XImageWrapper):