From 9cf2ce8736f4e0f3c6ea3339c72ca2f63a418471 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 11 Oct 2019 20:22:10 +0300 Subject: [PATCH] catwm: fs toggle --- catwm.c | 25 ++++++++++++++++++++++++- config.h | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/catwm.c b/catwm.c index 646e8bb..379b0f2 100644 --- a/catwm.c +++ b/catwm.c @@ -37,8 +37,9 @@ typedef struct client client; struct client{ client *next; client *prev; - Window win; + + int f, x, y, w, h; }; typedef struct desktop desktop; @@ -52,6 +53,7 @@ static void add_window(Window w); static void buttonpress(XEvent *e); static void buttonrelease(XEvent *e); static void center_window(); +static void fullscreen_toggle(); static void change_desktop(const Arg arg); static void client_to_desktop(const Arg arg); static void configurerequest(XEvent *e); @@ -150,6 +152,27 @@ void center_window() { XMoveWindow(dis, current->win, x, y); } +void fullscreen_toggle() { + if (current->f != 1) { + XGetWindowAttributes(dis, current->win, &attr); + + current->f = 1; + current->x = attr.x; + current->y = attr.y; + current->w = attr.width; + current->h = attr.height; + + XMoveResizeWindow(dis, current->win, 0, 0, sw, sh); + } + + else { + current->f = 0; + + XMoveResizeWindow(dis, current->win, current->x, current->y, \ + current->w, current->h); + } +} + void client_to_desktop(const Arg arg) { client *tmp = current; int tmp2 = curr_desk; diff --git a/config.h b/config.h index 4dd23e6..7060c6a 100644 --- a/config.h +++ b/config.h @@ -34,6 +34,7 @@ static struct key keys[] = { // MOD KEY FUNCTION ARGS { MOD, XK_q, kill_client, {NULL}}, { MOD, XK_c, center_window, {NULL}}, + { MOD, XK_f, fullscreen_toggle, {NULL}}, { Mod1Mask, XK_Tab, next_win, {NULL}}, { 0, XF86XK_AudioLowerVolume, spawn, {.com = voldown}}, { 0, XF86XK_AudioRaiseVolume, spawn, {.com = volup}},