From ab3d823a8190ae6ec4a1444aa3b5a01aaa018586 Mon Sep 17 00:00:00 2001 From: BossCode45 Date: Fri, 3 Feb 2023 17:45:07 +1300 Subject: feat: Windows that request to be fullscreen should become fullscreen - more testing neededs --- ewmh.cpp | 12 ++++++++++++ ewmh.h | 2 ++ main.cpp | 21 +++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/ewmh.cpp b/ewmh.cpp index 5a7e76c..5878e82 100644 --- a/ewmh.cpp +++ b/ewmh.cpp @@ -65,6 +65,18 @@ void setCurrentDesktop(int desktop) XChangeProperty(*dpy_, *root_, netCurrentDesktop, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)&currDesktop, 1); } +void setFullscreen(Window w, bool fullscreen) +{ + Atom netWMState = XInternAtom(*dpy_, "_NET_WM_STATE", true); + Atom netWMStateVal; + if(fullscreen) + netWMStateVal = XInternAtom(*dpy_, "_NET_WM_STATE_FULLSCREEN", true); + else + netWMStateVal = XInternAtom(*dpy_, "", true); + XChangeProperty(*dpy_, w, netWMState, XA_ATOM, 32, PropModeReplace, (unsigned char*)&netWMStateVal, 1); + +} + int getProp(Window w, char* propName, Atom* type, unsigned char** data) { Atom prop_type = XInternAtom(*dpy_, propName, false); diff --git a/ewmh.h b/ewmh.h index 5fbc9a4..e8bae0c 100644 --- a/ewmh.h +++ b/ewmh.h @@ -18,4 +18,6 @@ void setWindowDesktop(Window w, int desktop); void setCurrentDesktop(int desktop); +void setFullscreen(Window w, bool fullscreen); + int getProp(Window w, char* propName, Atom* type, unsigned char** data); diff --git a/main.cpp b/main.cpp index 6f1cd9b..01f01c7 100644 --- a/main.cpp +++ b/main.cpp @@ -589,6 +589,7 @@ void fullscreen(const KeyArg arg) int cID = getFrame(fID).cID; getClient(cID).fullscreen ^= true; tileRoots(); + setFullscreen(focusedWindow, getClient(cID).fullscreen); } void configureRequest(XConfigureRequestEvent e) @@ -862,6 +863,26 @@ void clientMessage(XClientMessageEvent e) setCurrentDesktop(currWS); */ } + else if(e.message_type == XInternAtom(dpy, "_NET_WM_STATE", false)) + { + if((Atom)e.data.l[0] == 0) + log("\tremove"); + if((Atom)e.data.l[0] == 1) + log("\ttoggle"); + if((Atom)e.data.l[0] == 2) + log("\tadd"); + char* prop1 = XGetAtomName(dpy, (Atom)e.data.l[1]); + log("\tprop1"); + if((Atom)e.data.l[1] == XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", false)) + { + int fID = getFrameID(e.window); + int cID = getFrame(fID).cID; + getClient(cID).fullscreen = (Atom) e.data.l[0] == 1; + setFullscreen(e.window, (Atom) e.data.l[0] == 1); + tileRoots(); + } + XFree(prop1); + } XFree(name); } -- cgit v1.2.3