bismuth icon indicating copy to clipboard operation
bismuth copied to clipboard

[DEV]: Port to C++

Open gikari opened this issue 2 years ago • 8 comments

Summary

This issue tracks the progress towards the C++ port of Bismuth, which is the main road block for all new major features in Bismuth, such as #23 (Tray Applet) or #413 (Tabbed Layout) or #93 (Sublayouts).

Motivation

The port to C++ is a necessity, because:

  1. JavaScript runtime for KWin Scripting is limited and does not allow us to access the file system, dbus or KDE libraries. These are essential for providing the integration between KDE Plasma and the tiling.
  2. It is not desirable to create C++ QML modules for each of the above functions, while keeping the existing code intact. Forwarding data between language boundaries is a chore and is needed each time we want to add new functionality.
  3. TypeScript compiler and NPM are additional tools developers and packagers need to use, which complicates both processes. It would be better if those did not exist.
  4. QML JS runtime has some weird intricacies, such as bad module support, lack of informative debug info when things go wrong and in general is a very niche environment for big applications written in JavaScript. The less we touch it, the better.

Current status

No MVP yet.

Current work is being done in polonium branch. PR for this branch would be nice, but currently it is in a raw state without a good shape, so that making the actual PRs would be problematic.

Current plan for MVP:

  • [x] C++ KWin API wrappers
  • [x] New Layouting system, which internally allows for sublayouts
  • [x] Basic 3 layouts without an ability to rotate them:
    • [x] Tabbed (currently without tabs, previously monocle layout)
    • [x] Master Stack (previously Tile Layout)
    • [x] Floating Layout
  • [ ] Some of the existing keyboard shortcuts, which are usable with the above model.
  • [ ] Enable use of some settings:
    • [x] Gaps
    • [ ] Enable/Disable some layouts
    • [ ] Tabbed layout "Minimize unfocused windows"
    • [ ] Untile windows by dragging
    • [ ] Windows spawn location
    • [ ] Floating windows rules
    • [ ] Prevent window minimization
    • [ ] Disable tiling rules for screens
  • [ ] Porting Scripts for users from previous version, so that their setup would not break substantially (i.e. shortcuts and settings are kept).

Once MVP is ready, the next steps are:

  • [ ] Readd some features, which will be considered essential
  • [ ] Quality Assurance (The most important step)

gikari avatar Apr 04 '22 16:04 gikari

Hi, @gikari - I started using bismuth yesterday, and it's well built! I appreciate your work on this so far, however - I observed through some comments that there is a feature freeze for Bismuth till the code is ported to C++ as it helps more in adding features.

I can understand it's difficult for you to solely put all the efforts in the limited time you might have, to push Bismuth forward, and I'm looking forward to helping. I was wondering if you are looking for help for this issue, or something else? I can help port the code to C++, and hopefully in the later issues, it will be too early to commit but I'm really eager to give it a try. :) Please let me know your thoughts. Again, thanks for all your work on this! ❤️

krshrimali avatar Jun 18 '22 04:06 krshrimali

I can understand it's difficult for you to solely put all the efforts in the limited time you might have, to push Bismuth forward, and I'm looking forward to helping. I was wondering if you are looking for help for this issue, or something else? I can help port the code to C++, and hopefully in the later issues, it will be too early to commit but I'm really eager to give it a try. :) Please let me know your thoughts. Again, thanks for all your work on this! ❤️

Yes, thank you. I can use some help. You're welcome to make PRs, that make the C++ port a little closer to the finish.

There is hidden config option experimentalBackend, that you can enable to test the port. Now it's pretty limited, but it's a starting point, so that you can restore some of features on top.

Also, there is probably a bug with Plasma 5.25, that breaks Bismuth. I suggest looking into it and fixing it ASAP. It's probably has to do something with recent refactorings in KWin, so that signals are not properly connected. Basically, we are using AbstractClient instead of Window, that was recently added in KWin 5.25.

I indeed do not have time currently for working on Bismuth myself, but you can ask me questions, and I will try to review your future PRs, when I have the time. Making a C++ port is not easy, since it requires some specific knowledge about how KWin Scripting works internally, although there are some examples on how to do it in the code already.

gikari avatar Jun 18 '22 08:06 gikari

Thank you, @gikari - I appreciate the response. I was looking at existing ports, and from this issue, it seems like Monocle layout is ported, right? However, the file: https://github.com/Bismuth-Forge/bismuth/blob/master/src/kwinscript/engine/layout/monocle_layout.ts looks quite different to https://github.com/Bismuth-Forge/bismuth/blob/master/src/core/engine/layout/monocle.cpp. Am I looking at the wrong file combination here? Just trying to understand from what ports were done before, in order to try porting rest of them.

krshrimali avatar Jun 20 '22 05:06 krshrimali

Thank you, @gikari - I appreciate the response. I was looking at existing ports, and from this issue, it seems like Monocle layout is ported, right? However, the file: https://github.com/Bismuth-Forge/bismuth/blob/master/src/kwinscript/engine/layout/monocle_layout.ts looks quite different to https://github.com/Bismuth-Forge/bismuth/blob/master/src/core/engine/layout/monocle.cpp. Am I looking at the wrong file combination here? Just trying to understand from what ports were done before, in order to try porting rest of them.

Yes, you're right, it looks different. That's because what the port essentially is - the rewrite from ground up. I.e. it is not a 1:1 copy, because it's just not possible for technical reasons.

I tried to simplify some stuff along the way, so something could be missing, so if you want to port some other layouts (that would probably be my point of start, if I would be able to do some porting right now) and don't see something in the new C++ code, that was in TS code, you can add it, if necessary.

gikari avatar Jun 20 '22 08:06 gikari

It is actually really hard to make a port with incremental changes at the current state. So currently, development of C++ port is done on polonium branch, where everything related to TypeScript, ESBuild and NPM is deleted. It's in fact a full rewrite with breaking changes, where some features are missing. It's not ready to use yet (heavy WIP). But the backbone (KWin API wrappers) is done. The next steps will be a lot easier in terms of R&D, however, my personal time is very limited.

The current plan is to write some kind of MVP with limited number of features and then expand it with what we have on the master branch with some adjustments.

gikari avatar Sep 13 '22 17:09 gikari

@gikari Is there a roadmap or laundry list of items for MVP for polonium? Asking because I'd like to try and take a stab at helping out (assuming my C++ skills are up to snuff).

zangman avatar Sep 23 '22 10:09 zangman

@gikari Is there a roadmap or laundry list of items for MVP for polonium? Asking because I'd like to try and take a stab at helping out (assuming my C++ skills are up to snuff).

There is a checklist in the description.

gikari avatar Sep 23 '22 10:09 gikari

Hi, noticed this was recently unpinned, and no commits since September - could I inquire as to the current status of polonium?

atagen avatar Dec 23 '22 05:12 atagen