mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-11-26 06:45:58 +01:00
Added some EWMH
This commit is contained in:
parent
7da0c70be8
commit
88546490ea
4 changed files with 39 additions and 43 deletions
|
@ -107,6 +107,9 @@ void Events::eventDestroy(xcb_generic_event_t* event) {
|
|||
|
||||
// refocus on new window
|
||||
g_pWindowManager->refocusWindowOnClosed();
|
||||
|
||||
// EWMH
|
||||
EWMH::updateClientList();
|
||||
}
|
||||
|
||||
void Events::eventUnmapWindow(xcb_generic_event_t* event) {
|
||||
|
@ -130,6 +133,9 @@ void Events::eventUnmapWindow(xcb_generic_event_t* event) {
|
|||
|
||||
// refocus on new window
|
||||
g_pWindowManager->refocusWindowOnClosed();
|
||||
|
||||
// EWMH
|
||||
EWMH::updateClientList();
|
||||
}
|
||||
|
||||
CWindow* Events::remapFloatingWindow(int windowID, int forcemonitor) {
|
||||
|
@ -187,7 +193,7 @@ CWindow* Events::remapFloatingWindow(int windowID, int forcemonitor) {
|
|||
const auto wm_type_cookiereply = xcb_get_property_reply(g_pWindowManager->DisplayConnection, wm_type_cookie, NULL);
|
||||
xcb_atom_t TYPEATOM = NULL;
|
||||
if (wm_type_cookiereply == NULL || xcb_get_property_value_length(wm_type_cookiereply) < 1) {
|
||||
Debug::log(LOG, "No preferred type found.");
|
||||
Debug::log(LOG, "No preferred type found. (RemapFloatingWindow)");
|
||||
} else {
|
||||
const auto ATOMS = (xcb_atom_t*)xcb_get_property_value(wm_type_cookiereply);
|
||||
if (!ATOMS) {
|
||||
|
@ -405,6 +411,9 @@ void Events::eventMapWindow(xcb_generic_event_t* event) {
|
|||
// Set not under
|
||||
pNewWindow->setUnderFullscreen(false);
|
||||
pNewWindow->setDirty(true);
|
||||
|
||||
// EWMH
|
||||
EWMH::updateClientList();
|
||||
}
|
||||
|
||||
void Events::eventButtonPress(xcb_generic_event_t* event) {
|
||||
|
|
|
@ -29,5 +29,27 @@ void EWMH::setupInitEWMH() {
|
|||
|
||||
xcb_change_property(g_pWindowManager->DisplayConnection, XCB_PROP_MODE_REPLACE, g_pWindowManager->Screen->root, HYPRATOMS["_NET_SUPPORTED"], XCB_ATOM_ATOM, 32, sizeof(supportedAtoms) / sizeof(xcb_atom_t), supportedAtoms);
|
||||
|
||||
// delete workarea
|
||||
xcb_delete_property(g_pWindowManager->DisplayConnection, g_pWindowManager->Screen->root, HYPRATOMS["_NET_WORKAREA"]);
|
||||
|
||||
Debug::log(LOG, "EWMH init done.");
|
||||
}
|
||||
|
||||
void EWMH::updateCurrentWindow(xcb_window_t w) {
|
||||
xcb_change_property(g_pWindowManager->DisplayConnection, XCB_PROP_MODE_REPLACE, g_pWindowManager->Screen->root, HYPRATOMS["_NET_ACTIVE_WINDOW"], XCB_ATOM_WINDOW, 32, 1, &w);
|
||||
}
|
||||
|
||||
void EWMH::updateClientList() {
|
||||
std::vector<xcb_window_t> windowsList;
|
||||
for (auto& w : g_pWindowManager->windows)
|
||||
if (w.getDrawable() > 0)
|
||||
windowsList.push_back(w.getDrawable());
|
||||
for (auto& w : g_pWindowManager->unmappedWindows)
|
||||
windowsList.push_back(w.getDrawable());
|
||||
|
||||
// hack
|
||||
xcb_window_t* ArrWindowList = &windowsList[0];
|
||||
|
||||
xcb_change_property(g_pWindowManager->DisplayConnection, XCB_PROP_MODE_REPLACE, g_pWindowManager->Screen->root, HYPRATOMS["_NET_CLIENT_LIST"], XCB_ATOM_WINDOW,
|
||||
32, windowsList.size(), ArrWindowList);
|
||||
}
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
namespace EWMH {
|
||||
void setupInitEWMH();
|
||||
void updateCurrentWindow(xcb_window_t);
|
||||
void updateClientList();
|
||||
|
||||
inline xcb_window_t EWMHwindow = 0;
|
||||
};
|
|
@ -447,6 +447,9 @@ void CWindowManager::setFocusedWindow(xcb_drawable_t window) {
|
|||
|
||||
// set focus in X11
|
||||
xcb_set_input_focus(DisplayConnection, XCB_INPUT_FOCUS_POINTER_ROOT, window, XCB_CURRENT_TIME);
|
||||
|
||||
// EWMH
|
||||
EWMH::updateCurrentWindow(LastWindow);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -526,46 +529,6 @@ void CWindowManager::sanityCheckOnWorkspace(int workspaceID) {
|
|||
Debug::log(ERR, "Malformed node ID " + std::to_string(w.getDrawable()) + " with 2 children but one or both are nullptr.");
|
||||
}
|
||||
}
|
||||
|
||||
// Check #3: Check if the window exists with xcb
|
||||
// Some windows do not report they are dead for w/e reason
|
||||
if (w.getDrawable() > 0) {
|
||||
const auto GEOMETRYCOOKIE = xcb_get_geometry(g_pWindowManager->DisplayConnection, w.getDrawable());
|
||||
const auto GEOMETRY = xcb_get_geometry_reply(g_pWindowManager->DisplayConnection, GEOMETRYCOOKIE, 0);
|
||||
|
||||
if (!GEOMETRY || (GEOMETRY->width < 1 || GEOMETRY->height < 1)) {
|
||||
Debug::log(LOG, "Found a dead window, ID: " + std::to_string(w.getDrawable()) + ", removing it.");
|
||||
|
||||
closeWindowAllChecks(w.getDrawable());
|
||||
continue;
|
||||
}
|
||||
|
||||
// Type 2: is hidden.
|
||||
const auto window = w.getDrawable();
|
||||
PROP(wm_type_cookie, HYPRATOMS["_NET_WM_WINDOW_TYPE"], UINT32_MAX);
|
||||
|
||||
if (wm_type_cookiereply == NULL || xcb_get_property_value_length(wm_type_cookiereply) < 1) {
|
||||
Debug::log(LOG, "No preferred type found.");
|
||||
} else {
|
||||
const auto ATOMS = (xcb_atom_t*)xcb_get_property_value(wm_type_cookiereply);
|
||||
if (!ATOMS) {
|
||||
Debug::log(ERR, "Atoms not found in preferred type!");
|
||||
} else {
|
||||
if (xcbContainsAtom(wm_type_cookiereply, HYPRATOMS["_NET_WM_STATE_HIDDEN"])) {
|
||||
// delete it
|
||||
// NOTE: this is NOT the cause of windows in tray not being able
|
||||
// to open.
|
||||
free(wm_type_cookiereply);
|
||||
|
||||
Debug::log(LOG, "Found a dead window, ID: " + std::to_string(w.getDrawable()) + ", removing it.");
|
||||
|
||||
closeWindowAllChecks(w.getDrawable());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(wm_type_cookiereply);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1591,7 +1554,7 @@ bool CWindowManager::shouldBeFloatedOnInit(int64_t window) {
|
|||
xcb_atom_t TYPEATOM = NULL;
|
||||
|
||||
if (wm_type_cookiereply == NULL || xcb_get_property_value_length(wm_type_cookiereply) < 1) {
|
||||
Debug::log(LOG, "No preferred type found.");
|
||||
Debug::log(LOG, "No preferred type found. (shouldBeFloatedOnInit)");
|
||||
} else {
|
||||
const auto ATOMS = (xcb_atom_t*)xcb_get_property_value(wm_type_cookiereply);
|
||||
if (!ATOMS) {
|
||||
|
@ -1642,7 +1605,7 @@ void CWindowManager::doPostCreationChecks(CWindow* pWindow) {
|
|||
PROP(wm_type_cookie, HYPRATOMS["_NET_WM_WINDOW_TYPE"], UINT32_MAX);
|
||||
|
||||
if (wm_type_cookiereply == NULL || xcb_get_property_value_length(wm_type_cookiereply) < 1) {
|
||||
Debug::log(LOG, "No preferred type found.");
|
||||
Debug::log(LOG, "No preferred type found. (doPostCreationChecks)");
|
||||
} else {
|
||||
const auto ATOMS = (xcb_atom_t*)xcb_get_property_value(wm_type_cookiereply);
|
||||
if (!ATOMS) {
|
||||
|
|
Loading…
Reference in a new issue