mirror of https://github.com/encounter/aurora.git
Add AURORA_WINDOW_MOVED event and add ability to set window position at launch
This commit is contained in:
parent
23b9ccb2cc
commit
5589b24df6
|
@ -31,6 +31,11 @@ typedef enum {
|
|||
LOG_FATAL,
|
||||
} AuroraLogLevel;
|
||||
|
||||
typedef struct {
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
} AuroraWindowPos;
|
||||
|
||||
typedef struct {
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
|
@ -52,6 +57,8 @@ typedef struct {
|
|||
uint32_t msaa;
|
||||
uint16_t maxTextureAnisotropy;
|
||||
bool startFullscreen;
|
||||
int32_t windowPosX;
|
||||
int32_t windowPosY;
|
||||
uint32_t windowWidth;
|
||||
uint32_t windowHeight;
|
||||
void* iconRGBA8;
|
||||
|
|
|
@ -17,6 +17,7 @@ typedef enum {
|
|||
AURORA_NONE,
|
||||
AURORA_EXIT,
|
||||
AURORA_SDL_EVENT,
|
||||
AURORA_WINDOW_MOVED,
|
||||
AURORA_WINDOW_RESIZED,
|
||||
AURORA_CONTROLLER_ADDED,
|
||||
AURORA_CONTROLLER_REMOVED,
|
||||
|
@ -28,6 +29,7 @@ struct AuroraEvent {
|
|||
AuroraEventType type;
|
||||
union {
|
||||
SDL_Event sdl;
|
||||
AuroraWindowPos windowPos;
|
||||
AuroraWindowSize windowSize;
|
||||
int32_t controller;
|
||||
};
|
||||
|
|
|
@ -59,6 +59,13 @@ const AuroraEvent* poll_events() {
|
|||
});
|
||||
break;
|
||||
}
|
||||
case SDL_WINDOWEVENT_MOVED: {
|
||||
g_events.push_back(AuroraEvent{
|
||||
.type = AURORA_WINDOW_MOVED,
|
||||
.windowPos = {.x = event.window.data1, .y = event.window.data2},
|
||||
});
|
||||
break;
|
||||
}
|
||||
case SDL_WINDOWEVENT_SIZE_CHANGED: {
|
||||
resize_swapchain(false);
|
||||
g_events.push_back(AuroraEvent{
|
||||
|
@ -154,8 +161,16 @@ bool create_window(AuroraBackend backend) {
|
|||
width = 1280;
|
||||
height = 960;
|
||||
}
|
||||
|
||||
int32_t x = g_config.windowPosX;
|
||||
int32_t y = g_config.windowPosY;
|
||||
if (x < 0 || y < 0) {
|
||||
x = SDL_WINDOWPOS_UNDEFINED;
|
||||
y = SDL_WINDOWPOS_UNDEFINED;
|
||||
}
|
||||
|
||||
#endif
|
||||
g_window = SDL_CreateWindow(g_config.appName, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, width, height, flags);
|
||||
g_window = SDL_CreateWindow(g_config.appName, x, y, width, height, flags);
|
||||
if (g_window == nullptr) {
|
||||
Log.report(LOG_WARNING, FMT_STRING("Failed to create window: {}"), SDL_GetError());
|
||||
return false;
|
||||
|
@ -196,7 +211,8 @@ void show_window() {
|
|||
|
||||
bool initialize() {
|
||||
/* We don't want to initialize anything input related here, otherwise the add events will get lost to the void */
|
||||
ASSERT(SDL_Init(SDL_INIT_EVERYTHING & ~(SDL_INIT_HAPTIC | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER)) == 0, "Error initializing SDL: {}", SDL_GetError());
|
||||
ASSERT(SDL_Init(SDL_INIT_EVERYTHING & ~(SDL_INIT_HAPTIC | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER)) == 0,
|
||||
"Error initializing SDL: {}", SDL_GetError());
|
||||
|
||||
#if !defined(_WIN32) && !defined(__APPLE__)
|
||||
SDL_SetHint(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, "0");
|
||||
|
|
Loading…
Reference in New Issue