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