Changeset View
Changeset View
Standalone View
Standalone View
placement.cpp
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 47 | { | |||
---|---|---|---|---|---|
48 | reinitCascading(0); | 48 | reinitCascading(0); | ||
49 | } | 49 | } | ||
50 | 50 | | |||
51 | Placement::~Placement() | 51 | Placement::~Placement() | ||
52 | { | 52 | { | ||
53 | s_self = NULL; | 53 | s_self = NULL; | ||
54 | } | 54 | } | ||
55 | 55 | | |||
56 | /*! | 56 | /** | ||
57 | Places the client \a c according to the workspace's layout policy | 57 | * Places the client \a c according to the workspace's layout policy | ||
58 | */ | 58 | **/ | ||
59 | void Placement::place(AbstractClient* c, QRect& area) | 59 | void Placement::place(AbstractClient* c, QRect& area) | ||
60 | { | 60 | { | ||
61 | Policy policy = c->rules()->checkPlacement(Default); | 61 | Policy policy = c->rules()->checkPlacement(Default); | ||
62 | if (policy != Default) { | 62 | if (policy != Default) { | ||
63 | place(c, area, policy); | 63 | place(c, area, policy); | ||
64 | return; | 64 | return; | ||
65 | } | 65 | } | ||
66 | 66 | | |||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Line(s) | 124 | if (titlePos != Client::PositionBottom && geo.bottom() == fullRect.bottom()) | |||
125 | corner.ry() += cs.height() - cp.y(); | 125 | corner.ry() += cs.height() - cp.y(); | ||
126 | if (titlePos != Client::PositionTop && geo.y() == fullRect.y()) | 126 | if (titlePos != Client::PositionTop && geo.y() == fullRect.y()) | ||
127 | corner.ry() -= cp.y(); | 127 | corner.ry() -= cp.y(); | ||
128 | } | 128 | } | ||
129 | c->move(corner); | 129 | c->move(corner); | ||
130 | } | 130 | } | ||
131 | } | 131 | } | ||
132 | 132 | | |||
133 | /*! | 133 | /** | ||
134 | Place the client \a c according to a simply "random" placement algorithm. | 134 | * Place the client \a c according to a simply "random" placement algorithm. | ||
135 | */ | 135 | **/ | ||
136 | void Placement::placeAtRandom(AbstractClient* c, const QRect& area, Policy /*next*/) | 136 | void Placement::placeAtRandom(AbstractClient* c, const QRect& area, Policy /*next*/) | ||
137 | { | 137 | { | ||
138 | const int step = 24; | 138 | const int step = 24; | ||
139 | static int px = step; | 139 | static int px = step; | ||
140 | static int py = 2 * step; | 140 | static int py = 2 * step; | ||
141 | int tx, ty; | 141 | int tx, ty; | ||
142 | 142 | | |||
143 | const QRect maxRect = checkArea(c, area); | 143 | const QRect maxRect = checkArea(c, area); | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 185 | if (!client->isOnDesktop(desktop)) | |||
186 | return true; | 186 | return true; | ||
187 | if (!client->isOnCurrentActivity()) | 187 | if (!client->isOnCurrentActivity()) | ||
188 | return true; | 188 | return true; | ||
189 | if (client->isDesktop()) | 189 | if (client->isDesktop()) | ||
190 | return true; | 190 | return true; | ||
191 | return false; | 191 | return false; | ||
192 | } | 192 | } | ||
193 | 193 | | |||
194 | /*! | 194 | /** | ||
195 | Place the client \a c according to a really smart placement algorithm :-) | 195 | * Place the client \a c according to a really smart placement algorithm :-) | ||
196 | */ | 196 | **/ | ||
197 | void Placement::placeSmart(AbstractClient* c, const QRect& area, Policy /*next*/) | 197 | void Placement::placeSmart(AbstractClient* c, const QRect& area, Policy /*next*/) | ||
198 | { | 198 | { | ||
199 | /* | 199 | /* | ||
200 | * SmartPlacement by Cristian Tibirna (tibirna@kde.org) | 200 | * SmartPlacement by Cristian Tibirna (tibirna@kde.org) | ||
201 | * adapted for kwm (16-19jan98) and for kwin (16Nov1999) using (with | 201 | * adapted for kwm (16-19jan98) and for kwin (16Nov1999) using (with | ||
202 | * permission) ideas from fvwm, authored by | 202 | * permission) ideas from fvwm, authored by | ||
203 | * Anthony Martin (amartin@engr.csulb.edu). | 203 | * Anthony Martin (amartin@engr.csulb.edu). | ||
204 | * Xinerama supported added by Balaji Ramani (balaji@yablibli.com) | 204 | * Xinerama supported added by Balaji Ramani (balaji@yablibli.com) | ||
▲ Show 20 Lines • Show All 161 Lines • ▼ Show 20 Line(s) | |||||
366 | } | 366 | } | ||
367 | 367 | | |||
368 | QPoint Workspace::cascadeOffset(const AbstractClient *c) const | 368 | QPoint Workspace::cascadeOffset(const AbstractClient *c) const | ||
369 | { | 369 | { | ||
370 | QRect area = clientArea(PlacementArea, c->geometry().center(), c->desktop()); | 370 | QRect area = clientArea(PlacementArea, c->geometry().center(), c->desktop()); | ||
371 | return QPoint(area.width()/48, area.height()/48); | 371 | return QPoint(area.width()/48, area.height()/48); | ||
372 | } | 372 | } | ||
373 | 373 | | |||
374 | /*! | 374 | /** | ||
375 | Place windows in a cascading order, remembering positions for each desktop | 375 | * Place windows in a cascading order, remembering positions for each desktop | ||
376 | */ | 376 | **/ | ||
377 | void Placement::placeCascaded(AbstractClient* c, QRect& area, Policy nextPlacement) | 377 | void Placement::placeCascaded(AbstractClient* c, QRect& area, Policy nextPlacement) | ||
378 | { | 378 | { | ||
379 | /* cascadePlacement by Cristian Tibirna (tibirna@kde.org) (30Jan98) | 379 | /* cascadePlacement by Cristian Tibirna (tibirna@kde.org) (30Jan98) | ||
380 | */ | 380 | */ | ||
381 | // work coords | 381 | // work coords | ||
382 | int xp, yp; | 382 | int xp, yp; | ||
383 | 383 | | |||
384 | //CT how do I get from the 'Client' class the size that NW squarish "handle" | 384 | //CT how do I get from the 'Client' class the size that NW squarish "handle" | ||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Line(s) | |||||
447 | 447 | | |||
448 | // place the window | 448 | // place the window | ||
449 | c->move(QPoint(xp, yp)); | 449 | c->move(QPoint(xp, yp)); | ||
450 | 450 | | |||
451 | // new position | 451 | // new position | ||
452 | cci[dn].pos = QPoint(xp + delta.x(), yp + delta.y()); | 452 | cci[dn].pos = QPoint(xp + delta.x(), yp + delta.y()); | ||
453 | } | 453 | } | ||
454 | 454 | | |||
455 | /*! | 455 | /** | ||
456 | Place windows centered, on top of all others | 456 | * Place windows centered, on top of all others | ||
457 | */ | 457 | **/ | ||
458 | void Placement::placeCentered(AbstractClient* c, const QRect& area, Policy /*next*/) | 458 | void Placement::placeCentered(AbstractClient* c, const QRect& area, Policy /*next*/) | ||
459 | { | 459 | { | ||
460 | 460 | | |||
461 | // get the maximum allowed windows space and desk's origin | 461 | // get the maximum allowed windows space and desk's origin | ||
462 | const QRect maxRect = checkArea(c, area); | 462 | const QRect maxRect = checkArea(c, area); | ||
463 | 463 | | |||
464 | const int xp = maxRect.left() + (maxRect.width() - c->width()) / 2; | 464 | const int xp = maxRect.left() + (maxRect.width() - c->width()) / 2; | ||
465 | const int yp = maxRect.top() + (maxRect.height() - c->height()) / 2; | 465 | const int yp = maxRect.top() + (maxRect.height() - c->height()) / 2; | ||
466 | 466 | | |||
467 | // place the window | 467 | // place the window | ||
468 | c->move(QPoint(xp, yp)); | 468 | c->move(QPoint(xp, yp)); | ||
469 | } | 469 | } | ||
470 | 470 | | |||
471 | /*! | 471 | /** | ||
472 | Place windows in the (0,0) corner, on top of all others | 472 | * Place windows in the (0,0) corner, on top of all others | ||
473 | */ | 473 | **/ | ||
474 | void Placement::placeZeroCornered(AbstractClient* c, const QRect& area, Policy /*next*/) | 474 | void Placement::placeZeroCornered(AbstractClient* c, const QRect& area, Policy /*next*/) | ||
475 | { | 475 | { | ||
476 | // get the maximum allowed windows space and desk's origin | 476 | // get the maximum allowed windows space and desk's origin | ||
477 | c->move(checkArea(c, area).topLeft()); | 477 | c->move(checkArea(c, area).topLeft()); | ||
478 | } | 478 | } | ||
479 | 479 | | |||
480 | void Placement::placeUtility(AbstractClient* c, QRect& area, Policy /*next*/) | 480 | void Placement::placeUtility(AbstractClient* c, QRect& area, Policy /*next*/) | ||
481 | { | 481 | { | ||
▲ Show 20 Lines • Show All 209 Lines • ▼ Show 20 Line(s) | 687 | { | |||
691 | move(left, top); | 691 | move(left, top); | ||
692 | if (screen() != oldScreen) { | 692 | if (screen() != oldScreen) { | ||
693 | workspace()->sendClientToScreen(this, screen()); // checks rule validity | 693 | workspace()->sendClientToScreen(this, screen()); // checks rule validity | ||
694 | if (maximizeMode() != MaximizeRestore) | 694 | if (maximizeMode() != MaximizeRestore) | ||
695 | checkWorkspacePosition(); | 695 | checkWorkspacePosition(); | ||
696 | } | 696 | } | ||
697 | } | 697 | } | ||
698 | 698 | | |||
699 | /*! | 699 | /** | ||
700 | Moves active window left until in bumps into another window or workarea edge. | 700 | * Moves active window left until in bumps into another window or workarea edge. | ||
701 | */ | 701 | **/ | ||
702 | void Workspace::slotWindowPackLeft() | 702 | void Workspace::slotWindowPackLeft() | ||
703 | { | 703 | { | ||
704 | if (active_client && active_client->isMovable()) | 704 | if (active_client && active_client->isMovable()) | ||
705 | active_client->packTo(packPositionLeft(active_client, active_client->geometry().left(), true), | 705 | active_client->packTo(packPositionLeft(active_client, active_client->geometry().left(), true), | ||
706 | active_client->y()); | 706 | active_client->y()); | ||
707 | } | 707 | } | ||
708 | 708 | | |||
709 | void Workspace::slotWindowPackRight() | 709 | void Workspace::slotWindowPackRight() | ||
▲ Show 20 Lines • Show All 239 Lines • Show Last 20 Lines |