This question is inspired by an almost complete solution. My aim is to have the figure (placed in a figure environment) occupy the maximum place possible given that it has a caption (without generating any warnings of course) and that there are things like a frame title and a navigation bar. The idea from the linked solution is to use
\includegraphics[width=\linewidth,height=\textheight,keepaspectratio]{picture}
However, this doesn't seem to take into account the fact that I have a frame title and a navigation bar (due to the Warsaw theme). Actually, even if I remove the theme, the frame title and the caption, it still results in a badbox. I've tried compiling with PDFLaTeX and lualatex from inside Texmaker.
Suggestions using additional packages (I already use tikz) or even lua are welcome. Here's the MWE.
\documentclass{beamer}
\usepackage{graphicx}
\usetheme{Warsaw}
\begin{document}
\section{Introduction}
\subsection{General considerations}
\begin{frame}{Definition}
\begin{figure}
\includegraphics[width=\linewidth,height=\textheight,keepaspectratio]{statesOfMatter}
\caption{Classical picture of the states of matter.}
\end{figure}
\end{frame}
\section{Placeholder I}
\begin{frame}
\end{frame}
\section{Placeholder II}
\begin{frame}
\end{frame}
\end{document}

height=\dimexpr\contentheight-\contentbottom-X\baselineskip\relax, where X=3 if there's a one-line caption and 0 otherwise, then I get a good enough size without a badbox (if the picture is higher than it is wide). It's a bit black magic to me, but I'll try delving into it a bit more these next few days. – Christoph B. Apr 19 '13 at 20:55