XWindows KeyRepeat toggle
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 1m56s
All checks were successful
Run ReCI Build Test / Explore-Gitea-Actions (push) Successful in 1m56s
This commit is contained in:
@@ -63,6 +63,7 @@ protected:
|
||||
bool vsync = false;
|
||||
bool cursor_visible = true;
|
||||
bool closing = false;
|
||||
bool key_repeat = false;
|
||||
|
||||
float delta_time = 0.f;
|
||||
float refresh_rate = 0.f;
|
||||
@@ -319,6 +320,11 @@ public:
|
||||
/// Sets whether or not to enable vertical synchronization.
|
||||
/// @note This is implemented per-OS, and as such, it simply requests the OS to do what we want. No guarantee about follow-through can be given.
|
||||
virtual void SetVsyncEnabled(bool state) = 0;
|
||||
/// Sets whether or not we're using key repeat.
|
||||
void SetKeyRepeatEnabled(bool state);
|
||||
|
||||
/// @returns If key repeat is enabled.
|
||||
[[nodiscard]] bool IsKeyRepeat() const { return key_repeat; };
|
||||
|
||||
/// Returns the name of the developer of the user's graphics driver, if it can be determined.
|
||||
virtual std::string GetGraphicsDriverVendor() = 0;
|
||||
|
5
main.cpp
5
main.cpp
@@ -70,12 +70,13 @@ int main() {
|
||||
window->SetVsyncEnabled(true);
|
||||
window->SetResizable(true);
|
||||
window->SetCursorVisible(false);
|
||||
window->SetKeyRepeatEnabled(true);
|
||||
window->UniqueFunctionNameForMessageBoxBecauseMicrosoftUsesMacros("MessageBox", "Generic message from a ReWindow MessageBox.");
|
||||
|
||||
|
||||
Logger::Debug(std::format("Window '{}' flags: IN_FOCUS={} FULLSCREEN={} RESIZEABLE={} VSYNC={} QUIT={}",
|
||||
Logger::Debug(std::format("Window '{}' flags: IN_FOCUS={} FULLSCREEN={} RESIZEABLE={} VSYNC={} KEY_REPEAT={} QUIT={}",
|
||||
window->GetTitle(), window->IsFocused(), window->IsFullscreen(),
|
||||
window->IsResizable(), window->IsVsyncEnabled(), window->IsClosing()) );
|
||||
window->IsResizable(), window->IsVsyncEnabled(), window->IsKeyRepeat(), window->IsClosing()) );
|
||||
|
||||
|
||||
window->OnKeyDownEvent += [&] (KeyDownEvent e) { jlog::Debug(e.key.Mnemonic); };
|
||||
|
@@ -28,6 +28,15 @@ public:
|
||||
|
||||
using namespace ReWindow;
|
||||
|
||||
void RWindow::SetKeyRepeatEnabled(bool state) {
|
||||
key_repeat = state;
|
||||
|
||||
if (state)
|
||||
return (void) XAutoRepeatOn(platform->display);
|
||||
|
||||
XAutoRepeatOff(platform->display);
|
||||
}
|
||||
|
||||
void RWindow::Flash() {
|
||||
if (IsFocused())
|
||||
return;
|
||||
@@ -179,7 +188,11 @@ void RWindow::PollEvents() {
|
||||
|
||||
if (platform->xev.type == FocusIn) {
|
||||
Logger::Debug(std::format("Event'{}'", "FocusIn"));
|
||||
XAutoRepeatOff(platform->display);
|
||||
|
||||
if (!key_repeat)
|
||||
XAutoRepeatOff(platform->display);
|
||||
else
|
||||
XAutoRepeatOn(platform->display);
|
||||
|
||||
if (platform->wm_hints) {
|
||||
platform->wm_hints->flags &= ~XUrgencyHint;
|
||||
|
Reference in New Issue
Block a user