Fix window auto-focus on Linux

This commit is contained in:
mafiesto4
2021-02-09 21:52:34 +01:00
parent 4ce6882fc0
commit 8fe04d6db4
3 changed files with 25 additions and 6 deletions

View File

@@ -242,10 +242,7 @@ void LinuxWindow::Show()
LINUX_WINDOW_PROLOG;
X11::XMapWindow(display, window);
X11::XFlush(display);
if (_settings.AllowInput && _settings.ActivateWhenFirstShown)
{
Focus();
}
_focusOnMapped = _settings.AllowInput && _settings.ActivateWhenFirstShown;
// Base
WindowBase::Show();
@@ -306,6 +303,11 @@ bool LinuxWindow::IsClosed() const
return _isClosing;
}
bool LinuxWindow::IsForegroundWindow() const
{
return _focused || _focusOnMapped;
}
void LinuxWindow::SetClientBounds(const Rectangle& clientArea)
{
int32 x = Math::TruncToInt(clientArea.GetX());
@@ -673,7 +675,14 @@ void LinuxWindow::SetOpacity(const float opacity)
void LinuxWindow::Focus()
{
// TODO: impl this
if (_focused || !IsWindowMapped())
return;
LINUX_WINDOW_PROLOG;
X11::XSetInputFocus(display, window, RevertToPointerRoot, CurrentTime);
X11::XFlush(display);
X11::XSync(display, 0);
}
void LinuxWindow::SetTitle(const StringView& title)