2024-03-11 13:33:26 +01:00
|
|
|
//
|
|
|
|
// Created by grimmauld on 11.03.24.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef SWAYMUX_MOVETOSCRATCHPADKEYLISTENER_H
|
|
|
|
#define SWAYMUX_MOVETOSCRATCHPADKEYLISTENER_H
|
|
|
|
|
|
|
|
|
|
|
|
#include "AbstractKeyListener.h"
|
|
|
|
#include "../mainwindow.h"
|
|
|
|
#include "../sway_bindings/Formatter.h"
|
|
|
|
#include "../tree/SwayTreeModel.h"
|
|
|
|
|
2024-03-11 17:11:26 +01:00
|
|
|
class MoveToScratchpadKeyListener : public MainWindowAwareKeyListener {
|
2024-03-11 13:33:26 +01:00
|
|
|
public:
|
2024-03-11 17:11:26 +01:00
|
|
|
explicit MoveToScratchpadKeyListener(MainWindow *pWindow) : MainWindowAwareKeyListener(pWindow) {}
|
2024-03-11 13:33:26 +01:00
|
|
|
|
|
|
|
void handleKeyEvent(const QKeyEvent *keyEvent) const override {
|
2024-03-11 17:11:26 +01:00
|
|
|
std::set<int> containersToScratch = getSelectedContainerIds();
|
2024-03-11 13:33:26 +01:00
|
|
|
|
|
|
|
if (containersToScratch.empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
Formatter cmd;
|
|
|
|
for (auto id: containersToScratch) {
|
|
|
|
cmd << "[con_id=" << id << "] move scratchpad ; ";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::cout << cmd.str() << "\n";
|
|
|
|
auto resp = SwayTreeModel::sway.sendIPC(swaymsg(0, cmd.str()));
|
|
|
|
std::cout << resp.msg << "\n";
|
|
|
|
|
2024-03-11 17:11:26 +01:00
|
|
|
updateMainWindow();
|
2024-03-11 13:33:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string getDescription() override {
|
|
|
|
return "Move selected windows to scratchpad";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string getKeyText() override {
|
|
|
|
return "-";
|
|
|
|
}
|
|
|
|
|
|
|
|
[[nodiscard]] bool canAcceptKey(int key) const override {
|
|
|
|
return key == Qt::Key_Minus;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //SWAYMUX_MOVETOSCRATCHPADKEYLISTENER_H
|