[Kde-games-devel] Extra resize events from KXmlGuiWindow

Parker Coates parker.coates at gmail.com
Tue Mar 24 03:30:41 CET 2009


Hello list,

In the KDEGames camp we've run into a small bit of trouble with
KXmlGuiWindow generating an extra resize event on startup. An extra
resize event may seem trivial enough, but because our games now all
have resizable SVG based interfaces, a single extra resize event can
mean extra SVG rendering, cache lookups, layout logic and a noticeable
increase in start up time.

The sequence I'm seeing looks like this: The KXmlGuiWindow has a
single resizeEvent when it is shown. Next, the main widget is resized.
The size given seems to be that of the main window minus the height of
the tool bar and status bar. The main widget is then resized again to
be shorter by the height of the menu bar.

If I manually call menuBar()->hide() before showing the window I only
get one resize event on startup, as expected. After playing around
with timers, it seems to me that the menu must be inserted only after
the program has reentered the event loop. An attempt to wait until
after all resize events with a QTimer::singleshot(0, ...) didn't work,
but after changing the delay from 0 to 50 ms it did. Obviously this is
a hackish solution, as the exact delay needed will change from machine
to machine and a conservative guess will waste valuable start up time.

So my questions are: Would it be possible to insert the menu bar at
the same time as the tool and status bars so that the main widget is
resized only once? If not, do you have any suggestions on how to avoid
these resize events without relying on timers? I've had a look at the
xmlgui code, but I'll quickly admit that most of it was over my head
and I really didn't know what I was looking for.

Please note I've CCed kde-game-devel, but please respond on kde-devel.

Many thanks,

Parker


More information about the kde-games-devel mailing list