RWindow::Flash
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 1m41s

This commit is contained in:
2025-01-28 18:00:12 -05:00
parent 8f8f3304ba
commit 1fec28b373
5 changed files with 28 additions and 3 deletions

View File

@@ -324,6 +324,10 @@ public:
/// Calling this function, therefore, creates the real 'window' object on the operating system.
[[nodiscard]] virtual bool Open() = 0;
/// Bring attention to the user, On X11 this flashes the entry for this window in the window list.
/// @note If the window is already in focus when this is called nothing happens.
void Flash();
/// @returns True if we are definitely running on a software renderer.
/// @note For some APIs this isn't typically possible.
[[nodiscard]] virtual bool SoftwareRendered() { return false; }

View File

@@ -87,7 +87,9 @@ int main() {
window->OnMouseButtonDownEvent += [&] (MouseButtonDownEvent e) { jlog::Debug(e.Button.Mnemonic + std::to_string(e.Button.ButtonIndex)); };
window->OnMouseWheelEvent += [&, window] (MouseWheelEvent e) { std::cout << window->GetMouseWheelPersistent() << std::endl; };
while (!window->IsClosing())
while (!window->IsClosing()) {
window->ManagedRefresh();
window->Flash();
}
delete window;
}

View File

@@ -21,6 +21,7 @@ public:
Atom windowTypeUtilityAtom;
XSizeHints hints;
Cursor invisible_cursor = 0;
XWMHints* wm_hints = nullptr;
};
void* glx_lib = nullptr;

View File

@@ -23,6 +23,7 @@ public:
Atom windowTypeUtilityAtom;
XSizeHints hints;
Cursor invisible_cursor = 0;
XWMHints* wm_hints = nullptr;
};
namespace Vulkan {

View File

@@ -20,11 +20,23 @@ public:
Atom windowTypeUtilityAtom;
XSizeHints hints;
Cursor invisible_cursor = 0;
XWMHints* wm_hints = nullptr;
};
using namespace ReWindow;
void RWindow::Flash() {
if (IsFocused())
return;
if (platform->wm_hints == nullptr)
platform->wm_hints = XAllocWMHints();
platform->wm_hints->flags = XUrgencyHint;
XSetWMHints(platform->display, platform->window, platform->wm_hints);
}
RWindow::RWindow() {
platform = new Platform();
extant = this;
@@ -128,8 +140,12 @@ void RWindow::PollEvents() {
if (platform->xev.type == FocusIn) {
Logger::Debug(std::format("Event'{}'", "FocusIn"));
XAutoRepeatOff(platform->display);
SetFlag(WindowFlag::IN_FOCUS, true);
if (platform->wm_hints) {
platform->wm_hints->flags &= ~XUrgencyHint;
XSetWMHints(platform->display, platform->window, platform->wm_hints);
XFree(platform->wm_hints);
}
if (!cursor_visible)
XDefineCursor(platform->display, platform->window, platform->invisible_cursor);
@@ -137,17 +153,18 @@ void RWindow::PollEvents() {
XGetWindowAttributes(platform->display, platform->window, &platform->windowAttributes);
render_area_position = { platform->windowAttributes.x, platform->windowAttributes.y };
processFocusIn();
focused = true;
}
if (platform->xev.type == FocusOut) {
Logger::Debug(std::format("Event '{}'", "FocusOut"));
XAutoRepeatOn(platform->display);
SetFlag(WindowFlag::IN_FOCUS, false);
if (!cursor_visible)
XUndefineCursor(platform->display, platform->window);
processFocusOut();
focused = false;
}
if (platform->xev.type == KeyRelease) {