From 5f0c7eaf259ea65ea8c79df63eac644a438989d1 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Mon, 8 Mar 2021 15:51:53 -0500 Subject: [PATCH] add SHOWMAX option and maximize menu item, fix (I think) shuffle on delete to only shuffle if there is no current after deletion --- config.h | 3 +++ dat.h | 4 +++- menu.c | 54 ++++++++++++++++++++++++++++++++++++++++++++---------- 3 files changed, 50 insertions(+), 11 deletions(-) diff --git a/config.h b/config.h index 624d275..4b7c6c8 100644 --- a/config.h +++ b/config.h @@ -94,6 +94,9 @@ */ #define CENTERVMAX +/* Show 'Maximize' menuitem? */ +//#define SHOWMAX + /* Show 'Stick' menuitem? */ //#define SHOWSTICK diff --git a/dat.h b/dat.h index fd4ea2e..c2a70d1 100644 --- a/dat.h +++ b/dat.h @@ -6,7 +6,9 @@ #define CORNER _corner #define INSET _inset #define MAXHIDDEN 128 -#ifdef SHOWSTICK +#if defined (SHOWMAX) && defined (SHOWSTICK) +#define B3FIXED 7 +#elif defined (SHOWMAX) || defined (SHOWSTICK) #define B3FIXED 6 #else #define B3FIXED 5 diff --git a/menu.c b/menu.c index c496941..b9b727b 100644 --- a/menu.c +++ b/menu.c @@ -35,24 +35,38 @@ char* b3items[B3FIXED + MAXHIDDEN + 1] = { "New", "Reshape", "Move", - "Delete", - "Hide", +#if defined(SHOWMAX) && defined(SHOWSTICK) + "Maximize", + "Stick", +#else +#ifdef SHOWMAX + "Maximize", +#endif #ifdef SHOWSTICK "Stick", #endif +#endif + "Delete", + "Hide", 0}; enum { New, Reshape, Move, - Delete, -#ifdef SHOWSTICK - Hide, - Stick +#if defined(SHOWMAX) && defined(SHOWSTICK) + Maximize, + Stick, #else - Hide +#ifdef SHOWMAX + Maximize, #endif +#ifdef SHOWSTICK + Stick, +#endif +#endif + Delete, + Hide }; Menu b3menu = {b3items}; @@ -65,6 +79,9 @@ void button(XButtonEvent* e) { Window dw; ScreenInfo* s; + static XWindowAttributes ra; + XGetWindowAttributes(dpy, DefaultRootWindow(dpy), &ra); + curtime = e->time; s = getscreen(e->root); if (s == 0) @@ -170,6 +187,23 @@ void button(XButtonEvent* e) { case Hide: hide(selectwin(1, 0, s)); break; +#ifdef SHOWMAX + case Maximize: + c = selectwin(1, 0, s); +#ifdef AUTOSTICK + if (isautostick(c)) + break; +#endif + quickreshape( + c, + -BORDER, + -BORDER, + ra.width + 2 * BORDER, + ra.height + 2 * BORDER); + active(c); + top(c); + break; +#endif #ifdef SHOWSTICK case Stick: stick(selectwin(1, 0, s)); @@ -260,13 +294,13 @@ void move(Client* c, int but) { } void delete (Client* c, int shift) { - int v; + //int v; if (c == 0) return; - v = c->virt; + //v = c->virt; if ((c->proto & Pdelete) && !shift) { sendcmessage(c->window, wm_protocols, wm_delete, 0, 0); - if (v == virt) { + if (!current) { shuffle(0); } }