Step 1: Split the integrand:
Write the integral as a sum of two parts.
\[ I = \int_{-\pi}^{\pi} \frac{2x}{1+\cos^2 x}\,dx + \int_{-\pi}^{\pi} \frac{2x\sin x}{1+\cos^2 x}\,dx \]
Step 2: Use even and odd functions:
Recall that \(\int_{-a}^{a} g(x)\,dx = 0\) if \(g\) is odd, and \(= 2\int_{0}^{a} g(x)\,dx\) if \(g\) is even.
In the first part, \(\frac{2x}{1+\cos^2 x}\) is odd, because \(\cos^2 x\) is even and \(x\) is odd. So the first integral is \(0\).
In the second part, \(x\sin x\) is even (odd times odd) and \(1+\cos^2 x\) is even. So the integrand is even.
\[ I = 2\int_{-\pi}^{\pi}\frac{x\sin x}{1+\cos^2 x}\,dx = 4\int_{0}^{\pi}\frac{x\sin x}{1+\cos^2 x}\,dx \]
Step 3: Apply the property \(\int_0^a h(x)\,dx = \int_0^a h(a-x)\,dx\):
Let \(J = \int_{0}^{\pi}\frac{x\sin x}{1+\cos^2 x}\,dx\). Replace \(x\) by \(\pi - x\).
\(\sin(\pi - x) = \sin x\) and \(\cos^2(\pi - x) = \cos^2 x\), so
\[ J = \int_{0}^{\pi}\frac{(\pi - x)\sin x}{1+\cos^2 x}\,dx \]
Add the two forms of \(J\):
\[ 2J = \pi\int_{0}^{\pi}\frac{\sin x}{1+\cos^2 x}\,dx \]
Step 4: Evaluate the remaining integral:
Put \(t = \cos x\), so \(dt = -\sin x\,dx\). When \(x = 0\), \(t = 1\). When \(x = \pi\), \(t = -1\).
\[ \int_{0}^{\pi}\frac{\sin x}{1+\cos^2 x}\,dx = \int_{-1}^{1}\frac{dt}{1+t^2} = \left[\tan^{-1} t\right]_{-1}^{1} = \frac{\pi}{4} + \frac{\pi}{4} = \frac{\pi}{2} \]
So \(2J = \frac{\pi^2}{2}\), which gives \(J = \frac{\pi^2}{4}\).
Step 5: Find I:
\[ I = 4J = 4 \cdot \frac{\pi^2}{4} = \pi^2 \]
Final Answer:
The value of the integral is \(\pi^2\).
\[ \boxed{I = \pi^2} \]