Fix resizing and maximizing window on Linux
This commit is contained in:
@@ -1714,7 +1714,7 @@ void LinuxPlatform::Tick()
|
||||
window = WindowsManager::GetByNativePtr((void*)event.xclient.window);
|
||||
if (window)
|
||||
{
|
||||
window->CheckForWindowResize();
|
||||
window->OnConfigureNotify(&event.xconfigure);
|
||||
}
|
||||
break;
|
||||
case PropertyNotify:
|
||||
|
||||
@@ -451,16 +451,17 @@ void LinuxWindow::CheckForWindowResize()
|
||||
|
||||
LINUX_WINDOW_PROLOG;
|
||||
|
||||
// Cache client size
|
||||
// Get client size
|
||||
X11::XWindowAttributes xwa;
|
||||
X11::XGetWindowAttributes(display, window, &xwa);
|
||||
int32 width = xwa.width;
|
||||
int32 height = xwa.height;
|
||||
_clientSize = Vector2(static_cast<float>(width), static_cast<float>(height));
|
||||
const int32 width = xwa.width;
|
||||
const int32 height = xwa.height;
|
||||
const Vector2 clientSize((float)width, (float)height);
|
||||
|
||||
// Check if window size has been changed
|
||||
if (width > 0 && height > 0 && (_swapChain == nullptr || width != _swapChain->GetWidth() || height != _swapChain->GetHeight()))
|
||||
{
|
||||
if (clientSize != _clientSize && width > 0 && height > 0)
|
||||
{
|
||||
_clientSize = clientSize;
|
||||
OnResize(width, height);
|
||||
}
|
||||
}
|
||||
@@ -580,6 +581,17 @@ void LinuxWindow::OnLeaveNotify(void* event)
|
||||
Input::Mouse->OnMouseLeave(this);
|
||||
}
|
||||
|
||||
void LinuxWindow::OnConfigureNotify(void* event)
|
||||
{
|
||||
auto configureEvent = (X11::XConfigureEvent*)event;
|
||||
const Vector2 clientSize((float)configureEvent->width, (float)configureEvent->height);
|
||||
if (clientSize != _clientSize)
|
||||
{
|
||||
_clientSize = clientSize;
|
||||
OnResize(configureEvent->width, configureEvent->height);
|
||||
}
|
||||
}
|
||||
|
||||
void LinuxWindow::Maximize(bool enable)
|
||||
{
|
||||
LINUX_WINDOW_PROLOG;
|
||||
|
||||
@@ -56,6 +56,7 @@ public:
|
||||
void OnButtonRelease(void* event);
|
||||
void OnMotionNotify(void* event);
|
||||
void OnLeaveNotify(void* event);
|
||||
void OnConfigureNotify(void* event);
|
||||
|
||||
private:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user