mirror of
https://github.com/hyprwm/Hypr.git
synced 2024-12-25 18:59:48 +01:00
Handle configure requests and GTK MOVERESIZE message
This commit is contained in:
parent
d12c35ce1b
commit
d8a7fd2a14
4 changed files with 61 additions and 1 deletions
|
@ -92,4 +92,9 @@
|
|||
#define RETURNIFBAR if (g_pWindowManager->statusBar) return;
|
||||
#define RETURNIFMAIN if (!g_pWindowManager->statusBar) return;
|
||||
|
||||
#define COLORDELTAOVERX(c, c1, d) (abs(RED(c) - RED(c1)) > d / 255.f || abs(GREEN(c) - GREEN(c1)) > d / 255.f || abs(BLUE(c) - BLUE(c1)) > d / 255.f || abs(ALPHA(c) - ALPHA(c1)) > d / 255.f)
|
||||
#define COLORDELTAOVERX(c, c1, d) (abs(RED(c) - RED(c1)) > d / 255.f || abs(GREEN(c) - GREEN(c1)) > d / 255.f || abs(BLUE(c) - BLUE(c1)) > d / 255.f || abs(ALPHA(c) - ALPHA(c1)) > d / 255.f)
|
||||
|
||||
#define _NET_MOVERESIZE_WINDOW_X (1 << 8)
|
||||
#define _NET_MOVERESIZE_WINDOW_Y (1 << 9)
|
||||
#define _NET_MOVERESIZE_WINDOW_WIDTH (1 << 10)
|
||||
#define _NET_MOVERESIZE_WINDOW_HEIGHT (1 << 11)
|
|
@ -863,6 +863,29 @@ void Events::eventClientMessage(xcb_generic_event_t* event) {
|
|||
}
|
||||
}
|
||||
|
||||
void Events::eventConfigure(xcb_generic_event_t* event) {
|
||||
const auto E = reinterpret_cast<xcb_configure_request_event_t*>(event);
|
||||
|
||||
Debug::log(LOG, "Window " + std::to_string(E->window) + " requests XY: " + std::to_string(E->x) + ", " + std::to_string(E->y) + ", WH: " + std::to_string(E->width) + "x" + std::to_string(E->height));
|
||||
|
||||
auto *const PWINDOW = g_pWindowManager->getWindowFromDrawable(E->window);
|
||||
|
||||
if (!PWINDOW) {
|
||||
Debug::log(LOG, "CONFIGURE: Window doesn't exist, ignoring.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PWINDOW->getIsFloating()) {
|
||||
Debug::log(LOG, "CONFIGURE: Window isn't floating, ignoring.");
|
||||
return;
|
||||
}
|
||||
|
||||
PWINDOW->setDefaultPosition(Vector2D(E->x, E->y));
|
||||
PWINDOW->setDefaultSize(Vector2D(E->width, E->height));
|
||||
PWINDOW->setEffectiveSize(PWINDOW->getDefaultSize());
|
||||
PWINDOW->setEffectivePosition(PWINDOW->getDefaultPosition());
|
||||
}
|
||||
|
||||
void Events::eventRandRScreenChange(xcb_generic_event_t* event) {
|
||||
|
||||
// fix sus randr events, that sometimes happen
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace Events {
|
|||
EVENT(KeyPress);
|
||||
EVENT(MotionNotify);
|
||||
EVENT(ClientMessage);
|
||||
EVENT(Configure);
|
||||
|
||||
EVENT(RandRScreenChange);
|
||||
|
||||
|
|
|
@ -313,6 +313,10 @@ void CWindowManager::recieveEvent() {
|
|||
Events::eventClientMessage(ev);
|
||||
Debug::log(LOG, "Event dispatched CLIENT_MESSAGE");
|
||||
break;
|
||||
case XCB_CONFIGURE_REQUEST:
|
||||
Events::eventConfigure(ev);
|
||||
Debug::log(LOG, "Event dispatched CONFIGURE");
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
|
@ -2231,6 +2235,33 @@ void CWindowManager::handleClientMessage(xcb_client_message_event_t* E) {
|
|||
setFocusedWindow(PWINDOW->getDrawable());
|
||||
|
||||
Debug::log(LOG, "Message recieved to set active for " + std::to_string(PWINDOW->getDrawable()));
|
||||
} else if (E->type == HYPRATOMS["_NET_MOVERESIZE_WINDOW"]) {
|
||||
void *const PEVENT = calloc(32, 1);
|
||||
xcb_configure_request_event_t* const GENEV = (xcb_configure_request_event_t*)PEVENT;
|
||||
|
||||
GENEV->window = E->window;
|
||||
GENEV->response_type = XCB_CONFIGURE_REQUEST;
|
||||
|
||||
GENEV->value_mask = 0;
|
||||
if (E->data.data32[0] & _NET_MOVERESIZE_WINDOW_X) {
|
||||
GENEV->value_mask |= XCB_CONFIG_WINDOW_X;
|
||||
GENEV->x = E->data.data32[1];
|
||||
}
|
||||
if (E->data.data32[0] & _NET_MOVERESIZE_WINDOW_Y) {
|
||||
GENEV->value_mask |= XCB_CONFIG_WINDOW_Y;
|
||||
GENEV->y = E->data.data32[2];
|
||||
}
|
||||
if (E->data.data32[0] & _NET_MOVERESIZE_WINDOW_WIDTH) {
|
||||
GENEV->value_mask |= XCB_CONFIG_WINDOW_WIDTH;
|
||||
GENEV->width = E->data.data32[3];
|
||||
}
|
||||
if (E->data.data32[0] & _NET_MOVERESIZE_WINDOW_HEIGHT) {
|
||||
GENEV->value_mask |= XCB_CONFIG_WINDOW_HEIGHT;
|
||||
GENEV->height = E->data.data32[4];
|
||||
}
|
||||
|
||||
Events::eventConfigure((xcb_generic_event_t*)GENEV);
|
||||
free(GENEV);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue