Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define MINWSZ 50 /* minimum window size in pixels */
#define DEFAULT_DESKTOP 0 /* the desktop to focus initially */
#define DESKTOPS 4 /* number of desktops - edit DESKTOPCHANGE keys to suit */
#define MAXHIDDEN 10 /* maximum number of hidden windows in a desktop */

/**
* open applications to specified desktop with specified mode.
Expand Down
46 changes: 46 additions & 0 deletions monsterwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ static void client_to_desktop(const Arg *arg);
static void focusurgent();
static void killclient();
static void last_desktop();
static void map_window();
static void move_down();
static void move_up();
static void moveresize(const Arg *arg);
Expand All @@ -98,6 +99,7 @@ static void spawn(const Arg *arg);
static void swap_master();
static void switch_mode(const Arg *arg);
static void togglepanel();
static void unmap_window();

#include "config.h"

Expand Down Expand Up @@ -131,11 +133,13 @@ typedef struct Client {
* curr - the currently highlighted window
* prev - the client that previously had focus
* sbar - the visibility status of the panel/statusbar
* hidden - array containing the hidden windows
*/
typedef struct {
int mode, masz, sasz;
Client *head, *curr, *prev;
Bool sbar;
Window hidden[MAXHIDDEN];
} Desktop;

/* hidden function prototypes sorted alphabetically */
Expand Down Expand Up @@ -732,6 +736,25 @@ void maprequest(XEvent *e) {
if (!follow) desktopinfo();
}

/**
* if there are hidden windows in the current desktop, show the last hidden window
*/
void map_window(){
if(desktops[currdeskidx].hidden[0] == 0) return;
for(int i = MAXHIDDEN; i >= 0; --i)
{
if(desktops[currdeskidx].hidden[i] != 0)
{
XMapWindow(dis,desktops[currdeskidx].hidden[i]);
Client* c = addwindow(desktops[currdeskidx].hidden[i],&desktops[currdeskidx]);
desktops[currdeskidx].hidden[i] = 0;
tile(&desktops[currdeskidx]);
focus(c,&desktops[currdeskidx]);
return;
}
}
};

/**
* handle resize and positioning of a window with the pointer.
*
Expand Down Expand Up @@ -1026,7 +1049,14 @@ void setup(void) {

/* initialize mode and panel visibility for each desktop */
for (unsigned int d = 0; d < DESKTOPS; d++)
{
desktops[d] = (Desktop){ .mode = DEFAULT_MODE, .sbar = SHOW_PANEL };
for(unsigned int n = 0; n < MAXHIDDEN; n++) /* initialize all the array slots to 0 */
{
desktops[d].hidden[n] = 0;
}
}


/* get color for focused and unfocused client borders */
win_focus = getcolor(FOCUS, screen);
Expand Down Expand Up @@ -1199,6 +1229,22 @@ void unmapnotify(XEvent *e) {
if (wintoclient(e->xunmap.window, &c, &d)) removeclient(c, d);
}

/**
* hide the focused window
*/
void unmap_window(){
Window current = desktops[currdeskidx].curr->win;
for(int i = 0; i < MAXHIDDEN;i++)
{
if(desktops[currdeskidx].hidden[i] == 0)
{
desktops[currdeskidx].hidden[i] = current;
break;
}
}
XUnmapWindow(dis,current);
}

/**
* find to which client and desktop the given window belongs to
*/
Expand Down