Systray icon behaviour: agreed, sounds logical.
I attach a patch. Please review.
I copied the behavior of other programs, which is:
1.- If hidden -> show on top
2.- if shown, but not on top -> show on top
3.- it shown on top -> hide
Warning: I have no experience with wxwindows, maybe I am not using the corrects methods here (specially for case 2 above)
The patch also includes compatibility with boost 1.46, since that is what I have in my box, and I think will be useful. I know that this should be in a different patch :$
A big BUT here: even though I have tested this and works OK, it won't reach users until the "fMinimizeToTray" option can be enabled int he GUI. The current code has a comment "// Minimize to tray is just too buggy on Linux" (around line 1655 in ui.cpp) and disables fMinimizeToTray.
For testing purposes, I hardcoded "fMinimizeToTray = true" before "ptaskbaricon->Show(fMinimizeToTray || fClosedToTray);" in CreateMainWindow (around line 2755, ui.cpp) and it worked perfect. I have KDE 4.6.2, Arch Linux.
Closing window: As long as the main windows represents the bitcoin program (and not just a view of the transaction list) it should actually close when the user clicks the "x". There's already the minimize button to hide the window instead.
This is a little odd: there is an option, "Minimize On Close" (which maps to fClosedToTray, afaik) that can be changed in the GUI. If the user enables this option, the "x" will, indeed, minimize the window, though it remains present in the task bar.
It seems that enabling both options almost produces the "standard" behavior (using the "x" hides the window, clicking in the systray icon hides/shows). The missing thing is that clicking the "x" still shows the icon in the task bar.