-// We do not check for the iconified state, since it only unsets our active window
-// but in openbox a shaded window is considered iconified. So we would loose the active window
-// property on unshading it again (commented 01.10.2009)
-// else if (at == server.atom.WM_STATE) {
-// // Iconic state
-// // TODO : try to delete following code
-// if (window_is_iconified (win)) {
-// if (task_active) {
-// if (task_active->win == tsk->win) {
-// Task *tsk2;
-// GSList *l0;
-// for (i=0 ; i < nb_panel ; i++) {
-// for (j=0 ; j < panel1[i].nb_desktop ; j++) {
-// for (l0 = panel1[i].taskbar[j].area.list; l0 ; l0 = l0->next) {
-// tsk2 = l0->data;
-// tsk2->area.is_active = 0;
-// }
-// }
-// }
-// task_active = 0;
-// }
-// }
-// }
-// }
+ else if (at == server.atom.WM_STATE) {
+ // Iconic state
+ int state = (task_active && tsk->win == task_active->win ? TASK_ACTIVE : TASK_NORMAL);
+ if (window_is_iconified(win))
+ state = TASK_ICONIFIED;
+ set_task_state(tsk, state);
+ panel_refresh = 1;
+ }