mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 23:45:58 +01:00
feat: dispatcher, add workspace renaming (#1336)
* feat: dispatcher, add workspace renaming Co-authored-by: vaxerski <vaxry@vaxry.net>
This commit is contained in:
parent
b1104b1ca7
commit
3173fbdc4a
4 changed files with 33 additions and 2 deletions
|
@ -391,11 +391,10 @@ void CCompositor::startCompositor() {
|
||||||
if (sd_booted() > 0)
|
if (sd_booted() > 0)
|
||||||
// tell systemd that we are ready so it can start other bond, following, related units
|
// tell systemd that we are ready so it can start other bond, following, related units
|
||||||
sd_notify(0, "READY=1");
|
sd_notify(0, "READY=1");
|
||||||
else
|
else
|
||||||
Debug::log(LOG, "systemd integration is baked in but system itself is not booted à la systemd!");
|
Debug::log(LOG, "systemd integration is baked in but system itself is not booted à la systemd!");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// This blocks until we are done.
|
// This blocks until we are done.
|
||||||
Debug::log(LOG, "Hyprland is ready, running the event loop!");
|
Debug::log(LOG, "Hyprland is ready, running the event loop!");
|
||||||
wl_display_run(m_sWLDisplay);
|
wl_display_run(m_sWLDisplay);
|
||||||
|
@ -2071,6 +2070,20 @@ CWorkspace* CCompositor::createNewWorkspace(const int& id, const int& monid, con
|
||||||
return PWORKSPACE;
|
return PWORKSPACE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CCompositor::renameWorkspace(const int& id, const std::string& name) {
|
||||||
|
const auto PWORKSPACE = getWorkspaceByID(id);
|
||||||
|
|
||||||
|
if (!PWORKSPACE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (isWorkspaceSpecial(id))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Debug::log(LOG, "renameWorkspace: Renaming workspace %d to '%s'", id, name);
|
||||||
|
wlr_ext_workspace_handle_v1_set_name(PWORKSPACE->m_pWlrHandle, name.c_str());
|
||||||
|
PWORKSPACE->m_szName = name;
|
||||||
|
}
|
||||||
|
|
||||||
void CCompositor::setActiveMonitor(CMonitor* pMonitor) {
|
void CCompositor::setActiveMonitor(CMonitor* pMonitor) {
|
||||||
if (m_pLastMonitor == pMonitor)
|
if (m_pLastMonitor == pMonitor)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -171,6 +171,7 @@ class CCompositor {
|
||||||
void forceReportSizesToWindowsOnWorkspace(const int&);
|
void forceReportSizesToWindowsOnWorkspace(const int&);
|
||||||
bool cursorOnReservedArea();
|
bool cursorOnReservedArea();
|
||||||
CWorkspace* createNewWorkspace(const int&, const int&, const std::string& name = ""); // will be deleted next frame if left empty and unfocused!
|
CWorkspace* createNewWorkspace(const int&, const int&, const std::string& name = ""); // will be deleted next frame if left empty and unfocused!
|
||||||
|
void renameWorkspace(const int&, const std::string& name = "");
|
||||||
void setActiveMonitor(CMonitor*);
|
void setActiveMonitor(CMonitor*);
|
||||||
bool isWorkspaceSpecial(const int&);
|
bool isWorkspaceSpecial(const int&);
|
||||||
int getNewSpecialID();
|
int getNewSpecialID();
|
||||||
|
|
|
@ -10,6 +10,7 @@ CKeybindManager::CKeybindManager() {
|
||||||
m_mDispatchers["closewindow"] = kill;
|
m_mDispatchers["closewindow"] = kill;
|
||||||
m_mDispatchers["togglefloating"] = toggleActiveFloating;
|
m_mDispatchers["togglefloating"] = toggleActiveFloating;
|
||||||
m_mDispatchers["workspace"] = changeworkspace;
|
m_mDispatchers["workspace"] = changeworkspace;
|
||||||
|
m_mDispatchers["renameworkspace"] = renameWorkspace;
|
||||||
m_mDispatchers["fullscreen"] = fullscreenActive;
|
m_mDispatchers["fullscreen"] = fullscreenActive;
|
||||||
m_mDispatchers["fakefullscreen"] = fakeFullscreenActive;
|
m_mDispatchers["fakefullscreen"] = fakeFullscreenActive;
|
||||||
m_mDispatchers["movetoworkspace"] = moveActiveToWorkspace;
|
m_mDispatchers["movetoworkspace"] = moveActiveToWorkspace;
|
||||||
|
@ -1289,6 +1290,21 @@ void CKeybindManager::workspaceOpt(std::string args) {
|
||||||
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(g_pCompositor->m_pLastMonitor->ID);
|
g_pLayoutManager->getCurrentLayout()->recalculateMonitor(g_pCompositor->m_pLastMonitor->ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CKeybindManager::renameWorkspace(std::string args) {
|
||||||
|
try {
|
||||||
|
const auto FIRSTSPACEPOS = args.find_first_of(' ');
|
||||||
|
if (FIRSTSPACEPOS != std::string::npos) {
|
||||||
|
int workspace = std::stoi(args.substr(0, FIRSTSPACEPOS));
|
||||||
|
std::string name = args.substr(FIRSTSPACEPOS + 1);
|
||||||
|
g_pCompositor->renameWorkspace(workspace, name);
|
||||||
|
} else {
|
||||||
|
g_pCompositor->renameWorkspace(std::stoi(args), "");
|
||||||
|
}
|
||||||
|
} catch (std::exception& e) {
|
||||||
|
Debug::log(ERR, "Invalid arg in renameWorkspace, expected numeric id only or a numeric id and string name. \"%s\": \"%s\"", args.c_str(), e.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CKeybindManager::exitHyprland(std::string argz) {
|
void CKeybindManager::exitHyprland(std::string argz) {
|
||||||
g_pCompositor->cleanup();
|
g_pCompositor->cleanup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,7 @@ class CKeybindManager {
|
||||||
static void toggleSplit(std::string);
|
static void toggleSplit(std::string);
|
||||||
static void moveCursorToCorner(std::string);
|
static void moveCursorToCorner(std::string);
|
||||||
static void workspaceOpt(std::string);
|
static void workspaceOpt(std::string);
|
||||||
|
static void renameWorkspace(std::string);
|
||||||
static void exitHyprland(std::string);
|
static void exitHyprland(std::string);
|
||||||
static void moveCurrentWorkspaceToMonitor(std::string);
|
static void moveCurrentWorkspaceToMonitor(std::string);
|
||||||
static void moveWorkspaceToMonitor(std::string);
|
static void moveWorkspaceToMonitor(std::string);
|
||||||
|
|
Loading…
Reference in a new issue