diff options
| author | BossCode45 <human.cyborg42@gmail.com> | 2023-02-02 21:17:12 +1300 |
|---|---|---|
| committer | BossCode45 <human.cyborg42@gmail.com> | 2023-06-21 20:18:53 +1200 |
| commit | ef998ee445e8a59a1cc5c9d15d721aabea187fd7 (patch) | |
| tree | ae07d4a8c9c6a5eb80150f437cb82fa6a1d060f5 | |
| parent | d7da80856ed209066b6f70d18bda9f506e05e67b (diff) | |
| download | YATwm-ef998ee445e8a59a1cc5c9d15d721aabea187fd7.tar.gz YATwm-ef998ee445e8a59a1cc5c9d15d721aabea187fd7.zip | |
feat: fullscreen keybind
| -rw-r--r-- | config.toml | 3 | ||||
| -rw-r--r-- | main.cpp | 44 | ||||
| -rw-r--r-- | notes.org | 16 | ||||
| -rw-r--r-- | structs.h | 1 |
4 files changed, 52 insertions, 12 deletions
diff --git a/config.toml b/config.toml index be0354f..682cda8 100644 --- a/config.toml +++ b/config.toml @@ -32,6 +32,9 @@ func = "kill" [[Keybinds.key]] bind = "mod+shift+r" func = "reload" +[[Keybinds.key]] +bind = "mod+f" +func = "fullscreen" #Focus [[Keybinds.key]] @@ -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,17 @@ 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]); } +void fullscreen(const KeyArg arg) +{ + Window focusedWindow; + int focusedRevert; + XGetInputFocus(dpy, &focusedWindow, &focusedRevert); + + int fID = getFrameID(focusedWindow); + int cID = getFrame(fID).cID; + getClient(cID).fullscreen ^= true; + tileRoots(); +} void configureRequest(XConfigureRequestEvent e) { @@ -670,7 +687,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 @@ -861,7 +878,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 +898,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 +923,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) @@ -1,5 +1,10 @@ #+TITLE: Features to add +* Main refactor for the future +** Make it possible to split up the code into mulitple files easier +- Header files for some functions such as ~tileRoots~, potentially classes as well +- Main variables like the list of clients as a stuct, pointer can then be passed for things like EWMH + * Remembering focus Use the variable ~whichChildFocused~ for each non client frame, this is the index of the child that is focused. To then find focused child for a root recurse through all the frames going through the focused child. ** Where it should be updated @@ -9,18 +14,17 @@ Use the variable ~whichChildFocused~ for each non client frame, this is the inde ** Where it should be used Whenever I set focus I should use the focused client of whichever workspace is focused -* Change focus and move between monitors -Perhaps I can just add something to the ~dirFind~ function - -* TOML config -put in ~/.config/YATwm/config.toml +* Config +rewrite it to be a scripting language like i3 * Fullscreen windows This should be another thing like floating windows except each workspace only gets one I should check it first when tiling and if it exists then draw it to the size of the screeen then return * General EWMH things -I should really figure out what all the client messages mean +** I should really figure out what all the client messages mean +- ~_NET_WM_STATE~ is used to change a windows state e.g. moving to fullscreen. It is an ~Atom[]~ * The eventual program to communicate with YATwm Use a unix socket +Same protocol as config langauge @@ -13,6 +13,7 @@ struct Client int ID; Window w; bool floating; + bool fullscreen; }; enum TileDir |
