mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 12:51:05 +08:00
Fixed Window::setSize not working without the sf::Style::Resize style (#466)
This commit is contained in:
parent
eee18a515a
commit
980477c1f1
@ -90,7 +90,8 @@ m_atomClose (0),
|
|||||||
m_oldVideoMode(-1),
|
m_oldVideoMode(-1),
|
||||||
m_hiddenCursor(0),
|
m_hiddenCursor(0),
|
||||||
m_keyRepeat (true),
|
m_keyRepeat (true),
|
||||||
m_previousSize(-1, -1)
|
m_previousSize(-1, -1),
|
||||||
|
m_useSizeHints(false)
|
||||||
{
|
{
|
||||||
// Open a connection with the X server
|
// Open a connection with the X server
|
||||||
m_display = OpenDisplay();
|
m_display = OpenDisplay();
|
||||||
@ -120,7 +121,8 @@ m_atomClose (0),
|
|||||||
m_oldVideoMode(-1),
|
m_oldVideoMode(-1),
|
||||||
m_hiddenCursor(0),
|
m_hiddenCursor(0),
|
||||||
m_keyRepeat (true),
|
m_keyRepeat (true),
|
||||||
m_previousSize(-1, -1)
|
m_previousSize(-1, -1),
|
||||||
|
m_useSizeHints(false)
|
||||||
{
|
{
|
||||||
// Open a connection with the X server
|
// Open a connection with the X server
|
||||||
m_display = OpenDisplay();
|
m_display = OpenDisplay();
|
||||||
@ -236,6 +238,7 @@ m_previousSize(-1, -1)
|
|||||||
// This is a hack to force some windows managers to disable resizing
|
// This is a hack to force some windows managers to disable resizing
|
||||||
if (!(style & Style::Resize))
|
if (!(style & Style::Resize))
|
||||||
{
|
{
|
||||||
|
m_useSizeHints = true;
|
||||||
XSizeHints* sizeHints = XAllocSizeHints();
|
XSizeHints* sizeHints = XAllocSizeHints();
|
||||||
sizeHints->flags = PMinSize | PMaxSize;
|
sizeHints->flags = PMinSize | PMaxSize;
|
||||||
sizeHints->min_width = sizeHints->max_width = width;
|
sizeHints->min_width = sizeHints->max_width = width;
|
||||||
@ -348,6 +351,17 @@ Vector2u WindowImplX11::getSize() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void WindowImplX11::setSize(const Vector2u& size)
|
void WindowImplX11::setSize(const Vector2u& size)
|
||||||
{
|
{
|
||||||
|
// If we used size hint to fix the size of the window, we must update them
|
||||||
|
if (m_useSizeHints)
|
||||||
|
{
|
||||||
|
XSizeHints* sizeHints = XAllocSizeHints();
|
||||||
|
sizeHints->flags = PMinSize | PMaxSize;
|
||||||
|
sizeHints->min_width = sizeHints->max_width = size.x;
|
||||||
|
sizeHints->min_height = sizeHints->max_height = size.y;
|
||||||
|
XSetWMNormalHints(m_display, m_window, sizeHints);
|
||||||
|
XFree(sizeHints);
|
||||||
|
}
|
||||||
|
|
||||||
XResizeWindow(m_display, m_window, size.x, size.y);
|
XResizeWindow(m_display, m_window, size.x, size.y);
|
||||||
XFlush(m_display);
|
XFlush(m_display);
|
||||||
}
|
}
|
||||||
|
@ -224,6 +224,7 @@ private :
|
|||||||
Cursor m_hiddenCursor; ///< As X11 doesn't provide cursor hidding, we must create a transparent one
|
Cursor m_hiddenCursor; ///< As X11 doesn't provide cursor hidding, we must create a transparent one
|
||||||
bool m_keyRepeat; ///< Is the KeyRepeat feature enabled?
|
bool m_keyRepeat; ///< Is the KeyRepeat feature enabled?
|
||||||
Vector2i m_previousSize; ///< Previous size of the window, to find if a ConfigureNotify event is a resize event (could be a move event only)
|
Vector2i m_previousSize; ///< Previous size of the window, to find if a ConfigureNotify event is a resize event (could be a move event only)
|
||||||
|
bool m_useSizeHints; ///< Is the size of the window fixed with size hints?
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
Loading…
Reference in New Issue
Block a user