mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-11-22 13:35:57 +01:00
parent
eb1d5f94d8
commit
da349a03b2
7 changed files with 33 additions and 7 deletions
|
@ -43,6 +43,7 @@ public:
|
|||
EXPOSED_MEMBER(MonitorID, int, i);
|
||||
EXPOSED_MEMBER(StatusCommand, std::string, sz); // TODO: make the bar better
|
||||
EXPOSED_MEMBER(LastWindowName, std::string, sz);
|
||||
EXPOSED_MEMBER(LastWindowClass, std::string, sz);
|
||||
EXPOSED_MEMBER(IsCovered, bool, b);
|
||||
|
||||
void draw();
|
||||
|
|
|
@ -108,12 +108,17 @@ std::string getCurrentWindowName() {
|
|||
return g_pWindowManager->statusBar->getLastWindowName();
|
||||
}
|
||||
|
||||
std::string getCurrentWindowClass() {
|
||||
return g_pWindowManager->statusBar->getLastWindowClass();
|
||||
}
|
||||
|
||||
std::string BarCommands::parsePercent(std::string token) {
|
||||
// check what the token is and act accordingly.
|
||||
|
||||
if (token == "RAM") return getRamString();
|
||||
else if (token == "CPU") return getCpuString();
|
||||
else if (token == "WINNAME") return getCurrentWindowName();
|
||||
else if (token == "WINCLASS") return getCurrentWindowClass();
|
||||
|
||||
Debug::log(ERR, "Unknown token while parsing module: %" + token + "%");
|
||||
|
||||
|
|
|
@ -105,6 +105,10 @@ CWindow* Events::remapFloatingWindow(int windowID, int forcemonitor) {
|
|||
Debug::log(LOG, "New window got name: " + WINNAME);
|
||||
window.setName(WINNAME);
|
||||
|
||||
const auto WINCLASSNAME = getClassName(windowID);
|
||||
Debug::log(LOG, "New window got class: " + WINCLASSNAME.second);
|
||||
window.setClassName(WINCLASSNAME.second);
|
||||
|
||||
// For all floating windows, get their default size
|
||||
const auto GEOMETRYCOOKIE = xcb_get_geometry(g_pWindowManager->DisplayConnection, windowID);
|
||||
const auto GEOMETRY = xcb_get_geometry_reply(g_pWindowManager->DisplayConnection, GEOMETRYCOOKIE, 0);
|
||||
|
@ -205,6 +209,10 @@ CWindow* Events::remapWindow(int windowID, bool wasfloating, int forcemonitor) {
|
|||
Debug::log(LOG, "New window got name: " + WINNAME);
|
||||
window.setName(WINNAME);
|
||||
|
||||
const auto WINCLASSNAME = getClassName(windowID);
|
||||
Debug::log(LOG, "New window got class: " + WINCLASSNAME.second);
|
||||
window.setClassName(WINCLASSNAME.second);
|
||||
|
||||
// For all floating windows, get their default size
|
||||
const auto GEOMETRYCOOKIE = xcb_get_geometry(g_pWindowManager->DisplayConnection, windowID);
|
||||
const auto GEOMETRY = xcb_get_geometry_reply(g_pWindowManager->DisplayConnection, GEOMETRYCOOKIE, 0);
|
||||
|
|
|
@ -67,16 +67,12 @@ void IPCSendMessage(const std::string path, SIPCMessageMainToBar smessage) {
|
|||
|
||||
message += IPC_MESSAGE_SEPARATOR + "barfullscreenwindow" + IPC_MESSAGE_EQUALITY + (smessage.fullscreenOnBar ? "1" : "0");
|
||||
|
||||
message += IPC_MESSAGE_SEPARATOR + "lastwindowname" + IPC_MESSAGE_EQUALITY;
|
||||
message += IPC_MESSAGE_SEPARATOR + "lastwindowname" + IPC_MESSAGE_EQUALITY + smessage.lastWindowName;
|
||||
|
||||
if (const auto PLASTWINDOW = g_pWindowManager->getWindowFromDrawable(g_pWindowManager->LastWindow); PLASTWINDOW) {
|
||||
message += PLASTWINDOW->getName() + IPC_MESSAGE_SEPARATOR;
|
||||
} else {
|
||||
message += IPC_MESSAGE_SEPARATOR;
|
||||
}
|
||||
message += IPC_MESSAGE_SEPARATOR + "lastwindowclass" + IPC_MESSAGE_EQUALITY + smessage.lastWindowClass;
|
||||
|
||||
// append the EOF
|
||||
message += IPC_END_OF_FILE;
|
||||
message += IPC_MESSAGE_SEPARATOR + IPC_END_OF_FILE;
|
||||
|
||||
// Send
|
||||
writeToIPCChannel(path, message);
|
||||
|
@ -137,6 +133,8 @@ void IPCRecieveMessageB(const std::string path) {
|
|||
std::sort(g_pWindowManager->statusBar->openWorkspaces.begin(), g_pWindowManager->statusBar->openWorkspaces.end());
|
||||
} else if (PROPNAME == "lastwindowname") {
|
||||
g_pWindowManager->statusBar->setLastWindowName(PROPVALUE);
|
||||
} else if (PROPNAME == "lastwindowclass") {
|
||||
g_pWindowManager->statusBar->setLastWindowClass(PROPVALUE);
|
||||
} else if (PROPNAME == "barfullscreenwindow") {
|
||||
g_pWindowManager->statusBar->setIsCovered(PROPVALUE == "1" ? true : false);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ struct SIPCMessageMainToBar {
|
|||
std::vector<int> openWorkspaces;
|
||||
uint64_t activeWorkspace;
|
||||
std::string lastWindowName;
|
||||
std::string lastWindowClass;
|
||||
bool fullscreenOnBar;
|
||||
};
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
// ------------------------------------- //
|
||||
|
||||
EXPOSED_MEMBER(Name, std::string, sz);
|
||||
EXPOSED_MEMBER(ClassName, std::string, sz);
|
||||
|
||||
// Tells the window manager to reload the window's params
|
||||
EXPOSED_MEMBER(Dirty, bool, b);
|
||||
|
|
|
@ -1191,7 +1191,9 @@ void CWindowManager::updateBarInfo() {
|
|||
|
||||
message.activeWorkspace = activeWorkspaces[getMonitorFromCursor()->ID];
|
||||
|
||||
|
||||
auto winname = getWindowFromDrawable(LastWindow) ? getWindowFromDrawable(LastWindow)->getName() : "";
|
||||
auto winclassname = getWindowFromDrawable(LastWindow) ? getWindowFromDrawable(LastWindow)->getClassName() : "";
|
||||
|
||||
for (auto& c : winname) {
|
||||
// Remove illegal chars
|
||||
|
@ -1201,8 +1203,18 @@ void CWindowManager::updateBarInfo() {
|
|||
c = ' ';
|
||||
}
|
||||
|
||||
for (auto& c : winclassname) {
|
||||
// Remove illegal chars
|
||||
if (c == '=')
|
||||
c = ' ';
|
||||
else if (c == '\t')
|
||||
c = ' ';
|
||||
}
|
||||
|
||||
message.lastWindowName = winname;
|
||||
|
||||
message.lastWindowClass = winclassname;
|
||||
|
||||
message.fullscreenOnBar = getWorkspaceByID(activeWorkspaces[ConfigManager::getInt("bar:monitor") > monitors.size() ? 0 : ConfigManager::getInt("bar:monitor")])->getHasFullscreenWindow();
|
||||
|
||||
for (auto& workspace : workspaces) {
|
||||
|
|
Loading…
Reference in a new issue