xpra icon
Bug tracker and wiki

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


Ticket #170: preserve-workspace.patch

File preserve-workspace.patch, 7.0 KB (added by Antoine Martin, 9 years ago)

much safer and simpler code - which works ok so far

  • wimpiggy/lowlevel/bindings.pyx

     
    17981798    else:
    17991799        return <long><unsigned long>i
    18001800
    1801 def sendClientMessage(target, propagate, event_mask,
     1801def sendClientMessage(target, window, propagate, event_mask,
    18021802                      message_type, data0, data1, data2, data3, data4):
    18031803    # data0 etc. are passed through get_xatom, so they can be integers, which
    18041804    # are passed through directly, or else they can be strings, which are
    18051805    # converted appropriately.
    18061806    cdef Display * display              #@DuplicatedSignature
     1807    cdef Window t
     1808    cdef Window w
     1809    cdef XEvent e
    18071810    display = get_xdisplay_for(target)
    1808     cdef Window w
    1809     w = get_xwindow(target)
     1811    t = get_xwindow(target)
     1812    w = get_xwindow(window)
    18101813    log("sending message to %s", hex(w))
    1811     cdef XEvent e
    18121814    e.type = ClientMessage
    18131815    e.xany.display = display
    18141816    e.xany.window = w
     
    18201822    e.xclient.data.l[3] = cast_to_long(get_xatom(data3))
    18211823    e.xclient.data.l[4] = cast_to_long(get_xatom(data4))
    18221824    cdef Status s
    1823     s = XSendEvent(display, w, propagate, event_mask, &e)
     1825    s = XSendEvent(display, t, propagate, event_mask, &e)
    18241826    if s == 0:
    18251827        raise ValueError, "failed to serialize ClientMessage"
    18261828
  • wimpiggy/lowlevel/send_wm.py

     
    2121
    2222def send_wm_take_focus(target, time):
    2323    log("sending WM_TAKE_FOCUS: %r, %r", target, time)
    24     sendClientMessage(target, False, 0,                     #@UndefinedVariable"
     24    sendClientMessage(target, target, False, 0,                     #@UndefinedVariable"
    2525                      "WM_PROTOCOLS",
    2626                      "WM_TAKE_FOCUS", int32(time), 0, 0, 0)
    2727
    2828def send_wm_delete_window(target):
    2929    log("sending WM_DELETE_WINDOW")
    30     sendClientMessage(target, False, 0,                     #@UndefinedVariable"
     30    sendClientMessage(target, target, False, 0,                     #@UndefinedVariable"
    3131                      "WM_PROTOCOLS",
    3232                      "WM_DELETE_WINDOW",
    3333                      const["CurrentTime"], 0, 0, 0)        #@UndefinedVariable"
  • wimpiggy/selection.py

     
    9292        self._xwindow = myGetSelectionOwner(self.clipboard, self.atom)
    9393
    9494        root = self.clipboard.get_display().get_default_screen().get_root_window()
    95         sendClientMessage(root, False, const["StructureNotifyMask"],
     95        sendClientMessage(root, root, False, const["StructureNotifyMask"],
    9696                          "MANAGER",
    9797                          ts_num, selection_xatom, self._xwindow, 0, 0)
    9898
  • wimpiggy/tray.py

     
    138138        setsel = mySetSelectionOwner(root, self.tray_window, SELECTION)
    139139        log("setup tray: set selection owner returned %s", setsel)
    140140        event_mask = const["StructureNotifyMask"]
    141         sendClientMessage(root, False, event_mask, "MANAGER",
     141        sendClientMessage(root, root, False, event_mask, "MANAGER",
    142142                          const["CurrentTime"], SELECTION,
    143143                          get_xwindow(self.tray_window), 0, 0)
    144144        owner = myGetSelectionOwner(root, SELECTION)
  • xpra/client_window.py

     
    186186            if transient_for is not None and transient_for.window is not None and type_hint in OR_TYPE_HINTS:
    187187                transient_for._override_redirect_windows.append(self)
    188188        self.connect("notify::has-toplevel-focus", self._focus_change)
     189        #deal with workspace mapping:
     190   
     191    def set_workspace(self):
     192        workspace = self._client_properties.get("workspace")
     193        if not workspace or sys.platform.startswith("win") or not has_wimpiggy_prop:
     194            return
     195        try:
     196            from wimpiggy.lowlevel import sendClientMessage, const  #@UnresolvedImport
     197            from wimpiggy.error import trap
     198            log("setting workspace=%s for %s", workspace, self.get_window())
     199            root = self.get_window().get_screen().get_root_window()
     200            event_mask = const["SubstructureNotifyMask"] | const["SubstructureRedirectMask"]
     201            trap.call(sendClientMessage, root, self.get_window(), False, event_mask, "_NET_WM_DESKTOP",
     202                      workspace, const["CurrentTime"],
     203                      0, 0, 0)
     204        except Exception, e:
     205            log.error("failed to set workspace: %s", e)
    189206
    190207    def is_OR(self):
    191208        return self._override_redirect
     
    194211        return False
    195212
    196213    def get_workspace(self):
     214        if sys.platform.startswith("win"):
     215            return  -1              #windows does not have workspaces
    197216        try:
    198             if sys.platform.startswith("win"):
    199                 return  -1              #windows does not have workspaces
    200217            if not has_wimpiggy_prop:
    201218                prop = self.window.get_screen().get_root_window().property_get("_NET_CURRENT_DESKTOP")
    202219                if not prop or len(prop)!=3 or len(prop[2])!=1:
     
    375392            self._size = (w, h)
    376393        self._been_mapped = True
    377394        gobject.idle_add(self._focus_change)
     395        self.set_workspace()
    378396
    379397    def do_configure_event(self, event):
    380398        log("Got configure event: %s", event)
  • xpra/platform/client_tray.py

     
    102102                                      (x, y), modifiers])
    103103
    104104    def draw_region(self, x, y, width, height, coding, img_data, rowstride, packet_sequence, options, callbacks):
    105         assert coding in ("rgb24", "png")
     105        assert coding in ("rgb24", "png"), "invalid encoding for tray data: %s" % coding
    106106        log("draw_region for tray")
    107107        def after_draw_update_tray(success):
    108108            if not success:
  • xpra/window_source.py

     
    811811            im.save(buf, "JPEG", quality=q)
    812812            client_options["quality"] = q
    813813        else:
     814            assert coding=="png"
    814815            log("sending as %s", coding)
     816            #transparency = False
     817            #transparency=transparency
    815818            im.save(buf, coding.upper())
    816819        data = buf.getvalue()
    817820        buf.close()