mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-11-07 16:35:59 +01:00
manage non-classed windows but added a shouldbemanaged check
This commit is contained in:
parent
1528659eeb
commit
d84d56a7ee
5 changed files with 53 additions and 11 deletions
|
@ -175,11 +175,6 @@ CWindow* Events::remapFloatingWindow(int windowID, int forcemonitor) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (PWINDOWINARR->getClassName() == "") {
|
||||
Debug::log(WARN, "remapFloatingWindow with Error, not managing.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
PWINDOWINARR->setIsFloating(true);
|
||||
PWINDOWINARR->setDirty(true);
|
||||
|
||||
|
@ -420,11 +415,6 @@ CWindow* Events::remapWindow(int windowID, bool wasfloating, int forcemonitor) {
|
|||
Debug::log(ERR, "remapWindow called with an invalid window!");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (PWINDOWINARR->getClassName() == "Error") {
|
||||
Debug::log(LOG, "Class error -> we wont manage this.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
PWINDOWINARR->setIsFloating(false);
|
||||
|
@ -622,6 +612,16 @@ void Events::eventMapWindow(xcb_generic_event_t* event) {
|
|||
|
||||
pNewWindow = g_pWindowManager->getWindowFromDrawable(E->window);
|
||||
} else {
|
||||
if (g_pWindowManager->getWindowFromDrawable(E->window)) {
|
||||
Debug::log(LOG, "Window already managed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!g_pWindowManager->shouldBeManaged(E->window)) {
|
||||
Debug::log(LOG, "window shouldn't be managed");
|
||||
return;
|
||||
}
|
||||
|
||||
CWindow window;
|
||||
window.setDrawable(E->window);
|
||||
g_pWindowManager->addWindowToVectorSafe(window);
|
||||
|
@ -635,7 +635,7 @@ void Events::eventMapWindow(xcb_generic_event_t* event) {
|
|||
}
|
||||
}
|
||||
|
||||
if (!pNewWindow || pNewWindow->getClassName() == "") {
|
||||
if (!pNewWindow) {
|
||||
Debug::log(LOG, "Removing, NULL.");
|
||||
g_pWindowManager->removeWindowFromVectorSafe(E->window);
|
||||
return;
|
||||
|
|
|
@ -110,4 +110,19 @@ void removeAtom(const int& window, xcb_atom_t prop, xcb_atom_t atom) {
|
|||
|
||||
free(REPLY);
|
||||
xcb_ungrab_server(DisplayConnection);
|
||||
}
|
||||
|
||||
uint8_t getWindowState(const int& win) {
|
||||
uint32_t returns = 0;
|
||||
|
||||
const auto COOKIE = xcb_get_property(DisplayConnection, 0, win, HYPRATOMS["_NET_WM_STATE"], HYPRATOMS["_NET_WM_STATE"], 0L, 2L);
|
||||
const auto REPLY = xcb_get_property_reply(DisplayConnection, COOKIE, NULL);
|
||||
if (REPLY) {
|
||||
if (REPLY->type == HYPRATOMS["_NET_WM_STATE"] && REPLY->format == 32 && REPLY->length == 2) {
|
||||
returns = *((uint32_t*)xcb_get_property_value(REPLY));
|
||||
}
|
||||
|
||||
free(REPLY);
|
||||
}
|
||||
return returns;
|
||||
}
|
|
@ -7,5 +7,6 @@
|
|||
std::pair<std::string, std::string> getClassName(int64_t window);
|
||||
std::string getRoleName(int64_t window);
|
||||
std::string getWindowName(uint64_t window);
|
||||
uint8_t getWindowState(const int& win);
|
||||
|
||||
void removeAtom(const int& window, xcb_atom_t prop, xcb_atom_t atom);
|
|
@ -2277,3 +2277,27 @@ void CWindowManager::dispatchQueuedWarp() {
|
|||
warpCursorTo(QueuedPointerWarp);
|
||||
QueuedPointerWarp = Vector2D(-1,-1);
|
||||
}
|
||||
|
||||
bool CWindowManager::shouldBeManaged(const int& window) {
|
||||
const auto WINDOWATTRS = xcb_get_window_attributes_reply(DisplayConnection, xcb_get_window_attributes(DisplayConnection, window), NULL);
|
||||
|
||||
if (!WINDOWATTRS) {
|
||||
Debug::log(LOG, "Skipping: window attributes null");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (WINDOWATTRS->override_redirect) {
|
||||
Debug::log(LOG, "Skipping: override redirect");
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto GEOMETRY = xcb_get_geometry_reply(DisplayConnection, xcb_get_geometry(DisplayConnection, window), NULL);
|
||||
if (!GEOMETRY) {
|
||||
Debug::log(LOG, "Skipping: No geometry");
|
||||
return false;
|
||||
}
|
||||
|
||||
Debug::log(LOG, "shouldBeManaged passed!");
|
||||
|
||||
return true;
|
||||
}
|
|
@ -141,6 +141,8 @@ public:
|
|||
|
||||
void handleClientMessage(xcb_client_message_event_t*);
|
||||
|
||||
bool shouldBeManaged(const int&);
|
||||
|
||||
private:
|
||||
|
||||
// Internal WM functions that don't have to be exposed
|
||||
|
|
Loading…
Reference in a new issue