Description: TODO: Put a short summary on the line above and replace this paragraph with a longer explanation of this change. Complete the meta-information with other relevant fields (see below for details). To make it easier, the information below has been extracted from the changelog. Adjust it or drop it. . compiz (1:0.9.7.12-0ubuntu4) precise; urgency=low . * debian/patches/fix_external_monitor_hotplug.patch - Cherry-pick fixes upstream for window mismanagement when adding and/or removing an external monitor. (LP: #763148) (LP: #1171878) Author: Jing Wang Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/compiz/+bug/1302098 --- The information above should follow the Patch Tagging Guidelines, please checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here are templates for supplementary fields that you might want to add: Origin: , Bug: Bug-Debian: http://bugs.debian.org/ Bug-Ubuntu: https://launchpad.net/bugs/ Forwarded: Reviewed-By: Last-Update: --- compiz-0.9.7.12.orig/plugins/place/src/place.cpp +++ compiz-0.9.7.12/plugins/place/src/place.cpp @@ -255,7 +255,8 @@ compareLeftmost (compiz::place::Placeabl ax = a->geometry ().x () - a->extents ().left; bx = b->geometry ().x () - a->extents ().left; - return (ax <= bx); + /* fixed to segfault */ + return (ax < bx); } static bool @@ -267,7 +268,8 @@ compareTopmost (compiz::place::Placeable ay = a->geometry ().y () - a->extents ().top; by = b->geometry ().y () - a->extents ().top; - return (ay <= by); + /* fixed to segfault */ + return (ay < by); } static bool @@ -288,7 +290,8 @@ compareNorthWestCorner (compiz::place::P fromOriginA = sqrt (ax * ax + ay * ay); fromOriginB = sqrt (bx * bx + by * by); - return (fromOriginA <= fromOriginB); + /* fixed to segfault */ + return (fromOriginA < fromOriginB); } PlaceWindow::PlaceWindow (CompWindow *w) : @@ -850,8 +853,9 @@ PlaceWindow::cascadeFindFirstFit (const /* To the right of each window */ rightSorted = placeables; - std::sort (belowSorted.begin (), belowSorted.end (), compareTopmost); - std::sort (belowSorted.begin (), belowSorted.end (), compareLeftmost); + /* fixed to segfault */ + std::sort (rightSorted.begin (), rightSorted.end (), compareTopmost); + std::sort (rightSorted.begin (), rightSorted.end (), compareLeftmost); CompRect rect = this->geometry (); @@ -943,10 +947,10 @@ PlaceWindow::cascadeFindNext (const Plac int xThreshold, yThreshold; int winWidth, winHeight; int cascadeStage; - sorted = placeables; std::sort (sorted.begin (), sorted.end (), compareNorthWestCorner); + int cycle = 0; /* This is a "fuzzy" cascade algorithm. * For each window in the list, we find where we'd cascade a * new window after it. If a window is already nearly at that @@ -957,7 +961,7 @@ PlaceWindow::cascadeFindNext (const Plac * manually cascade. */ #define CASCADE_FUZZ 15 - +#define DETAIL_INTERVAL 17 xThreshold = MAX (this->extents ().left, CASCADE_FUZZ); yThreshold = MAX (this->extents ().top, CASCADE_FUZZ); @@ -965,15 +969,13 @@ PlaceWindow::cascadeFindNext (const Plac * cascade_x, cascade_y are the target position * of NW corner of window frame. */ - - cascadeX = MAX (0, workArea.x ()); + cascadeX = MAX (0, workArea.x ());// + cascadeX_pos; cascadeY = MAX (0, workArea.y ()); /* Find first cascade position that's not used. */ winWidth = window->serverWidth (); winHeight = window->serverHeight (); - cascadeStage = 0; for (iter = sorted.begin (); iter != sorted.end (); iter++) { @@ -991,17 +993,17 @@ PlaceWindow::cascadeFindNext (const Plac * point. The new window frame should go at the origin * of the client window we're stacking above. */ - wx = cascadeX = p->geometry ().x (); + wx = cascadeX = p->geometry ().x () + p->extents ().top/2; wy = cascadeY = p->geometry ().y (); /* If we go off the screen, start over with a new cascade */ - if ((cascadeX + winWidth > workArea.right ()) || - (cascadeY + winHeight > workArea.bottom ())) + if ((cascadeX + winWidth > workArea.right () ) || + (cascadeY + winHeight + p->extents ().top > workArea.bottom () )) { - cascadeX = MAX (0, workArea.x ()); + cascadeX = MAX (0, workArea.x ()) + DETAIL_INTERVAL * cycle; cascadeY = MAX (0, workArea.y ()); -#define CASCADE_INTERVAL 50 /* space between top-left corners of cascades */ +#define CASCADE_INTERVAL 51 /* space between top-left corners of cascades */ cascadeStage += 1; cascadeX += CASCADE_INTERVAL * cascadeStage; @@ -1016,9 +1018,14 @@ PlaceWindow::cascadeFindNext (const Plac } else { - /* All out of space, this cascade_x won't work */ cascadeX = MAX (0, workArea.x ()); - break; + /* All out of space, this cascade_x won't work */ + cycle++; + if (cycle == 3) break; + cascadeX += DETAIL_INTERVAL * cycle; + cascadeStage = 0; + iter = sorted.begin (); + continue; } } } @@ -1027,7 +1034,6 @@ PlaceWindow::cascadeFindNext (const Plac /* Keep searching for a further-down-the-diagonal window. */ } } - /* cascade_x and cascade_y will match the last window in the list * that was "in the way" (in the approximate cascade diagonal) */