Skip to content

Fix multiple windows and tabs support #1739

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 6, 2025

Conversation

Yaraslaut
Copy link
Member

@Yaraslaut Yaraslaut commented Mar 23, 2025

closes #1725
closes #1728
closes #1729
closes #1730

@github-actions github-actions bot added VT: Backend Virtual Terminal Backend (libterminal API) frontend Contour Terminal Emulator (GUI frontend) labels Mar 23, 2025
@Yaraslaut Yaraslaut force-pushed the fix/tabs_and_multiple_windows branch 2 times, most recently from 205b526 to b1a89f7 Compare March 26, 2025 21:39
@Yaraslaut Yaraslaut changed the title initial take on multiple windows support Fix multiple windows and tabs support Mar 26, 2025
@Yaraslaut Yaraslaut requested a review from Copilot April 4, 2025 20:26
@Yaraslaut Yaraslaut marked this pull request as ready for review April 4, 2025 20:27
@Yaraslaut Yaraslaut force-pushed the fix/tabs_and_multiple_windows branch from b1a89f7 to 502cd09 Compare April 4, 2025 20:27
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • metainfo.xml: Language not supported

@Yaraslaut Yaraslaut force-pushed the fix/tabs_and_multiple_windows branch 2 times, most recently from 6c4e0c3 to 5723019 Compare April 16, 2025 15:43
@Yaraslaut Yaraslaut force-pushed the fix/tabs_and_multiple_windows branch from 5723019 to 2ac0fda Compare April 27, 2025 15:57
@github-actions github-actions bot added the CMake label May 20, 2025
@Yaraslaut Yaraslaut force-pushed the fix/tabs_and_multiple_windows branch 2 times, most recently from c1747bf to d9d554c Compare May 29, 2025 19:55
@github-actions github-actions bot added the CI GitHub Actions & CI label May 29, 2025
Copy link
Member

@christianparpart christianparpart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one thing I've committed and pushed right away, but some more comments I still wanted to leave :)

@Yaraslaut Yaraslaut force-pushed the fix/tabs_and_multiple_windows branch 4 times, most recently from cd91d85 to 20e0a01 Compare June 1, 2025 18:07
@Yaraslaut Yaraslaut requested a review from Copilot June 1, 2025 18:07
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements support for multiple windows and tabs by tracking sessions per display, adding handlers to properly close sessions on window close or termination, and introduces atomic flags to coordinate session creation and switching.

  • Add onClosing QML handler to remove a session when its window closes
  • Update termination logic to choose between closing a window or a tab via canCloseWindow()
  • Implement a displayStates map in TerminalSessionManager to manage sessions per display

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/contour/ui/main.qml Added onClosing handler to call terminalSessions.closeWindow()
src/contour/ui/Terminal.qml Changed onTerminated to use canCloseWindow() for window vs tab
src/contour/display/TerminalDisplay.h Removed outdated comment about single-terminal limitation
src/contour/display/TerminalDisplay.cpp Notify session manager on focus-in event
src/contour/TerminalSessionManager.h Added displayStates, closeWindow, canCloseWindow, etc.
src/contour/TerminalSessionManager.cpp Major multi-display/session logic, focus management, and closing
src/contour/TerminalSession.h Exposed getTerminalManager()
src/contour/TerminalSession.cpp Notify manager on session termination and coordinate new tabs
src/contour/ContourGuiApp.cpp Removed direct display assignment in newWindow()
metainfo.xml Documented the multiple windows/tabs fix
CMakeLists.txt Added /bigobj compile flag for MSVC
.github/actions/spelling/allow/uncategorized.txt Allowed bigobj in spelling whitelist
Comments suppressed due to low confidence (3)

src/contour/TerminalSessionManager.h:59

  • [nitpick] Method name FocusOnDisplay uses uppercase first letter, but other methods use lowerCamelCase. Rename it to focusOnDisplay for consistency.
void FocusOnDisplay(display::TerminalDisplay* display);

src/contour/TerminalSessionManager.cpp:384

  • New logic in tryFindSessionForDisplayOrClose and window/tab management is complex; consider adding unit tests to cover behavior when sessions equal, exceed, or are fewer than displays.
void TerminalSessionManager::tryFindSessionForDisplayOrClose()

src/contour/ui/Terminal.qml:199

  • The else branch for closing a tab was removed; if canCloseWindow() is false, nothing happens. Restore or add a fallback to call terminalSessions.closeTab().
if (terminalSessions.canCloseWindow())

@Yaraslaut Yaraslaut force-pushed the fix/tabs_and_multiple_windows branch 3 times, most recently from 222a3ae to a113497 Compare June 1, 2025 18:57
@Yaraslaut Yaraslaut force-pushed the fix/tabs_and_multiple_windows branch from a113497 to 2b417aa Compare June 15, 2025 12:23
@christianparpart christianparpart force-pushed the fix/tabs_and_multiple_windows branch from 2b417aa to a2aa73f Compare June 21, 2025 08:39
@Yaraslaut
Copy link
Member Author

I tested this on windows and it is save to use in release build, debug might throw here and there issues because of the state verification but this is timing issues with windows and we check it on linux more thoughtful

Copy link
Member

@christianparpart christianparpart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do this! 😄

@christianparpart christianparpart merged commit 598eb09 into master Jul 6, 2025
33 checks passed
@christianparpart christianparpart deleted the fix/tabs_and_multiple_windows branch July 6, 2025 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI GitHub Actions & CI CMake frontend Contour Terminal Emulator (GUI frontend) VT: Backend Virtual Terminal Backend (libterminal API)
Projects
None yet
2 participants