Changeset View
Changeset View
Standalone View
Standalone View
placement.cpp
Show First 20 Lines • Show All 492 Lines • ▼ Show 20 Line(s) | 491 | { | |||
---|---|---|---|---|---|
493 | const int x = area.left() + (area.width() - c->width()) / 2; | 493 | const int x = area.left() + (area.width() - c->width()) / 2; | ||
494 | const int y = area.top() + 2 * (area.height() - c->height()) / 3; | 494 | const int y = area.top() + 2 * (area.height() - c->height()) / 3; | ||
495 | 495 | | |||
496 | c->move(QPoint(x, y)); | 496 | c->move(QPoint(x, y)); | ||
497 | } | 497 | } | ||
498 | 498 | | |||
499 | void Placement::placeTransient(AbstractClient *c) | 499 | void Placement::placeTransient(AbstractClient *c) | ||
500 | { | 500 | { | ||
501 | const QPoint target = c->transientFor()->pos() + c->transientFor()->clientPos() + c->transientPlacementHint(); | | |||
502 | c->move(target); | | |||
503 | const QRect screen = screens()->geometry(c->transientFor()->screen()); | 501 | const QRect screen = screens()->geometry(c->transientFor()->screen()); | ||
504 | // TODO: work around Qt's transient placement of sub-menus, see https://bugreports.qt.io/browse/QTBUG-51640 | 502 | const QPoint popupPos = c->transientPlacement(screen).topLeft(); | ||
505 | #define CHECK \ | 503 | c->move(popupPos); | ||
506 | if (screen.contains(c->geometry())) { \ | 504 | | ||
507 | return; \ | 505 | // potentially a client could set no constraint adjustments | ||
508 | } | 506 | if (!screen.contains(c->geometry())) { | ||
509 | CHECK | | |||
510 | if (screen.x() + screen.width() < c->x() + c->width()) { | | |||
511 | // overlaps on right | | |||
512 | c->move(screen.x() + screen.width() - c->width(), c->y()); | | |||
513 | CHECK | | |||
514 | } | | |||
515 | if (screen.y() + screen.height() < c->y() + c->height()) { | | |||
516 | // overlaps on bottom | | |||
517 | c->move(c->x(), screen.y() + screen.height() - c->height()); | | |||
518 | CHECK | | |||
519 | } | | |||
520 | if (screen.y() > c->y()) { | | |||
521 | // top is not on screen | | |||
522 | c->move(c->x(), screen.y()); | | |||
523 | CHECK | | |||
524 | } | | |||
525 | if (screen.x() > c->x()) { | | |||
526 | // left is not on screen | | |||
527 | c->move(screen.x(), c->y()); | | |||
528 | CHECK | | |||
529 | } | | |||
530 | #undef CHECK | | |||
531 | // so far the sanitizing didn't help, let's move back to orig target position and use keepInArea | | |||
532 | c->move(target); | | |||
533 | c->keepInArea(screen); | 507 | c->keepInArea(screen); | ||
534 | } | 508 | } | ||
509 | } | ||||
zzag: Please reformat it. | |||||
535 | 510 | | |||
536 | void Placement::placeDialog(AbstractClient* c, QRect& area, Policy nextPlacement) | 511 | void Placement::placeDialog(AbstractClient* c, QRect& area, Policy nextPlacement) | ||
537 | { | 512 | { | ||
538 | placeOnMainWindow(c, area, nextPlacement); | 513 | placeOnMainWindow(c, area, nextPlacement); | ||
539 | } | 514 | } | ||
540 | 515 | | |||
541 | void Placement::placeUnderMouse(AbstractClient* c, QRect& area, Policy /*next*/) | 516 | void Placement::placeUnderMouse(AbstractClient* c, QRect& area, Policy /*next*/) | ||
542 | { | 517 | { | ||
▲ Show 20 Lines • Show All 425 Lines • Show Last 20 Lines |
Please reformat it.