!7 sclass TaskBar extends DynSCP { transient Bool vertical; transient L status; transient L buttons; start { doEvery(0.0, 10.0, r revisualize2); } bool shouldBeVertical() { Rect r = dm_getBounds(); ret r != null && r.h > r.w*0.3; } JComponent visualize2() { temp enter(); if (vertical == null) vertical = shouldBeVertical(); if (!makeButtons() && getComponent() != null) ret getComponent(); ret vertical ? jscroll_dynamicvstack(withRightMargin(6, dynamicVStack2((L) (L) buttons, ))) : hgrid(buttons); } enhanceFrame { addTitlePopupMenuItems(f, "Place on bottom", rThread placeOnBottom, "Place on the right", rThread placeOnRight); onResize(f, r { if (vertical == shouldBeVertical()) ret; vertical = shouldBeVertical(); revisualize2(); }); } void placeOnBottom { temp enter(); if (!isFalse(vertical)) { vertical = false; revisualize2_impl(); } // for height calculation dm_placeOnBottom(); } void placeOnRight { temp enter(); dm_placeOnRight(); } // returns true if change bool makeButtons() { L list = [wmctrl_Entry e : linux_wmctrl_list() | e.desktopNumber >= 0]; L status = ll(vertical, list); // TODO: less fields if (eq(status, this.status)) false; this.status = status; print("Linux Task Bar: Making new buttons"); new L out; L>> menuItems = (L) ll(pair("Close window", voidfunc(wmctrl_Entry e) { wmctrl_closeWindow(e) })); for (final wmctrl_Entry e : list) { JButton btn = jbutton(e.windowTitle, r { wmctrl_activateWindow(e) }); for (final Pair> p : menuItems) componentPopupMenuItem(btn, p.a, rThread { callF(p.b, e) }); out.add(btn); } buttons = out; true; } }