示例#1
0
 def test_call(self):
     assert trap.call(lambda: 0) == 0
     assert trap.call(lambda: 1) == 1
     try:
         trap.call(self.cause_badwindow)
     except XError, e:
         assert e.args == (wimpiggy.lowlevel.const["BadWindow"], )
示例#2
0
 def test_call(self):
     assert trap.call(lambda: 0) == 0
     assert trap.call(lambda: 1) == 1
     try:
         trap.call(self.cause_badwindow)
     except XError, e:
         assert e.args == (wimpiggy.lowlevel.const["BadWindow"],)
示例#3
0
    def __init__(self, window, already_composited):
        super(CompositeHelper, self).__init__()
        self._window = window
        self._already_composited = already_composited
        def setup():
            if not self._already_composited:
                xcomposite_redirect_window(window)
            (_, _, _, _, self._border_width) = geometry_with_border(window)
        trap.call(setup)
        self._listening_to = None
        self.invalidate_pixmap()
        self._damage_handle = xdamage_start(window)

        add_event_receiver(self._window, self)
示例#4
0
    def __init__(self, window, already_composited):
        super(CompositeHelper, self).__init__()
        self._window = window
        self._already_composited = already_composited

        def setup():
            if not self._already_composited:
                xcomposite_redirect_window(window)
            (_, _, _, _, self._border_width) = geometry_with_border(window)

        trap.call(setup)
        self._listening_to = None
        self.invalidate_pixmap()
        self._damage_handle = xdamage_start(window)

        add_event_receiver(self._window, self)
示例#5
0
文件: selection.py 项目: jmesmon/xpra
    def acquire(self, when):
        old_owner = self._owner()
        if when is self.IF_UNOWNED and old_owner != const["XNone"]:
            raise AlreadyOwned

        self.clipboard.set_with_data([("VERSION", 0, 0)],
                                     self._get,
                                     self._clear,
                                     None)

        # Having acquired the selection, we have to announce our existence
        # (ICCCM 2.8, still).  The details here probably don't matter too
        # much; I've never heard of an app that cares about these messages,
        # and metacity actually gets the format wrong in several ways (no
        # MANAGER or owner_window atoms).  But might as well get it as right
        # as possible.

        # To announce our existence, we need:
        #   -- the timestamp we arrived at
        #   -- the manager selection atom
        #   -- the window that registered the selection
        # Of course, because Gtk is doing so much magic for us, we have to do
        # some weird tricks to get at these.

        # Ask ourselves when we acquired the selection:
        ts_data = self.clipboard.wait_for_contents("TIMESTAMP").data
        ts_num = unpack("@i", ts_data[:4])[0]
        # Calculate the X atom for this selection:
        selection_xatom = get_xatom(self.clipboard, self.atom)
        # Ask X what window we used:
        self._xwindow = myGetSelectionOwner(self.clipboard, self.atom)

        root = self.clipboard.get_display().get_default_screen().get_root_window()
        sendClientMessage(root, False, const["StructureNotifyMask"],
                          "MANAGER",
                          ts_num, selection_xatom, self._xwindow, 0, 0)

        if old_owner != const["XNone"] and when is self.FORCE:
            # Block in a recursive mainloop until the previous owner has
            # cleared out.
            def getwin():
                window = get_pywindow(self.clipboard, old_owner)
                window.set_events(window.get_events() | gtk.gdk.STRUCTURE_MASK)
                return window
            try:
                window = trap.call(getwin)
                log("got window")
            except XError:
                log("Previous owner is already gone, not blocking")
            else:
                log("Waiting for previous owner to exit...")
                add_event_receiver(window, self)
                gtk.main()
                log("...they did.")
示例#6
0
    def acquire(self, when):
        old_owner = self._owner()
        if when is self.IF_UNOWNED and old_owner != const["XNone"]:
            raise AlreadyOwned

        self.clipboard.set_with_data([("VERSION", 0, 0)], self._get,
                                     self._clear, None)

        # Having acquired the selection, we have to announce our existence
        # (ICCCM 2.8, still).  The details here probably don't matter too
        # much; I've never heard of an app that cares about these messages,
        # and metacity actually gets the format wrong in several ways (no
        # MANAGER or owner_window atoms).  But might as well get it as right
        # as possible.

        # To announce our existence, we need:
        #   -- the timestamp we arrived at
        #   -- the manager selection atom
        #   -- the window that registered the selection
        # Of course, because Gtk is doing so much magic for us, we have to do
        # some weird tricks to get at these.

        # Ask ourselves when we acquired the selection:
        ts_data = self.clipboard.wait_for_contents("TIMESTAMP").data
        ts_num = unpack("@i", ts_data[:4])[0]
        # Calculate the X atom for this selection:
        selection_xatom = get_xatom(self.atom)
        # Ask X what window we used:
        self._xwindow = myGetSelectionOwner(self.clipboard, self.atom)

        root = self.clipboard.get_display().get_default_screen(
        ).get_root_window()
        sendClientMessage(root, False, const["StructureNotifyMask"], "MANAGER",
                          ts_num, selection_xatom, self._xwindow, 0, 0)

        if old_owner != const["XNone"] and when is self.FORCE:
            # Block in a recursive mainloop until the previous owner has
            # cleared out.
            def getwin():
                window = get_pywindow(self.clipboard, old_owner)
                window.set_events(window.get_events() | gtk.gdk.STRUCTURE_MASK)
                return window

            try:
                window = trap.call(getwin)
                log("got window")
            except XError:
                log("Previous owner is already gone, not blocking")
            else:
                log("Waiting for previous owner to exit...")
                add_event_receiver(window, self)
                gtk.main()
                log("...they did.")
示例#7
0
    def test_assert_out(self):
        def foo():
            assert_raises(AssertionError, trap.assert_out)

        trap.call(foo)
示例#8
0
 def test_assert_out(self):
     def foo():
         assert_raises(AssertionError, trap.assert_out)
     trap.call(foo)