def relocate_to(self, window: Window, to_desktop: Desktop): """ Relocates window to a specific desktop. """ if window.sticky: self.log.debug( "%s is meant to be on all desktops, cannot relocate to specific one" % window) return from_desktop = self.cur_desktop if from_desktop == to_desktop: self.log.debug( "no need to relocate %s because remains on the same desktop" % window) return from_desktop.remove(window) to_desktop.add(window)
def init(w, h, renderer="p3d", fullscreen=0, title=""): """Initialize pyui. Will set to fullscreen if specified. default is to run in a window. This will return a Desktop Object. (public) """ global gDesktop, gRenderer if renderer == "null": from rendererBase import RendererBase gRenderer = RendererBase(w, h, fullscreen, title) elif renderer == "null3d": from pyui.renderer3d import Renderer3DBase gRenderer = Renderer3DBase(w, h, fullscreen, title) elif renderer == "2d": from renderers.pygame2D import Pygame2D gRenderer = Pygame2D(w, h, fullscreen, title) elif renderer == "gl": from renderers.openglGlut import OpenGLGlut gRenderer = OpenGLGlut(w, h, fullscreen, title) elif renderer == "p3d": from renderers.openglPygame import OpenGLPygame gRenderer = OpenGLPygame(w, h, fullscreen, title) elif renderer == "dx": from renderers import unseen gRenderer = unseen.Unseen(w, h, fullscreen, title) elif renderer == "nebula": from renderers import nebula gRenderer = nebula.RendererNeb(w, h, fullscreen) elif renderer == "gdi": from renderers import rendererGDI rendererGDI.initialize(w, h) gRenderer = rendererGDI else: raise "Unsupported renderer type", renderer (w, h) = gRenderer.getScreenSize() # create the theme and desktop ##from themes import comic ##theTheme = comic.ComicTheme(gRenderer) ##from themes import green ##theTheme = green.GreenTheme(gRenderer) ##from themes import win2k ##theTheme = win2k.Win2kTheme(gRenderer) ##from themes import future ##theTheme = future.FutureTheme(gRenderer) from themes import anw ##theTheme = anw.ANWTheme(gRenderer) theTheme = anw.ANWTheme3(gRenderer) gDesktop = Desktop(gRenderer, w, h, fullscreen, theTheme) colors.init(gRenderer) return gDesktop
def __init__(self): ShowBase.__init__(self) self.setBackgroundColor(0.1, 0.5, 0.7) # self.enableParticles() # self.cTrav = CollisionTraverser() globals.back_texture = loader.loadTexture('models/sandstone2.jpg') self.buttonThrowers[0].node().setButtonDownEvent('keydown') self.buttonThrowers[0].node().setButtonUpEvent('keyup') self.buttonThrowers[0].node().setKeystrokeEvent('keystroke') self.buttonThrowers[0].node().setButtonRepeatEvent('keyrepeat') self.disableMouse() self.picker = Picker() props = WindowProperties(self.win.getProperties()) props.setTitle('desk') # props.setFullscreen(True) # props.setUndecorated(True) props.setSize(3800, 2000) self.win.requestProperties(props) self.lights = [] self.add_point_light((0.9, 0.9, 0.9, 1), (0, -1000, -1500), False) self.add_point_light((0.9, 0.9, 0.9, 1), (0, 1000, 1800), True) self.camLens.setFov(70) self.camera.setPos(0, -2080, 200) self.camera.setHpr(0, 0, 0) # -8 render.setShaderAuto() # debugNode = BulletDebugNode('Debug') # debugNode.showWireframe(True) # debugNode.showConstraints(True) # debugNode.showBoundingBoxes(False) # debugNode.showNormals(False) # debugNP = self.render.attachNewNode(debugNode) # debugNP.show() self.world = BulletWorld() self.world.setGravity(Vec3(0, 0, -1000)) # self.world.setDebugNode(debugNP.node()) self.last_time = None self.desk = Desktop(self) self.debug_text = OnscreenText(text='', pos=(-1, 0.8), scale=0.05)
def __init__(self, gap=6): """Initializes the WM and makes a desktop. Args: gap (int, optional): The gap between windows Attributes: desktop (Desktop): Stores the desktop object. """ width, height = window_api.get_screen_resolution() # TODO add multi-desktop support # TODO consider desktop manipulating windows. self.desktop = Desktop(width, height) self.gap = gap # TODO option to add all on run for window in window_api.get_all_windows(): self.desktop.insert(window)
def __init__(self, display=None, desktops=None, loop=None): self.log = Log("WM") # INIT SOME BASIC STUFF self.hook = Hook() self.windows = {} # mapping between window id and Window self.win2desk = {} if not display: display = os.environ.get("DISPLAY") try: self._conn = xcffib.connect(display=display) except xcffib.ConnectionException: sys.exit("cannot connect to %s" % display) self.atoms = AtomVault(self._conn) self.desktops = desktops or [Desktop()] self.cur_desktop = self.desktops[0] self.cur_desktop.show() # CREATE ROOT WINDOW xcb_setup = self._conn.get_setup() xcb_screens = [i for i in xcb_setup.roots] self.xcb_default_screen = xcb_screens[self._conn.pref_screen] root_wid = self.xcb_default_screen.root self.root = Window(self, wid=root_wid, atoms=self.atoms, mapped=True) self.windows[root_wid] = self.root # for desktop in self.desktops: # desktop.windows.append(self.root) self.root.set_attr( eventmask=( EventMask.StructureNotify | EventMask.SubstructureNotify | EventMask.FocusChange # | EventMask.SubstructureRedirect | EventMask.EnterWindow # | EventMask.LeaveWindow # | EventMask.PropertyChange | EventMask.OwnerGrabButton ) ) # INFORM X WHICH FEATURES WE SUPPORT self.root.props[self.atoms._NET_SUPPORTED] = [self.atoms[a] for a in SUPPORTED_ATOMS] # PRETEND TO BE A WINDOW MANAGER supporting_wm_check_window = self.create_window(-1, -1, 1, 1) supporting_wm_check_window.props['_NET_WM_NAME'] = "SWM" self.root.props['_NET_SUPPORTING_WM_CHECK'] = supporting_wm_check_window.wid self.root.props['_NET_NUMBER_OF_DESKTOPS'] = len(self.desktops) self.root.props['_NET_CURRENT_DESKTOP'] = 0 # TODO: set cursor # EVENTS THAT HAVE LITTLE USE FOR US... self.ignoreEvents = { "KeyRelease", "ReparentNotify", # "CreateNotify", # DWM handles this to help "broken focusing windows". # "MapNotify", "ConfigureNotify", "LeaveNotify", "FocusOut", "FocusIn", "NoExposure", } # KEYBOARD self.kbd = Keyboard(xcb_setup, self._conn) self.mouse = Mouse(conn=self._conn, root=self.root) # FLUSH XCB BUFFER self.xsync() # apply settings # the event loop is not yet there, but we might have some pending # events... self._xpoll() # TODO: self.grabMouse # NOW IT'S TIME TO GET PHYSICAL SCREEN CONFIGURATION self.xrandr = Xrandr(root=self.root, conn=self._conn) # TODO: self.update_net_desktops() # SETUP EVENT LOOP if not loop: loop = asyncio.new_event_loop() self._eventloop = loop self._eventloop.add_signal_handler(signal.SIGINT, self.stop) self._eventloop.add_signal_handler(signal.SIGTERM, self.stop) self._eventloop.add_signal_handler(signal.SIGCHLD, self.on_sigchld) self._eventloop.set_exception_handler( lambda loop, ctx: self.log.error( "Got an exception in {}: {}".format(loop, ctx)) ) fd = self._conn.get_file_descriptor() self._eventloop.add_reader(fd, self._xpoll) # HANDLE STANDARD EVENTS self.hook.register("MapRequest", self.on_map_request) self.hook.register("MapNotify", self.on_map_notify) self.hook.register("UnmapNotify", self.on_window_unmap) self.hook.register("KeyPress", self.on_key_press) # self.hook.register("KeyRelease", self.on_key_release) # self.hook.register("CreateNotify", self.on_window_create) self.hook.register("PropertyNotify", self.on_property_notify) self.hook.register("ClientMessage", self.on_client_message) self.hook.register("DestroyNotify", self.on_window_destroy) self.hook.register("EnterNotify", self.on_window_enter) self.hook.register("ConfigureRequest", self.on_configure_window) self.hook.register("MotionNotify", self.on_mouse_event) self.hook.register("ButtonPress", self.on_mouse_event) self.hook.register("ButtonRelease", self.on_mouse_event)
def get_instance(args): return Desktop(args)
osd = OSD() mod = win # PRE-INIT # switch to english just in case run_("setxkbmap -layout en") # create event loop and setup text GUI loop = asyncio.new_event_loop() # logwidget = gui(loop=loop) # Log.file = logwidget # INIT num_desktops = 4 desktops = [Desktop(id=i, name=str(i + 1)) for i in range(num_desktops)] wm = WM(desktops=desktops, loop=loop) # MOUSE STUFF orig_pos = None orig_geometry = None # move @wm.hook(wm.grab_mouse([mod], MouseL)) def on_mouse_move(evhandler, evtype, xcb_ev): global orig_pos global orig_geometry cur_pos = xcb_ev.root_x, xcb_ev.root_y window = wm.cur_desktop.cur_focus
def __init__(self): Speaker.__init__(self, "fr", 1) Desktop.__init__(self)
class WindowManager: """Initializes, keeps track of, and calls functions to modify windows. """ def __init__(self, gap=6): """Initializes the WM and makes a desktop. Args: gap (int, optional): The gap between windows Attributes: desktop (Desktop): Stores the desktop object. """ width, height = window_api.get_screen_resolution() # TODO add multi-desktop support # TODO consider desktop manipulating windows. self.desktop = Desktop(width, height) self.gap = gap # TODO option to add all on run for window in window_api.get_all_windows(): self.desktop.insert(window) def increase_gaps(self): """Increase gap size. """ self.gap += 2 self.desktop.update_all(self.desktop.root) def decrease_gaps(self): """Decrease gap size. """ self.gap = max(self.gap - 2, 0) self.desktop.update_all(self.desktop.root) def swap_split(self): """Swap split type on focused window. """ hwnd = window_api.get_foreground_window() node = self.findNode(hwnd, self.desktop.root) if node: if node.parent: node.parent.split = node.parent.split.swap() else: node.split = node.split.swap() self.desktop.update_all(self.desktop.root) def exit(self): """Tears down all windows and exits. """ # TODO: save original state and restore after self.teardown(self.desktop.root) sys.exit(0) def teardown(self, node): """Tells a node to teardown its window and tells its children to. """ if node is None: return if node.window: node.window.teardown_window() self.teardown(node.first) self.teardown(node.second) def findNode(self, hwnd, node): """Searches through all nodes for the given hwnd. If not found, returns null. """ if node is None: return None if node.window and node.window.hwnd == hwnd: return node return self.findNode(hwnd, node.first) or self.findNode(hwnd, node.second) def insert(self): """Tells desktop to insert focused window. """ focused = window_api.get_foreground_window() self.desktop.insert(focused) def remove(self): """Tells desktop to remove focused window. """ focused = window_api.get_foreground_window()