diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -3686,6 +3686,12 @@ break; case QEvent::FocusOut: case QEvent::FocusIn: + if(_screenWindow) { + // force a redraw on focusIn, fixes the + // black screen bug when the view is focused + // but doesn't redraws. + _screenWindow->notifyOutputChanged(); + } update(); break; default: diff --git a/src/ViewContainer.h b/src/ViewContainer.h --- a/src/ViewContainer.h +++ b/src/ViewContainer.h @@ -159,9 +159,8 @@ * to append it. This index should be passed to addView() when the new view * has been created. * @param id The identifier of the view. - * @param sourceContainer Initial move event Tabbed view container. */ - void moveViewRequest(int index, int id, TabbedViewContainer *sourceContainer); + void moveViewRequest(int index, int sessionControllerId); /** Emitted when the active view changes */ void activeViewChanged(QWidget *view); diff --git a/src/ViewContainer.cpp b/src/ViewContainer.cpp --- a/src/ViewContainer.cpp +++ b/src/ViewContainer.cpp @@ -88,15 +88,7 @@ connect(tabBarWidget, &DetachableTabBar::detachTab, this, [this](int idx) { emit detachTab(this, widget(idx)); }); - connect(this, &TabbedViewContainer::currentChanged, this, [this](int index) { - if (index != -1) { - QWidget *view = widget(index); - view->setFocus(); - updateTabHistory(view); - } else { - deleteLater(); - } - }); + connect(this, &TabbedViewContainer::currentChanged, this, &TabbedViewContainer::currentTabChanged); // The context menu of tab bar _contextPopupMenu = new QMenu(tabBar()); @@ -161,7 +153,7 @@ const auto currentPos = QCursor::pos(); for(const auto dropWidget : widgets) { if (dropWidget->rect().contains(dropWidget->mapFromGlobal(currentPos))) { - emit dropWidget->moveViewRequest(-1, id, this); + emit dropWidget->moveViewRequest(-1, id); removeView(widget(index)); } } @@ -449,13 +441,15 @@ void TabbedViewContainer::currentTabChanged(int index) { - setCurrentIndex(index); - if (widget(index) != nullptr) { - emit activeViewChanged(widget(index)); + if (index != -1) { + QWidget *view = widget(index); + view->setFocus(); + updateTabHistory(view); + emit activeViewChanged(view); + setTabActivity(index, false); + } else { + deleteLater(); } - - // clear activity indicators - setTabActivity(index, false); } void TabbedViewContainer::wheelScrolled(int delta) diff --git a/src/ViewManager.h b/src/ViewManager.h --- a/src/ViewManager.h +++ b/src/ViewManager.h @@ -375,8 +375,7 @@ // called when a ViewContainer requests a view be // moved - void containerMoveViewRequest(int index, int id, - TabbedViewContainer *sourceTabbedContainer); + void containerMoveViewRequest(int index, int sessionControllerId); void detachView(TabbedViewContainer *container, QWidget *view); diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -465,20 +465,17 @@ { TabbedViewContainer *container = createContainer(); - // iterate over each session which has a view in the current active - // container and create a new view for that session in a new container - for(int i = 0, end = _viewSplitter->activeContainer()->count(); i < end; i++) { - auto view = _viewSplitter->activeContainer()->widget(i); - Session *session = _sessionMap[qobject_cast(view)]; - TerminalDisplay *display = createTerminalDisplay(session); - const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session); - applyProfileToView(display, profile); - ViewProperties *properties = createController(session, display); - - _sessionMap[display] = session; - - container->addView(display, properties); - session->addView(display); + if (_viewSplitter->activeContainer()->count()) { + // get the currently applied profile and use it to create the new tab. + auto *activeContainer= _viewSplitter->activeContainer(); + auto *currentDisplay = qobject_cast(activeContainer->currentWidget()); + auto profile = SessionManager::instance()->sessionProfile(_sessionMap[currentDisplay]); + + // Create a new session with the selected profile. + auto *session = SessionManager::instance()->createSession(profile); + session->addEnvironmentEntry(QStringLiteral("KONSOLE_DBUS_WINDOW=/Windows/%1").arg(managerId())); + + createView(session, container, 0); } _viewSplitter->addContainer(container, orientation); @@ -638,12 +635,7 @@ index = _viewSplitter->activeContainer()->currentIndex() + 1; } - // iterate over the view containers owned by this view manager - // and create a new terminal display for the session in each of them, along with - // a controller for the session/display pair - foreach (TabbedViewContainer *container, _viewSplitter->containers()) { - createView(session, container, index); - } + createView(session, _viewSplitter->activeContainer(), index); } TabbedViewContainer *ViewManager::createContainer() @@ -682,34 +674,16 @@ return container; } -void ViewManager::containerMoveViewRequest(int index, int id, - TabbedViewContainer *sourceTabbedContainer) +void ViewManager::containerMoveViewRequest(int index, int id) { auto *container = qobject_cast(sender()); auto *controller = qobject_cast(ViewProperties::propertiesById(id)); - - if (controller == nullptr) { - return; - } - - // do not move the last tab in a split view. - if (sourceTabbedContainer != nullptr) { - QPointer sourceContainer = qobject_cast(sourceTabbedContainer); - - if (_viewSplitter->containers().contains(sourceContainer)) { - return; - } else { - ViewManager *sourceViewManager = sourceTabbedContainer->connectedViewManager(); - - // do not remove the last tab on the window - if (qobject_cast(sourceViewManager->widget())->containers().size() > 1) { - return; - } - } - } + Q_ASSERT(container); + Q_ASSERT(controller); createView(controller->session(), container, index); controller->session()->refresh(); + container->currentWidget()->setFocus(); } void ViewManager::setNavigationMethod(NavigationMethod method)