Skip to content

Commit 441a156

Browse files
author
Miles Sandlar
committed
Removal of Windows array in Workspace struct
1 parent cba035e commit 441a156

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

simple-wm.c

+15-20
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,12 @@ void centerPointer(Window *window) {
106106
}
107107
//Raises Window, Focuses, Makes Window the Active Window
108108
void raiseWindow(Window *window){
109-
int i;
110-
for (i = 0; i <= workspaces[0].lastElement; i++) {
111-
applyBorder(&workspaces[0].windows[i], unfocusedColor);
109+
Client *client;
110+
for (client=workspaces[currentWorkspace].last; client; client = client->previous) {
111+
applyBorder(&(client -> window), unfocusedColor);
112112
}
113113

114+
114115
XRaiseWindow(display, *window);
115116
applyBorder(window, focusedColor);
116117

@@ -133,29 +134,28 @@ void raiseWindow(Window *window){
133134
}
134135

135136
void dumpWorkspace(int wn) {
136-
int run = 1;
137-
138-
Client *cp;
137+
Client *client;
139138

140-
for (cp=workspaces[wn].last; cp; cp = cp -> previous) {
141-
fprintf(stderr, "Client pointer %d\n", cp);
139+
for (client=workspaces[wn].last; client; client = client->previous) {
140+
fprintf(stderr, "Client pointer %d\n", client);
142141
}
143-
144-
145142
}
146143

147144
int changeWorkspace(int workspace) {
145+
148146
//Trying to change to the current workspace
149147
if (workspace == currentWorkspace) { return False; }
150148
dumpWorkspace(workspace);
151149

152-
int wksp;
153-
for (wksp = 0; wksp <= workspaces[workspace].lastElement; wksp++) {
154-
XMapWindow(display, workspaces[workspace].windows[wksp]);
150+
Client *client;
151+
for (client=workspaces[workspace].last; client; client = client -> previous) {
152+
XMapWindow(display, client -> window);
155153
}
156-
for (wksp = 0; wksp <= workspaces[currentWorkspace].lastElement; wksp++) {
157-
XUnmapWindow(display, workspaces[currentWorkspace].windows[wksp]);
154+
155+
for (client=workspaces[currentWorkspace].last; client; client = client -> previous) {
156+
XUnmapWindow(display, client -> window);
158157
}
158+
159159
currentWorkspace = workspace;
160160
return True;
161161
}
@@ -179,10 +179,6 @@ void hMapRequest(XEvent *event) {
179179
//Map
180180
XMapWindow(display, newClient -> window);
181181

182-
workspaces[currentWorkspace].windows[workspaces[currentWorkspace].lastElement] = newClient -> window;
183-
workspaces[currentWorkspace].lastElement++;
184-
185-
186182
//Window Fns: Raise, Border, Center Pointer, Setup Events
187183
raiseWindow (&(newClient -> window) );
188184
applyBorder (&(newClient -> window), unfocusedColor);
@@ -400,7 +396,6 @@ int main() {
400396
activeScreen = DefaultScreen(display);
401397
setupEvents(&root);
402398
setCursor(&root, 56);
403-
workspaces[0].lastElement = 0;
404399

405400
unfocusedColor = getColor(UNFOCUSEDCOLOR);
406401
focusedColor = getColor(FOCUSEDCOLOR);

structs.h

-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,5 @@ struct Client {
1717

1818
typedef struct {
1919
Window active;
20-
Window windows[20];
2120
Client *last;
22-
int lastElement;
2321
} Workspace;

0 commit comments

Comments
 (0)