forked from nir9/lightwm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tiling.c
46 lines (35 loc) · 891 Bytes
/
tiling.c
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
#include "tiling.h"
#include "error.h"
#include <Windows.h>
HWND managed[256];
int currentManagedIndex = 0;
BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lparam) {
if (!IsWindowVisible(hwnd) || IsHungAppWindow(hwnd)) {
return TRUE;
}
if (currentManagedIndex > 255) {
return FALSE;
}
if (GetWindowTextLengthW(hwnd) == 0) {
return TRUE;
}
RECT clientRect;
if (!GetClientRect(hwnd, &clientRect)) {
return TRUE;
}
// Skip small windows to avoid bugs
if (clientRect.right < 100 || clientRect.bottom < 100){
return TRUE;
}
managed[currentManagedIndex] = hwnd;
currentManagedIndex++;
return TRUE;
}
void tileWindows() {
currentManagedIndex = 0;
EnumChildWindows(GetDesktopWindow(), EnumChildProc, 0);
if (currentManagedIndex == 0) {
return;
}
TileWindows(GetDesktopWindow(), MDITILE_VERTICAL | MDITILE_SKIPDISABLED, NULL, currentManagedIndex, managed);
}