Skip to content

Instantly share code, notes, and snippets.

@rikkimax
Created May 7, 2016 12:26
Show Gist options
  • Save rikkimax/5346adffe29856ef296970eb5afcf30e to your computer and use it in GitHub Desktop.
Save rikkimax/5346adffe29856ef296970eb5afcf30e to your computer and use it in GitHub Desktop.
int callbackGetWindows(HWND hwnd, LPARAM lParam) nothrow {
import std.experimental.ui.internal.window;
GetWindows* ctx = cast(GetWindows*)lParam;
if (!IsWindowVisible(hwnd))
return true;
RECT rect;
GetWindowRect(hwnd, &rect);
if (rect.right - rect.left == 0 || rect.bottom - rect.top == 0)
return true;
try {
WinAPIWindowImpl window = ctx.alloc.make!WinAPIWindowImpl(hwnd, cast(IContext)null, ctx.alloc, ctx.platform);
if (ctx.display is null) {
ctx.alloc.expandArray(ctx.windows, 1);
ctx.windows[$-1] = window;
} else {
auto display2 = window.display;
if (display2 is null) {
ctx.alloc.dispose(window);
return true;
}
if (display2.name == ctx.display.name) {
ctx.alloc.expandArray(ctx.windows, 1);
ctx.windows[$-1] = window;
} else
ctx.alloc.dispose(window);
}
} catch(Exception e) {}
return true;
}
int callbackGetWindows(HWND hwnd, LPARAM lParam) nothrow {
import std.experimental.ui.internal.window;
GetWindows* ctx = cast(GetWindows*)lParam;
if (!IsWindowVisible(hwnd))
return true;
RECT rect;
GetWindowRect(hwnd, &rect);
if (rect.right - rect.left == 0 || rect.bottom - rect.top == 0)
return true;
try {
WinAPIWindowImpl window = ctx.alloc.make!WinAPIWindowImpl(hwnd, cast(IContext)null, ctx.alloc, ctx.platform);
if (ctx.display is null) {
ctx.alloc.expandArray(ctx.windows, 1);
ctx.windows[$-1] = window;
} else {
IDisplay display2 = (cast(IWindow)window).display;
if (display2 is null) {
ctx.alloc.dispose(window);
return true;
}
if (display2.name == ctx.display.name) {
ctx.alloc.expandArray(ctx.windows, 1);
ctx.windows[$-1] = window;
} else
ctx.alloc.dispose(window);
}
} catch(Exception e) {}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment