mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-11-22 13:35:57 +01:00
better window killing method
This commit is contained in:
parent
565bcd3e5f
commit
e9313fe3aa
6 changed files with 45 additions and 2 deletions
|
@ -89,7 +89,27 @@ xcb_keycode_t KeybindManager::getKeycodeFromKeysym(xcb_keysym_t keysym) {
|
|||
|
||||
void KeybindManager::killactive(std::string args) {
|
||||
// args unused
|
||||
xcb_destroy_window(g_pWindowManager->DisplayConnection, g_pWindowManager->LastWindow);
|
||||
const auto PLASTWINDOW = g_pWindowManager->getWindowFromDrawable(g_pWindowManager->LastWindow);
|
||||
|
||||
if (!PLASTWINDOW)
|
||||
return;
|
||||
|
||||
if (PLASTWINDOW->getCanKill()) {
|
||||
// Send a kill message
|
||||
xcb_client_message_event_t event;
|
||||
bzero(&event, sizeof(event));
|
||||
event.response_type = XCB_CLIENT_MESSAGE;
|
||||
event.window = PLASTWINDOW->getDrawable();
|
||||
event.type = HYPRATOMS["WM_PROTOCOLS"];
|
||||
event.format = 32;
|
||||
event.data.data32[0] = HYPRATOMS["WM_DELETE_WINDOW"];
|
||||
event.data.data32[1] = 0;
|
||||
|
||||
xcb_send_event(g_pWindowManager->DisplayConnection, 0, PLASTWINDOW->getDrawable(), XCB_EVENT_MASK_NO_EVENT, (const char*)&event);
|
||||
} else
|
||||
xcb_kill_client(g_pWindowManager->DisplayConnection, g_pWindowManager->LastWindow);
|
||||
|
||||
g_pWindowManager->closeWindowAllChecks(g_pWindowManager->LastWindow);
|
||||
}
|
||||
|
||||
void KeybindManager::call(std::string args) {
|
||||
|
@ -160,12 +180,14 @@ void KeybindManager::toggleActiveWindowFloating(std::string unusedArg) {
|
|||
const auto RESTOREACSIZE = PWINDOW->getDefaultSize();
|
||||
const auto RESTOREACPOS = PWINDOW->getDefaultPosition();
|
||||
const auto RESTOREWINID = PWINDOW->getDrawable();
|
||||
const auto RESTORECANKILL = PWINDOW->getCanKill();
|
||||
|
||||
g_pWindowManager->removeWindowFromVectorSafe(PWINDOW->getDrawable());
|
||||
const auto PNEWWINDOW = Events::remapWindow(RESTOREWINID, true);
|
||||
|
||||
PNEWWINDOW->setDefaultPosition(RESTOREACPOS);
|
||||
PNEWWINDOW->setDefaultSize(RESTOREACSIZE);
|
||||
PNEWWINDOW->setCanKill(RESTORECANKILL);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -308,6 +308,9 @@ void Events::eventMapWindow(xcb_generic_event_t* event) {
|
|||
|
||||
// Do post-creation checks.
|
||||
g_pWindowManager->doPostCreationChecks(pNewWindow);
|
||||
|
||||
// Do ICCCM
|
||||
g_pWindowManager->getICCCMWMProtocols(pNewWindow);
|
||||
}
|
||||
|
||||
void Events::eventButtonPress(xcb_generic_event_t* event) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "window.hpp"
|
||||
#include "windowManager.hpp"
|
||||
|
||||
CWindow::CWindow() { this->setImmovable(false); this->setNoInterventions(false); this->setDirty(true); this->setFullscreen(false); this->setIsFloating(false); this->setParentNodeID(0); this->setChildNodeAID(0); this->setChildNodeBID(0); this->setName(""); }
|
||||
CWindow::CWindow() { this->setCanKill(false); this->setImmovable(false); this->setNoInterventions(false); this->setDirty(true); this->setFullscreen(false); this->setIsFloating(false); this->setParentNodeID(0); this->setChildNodeAID(0); this->setChildNodeBID(0); this->setName(""); }
|
||||
CWindow::~CWindow() { }
|
||||
|
||||
void CWindow::generateNodeID() {
|
||||
|
|
|
@ -65,6 +65,9 @@ public:
|
|||
// Docks etc
|
||||
EXPOSED_MEMBER(Immovable, bool, b);
|
||||
EXPOSED_MEMBER(NoInterventions, bool, b);
|
||||
|
||||
// ICCCM
|
||||
EXPOSED_MEMBER(CanKill, bool, b);
|
||||
|
||||
|
||||
private:
|
||||
|
|
|
@ -1348,4 +1348,18 @@ void CWindowManager::doPostCreationChecks(CWindow* pWindow) {
|
|||
|
||||
Debug::log(LOG, "Post creation checks ended");
|
||||
//
|
||||
}
|
||||
|
||||
void CWindowManager::getICCCMWMProtocols(CWindow* pWindow) {
|
||||
xcb_icccm_get_wm_protocols_reply_t WMProtocolsReply;
|
||||
if (!xcb_icccm_get_wm_protocols_reply(DisplayConnection,
|
||||
xcb_icccm_get_wm_protocols(DisplayConnection, pWindow->getDrawable(), HYPRATOMS["WM_PROTOCOLS"]), &WMProtocolsReply, NULL))
|
||||
return;
|
||||
|
||||
for (auto i = 0; i < (int)WMProtocolsReply.atoms_len; i++) {
|
||||
if (WMProtocolsReply.atoms[i] == HYPRATOMS["WM_DELETE_WINDOW"])
|
||||
pWindow->setCanKill(true);
|
||||
}
|
||||
|
||||
xcb_icccm_get_wm_protocols_reply_wipe(&WMProtocolsReply);
|
||||
}
|
|
@ -95,6 +95,7 @@ public:
|
|||
|
||||
bool shouldBeFloatedOnInit(int64_t);
|
||||
void doPostCreationChecks(CWindow*);
|
||||
void getICCCMWMProtocols(CWindow*);
|
||||
|
||||
void setupRandrMonitors();
|
||||
void createAndOpenAllPipes();
|
||||
|
|
Loading…
Reference in a new issue