Changeset View
Changeset View
Standalone View
Standalone View
manage.cpp
Show First 20 Lines • Show All 334 Lines • ▼ Show 20 Line(s) | 308 | #endif | |||
---|---|---|---|---|---|
335 | if (isMovable() && (geom.x() > area.right() || geom.y() > area.bottom())) | 335 | if (isMovable() && (geom.x() > area.right() || geom.y() > area.bottom())) | ||
336 | placementDone = false; // Weird, do not trust. | 336 | placementDone = false; // Weird, do not trust. | ||
337 | 337 | | |||
338 | if (placementDone) | 338 | if (placementDone) | ||
339 | move(geom.x(), geom.y()); // Before gravitating | 339 | move(geom.x(), geom.y()); // Before gravitating | ||
340 | 340 | | |||
341 | // Create client group if the window will have a decoration | 341 | // Create client group if the window will have a decoration | ||
342 | bool dontKeepInArea = false; | 342 | bool dontKeepInArea = false; | ||
343 | setTabGroup(NULL); | | |||
344 | if (!noBorder() && false) { | | |||
345 | const bool autogrouping = rules()->checkAutogrouping(options->isAutogroupSimilarWindows()); | | |||
346 | const bool autogroupInFg = rules()->checkAutogroupInForeground(options->isAutogroupInForeground()); | | |||
347 | // Automatically add to previous groups on session restore | | |||
348 | if (session && session->tabGroupClient && !workspace()->hasClient(session->tabGroupClient)) | | |||
349 | session->tabGroupClient = NULL; | | |||
350 | if (session && session->tabGroupClient && session->tabGroupClient != this) { | | |||
351 | tabBehind(session->tabGroupClient, autogroupInFg); | | |||
352 | } else if (isMapped && autogrouping) { | | |||
353 | // If the window is already mapped (Restarted KWin) add any windows that already have the | | |||
354 | // same geometry to the same client group. (May incorrectly handle maximized windows) | | |||
355 | foreach (Client *other, workspace()->clientList()) { | | |||
356 | if (other->maximizeMode() != MaximizeFull && | | |||
357 | geom == QRect(other->pos(), other->clientSize()) && | | |||
358 | desk == other->desktop() && activities() == other->activities()) { | | |||
359 | | ||||
360 | tabBehind(other, autogroupInFg); | | |||
361 | break; | | |||
362 | | ||||
363 | } | | |||
364 | } | | |||
365 | } | | |||
366 | if (!(tabGroup() || isMapped || session)) { | | |||
367 | // Attempt to automatically group similar windows | | |||
368 | Client* similar = findAutogroupCandidate(); | | |||
369 | if (similar && !similar->noBorder()) { | | |||
370 | if (autogroupInFg) { | | |||
371 | similar->setDesktop(desk); // can happen when grouping by id. ... | | |||
372 | similar->setMinimized(false); // ... or anyway - still group, but "here" and visible | | |||
373 | } | | |||
374 | if (!similar->isMinimized()) { // do not attempt to tab in background of a hidden group | | |||
375 | geom = QRect(similar->pos() + similar->clientPos(), similar->clientSize()); | | |||
376 | updateDecoration(false); | | |||
377 | if (tabBehind(similar, autogroupInFg)) { | | |||
378 | // Don't move entire group | | |||
379 | geom = QRect(similar->pos() + similar->clientPos(), similar->clientSize()); | | |||
380 | placementDone = true; | | |||
381 | dontKeepInArea = true; | | |||
382 | } | | |||
383 | } | | |||
384 | } | | |||
385 | } | | |||
386 | } | | |||
387 | | ||||
388 | readColorScheme(colorSchemeCookie); | 343 | readColorScheme(colorSchemeCookie); | ||
389 | 344 | | |||
390 | readApplicationMenuServiceName(applicationMenuServiceNameCookie); | 345 | readApplicationMenuServiceName(applicationMenuServiceNameCookie); | ||
391 | readApplicationMenuObjectPath(applicationMenuObjectPathCookie); | 346 | readApplicationMenuObjectPath(applicationMenuObjectPathCookie); | ||
392 | 347 | | |||
393 | updateDecoration(false); // Also gravitates | 348 | updateDecoration(false); // Also gravitates | ||
394 | // TODO: Is CentralGravity right here, when resizing is done after gravitating? | 349 | // TODO: Is CentralGravity right here, when resizing is done after gravitating? | ||
395 | plainResize(rules()->checkSize(sizeForClientSize(geom.size()), !isMapped)); | 350 | plainResize(rules()->checkSize(sizeForClientSize(geom.size()), !isMapped)); | ||
▲ Show 20 Lines • Show All 333 Lines • ▼ Show 20 Line(s) | 621 | { | |||
729 | // receiving any unexpected events from the wrapper creation or the reparenting. | 684 | // receiving any unexpected events from the wrapper creation or the reparenting. | ||
730 | m_frame.selectInput(frame_event_mask); | 685 | m_frame.selectInput(frame_event_mask); | ||
731 | m_wrapper.selectInput(wrapper_event_mask); | 686 | m_wrapper.selectInput(wrapper_event_mask); | ||
732 | m_client.selectInput(client_event_mask); | 687 | m_client.selectInput(client_event_mask); | ||
733 | 688 | | |||
734 | updateMouseGrab(); | 689 | updateMouseGrab(); | ||
735 | } | 690 | } | ||
736 | 691 | | |||
737 | // To accept "mainwindow#1" to "mainwindow#2" | | |||
738 | static QByteArray truncatedWindowRole(QByteArray a) | | |||
739 | { | | |||
740 | int i = a.indexOf('#'); | | |||
741 | if (i == -1) | | |||
742 | return a; | | |||
743 | QByteArray b(a); | | |||
744 | b.truncate(i); | | |||
745 | return b; | | |||
746 | } | | |||
747 | | ||||
748 | Client* Client::findAutogroupCandidate() const | | |||
749 | { | | |||
750 | // Attempt to find a similar window to the input. If we find multiple possibilities that are in | | |||
751 | // different groups then ignore all of them. This function is for automatic window grouping. | | |||
752 | Client *found = NULL; | | |||
753 | | ||||
754 | // See if the window has a group ID to match with | | |||
755 | QString wGId = rules()->checkAutogroupById(QString()); | | |||
756 | if (!wGId.isEmpty()) { | | |||
757 | foreach (Client *c, workspace()->clientList()) { | | |||
758 | if (activities() != c->activities()) | | |||
759 | continue; // don't cross activities | | |||
760 | if (wGId == c->rules()->checkAutogroupById(QString())) { | | |||
761 | if (found && found->tabGroup() != c->tabGroup()) { // We've found two, ignore both | | |||
762 | found = NULL; | | |||
763 | break; // Continue to the next test | | |||
764 | } | | |||
765 | found = c; | | |||
766 | } | | |||
767 | } | | |||
768 | if (found) | | |||
769 | return found; | | |||
770 | } | | |||
771 | | ||||
772 | // If this is a transient window don't take a guess | | |||
773 | if (isTransient()) | | |||
774 | return NULL; | | |||
775 | | ||||
776 | // If we don't have an ID take a guess | | |||
777 | if (rules()->checkAutogrouping(options->isAutogroupSimilarWindows())) { | | |||
778 | QByteArray wRole = truncatedWindowRole(windowRole()); | | |||
779 | foreach (Client *c, workspace()->clientList()) { | | |||
780 | if (desktop() != c->desktop() || activities() != c->activities()) | | |||
781 | continue; | | |||
782 | QByteArray wRoleB = truncatedWindowRole(c->windowRole()); | | |||
783 | if (resourceClass() == c->resourceClass() && // Same resource class | | |||
784 | wRole == wRoleB && // Same window role | | |||
785 | c->isNormalWindow()) { // Normal window TODO: Can modal windows be "normal"? | | |||
786 | if (found && found->tabGroup() != c->tabGroup()) // We've found two, ignore both | | |||
787 | return NULL; | | |||
788 | found = c; | | |||
789 | } | | |||
790 | } | | |||
791 | } | | |||
792 | | ||||
793 | return found; | | |||
794 | } | | |||
795 | | ||||
796 | } // namespace | 692 | } // namespace |