Ejemplo n.º 1
0
 def move_to_workspace(self, *args):
     w = self.window.get_window()
     try:
         workspace = int(self.entry.get_text())
         send_wm_workspace(w.get_screen().get_root_window(), w, workspace)
     except Exception as e:
         self.warn.set_text("invalid workspace specified: %s" % e)
Ejemplo n.º 2
0
 def move_to_workspace(self, *args):
     w = self.window.get_window()
     try:
         workspace = int(self.entry.get_text())
         send_wm_workspace(w.get_screen().get_root_window(), w, workspace)
     except Exception as e:
         self.warn.set_text("invalid workspace specified: %s" % e)
Ejemplo n.º 3
0
 def set_workspace(self, workspace):
     if not self._can_set_workspace:
         return None
     desktop = self.get_desktop_workspace()
     if self._been_mapped and (workspace == desktop or desktop is None):
         #window is back in view
         self._client.control_refresh(self._id, False, False)
     ndesktops = self.get_workspace_count()
     if ndesktops is None or ndesktops <= 1:
         workspacelog(
             "number of desktops not defined, cannot set workspace")
         return None
     if workspace < 0:
         #this should not happen, workspace is unsigned! (CARDINAL)
         workspace = WORKSPACE_UNSET
         workspacelog.warn("invalid workspace number: %s",
                           self._window_workspace)
     workspacelog("%s.set_workspace() workspace=%s ndesktops=%s", self,
                  workspace, ndesktops)
     #we will need the gdk window:
     if not self.is_realized():
         self.realize()
     gdkwin = self.get_window()
     if workspace == WORKSPACE_UNSET:
         #we want to remove the setting, so access the window property directly:
         self._window_workspace = workspace
         with xswallow:
             X11Window.XDeleteProperty(gdkwin.xid, "_NET_WM_DESKTOP")
         return self._window_workspace
     #clamp to number of workspaces just in case we have a mismatch:
     if workspace == WORKSPACE_ALL:
         self._window_workspace = WORKSPACE_ALL
     else:
         self._window_workspace = max(0, min(ndesktops - 1, workspace))
     workspacelog("%s.set_workspace() clamped workspace=%s", self,
                  self._window_workspace)
     if not gdkwin.is_visible():
         #window is unmapped so we can set the window property directly:
         prop_set(self.get_window(), "_NET_WM_DESKTOP", "u32",
                  self._window_workspace)
         return self._window_workspace
     #the window is visible, so we have to ask the window manager politely
     with xsync:
         send_wm_workspace(root, self.get_window(), self._window_workspace)
     return self._window_workspace
Ejemplo n.º 4
0
 def set_workspace(self, workspace):
     if not self._can_set_workspace:
         return None
     desktop = self.get_desktop_workspace()
     if self._been_mapped and (workspace==desktop or desktop is None):
         #window is back in view
         self._client.control_refresh(self._id, False, False)
     ndesktops = self.get_workspace_count()
     if ndesktops is None or ndesktops<=1:
         workspacelog("number of desktops not defined, cannot set workspace")
         return None
     if workspace<0:
         #this should not happen, workspace is unsigned! (CARDINAL)
         workspace = WORKSPACE_UNSET
         workspacelog.warn("invalid workspace number: %s", self._window_workspace)
     workspacelog("%s.set_workspace() workspace=%s ndesktops=%s", self, workspace, ndesktops)
     #we will need the gdk window:
     if not self.is_realized():
         self.realize()
     gdkwin = self.get_window()
     if workspace==WORKSPACE_UNSET:
         #we want to remove the setting, so access the window property directly:
         self._window_workspace = workspace
         with xswallow:
             X11Window.XDeleteProperty(gdkwin.xid, "_NET_WM_DESKTOP")
         return self._window_workspace
     #clamp to number of workspaces just in case we have a mismatch:
     if workspace==WORKSPACE_ALL:
         self._window_workspace = WORKSPACE_ALL
     else:
         self._window_workspace = max(0, min(ndesktops-1, workspace))
     workspacelog("%s.set_workspace() clamped workspace=%s", self, self._window_workspace)
     if not gdkwin.is_visible():
         #window is unmapped so we can set the window property directly:
         prop_set(self.get_window(), "_NET_WM_DESKTOP", "u32", self._window_workspace)
         return self._window_workspace
     #the window is visible, so we have to ask the window manager politely
     with xsync:
         send_wm_workspace(root, self.get_window(), self._window_workspace)
     return self._window_workspace
Ejemplo n.º 5
0
 def set_workspace(self, workspace):
     workspacelog("set_workspace(%s)", workspace)
     if not self._been_mapped:
         #will be dealt with in the map event handler
         #which will look at the window metadata again
         workspacelog("workspace=%s will be set when the window is mapped", wn(workspace))
         return
     desktop = self.get_desktop_workspace()
     ndesktops = self.get_workspace_count()
     current = self.get_window_workspace()
     workspacelog("set_workspace(%s) realized=%s, current workspace=%s, detected=%s, desktop workspace=%s, ndesktops=%s",
                  wn(workspace), self.is_realized(), wn(self._window_workspace), wn(current), wn(desktop), ndesktops)
     if not self._can_set_workspace or ndesktops is None:
         return None
     if workspace==desktop or workspace==WORKSPACE_ALL or desktop is None:
         #window is back in view
         self._client.control_refresh(self._id, False, False)
     if (workspace<0 or workspace>=ndesktops) and workspace not in(WORKSPACE_UNSET, WORKSPACE_ALL):
         #this should not happen, workspace is unsigned (CARDINAL)
         #and the server should have the same list of desktops that we have here
         workspacelog.warn("Warning: invalid workspace number: %s", wn(workspace))
         workspace = WORKSPACE_UNSET
     if workspace==WORKSPACE_UNSET:
         #we cannot unset via send_wm_workspace, so we have to choose one:
         workspace = self.get_desktop_workspace()
     if workspace in (None, WORKSPACE_UNSET):
         workspacelog.warn("workspace=%s (doing nothing)", wn(workspace))
         return
     #we will need the gdk window:
     if current==workspace:
         workspacelog("window workspace unchanged: %s", wn(workspace))
         return
     gdkwin = self.get_window()
     workspacelog("do_set_workspace: gdkwindow: %#x, mapped=%s, visible=%s", gdkwin.xid, self.is_mapped(), gdkwin.is_visible())
     with xsync:
         send_wm_workspace(root, gdkwin, workspace)