From 8b6b0a20f33bea381c5b06c7d62264adc3f36132 Mon Sep 17 00:00:00 2001 From: Diogo Cruz Diniz Date: Thu, 16 Apr 2026 21:51:47 +0100 Subject: [PATCH] feat: Testing setup outside i3 --- makefile | 4 +++- src/main.cpp | 23 +++++++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/makefile b/makefile index 417a3d1..af8f773 100644 --- a/makefile +++ b/makefile @@ -1,6 +1,5 @@ CC=g++ C_FLAGS=-g -Wall -Wextra -O0 -Wno-unused-function -#C_FLAGS=-Wall -Wextra -O3 -Wno-unused-function VAL_FLAGS=--leak-check=full --show-leak-kinds=all --track-origins=yes -s DIR_SRC=src @@ -28,6 +27,9 @@ rebuild: clean .WAIT build run: $(OUTBIN) ./i3bgwin $(OUTBIN) {windowid} +runn: $(OUTBIN) + $(OUTBIN) + $(OUTBIN): $(OBJS) @mkdir -p $(@D) $(CC) $(OBJS) $(DEPS_EXT) -o $@ diff --git a/src/main.cpp b/src/main.cpp index d5c2b59..a404a8f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,21 +15,28 @@ static int width, height; int main(int argc, char *argv[]) { - if (argc != 2) + if (argc > 2) { - printf("Usage: %s \n", argv[0]); + printf("Usage: %s [WID]\n", argv[0]); exit(1); } - int wid = 0; - sscanf(argv[1], "%d", &wid); - SDL_Init(SDL_INIT_VIDEO); - SDL_PropertiesID props = SDL_CreateProperties(); - SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X11_WINDOW_NUMBER, wid); + if (argc == 2) + { + int wid = 0; + sscanf(argv[1], "%d", &wid); + + SDL_PropertiesID props = SDL_CreateProperties(); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X11_WINDOW_NUMBER, wid); + window = SDL_CreateWindowWithProperties(props); + } + else + { + window = SDL_CreateWindow("dxdesktop", 1024, 1024, SDL_WINDOW_OPENGL); + } - window = SDL_CreateWindowWithProperties(props); sdl_renderer = SDL_CreateRenderer(window, NULL); SDL_GetWindowSize(window, &width, &height);