From 9340fea0022425300d3cc1987d244e3a2c5cb452 Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Mon, 22 May 2023 07:56:56 -0400 Subject: [PATCH] checkpoint commit --- bin/winmgr/mons.c | 422 ++-------------------------------------------- bin/winmgr/tile.c | 126 +------------- 2 files changed, 18 insertions(+), 530 deletions(-) diff --git a/bin/winmgr/mons.c b/bin/winmgr/mons.c index 69fa19c..4fdb7c5 100644 --- a/bin/winmgr/mons.c +++ b/bin/winmgr/mons.c @@ -3,67 +3,10 @@ int PtrX = 0, PtrY = 0; -//static Monitor* pickmon(void); -//static Column* pickcol(Column* cols, int relx); -//static Workspace* pickws(Monitor* mon, int wsid); -//static void client_visibility(Workspace* wspace, int show); -//static Client* client_find(Client* clients, Window win); -//static void add_client(Monitor* mon, Client* c, int ptrx); -//static void remove_client(Location* loc, Client* c); -//static void adjust_all(Column* col, int xoff); -//static void change_wspace(Monitor* mon, Workspace* wspace); - Monitor Monitors[MAX_MONITORS]; void Monitors_Place(Client* c) -{ -// Location loc; -// int cleft = (c->x - BORDER_WIDTH); -// int cright = (c->x + c->w + 2*BORDER_WIDTH); -// int ctop = (c->y - BORDER_WIDTH); -// int cbot = (c->y + c->h + 2*BORDER_WIDTH + TITLE_HEIGHT); -// if (mons_find(c->win, &loc) && !loc.column) -// { -// int maxarea = 0; -// Monitor *mon = NULL, *closest = NULL; -// for (int m = 0; m < MAX_MONITORS; m++) -// { -// mon = &Monitors[m]; -// int left = max(cleft, mon->x); -// int right = min(cright, mon->x + mon->w); -// int top = max(ctop, mon->y); -// int bot = min(cbot, mon->y + mon->h); -// if (left < right && top < bot) -// { -// int area = (right - left) * (bot - top); -// if (area > maxarea) -// { -// maxarea = area; -// closest = mon; -// } -// } -// } -// /* if we changed monitors, make sure we update accordingly */ -// if (closest && loc.monitor != closest) -// { -// loc.workspace->floating = list_del(loc.workspace->floating, c); -// c->next = closest->cspace->floating; -// closest->cspace->floating = c; -// } -// } -} - - - - - - - - -//static int min_col_width(Monitor* mon) -//{ -// return (int)(mon->w * MIN_COL_FACT); -//} +{} void mons_init(void) { @@ -91,100 +34,21 @@ void mons_init(void) int mons_find(Window win, Location* loc) { -// for (int m = 0; m < MAX_MONITORS; m++) -// { -// for (int i = 0; i < NUM_WORKSPACES; i++) -// { -// Workspace* wspace = &(Monitors[m].wspaces[i]); -// Column* column = NULL; -// Client* client = client_find(wspace->floating, win); -// if (!client) -// { -// for (int i =0; i < wspace->ncolumns; i++) -// { -// Column* column = &wspace->columns[i]; -// if ( (client = client_find(column->clients, win)) ) -// { -// break; -// } -// } -// } -// /* return the client location if we found it */ -// if (client) -// { -// loc->monitor = &Monitors[m]; -// loc->workspace = wspace; -// loc->column = column; -// loc->client = client; -// return 1; -// } -// } -// } return 0; } /* adds a new client to the most appropriate monitor */ void mons_addclient(Client* c) -{ -// Monitor* mon = pickmon(); -// add_client(mon, c, PtrX); -// mouse_totitle(c); -} +{} void mons_delclient(Location* loc) -{ -// if (Focused == loc->client) -// { -// Focused = NULL; -// } -// remove_client(loc, loc->client); -// xfree(loc->client->name); -// XDestroyWindow(X.disp, loc->client->frame); -// free(loc->client); -} +{} void mons_layer(Monitor* mon) -{ -// int nwins = 0; -// Window* wins = NULL; -// Client* c; -// Column* col; -// LIST_FOR_EACH(c, mon->cspace->floating) -// { -// wins = realloc(wins, ++nwins * sizeof(Window)); -// wins[nwins-1] = c->frame; -// } -// -// /* first lower all of the tiled windows */ -// for (int i =0; i < mon->cspace->ncolumns; i++) -// { -// col = &mon->cspace->columns[i]; -// LIST_FOR_EACH(c, col->clients) -// { -// wins = realloc(wins, ++nwins * sizeof(Window)); -// wins[nwins-1] = c->frame; -// } -// } -// if (nwins) -// { -// XRestackWindows(X.disp, wins, nwins); -// } -// xfree(wins); -} +{} void mons_togglefloat(Location* loc) -{ -// remove_client(loc, loc->client); -// if (loc->client->flags & (F_FLOATING)) -// { -// loc->client->flags &= ~F_FLOATING; -// } -// else -// { -// loc->client->flags |= F_FLOATING; -// } -// mons_addclient(loc->client); -} +{} /* find the best monitor to own the window by calculating the overlap */ void mons_place(Client* c) @@ -193,286 +57,28 @@ void mons_place(Client* c) } void mons_wspace(int wsid) -{ -// Monitor* mon = pickmon(); -// change_wspace(mon, pickws(mon, wsid)); -} +{} void mons_towspace(Client* c, int wsid) -{ -// Location loc = {0}; -// if (mons_find(c->win, &loc)) -// { -// mouse_get(&PtrX, &PtrY); -// Workspace* wspace = pickws(loc.monitor, wsid); -// if (wspace != loc.workspace) -// { -// remove_client(&loc, c); -//// client_show(c, 0); -// Workspace* prev = loc.monitor->cspace; -// loc.monitor->cspace = wspace; -// add_client(loc.monitor, c, PtrX); -// loc.monitor->cspace = prev; -// } -// } -} +{} void mons_raise(Monitor* mon, Client* c) -{ -// mon->cspace->floating = list_del(mon->cspace->floating, c); -// c->next = mon->cspace->floating; -// mon->cspace->floating = c; -// mons_layer(mon); -} +{} void mons_lower(Monitor* mon, Client* c) -{ -// mon->cspace->floating = list_del(mon->cspace->floating, c); -// c->next = NULL; -// if (mon->cspace->floating) -// { -// Client* curr = list_last(mon->cspace->floating); -// curr->next = c; -// } -// else -// { -// mon->cspace->floating = c; -// } -// mons_layer(mon); -} +{} void mons_colsplit(void) -{ -// Monitor* mon = pickmon(); -// Column* col = pickcol(mon->cspace->columns, PtrX - mon->x); -// int next_empty = (col->next && !col->next->clients); -// if (col->clients && !next_empty && col->width >= 2*min_col_width(mon)) -// { -// Column* newcol = ecalloc(1, sizeof(Column)); -// newcol->width = col->width/2; -// col->width -= newcol->width; -// newcol->next = col->next; -// col->next = newcol; -// adjust_all(col, 0); -// } -} +{} void mons_coljoin(void) -{ -// Monitor* mon = pickmon(); -// Column* dest = pickcol(mon->cspace->columns, PtrX - mon->x); -// Column* dead = dest->next; -// if (!dead) -// { -// dead = dest; -// dest = list_prev(mon->cspace->columns, dead); -// } -// -// if (dest && dead) -// { -// /* add the clients to the current col */ -// for (Client* c = dead->clients; c;) -// { -// Client* next = c->next; -// tile_add(&(Location){mon, NULL, dest, c}); -// c = next; -// } -// dest->next = dead->next; -// dest->width += dead->width; -// free(dead); -// adjust_all(dest, 0); -// } -} +{} void mons_coladjust(Monitor* mon, Column* col, int wdiff) -{ -// Column* neighbor = col->next; -// int minwidth = min_col_width(mon); -// if (X.edge == E_LEFT && mon->cspace->columns != col) -// { -// for (neighbor = mon->cspace->columns; neighbor && neighbor->next != col; neighbor = neighbor->next); -// int minadj = -(neighbor->width - minwidth); -// int maxadj = (col->width - minwidth); -// wdiff = min(max(minadj, wdiff), maxadj); -// neighbor->width += wdiff; -// col->width -= wdiff; -// adjust_all(col, wdiff); -// adjust_all(neighbor, 0); -// } -// else if (X.edge == E_RIGHT && col->next) -// { -// int minadj = -(col->width - minwidth); -// int maxadj = (neighbor->width - minwidth); -// wdiff = min(max(minadj, wdiff), maxadj); -// col->width += wdiff; -// neighbor->width -= wdiff; -// adjust_all(col, 0); -// adjust_all(neighbor, wdiff); -// } -// else -// { -// /* invalid edge */ -// } -} +{} void mons_tilemove(Location* loc, int hdiff) -{ -// Monitor* mon = pickmon(); -// Column* col = pickcol(mon->cspace->columns, PtrX - mon->x); -// if (loc->monitor != mon || loc->column != col) -// { -// remove_client(loc, loc->client); -// client_setshade(loc->client, 0); -// loc->monitor = mon; -// loc->column = col; -// tile_add(loc); -// } -// else -// { -// tile_addheight(loc, hdiff); -// } -// mouse_totitle(loc->client); -} +{} void mons_activate(Window win) -{ -// Location loc; -// if (mons_find(win, &loc)) -// { -// change_wspace(loc.monitor, loc.workspace); -// if (!loc.column) -// { -// mons_raise(loc.monitor, loc.client); -// } -// } -} - -//static Monitor* pickmon(void) -//{ -// mouse_get(&PtrX, &PtrY); -// int m = 0; -// Monitor* mon; -// for (; m < MAX_MONITORS; m++) -// { -// mon = &Monitors[m]; -// if ((mon->x <= PtrX && PtrX < mon->x+mon->w) && -// (mon->y <= PtrY && PtrY < mon->y+mon->h)) -// { -// break; -// } -// } -// mon = (m < MAX_MONITORS ? mon : &Monitors[0]); -// return mon; -//} - -//static Column* pickcol(Column* cols, int relx) -//{ -// Column* col; -// int left = 0, right = 0; -// printf("cols %p\n", (void*)cols); -// for (int i = 0; i < MAX_COLUMNS; i++) -// { -// col = &(cols[i]); -// printf("curr = %p\n", (void*)col); -// left = right, right += col->width; -// printf("%d <= %d < %d\n", left, relx, right); -// if (left <= relx && relx < right) -// { -// break; /* we found the column holding the mouse */ -// } -// } -// printf("%p\n", (void*)col); -//// if (!col) col = cols; -// return col; -//} - -//static Workspace* pickws(Monitor* mon, int wsid) -//{ -// return &(mon->wspaces[wsid]); -//} -// -//static void client_visibility(Workspace* wspace, int show) -//{ -// Column* col; -// Client* client; -// LIST_FOR_EACH(client, wspace->floating) -// { -//// client_show(client, show); -// } -// for (int i = 0; i < wspace->ncolumns; i++) -// { -// col = &(wspace->columns[i]); -// LIST_FOR_EACH(client, col->clients) -// { -//// client_show(client, show); -// } -// } -//} -// -//static Client* client_find(Client* clients, Window win) -//{ -// Client* client; -// LIST_FOR_EACH_UNTIL(client, clients, -// (client->frame == win || client->win == win)); -// return client; -//} -// -//static void add_client(Monitor* mon, Client* c, int ptrx) -//{ -// if (X.mode == M_INIT || c->flags & (F_DIALOG|F_FLOATING)) -// { -// c->next = mon->cspace->floating; -// mon->cspace->floating = c; -// c->x = mon->midx - c->w/2; -// c->y = mon->midy - c->h/2; -// Client_AdjustSize(c); -// } -// else -// { -// /* find first empty column, and fill that first, otherwise use the last column we find */ -// Column* col = NULL; -// for (int i = 0; i < mon->cspace->ncolumns; i++) -// { -// col = &(mon->cspace->columns[i]); -// if (col->clients == NULL) -// { -// break; -// } -// } -// tile_add(&(Location){mon, NULL, col, c}); -// } -// mons_layer(mon); -//} -// -//static void remove_client(Location* loc, Client* c) -//{ -// if (!loc->column) -// { -// loc->workspace->floating = list_del(loc->workspace->floating, c); -// } -// else -// { -// tile_del(loc); -// } -//} - -//static void adjust_all(Column* col, int xoff) -//{ -// Client* c; -// LIST_FOR_EACH(c, col->clients) -// { -// c->x += xoff; -// c->w = col->width; -// client_adjust(c); -// } -//} - -//static void change_wspace(Monitor* mon, Workspace* wspace) -//{ -// if (mon->cspace != wspace) -// { -// client_visibility(mon->cspace, 0); -// client_visibility(wspace, 1); -// mon->cspace = wspace; -// } -//} +{} diff --git a/bin/winmgr/tile.c b/bin/winmgr/tile.c index 823edcc..f560b1b 100644 --- a/bin/winmgr/tile.c +++ b/bin/winmgr/tile.c @@ -1,131 +1,13 @@ #include "anvil.h" -//static void coldims(Monitor *mon, Column *col, int *x, int *y, int *w, int *h) -//{ -// Column* c; -// *x = mon->x, *y = mon->y, *w = col->width, *h = mon->h; -// -// int curr = (col - &mon->cspace->columns[0]) / sizeof(Column); -// for (int i = 0; i < curr; i++) -// { -// c = &mon->cspace->columns[i]; -// *x += c->width; -// } -//} - void tile_add(Location* loc) -{ -// Client* c = loc->client; -// coldims(loc->monitor, loc->column, &(c->x), &(c->y), &(c->w), &(c->h)); -// if (loc->column->clients) -// { -// Client *cl, *max = loc->column->clients; -// LIST_FOR_EACH(cl, max) -// { -// if (cl->h > max->h) -// { -// max = cl; -// } -// } -// if (max->h < 3*MIN_HEIGHT) -// { -// c->next = loc->monitor->cspace->floating; -// loc->monitor->cspace->floating = c; -// c->x = loc->monitor->midx - c->w/2; -// c->y = loc->monitor->midy - c->h/2; -// client_adjust(c); -// } -// else -// { -// c->h = max->h/2; -// c->y = max->y + c->h; -// c->w = max->w; -// max->h -= max->h/2; -// c->next = max->next; -// max->next = c; -// client_adjust(c); -// client_adjust(max); -// } -// } -// else -// { -// c->next = loc->column->clients; -// loc->column->clients = c; -// client_adjust(c); -// } -} +{} void tile_del(Location* loc) -{ -// Client* c = loc->client; -// if (loc->column->clients == c) -// { -// loc->column->clients = c->next; -// if (loc->column->clients) -// { -// loc->column->clients->h += loc->column->clients->y - loc->monitor->y; -// loc->column->clients->y = loc->monitor->y; -// client_setshade(loc->column->clients, 0); -// client_adjust(loc->column->clients); -// } -// } -// else -// { -// Client* prev = list_prev(loc->column->clients, c); -// prev->next = c->next; -// prev->h += c->h; -// client_setshade(prev, 0); -// client_adjust(prev); -// } -} +{} void tile_set(Location* loc) -{ -// Client *curr, *c = loc->client; -// int starty = loc->monitor->y; -// /* stack the windows before the target */ -// LIST_FOR_EACH_UNTIL(curr, loc->column->clients, curr == c) -// { -// curr->y = starty; -// curr->h = MIN_HEIGHT; -// client_setshade(curr, 1); -// client_adjust(curr); -// starty += MIN_HEIGHT; -// } -// /* expand the target window */ -// int nclients = list_length(curr->next); -// curr->y = starty; -// curr->h = (loc->monitor->h - starty) - (nclients * MIN_HEIGHT); -// client_setshade(c, 0); -// client_adjust(curr); -// mouse_totitle(curr); -// starty = (curr->y + curr->h - 1); -// /* stack the windows after the target */ -// LIST_FOR_EACH(curr, curr->next) -// { -// curr->y = starty; -// curr->h = MIN_HEIGHT; -// client_setshade(curr, 1); -// client_adjust(curr); -// starty += MIN_HEIGHT; -// } -} +{} void tile_addheight(Location* loc, int amount) -{ -// Client* c = loc->client; -// Client* prev = list_prev(loc->column->clients, c); -// if (prev) -// { -// amount = (abs(amount) < BORDER_WIDTH ? min((int)(-c->h * 0.25), -2*MIN_HEIGHT) : amount); -// int miny = (prev->y + MIN_HEIGHT); -// int maxy = min((loc->monitor->y + loc->monitor->h) , (c->y + c->h)) - MIN_HEIGHT; -// c->y = max(miny, min(maxy, c->y + amount)); -// prev->h = c->y - prev->y; -// c->h = (c->next ? c->next->y : loc->monitor->y + loc->monitor->h) - c->y; -// client_setshade(prev, (prev->h <= MIN_HEIGHT)); -// client_setshade(c, (c->h <= MIN_HEIGHT)); -// client_adjust(prev); -// client_adjust(c); -// } -} +{} -- 2.54.0