(I rewrote this answer completely after the OP clarified the posting's objective.)
Assuming you use \( and \) (rather than $) to initiate and terminate inline-math mode, you could achieve your objective by (a) patching these two commands so that a toggle is set to either true or false, respectively, and (b) defining the \vartilde macro so that it invokes either \tilde or \widetilde depending on whether the toggle is true or not.

\documentclass{article}
\newif\ifinlinemath\inlinemathfalse % initialize to "false"
\usepackage{etoolbox} % for \pretocmd and \apptocmd macros
\pretocmd{\(}{\inlinemathtrue}{}{}
\apptocmd{\)}{\inlinemathfalse}{}{}
\newcommand{\vartilde}[1]{\ifinlinemath\tilde{#1}\else\widetilde{#1}\fi}
\begin{document}
\centering
\( \tilde{X} \quad \vartilde{X} \quad \widetilde{X} \)
\[ \tilde{X} \quad \vartilde{X} \quad \widetilde{X} \]
\( \tilde{X} \quad \vartilde{X} \quad \widetilde{X} \)
\end{document}
Two asides:
I'm not knowledgeable enough to figure out how to do this if $, rather than \( and \), is used to initiate and terminate inline math mode.
Speaking for myself, I think that using different tilde styles for one and the same variable, depending only on whether the material occurs in inline math mode or display math mode, is bound to utterly confuse your readers. (Expecting your readers to appreciate the difference between inline and display math mode might be a tad unrealistic...) I certainly wouldn't do this in my own documents.
Addendum, to address the OP's comment that using \widetilde for inline math material "an push the line down". AFAICT, this can only happen if you have an unusually small value for \baselineskip. For most Roman fonts -- blackletter fonts, such as any Fraktur-type text font, are a different matter -- the baselineskip is usually set to 120% of the nominal font size. E.g., if 10pt is the nominal font size and Computer Modern is in use, the baselineskip is set to 12pt. This should be more than enough to keep TeX from widening the interline spacing when either \widetilde or \widehat are used in conjunction with uppercase letters.
In the following screenshot, the left-hand column uses no accents, the middle column uses \tilde and \hat, and the right-hand column uses \widetilde and \widehat. AFAICT, there's no difference in the line spacing; in particular, the "wide" accents didn't modify the line spacing.

\documentclass{article}
\usepackage{multicol}
\newcommand\blurb{Once upon a time, there was \dots\ }
\begin{document}
\begin{multicols}{3}
\blurb $X$ $X$ $X$ $X$ \blurb $X$ $X$ $X$ $X$ \blurb $X$ $X$ $X$ $X$ \blurb $X$ $X$ $X$ $X$ \blurb $X$ $X$ $X$ $X$ \blurb $X$ $X$ $X$ $X$
\blurb $\tilde{X}$ $\tilde{X}$ $\tilde{X}$ $\tilde{X}$ \blurb $\tilde{X}$ $\tilde{X}$ $\tilde{X}$ $\tilde{X}$ \blurb $\tilde{X}$ $\tilde{X}$ $\tilde{X}$ $\tilde{X}$ \blurb $\tilde{X}$ $\tilde{X}$ $\tilde{X}$ $\tilde{X}$ \blurb $\tilde{X}$ $\tilde{X}$ $\tilde{X}$ $\tilde{X}$ \blurb $\tilde{X}$ $\tilde{X}$ $\tilde{X}$ $\tilde{X}$
\blurb $\widetilde{X}$ $\widetilde{X}$ $\widetilde{X}$ $\widetilde{X}$ \blurb $\widetilde{X}$ $\widetilde{X}$ $\widetilde{X}$ $\widetilde{X}$ \blurb $\widetilde{X}$ $\widetilde{X}$ $\widetilde{X}$ $\widetilde{X}$ \blurb $\widetilde{X}$ $\widetilde{X}$ $\widetilde{X}$ $\widetilde{X}$ \blurb $\widetilde{X}$ $\widetilde{X}$ $\widetilde{X}$ $\widetilde{X}$ \blurb $\widetilde{X}$ $\widetilde{X}$ $\widetilde{X}$ $\widetilde{X}$
\end{multicols}
\begin{multicols}{3}
\blurb $X$ $X$ $X$ $X$ \blurb $X$ $X$ $X$ $X$ \blurb $X$ $X$ $X$ $X$ \blurb $X$ $X$ $X$ $X$ \blurb $X$ $X$ $X$ $X$ \blurb $X$ $X$ $X$ $X$
\blurb $\hat{X}$ $\hat{X}$ $\hat{X}$ $\hat{X}$ \blurb $\hat{X}$ $\hat{X}$ $\hat{X}$ $\hat{X}$ \blurb $\hat{X}$ $\hat{X}$ $\hat{X}$ $\hat{X}$ \blurb $\hat{X}$ $\hat{X}$ $\hat{X}$ $\hat{X}$ \blurb $\hat{X}$ $\hat{X}$ $\hat{X}$ $\hat{X}$ \blurb $\hat{X}$ $\hat{X}$ $\hat{X}$ $\hat{X}$
\blurb $\widehat{X}$ $\widehat{X}$ $\widehat{X}$ $\widehat{X}$ \blurb $\widehat{X}$ $\widehat{X}$ $\widehat{X}$ $\widehat{X}$ \blurb $\widehat{X}$ $\widehat{X}$ $\widehat{X}$ $\widehat{X}$ \blurb $\widehat{X}$ $\widehat{X}$ $\widehat{X}$ $\widehat{X}$ \blurb $\widehat{X}$ $\widehat{X}$ $\widehat{X}$ $\widehat{X}$ \blurb $\widehat{X}$ $\widehat{X}$ $\widehat{X}$ $\widehat{X}$
\end{multicols}
\end{document}
\tildeespecially with a text component isn't the best idea in the world. for some reasons, see Textual substitution of macros in a LaTeX file. on the other hand\vartildeisn't unreasonable. – barbara beeton Dec 18 '17 at 18:16\tildeis not legal in text mode. – egreg Dec 18 '17 at 18:46\vartildeisn't exactly difficult to write! – Sam OT Dec 18 '17 at 20:07$symbols. I didn't know about using\(and\)-- although it is a very natural counterpart to\[and\]. There is, of course, no harm to changing to\(...\)if necessary! – Sam OT Dec 18 '17 at 21:15