!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); } void enhanceFrame(Container f) { super.enhanceFrame(f); addTitlePopupMenuItems((RootPaneContainer) 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 = linux_wmctrl_list(); LS namesInvis = map dm_moduleName(p.b); 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 = dm_moduleMenuItems(); for (final wmctrl_Entry e : list) { JButton btn = jbutton(e.windowTitle, r { dm_showModule(ref!) }); for (final Pair> p : menuItems) componentPopupMenuItem(btn, p.a, rThread { callF(p.b, e) }); out.add(btn); } buttons = out; true; } }