Basic approach. Imagine an infinite grid. An imaginary ball, corresponding to the real ball on your screen, starts in the unit square. It starts moving in some direction and continues moving forever in that direction.
When it passes a line of the form $x = j$, where $j$ is an integer, that corresponds to the real ball bouncing off either the left or the right side of the screen. When it passes a line of the form $y = k$, where $k$ is an integer, that corresponds to the real ball bouncing off either the upper or the lower side of the screen.
The imaginary ball always moves in the same direction, but the real ball, of course, changes direction each time it passes one of these integer lines.
However, the moments at which the imaginary ball encounters a corner of the form $(j, k)$, where $j$ and $k$ are both integers, correspond to those moments when the real ball hits a corner as well. So the question is, given an initial starting point $(x_0, y_0)$ and a velocity vector $(v_x, v_y)$, if the line
$$
\frac{y-y_0}{v_y} = \frac{x-x_0}{v_x}
$$
has an integer solution. If so, the displacement between the initial point $(x_0, y_0)$ and the solution point $(j, k)$, along with the component velocities $v_x$ and $v_y$ will tell you how long it takes to get there.
I'll try to add more about this problem when I get more time.