Beispiel #1
0
    def prepare():
        App.running = True

        App.num_displays = sdl2.SDL_GetNumVideoDisplays()
        logger.info(f"Number of displays: {App.num_displays}")

        for display in range(0, App.num_displays):
            rect = sdl2.SDL_Rect()
            sdl2.SDL_GetDisplayBounds(display, rect)

            border_width = rect.w * App.BORDER_WIDTH_PERCENT / 100
            border_height = rect.h * App.BORDER_WIDTH_PERCENT / 100
            window = sdl2.SDL_CreateWindow(
                f"{display}".encode("ascii"),
                0,
                0,
                int(rect.w - 2 * border_width),
                int(rect.h - 2 * border_height),
                int(sdl2.SDL_WINDOW_BORDERLESS),
            )
            window_id = sdl2.SDL_GetWindowID(window)

            renderer = sdl2.SDL_CreateRenderer(window, -1, 0)
            sdl2.SDL_SetRenderDrawColor(renderer, 30, 30, 30, 255)

            sdl2.SDL_ShowWindow(window)
            sdl2.SDL_SetWindowPosition(window, int(rect.x + border_width),
                                       int(rect.y + border_height))

            scale_factor = (100 - 2 * App.BORDER_WIDTH_PERCENT) / 100
            internal_rect = sdl2.SDL_Rect(
                int(rect.x * scale_factor),
                int(rect.y * scale_factor),
                int(rect.w * scale_factor),
                int(rect.h * scale_factor),
            )

            App.windows.append({
                "rect": rect,
                "internal_rect": internal_rect,
                "window_id": window_id,
                "window": window,
                "renderer": renderer,
            })

        Events.add_listener(*App.handle_window_leave)
        Events.add_listener(*App.handle_window_close)
        Events.add_listener(*App.handle_q)
Beispiel #2
0
 def position(self, value: Tuple[int, int]):
     sdl2.SDL_SetWindowPosition(self._window, value[0], value[1])
Beispiel #3
0
 def _vispy_set_position(self, x, y):
     if self._id is None:
         return
     # Set position of the widget or window. May have no effect for widgets
     sdl2.SDL_SetWindowPosition(self._id.window, x, y)
Beispiel #4
0
 def setWindowPosition(self, x, y):
     sdl2.SDL_SetWindowPosition(self.window, x, y)