Esempio n. 1
0
    def setup_window_handler(self):
        self.window_handler = ffi.new("struct swc_window_handler *")

        @ffi.callback("void (* entered)(void * data)")
        def on_window_entered(data):
            window_data = ffi.cast("struct window *", data)
            wid = window_data.window_id
            self.on_window_entered(wid)

        self._on_window_entered = on_window_entered

        @ffi.callback("void (* destroy)(void * data)")
        def on_window_destroy(data):
            window_data = ffi.cast("struct window *", data)
            wid = window_data.window_id

            window = self.windows[wid]
            window.hide()
            del self.windows[wid]
            self.on_window_destroy(wid)

        self._on_window_destroy = on_window_destroy

        self.window_handler.entered = self._on_window_entered
        self.window_handler.destroy = self._on_window_destroy
Esempio n. 2
0
    def set_geometry(self, x, y, width, height):
        geometry = ffi.new("struct swc_rectangle *")
        geometry.x = x
        geometry.y = y
        geometry.width = width
        geometry.height = height

        lib.swc_window_set_geometry(self.swc_window, geometry)
Esempio n. 3
0
    def __init__(self, swc_screen, screen_handler):
        self.swc_screen = swc_screen
        self._id = id(swc_screen)

        # struct with the id of the screen
        screen_data = ffi.new("struct screen *")
        screen_data.screen_id = self._id
        self._screen_data = screen_data
Esempio n. 4
0
    def __init__(self, swc_window, window_handler):
        self._tiled = False
        self._id = id(swc_window)
        self.swc_window = swc_window

        # struct with the id of the window
        self._window_data = ffi.new("struct window *")
        self._window_data.window_id = self._id

        lib.swc_window_set_handler(swc_window, window_handler,
                                   self._window_data)
Esempio n. 5
0
    def __init__(self):
        self.screens = {}
        self.windows = {}

        self.screen_handler = ffi.new("struct swc_screen_handler *")
        self.setup_window_handler()
        self.setup_swc_manager()

        # TODO
        # self.screen_handler.entered = self._on_screen_entered
        # self.screen_handler.destroy = self._on_screen_destroy
        # self.screen_handler.geometry_changed = self.on_geometry_change
        # self.screen_handler.usable_geometry_changed = self.on_geometry_change

        self.wl_display = lib.wl_display_create()
        lib.wl_display_add_socket(self.wl_display, ffi.NULL)
        self.event_loop = lib.wl_display_get_event_loop(self.wl_display)
Esempio n. 6
0
    def setup_swc_manager(self):
        self.swc_manager = ffi.new("struct swc_manager *")

        @ffi.callback("void (* new_screen)(struct swc_screen * screen)")
        def on_new_screen(swc_screen):
            screen = Screen(swc_screen, self.screen_handler)
            self.screens[screen._id] = screen
            self.on_new_screen(screen._id)

        self._on_new_screen = on_new_screen

        @ffi.callback("void (* new_window)(struct swc_window * window)")
        def on_new_window(swc_window):
            window = Window(swc_window, self.window_handler)
            self.windows[window._id] = window
            self.on_new_window(window._id)

        self._on_new_window = on_new_window

        self.swc_manager.new_window = self._on_new_window
        self.swc_manager.new_screen = self._on_new_screen