--- icewm-1.3.7/src/wmmgr.cc.orig 2014-09-26 13:34:43.587262031 +1000 +++ icewm-1.3.7/src/wmmgr.cc 2014-09-26 13:45:33.006326774 +1000 @@ -28,6 +28,9 @@ #include "yprefs.h" #include "yrect.h" +#include +#include + XContext frameContext; XContext clientContext; @@ -1239,29 +1242,43 @@ focusTopWindow(); } +int YWindowManager::bellCurve(int min, int max, int offset, double std_deviation) { + double u1, u2, guassian; + int locus, result; + + u1 = drand48(); + u2 = drand48(); + guassian = sqrt(-2 * log(u1)) * cos(2 * M_PI * u2); + locus = (min + max) / 2 - offset; + result = (int)trunc(guassian * std_deviation) + locus; + if (result < min || result > max) { + result = bellCurve(min, max, offset, std_deviation); + } + return result; +} + +void YWindowManager::getRandomPlace(YFrameWindow *frame, int &x, int &y, int w, int h) { + int mx, my, Mx, My; + + manager->getWorkArea(frame, &mx, &my, &Mx, &My); + x = bellCurve(mx, Mx, w + frame->borderXN(), (double)(Mx - mx) / 3); + y = bellCurve(my, My, h + frame->borderYN() + frame ->titleYN(), (double) (My - my) / 3); +} + void YWindowManager::getNewPosition(YFrameWindow *frame, int &x, int &y, int w, int h, int xiscreen) { if (centerTransientsOnOwner && frame->owner() != 0) { x = frame->owner()->x() + frame->owner()->width() / 2 - w / 2; y = frame->owner()->y() + frame->owner()->height() / 2 - h / 2; + } else if (randomPlacement) { + getRandomPlace(frame, x, y, w, h); } else if (smartPlacement) { getSmartPlace(true, frame, x, y, w, h, xiscreen); } else { - static int lastX = 0; - static int lastY = 0; + static int lastY = 0; getCascadePlace(frame, lastX, lastY, x, y, w, h); } - if (centerLarge) { - int mx, my, Mx, My; - manager->getWorkArea(frame, &mx, &my, &Mx, &My); - if (w > (Mx - mx) / 2 && h > (My - my) / 2) { - x = (mx + Mx - w) / 2; /* = mx + (Mx - mx - w) / 2 */ - if (x < mx) x = mx; - y = (my + My - h) / 2; /* = my + (My - my - h) / 2 */ - if (y < my) y = my; - } - } } void YWindowManager::placeWindow(YFrameWindow *frame, --- icewm-1.3.7/src/wmmgr.h.orig 2014-09-26 13:34:43.552262184 +1000 +++ icewm-1.3.7/src/wmmgr.h 2014-09-26 13:34:51.774224057 +1000 @@ -101,6 +101,8 @@ void tryCover(bool down, YFrameWindow *frame, int x, int y, int w, int h, int &px, int &py, int &cover, int xiscreen); bool getSmartPlace(bool down, YFrameWindow *frame, int &x, int &y, int w, int h, int xiscreen); + int bellCurve(int min, int max, int offset, double std_deviation); + void getRandomPlace(YFrameWindow *frame, int &x, int &y, int w, int h); void getNewPosition(YFrameWindow *frame, int &x, int &y, int w, int h, int xiscreen); void placeWindow(YFrameWindow *frame, int x, int y, int cw, int ch, bool newClient, bool &canActivate); --- icewm-1.3.7/src/default.h.orig 2014-09-26 13:34:43.571262087 +1000 +++ icewm-1.3.7/src/default.h 2014-09-26 13:35:05.639159733 +1000 @@ -80,7 +80,7 @@ XIV(bool, miniIconsBottomToTop, false) XIV(bool, manualPlacement, false) XIV(bool, smartPlacement, true) -XIV(bool, centerLarge, false) +XIV(bool, randomPlacement, false) XIV(bool, centerTransientsOnOwner, true) XIV(bool, autoRaise, false) XIV(bool, delayPointerFocus, true) @@ -233,11 +233,11 @@ OBV("StrongPointerFocus", &strongPointerFocus, "Always maintain focus under mouse window (makes some keyboard support non-functional or unreliable"), OBV("OpaqueMove", &opaqueMove, "Opaque window move"), OBV("OpaqueResize", &opaqueResize, "Opaque window resize"), - OBV("ManualPlacement", &manualPlacement, "Windows initially placed manually by user"), + OBV("ManualPlacement", &manualPlacement, "Windows initially placed manually by user (supercedes all other placement options)"), OBV("SmartPlacement", &smartPlacement, "Smart window placement (minimal overlap)"), + OBV("RandomPlacement", &randomPlacement, "Semi-random window placement with a center bias (supercedes SmartPlacement)"), OBV("HideTitleBarWhenMaximized", &hideTitleBarWhenMaximized, "Hide title bar when maximized"), - OBV("CenterLarge", ¢erLarge, "Center large windows"), - OBV("CenterTransientsOnOwner", ¢erTransientsOnOwner, "Center dialogs on owner window"), + OBV("CenterTransientsOnOwner", ¢erTransientsOnOwner, "Center dialogs on owner window (supercedes RandomPlacement and SmartPlacement)"), OBV("MenuMouseTracking", &menuMouseTracking, "Menus track mouse even with no mouse buttons held"), OBV("AutoRaise", &autoRaise, "Auto raise windows after delay"), OBV("DelayPointerFocus", &delayPointerFocus, "Delay pointer focusing when mouse moves"),