diff options
| author | BossCode45 <human.cyborg42@gmail.com> | 2023-06-21 20:38:49 +1200 |
|---|---|---|
| committer | BossCode45 <human.cyborg42@gmail.com> | 2023-06-21 20:38:49 +1200 |
| commit | 6a9f1b77d3a815afa870386d626fb01dceed944f (patch) | |
| tree | cdeb26bb70aaa0b5782680908df176cff1ec9cfe /main.cpp | |
| parent | 4f090897faae6c6d8e451281dc862d58bf9f05ba (diff) | |
| parent | c4813b0ad3f8e0cc4f55b0f0fda8359eb9729417 (diff) | |
| download | YATwm-6a9f1b77d3a815afa870386d626fb01dceed944f.tar.gz YATwm-6a9f1b77d3a815afa870386d626fb01dceed944f.zip | |
Merge branch 'fullscreen'
Added fullscreen functionality
Diffstat (limited to 'main.cpp')
| -rw-r--r-- | main.cpp | 65 |
1 files changed, 59 insertions, 6 deletions
@@ -75,6 +75,7 @@ int mX, mY; #define getClient(c) clients.find(c)->second #define getFrame(f) frames.find(f)->second +#define getFrameID(w) frameIDS.find(w)->second Window bar; @@ -95,9 +96,14 @@ void clientMessage(XClientMessageEvent e); static int OnXError(Display* display, XErrorEvent* e); +// Tiling +// Call this one to tile everything (it does all the fancy stuff trust me just call this one) void tileRoots(); +// Call this one to until everything (it handles multiple monitors) void untileRoots(); -void tile(int frameID, int x, int y, int w, int h); +// This is to be called by tileRoots, it takes in the x, y, w, and h of where it's allowed to tile windows to, and returns the ID of a fullscreen client if one is found, or noID (-1) if none are found +int tile(int frameID, int x, int y, int w, int h); +// This is to be called by tileRoots, it takes in a frameID and recursively unmaps all its children void untile(int frameID); // Usefull functions @@ -573,6 +579,18 @@ const void nextMonitor(const CommandArg* argv) XWarpPointer(dpy, root, root, 0, 0, 0, 0, screens[focusedScreen].x + screens[focusedScreen].w/2, screens[focusedScreen].y + screens[focusedScreen].h/2); focusRoot(focusedWorkspaces[focusedScreen]); } +const void fullscreen(const CommandArg* arg) +{ + Window focusedWindow; + int focusedRevert; + XGetInputFocus(dpy, &focusedWindow, &focusedRevert); + + int fID = getFrameID(focusedWindow); + int cID = getFrame(fID).cID; + getClient(cID).fullscreen ^= true; + tileRoots(); + setFullscreen(focusedWindow, getClient(cID).fullscreen); +} void configureRequest(XConfigureRequestEvent e) { @@ -670,7 +688,7 @@ void mapRequest(XMapRequestEvent e) XSelectInput(dpy, e.window, EnterWindowMask); //Make client - Client c = {currClientID, e.window, false}; + Client c = {currClientID, e.window, false, false}; currClientID++; //Add to clients map @@ -845,6 +863,25 @@ 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]); + 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] > 0; + setFullscreen(e.window, (Atom) e.data.l[0] > 0); + tileRoots(); + } + XFree(prop1); + } XFree(name); } @@ -861,7 +898,17 @@ void tileRoots() { for(int i = 0; i < nscreens; i++) { - tile(focusedWorkspaces[i], screens[i].x + cfg.outerGaps, screens[i].y + cfg.outerGaps, screens[i].w - cfg.outerGaps*2, screens[i].h - cfg.outerGaps*2 - bH); + int fullscreenClientID = tile(focusedWorkspaces[i], screens[i].x + cfg.outerGaps, screens[i].y + cfg.outerGaps, screens[i].w - cfg.outerGaps*2, screens[i].h - cfg.outerGaps*2 - bH); + if(fullscreenClientID!=noID) + { + untile(focusedWorkspaces[i]); + Client c = getClient(fullscreenClientID); + XMapWindow(dpy, c.w); + XMoveWindow(dpy, c.w, + screens[i].x, screens[i].y); + XResizeWindow(dpy, c.w, + screens[i].w, screens[i].h); + } } } void untileRoots() @@ -871,7 +918,7 @@ void untileRoots() untile(focusedWorkspaces[i]); } } -void tile(int frameID, int x, int y, int w, int h) +int tile(int frameID, int x, int y, int w, int h) { for(int fID : frames.find(frameID)->second.floatingFrameIDs) { @@ -896,20 +943,25 @@ void tile(int frameID, int x, int y, int w, int h) } if(!f.isClient) { - tile(fID, wX, wY, wW, wH); + int fullscreenClientID = tile(fID, wX, wY, wW, wH); + if(fullscreenClientID == noID) + return fullscreenClientID; continue; } + Client c = clients.find(f.cID)->second; + if(c.fullscreen) + return c.ID; wX += cfg.gaps; wY += cfg.gaps; wW -= cfg.gaps * 2; wH -= cfg.gaps * 2; - Client c = clients.find(f.cID)->second; XMapWindow(dpy, c.w); XMoveWindow(dpy, c.w, wX, wY); XResizeWindow(dpy, c.w, wW, wH); } + return noID; } void untile(int frameID) @@ -966,6 +1018,7 @@ int main(int argc, char** argv) commandsModule.addCommand("reload", reload, 0, {}); commandsModule.addCommand("wsDump", wsDump, 0, {}); commandsModule.addCommand("nextMonitor", nextMonitor, 0, {}); + commandsModule.addCommand("fullscreen", fullscreen, 0, {}); //Config std::vector<Err> cfgErr; |
