-
Notifications
You must be signed in to change notification settings - Fork 0
/
rio.only-tile.patch
246 lines (242 loc) · 4.48 KB
/
rio.only-tile.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
diff -r 2447a1b462c2 sys/src/cmd/rio/rio.c
--- a/sys/src/cmd/rio/rio.c Thu Apr 12 17:50:10 2018 -0400
+++ b/sys/src/cmd/rio/rio.c Fri Apr 20 15:51:25 2018 -0700
@@ -24,6 +24,7 @@
void move(void);
void delete(void);
void hide(void);
+void tile(void);
void unhide(int);
void newtile(int);
Image* sweep(void);
@@ -35,6 +36,7 @@
Channel *kbdchan; /* chan(char*); */
Rectangle viewr;
int threadrforkflag = 0; /* should be RFENVG but that hides rio from plumber */
+int ctrldown;
void mousethread(void*);
void keyboardthread(void*);
@@ -52,6 +54,7 @@
Move,
Delete,
Hide,
+ Tile,
Exit,
};
@@ -90,6 +93,7 @@
[Move] "Move",
[Delete] "Delete",
[Hide] "Hide",
+ [Tile] "Tile",
[Exit] "Exit",
nil
};
@@ -339,6 +343,50 @@
write(window[i]->notefd, "hangup", 6);
}
+void movewindowforward(void) {
+ Window *w;
+ int i;
+ for(i = 0; i <= nwindow; i++) {
+ if(window[i] == input) {
+ if (i >= nwindow - 1) {
+ w = window[0];
+ incref(w);
+ wtopme(w);
+ wcurrent(w);
+ wclose(w);
+ } else {
+ w = window[i+1];
+ incref(w);
+ wtopme(w);
+ wcurrent(w);
+ wclose(w);
+ }
+ }
+ }
+}
+
+void movewindowbackwards(void) {
+ Window *w;
+ int i;
+ for(i = 0; i <= nwindow; i++) {
+ if(window[i] == input) {
+ if (i == 0 ) {
+ w = window[nwindow - 1];
+ incref(w);
+ wtopme(w);
+ wcurrent(w);
+ wclose(w);
+ } else {
+ w = window[i-1];
+ incref(w);
+ wtopme(w);
+ wcurrent(w);
+ wclose(w);
+ }
+ }
+ }
+}
+
void
keyboardthread(void*)
{
@@ -763,6 +811,9 @@
case Hide:
hide();
break;
+ case Tile:
+ tile();
+ break;
case Exit:
if(Hidden > Exit){
send(exitchan, nil);
@@ -1159,6 +1210,149 @@
}
}
+void
+tile(void)
+{
+ Window *w;
+ Image *im;
+ Point o, n;
+// Point canvas;
+ uint i, k, j;
+ uint ytiles = 0;
+ uint xtiles = 1;
+
+ // int s = 0;
+
+ if (nwindow < 1) {
+ return;
+ }
+
+ for(k = 1; xtiles * ytiles < nwindow; k++) {
+ switch(k % 2) {
+ case 0:
+ xtiles++;
+ break;
+ default:
+ ytiles++;
+ break;
+ }
+ }
+
+ o = subpt(viewr.max, viewr.min);
+ n = subpt(view->clipr.max, view->clipr.min);
+
+/*
+ unsigned int sw, sh, x, y;
+ //canvas = subpt(view -> clipr.max, view -> clipr.min);
+ canvas = subpt(viewr.max, viewr.min);
+
+ x = canvas.x;
+ y = viewr.min.y;
+// x = view -> clipr.max.x;
+// y = view -> clipr.min.y;
+
+ sw = canvas.x;
+ sh = canvas.y;
+
+ for(i = 0; i < nwindow; i++) {
+ // print("X: %d, Y: %d, SW : %d, SH: %d, I : %d, NWindow: %d \n", x, y, sw, sh, i, nwindow);
+ w = window[i];
+// qsort(w, nwindow, sizeof(window[0]), wtopcmp);
+
+ Rectangle r;
+
+ if(i < nwindow - 1) {
+ if(i % 2) {
+ sh /= 2;
+ } else {
+ sw /= 2;
+ } if((i % 4) == 2 && !s) {
+ x += sw;
+ } else if((i % 4) == 3 && !s) {
+ y += sh;
+ }
+ }
+ if((i % 4) == 0) {
+ if(s) { y += sh; }
+ else { y -= sh; }
+ } else if((i % 4) == 1) {
+ x += sw;
+ } else if((i % 4) == 2) {
+ y += sh;
+ } else if((i % 4) == 3) {
+ if(s) { x += sw; }
+ else { x -= sw; }
+ }
+
+ if(i == 0) {
+ if (nwindow != 1) { sw = canvas.x; }
+ y = canvas.y;
+ } else if(i == 1) {
+ sw = canvas.x - sw;
+ }
+ r.min.x = x;
+ r.min.y = y;
+
+ r.max.x = sw;
+ r.max.y = sh;
+
+ for(j = 0; j < nhidden; ++j) {
+ if(w == hidden[j])
+ break;
+ }
+
+ incref(w);
+ if(j > nhidden) {
+ im = allocimage(display, r, screen->chan, 0, DNofill);
+ r = ZR;
+ } else {
+ im = allocwindow(wscreen, r, Refbackup, DNofill);
+ }
+
+ if(im) {
+ wsendctlmesg(w, Reshaped, r, im);
+ }
+ wclose(w);
+ }
+ flushimage(display, 1);
+} */
+ for(i = 0; i < nwindow; ++i) {
+ w = window[i];
+ Rectangle r;
+ int sw, sh, x, y;
+
+ sw = o.x / xtiles;
+ sh = o.y / ytiles;
+ x = sw * (i % xtiles);
+ y = sh * ((i / xtiles) % ytiles);
+
+ r.min.x = x;
+ r.min.y = y;
+
+ r.max.x = x + sw;
+ r.max.y = y + sh;
+
+ r = rectaddpt(r, screen->clipr.min);
+
+ for(j = 0; j < nhidden; ++j)
+ if(w == hidden[j])
+ break;
+
+ incref(w);
+ if(j < nhidden) {
+ im = allocimage(display, r, screen->chan, 0, DNofill);
+ } else {
+ im = allocwindow(wscreen, r, Refbackup, DNofill);
+ }
+
+ if(im)
+ wsendctlmesg(w, Reshaped, r, im);
+ wclose(w);
+ }
+
+ flushimage(display, 1);
+}
+
Window*
new(Image *i, int hideit, int scrollit, int pid, char *dir, char *cmd, char **argv)
{