Re: Getting the viewport location/size



monkeyiq dingoblue net au writes:
> I see the gtk_viewport_get_Xadjustment() calls, but they would only solve the
> x,y part of the problem from what I can put together.
> Is there an easy way to get the x,y,w,h of the currently viewed part of a
> GtkViewPort?

I think gdk_window_get_size (viewport->view_window) probably works. 

However, this is normally handled by doing your redraw in response to
an expose event which has the redraw area in it.

Getting the current area is inherently incorrect code, because of a
race condition:

 get_area ();
 /* area may change here... */
 draw_to_area ();

So if you need to redraw the area because of a change in your
program's data, rather than an expose, typically you would redraw the
entire area that was affected by the data change, not just the
viewport bit. X will automatically optimize by clipping to the visible
part of the window, so the only cost here is sending the X request
packets, actual drawing won't happen outside the window. Also, you can
optimize by using gtk_widget_queue_draw() to trigger the redraw
instead of doing it immediately, then multiple redraws in short
sequence will get compressed into one.

Havoc







[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]