NAME
Gtk2::Ex::SyncCall -- server sync callback
SYNOPSIS
use Gtk2::Ex::SyncCall;
Gtk2::Ex::SyncCall->sync ($widget, sub { some code; });
DESCRIPTION
Gtk2::Ex::SyncCall
sends a dummy synchronizing request to the X server and calls back to your code when response arrives back. This is like Gtk2::Gdk::Display::sync()
, but as a callback instead of blocking.
A sync like this is a good way to avoid hammering the server with more drawing requests etc than it can keep up with. Choosing where in your program is a good place to pause is of course up to you.
Implmentation
SyncCall is done with a dummy property change on the given $widget
, so the widget must be realized. The property change setups on that widget are left installed ready for further use to the same display. An unrealize or destroy on the widget will call pending callbacks and then reset ready for a different widget on subsequent syncs.
It's a good idea if $widget
isn't your top-level Gtk2::Window
widget, since generally the window manager listens for property changes on that. The "Gtk2::Ex::SyncCall"
property will be ignored by it, but it's a little wasteful to have it see unnecessary change events.
(There's various alternatives to this approach. Something not directly involving a widget would be better, the widget then only indicating the target display.)
FUNCTIONS
Gtk2::Ex::SyncCall->sync ($widget, $coderef, $userdata)
-
Send a dummy synchronizing message to the X server and when it replies call
$coderef->($userdata)
.$widget
must be realized ($widget->realize()
).Multiple
sync
calls on the same display are collected up so just one synchronising message is sent, with all the registered callbacks then done when the reply comes.