xpra icon
Bug tracker and wiki

Ticket #1321: osx-shadow-scrolling.patch

File osx-shadow-scrolling.patch, 5.5 KB (added by Antoine Martin, 3 years ago)

attempt to use CGScreenRegisterMoveCallback

  • etc/xpra/xorg.conf

     
    168168  Identifier "dummy_screen"
    169169  Device "dummy_videocard"
    170170  Monitor "dummy_monitor"
    171   DefaultDepth 24
     171  DefaultDepth 30
    172172  SubSection "Display"
    173173    Viewport 0 0
    174174    Depth 24
  • xpra/platform/darwin/shadow_server.py

     
    6868            raise InitExit(1, "cannot grab pixels from the screen, make sure this command is launched from a GUI session")
    6969        patch_picture_encode()
    7070        self.refresh_count = 0
     71        self.move_count = 0
     72        self.move_rectangle_count = 0
     73        self.move_registered = False
    7174        self.refresh_rectangle_count = 0
    7275        self.refresh_registered = False
    7376        GTKShadowServerBase.__init__(self)
     
    8992        return  OSXRootWindowModel(self.root)
    9093
    9194
    92     def screen_refresh_callback(self, count, rects, info):
    93         #log("screen_refresh_callback%s mapped=%s", (count, rects, info), self.mapped)
    94         self.refresh_count += 1
     95
     96    def _cgrects_to_list(self, count, rects):
    9597        rlist = []
    96         for r in rects:
     98        for i in range(count):
     99            r = rects[i]
    97100            if not isinstance(r, CG.CGRect):
    98101                log.error("Error: invalid rectangle in refresh list: %s", r)
    99102                continue
    100             self.refresh_rectangle_count += 1
    101103            rlist.append((r.origin.x, r.origin.y, r.size.width, r.size.height))
     104        return rlist
     105
     106    def screen_refresh_callback(self, count, rects, info):
     107        #log("screen_refresh_callback%s mapped=%s", (count, rects, info), self.mapped)
     108        self.refresh_count += 1
     109        rlist = self._cgrects_to_list(count, rects)
     110        self.refresh_rectangle_count += len(rlist)
    102111        #return quickly, and process the list copy via idle add:
    103112        self.idle_add(self.do_screen_refresh, rlist)
    104113
     
    107116        for x, y, w, h in rlist:
    108117            self._damage(self.root_window_model, x, y, w, h)
    109118
     119    def screen_move_callback(self, delta, count, rects, info):
     120        log.info("screen_move_callback")
     121        self.move_count += 1
     122        rlist = self._cgrects_to_list(count, rects)
     123        self.move_rectangle_count += len(rlist)
     124        self.idle_add(self.do_screen_move, delta, rlist)
     125
     126    def do_screen_move(self, delta, rlist):
     127        log.info("do_screen_move%s", (delta, rlist))
     128
    110129    def start_refresh(self):
    111130        #don't use the timer, get damage notifications:
    112131        if self.refresh_registered:
     
    115134        if not USE_TIMER:
    116135            err = CG.CGRegisterScreenRefreshCallback(self.screen_refresh_callback, None)
    117136            log("CGRegisterScreenRefreshCallback(%s)=%s", self.screen_refresh_callback, err)
    118             if err==0:
    119                 self.refresh_registered = True
     137            self.refresh_registered = err==0
     138            if self.refresh_registered:
     139                #now try to register move callback (optional):
     140                err = CG.CGScreenRegisterMoveCallback(self.screen_move_callback, None)
     141                log("CGScreenRegisterMoveCallback(%s)=%s", self.screen_move_callback, err)
     142                self.move_registered = err==0
     143                if not self.move_registered:
     144                    log.warn("Warning: CGScreenRegisterMoveCallback failed with error %i", err)
     145                    log.warn(" no scrolling detection")
    120146                return
    121147            else:
    122148                log.warn("Warning: CGRegisterScreenRefreshCallback failed with error %i", err)
     
    130156                err = CG.CGUnregisterScreenRefreshCallback(self.screen_refresh_callback, None)
    131157                log("CGUnregisterScreenRefreshCallback(%s)=%s", self.screen_refresh_callback, err)
    132158                if err:
    133                     log.warn(" unregistering the existing one returned %s", {0 : "OK"}.get(err, err))
     159                    log.warn(" unregistering the refresh callback returned %s", err)
    134160            except ValueError as e:
    135161                log.warn("Error unregistering screen refresh callback:")
    136162                log.warn(" %s", e)
    137163            self.refresh_registered = False
     164        if self.move_registered:
     165            try:
     166                err = CG.CGScreenUnregisterMoveCallback(self.screen_move_callback, None)
     167                log("CGScreenUnregisterMoveCallback(%s)=%s", self.screen_move_callback, err)
     168                if err:
     169                    log.warn(" unregistering the move callback returned %s", err)
     170            except ValueError as e:
     171                log.warn("Error unregistering screen refresh callback:")
     172                log.warn(" %s", e)
     173            self.move_registered = False
     174                 
    138175        #may stop the timer fallback:
    139176        GTKShadowServerBase.stop_refresh(self)
    140177
     
    193230                                              "notifications"   : self.refresh_registered,
    194231                                              "count"           : self.refresh_count,
    195232                                              "rectangles"      : self.refresh_rectangle_count,
     233                                              "move"            : self.move_count,
     234                                              "move-rectangles" : self.move_rectangle_count,
    196235                                              })
    197236        return info