Skip to content

Commit

Permalink
libgui|GLWindow: Fixed the initial window size notification
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent 195fb6c commit 22c9bed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 2 additions & 3 deletions doomsday/apps/client/src/ui/clientwindow.cpp
Expand Up @@ -517,7 +517,7 @@ DE_PIMPL(ClientWindow)
LOG_AS("ClientWindow");

Size size = self().pixelSize();
LOG_TRACE("Window resized to %s pixels", size.asText());
LOG_VERBOSE("Window resized to %s pixels") << size.asText();

GLState::current().setViewport(Rectangleui(0, 0, size.x, size.y));

Expand Down Expand Up @@ -849,8 +849,7 @@ ClientWindow::ClientWindow(String const &id)
// Stay out from under the virtual keyboard.
connect(this, &GLWindow::rootDimensionsChanged, [this] (QRect rect)
{
d->root.rootOffset().setValue(Vec2f(0, int(rect.height()) - int(pixelSize().y)),
0.3);
d->root.rootOffset().setValue(Vec2f(0, int(rect.height()) - int(pixelSize().y)), 0.3);
});
#endif
}
Expand Down
11 changes: 11 additions & 0 deletions doomsday/libs/gui/src/glwindow.cpp
Expand Up @@ -145,6 +145,8 @@ DE_PIMPL(GLWindow)

LIBGUI_ASSERT_GL_OK();

debug("Window pixel size at notifyReady: %s", currentSize.asText().c_str());

// Everybody can perform GL init now.
DE_FOR_PUBLIC_AUDIENCE2(Init, i) i->windowInit(self());
DE_FOR_PUBLIC_AUDIENCE2(Resize, i) i->windowResized(self());
Expand Down Expand Up @@ -420,6 +422,15 @@ void GLWindow::setGeometry(const Rectanglei &rect)
{
SDL_SetWindowPosition(d->window, rect.left(), rect.top());
SDL_SetWindowSize (d->window, rect.width(), rect.height());

// Update the current size immediately.
Vec2i pixels;
SDL_GL_GetDrawableSize(d->window, &pixels.x, &pixels.y);
if (d->currentSize != pixels.toVec2ui())
{
d->currentSize = pixels.toVec2ui();
DE_FOR_AUDIENCE2(Resize, i) { i->windowResized(*this); }
}
}

#if defined (DE_MOBILE)
Expand Down

0 comments on commit 22c9bed

Please sign in to comment.