alaingalvan / CrossWindow

💻📱 A cross platform system abstraction library written in C++ for managing windows and performing OS tasks.
https://alain.xyz/libraries/crosswindow
MIT License
632 stars 50 forks source link

No window close button on Win32 window? #8

Closed andraantariksa closed 2 years ago

andraantariksa commented 3 years ago

image

#include <CrossWindow/CrossWindow.h>
#include <cassert>

void xmain(int argc, const char** argv)
{
    xwin::WindowDesc window_desc;
    window_desc.name = "test";
    window_desc.title = "Vulkan Playground";
    window_desc.width = 1280;
    window_desc.height = 720;
    window_desc.visible = true;
    window_desc.closable = true;

    xwin::EventQueue event_queue;

    xwin::Window window;
    if (!window.create(window_desc, event_queue))
    {
        assert(false);
        return;
    }

    bool is_running = true;
    while (is_running)
    {
        event_queue.update();
        while (!event_queue.empty())
        {
            const auto& event = event_queue.front();
            if (event.type == xwin::EventType::Close)
            {
                window.close();
                is_running = false;
            }
            else if (event.type == xwin::EventType::Keyboard)
            {
                if (event.data.keyboard.state == xwin::ButtonState::Pressed && event.data.keyboard.key == xwin::Key::Escape)
                {
                    window.close();
                    is_running = false;
                }
            }
            event_queue.pop();
        }

    }
}

Commit d24b01b9771e446e495845e283f5e891d9197090

alaingalvan commented 3 years ago

Win32 has a few issues with it currently while I was working on borderless windows, thanks for letting me know I'll fix this one right away. 👍

EDIT: This is fixed in https://github.com/alaingalvan/CrossWindow/commit/33f45b9810be2d5ef17df01d5bb33ddf8f68c01e.