contour-terminal / contour

Modern C++ Terminal Emulator
http://contour-terminal.org/
Apache License 2.0
2.37k stars 102 forks source link

Possible Integration with tabbed? #1358

Open xinslu opened 8 months ago

xinslu commented 8 months ago

Hi, really like the work done with this terminal. I was just wondering if it was possible to use the tabbing utility from suckless, tabbed (https://tools.suckless.org/tabbed/) along with contour. Other terminals like alacritty allow the ability to embed using the --embed flag allowing integration. Could this possibly pursued be as a short term solution to UI tab? I didn't mark this as a feature request because I'm not sure if something needs to be changed.

christianparpart commented 8 months ago

Nice idea. And many thanks for the interest .

We should just find out how to do that when working with Qt library, which we use for the frontend. 🤔

ghost commented 8 months ago

We should just find out how to do that when working with Qt library, which we use for the frontend. 🤔

Qt has a QTabWidget widget that can replace the current central widget in the main window. This does exactly what is needed and only really needs reorder, tab close, new tab, and tab naming schemes. With a bit of theming it can be implemented quite nicely into the terminal look and feel.

Now, if you want to have trees... that's a little more complex

christianparpart commented 8 months ago

I tried looking up how to do embedd a QML application into an external window that is only known by its Window Id. I could not really find anything (only very old Qt 4.8-style way that would have accepted a Window-Id).

NB: On tabbed support, I planned using: https://github.com/antonypro/QGoodWindow

christianparpart commented 8 months ago

Update: I may have found a way to get this implemented for Qt based applications (like Contour) via QWindow::fromId(WId embedInto)

PoC draft

// Target window to embed into
unsigned int windowId = 0x12345;

// Convert window ID to native X11 window handle
Window nativeWindow = XGetWindow(display, XDefaultRootWindow(display), windowId);

// Create a QWindow from the native window
QWindow* qWindow = QWindow::fromWinId(nativeWindow);

// Create a QWidget from the QWindow
QWidget* embeddedWidget = QWidget::createWindowContainer(qWindow);

// Add contour QML app here (?)
QQuickView* qmlView = new QQuickView();
embeddedWidget->layout()->addWidget(qmlView);

// Parent the embeddedWidget to the native window
embeddedWidget->setParent(nativeWindow);

// Show and manage the embeddedWidget
embeddedWidget->show();