Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix frameless, resizable, and constrained windows on win32 #1000

Merged
merged 9 commits into from
Nov 7, 2024
554 changes: 277 additions & 277 deletions api/README.md

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions src/app/app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,34 @@ namespace SSC {
break;
}

case WM_GETMINMAXINFO: {
const auto screen = Window::getScreenSize();
auto info = reinterpret_cast<LPMINMAXINFO>(lParam);

info->ptMinTrackSize.x = Window::getSizeInPixels(
app->windowManager.options.defaultMinWidth,
screen.width
);

info->ptMinTrackSize.y = Window::getSizeInPixels(
app->windowManager.options.defaultMinHeight,
screen.height
);

info->ptMaxTrackSize.x = Window::getSizeInPixels(
app->windowManager.options.defaultMaxWidth,
screen.width
);

info->ptMaxTrackSize.y = Window::getSizeInPixels(
app->windowManager.options.defaultMaxHeight,
screen.height
);
break;
}

//case WM_WINDOWPOSCHANGING: { break; }

default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
Expand Down
6 changes: 4 additions & 2 deletions src/cli/cli.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4798,11 +4798,13 @@ int main (int argc, char* argv[]) {
command
<< CXX
<< " -shared"
<< " -rdynamic"
<< " -fPIC"
<< " " << flags
<< " -o " << (desktopExtensionsPath / "libsocket-runtime-desktop-extension.so").string()
<< " " << prefixFile("objects/" + platform.arch + "-desktop/extensions/linux.o")
<< " " << prefixFile("lib/" + platform.arch + "-desktop/libsocket-runtime.a")
<< " " << prefixFile("lib/" + platform.arch + "-desktop/libuv.a")
<< " " << prefixFile("objects/" + platform.arch + "-desktop/extensions/linux.o")
<< " -o " << (desktopExtensionsPath / "libsocket-runtime-desktop-extension.so").string()
;

log(command.str());
Expand Down
2 changes: 1 addition & 1 deletion src/desktop/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ MAIN {
#if SOCKET_RUNTIME_PLATFORM_LINUX
// use 'SIGPWR' instead of the default 'SIGUSR1' handler
// see https://github.com/WebKit/WebKit/blob/2fd8f81aac4e867ffe107c0e1b3e34b1628c0953/Source/WTF/wtf/posix/ThreadingPOSIX.cpp#L185
Env::set("JSC_SIGNAL_FOR_GC", "30");
// Env::set("JSC_SIGNAL_FOR_GC", "30");
gtk_init(&argc, &argv);
#endif

Expand Down
6 changes: 3 additions & 3 deletions src/ipc/preload.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ namespace SSC::IPC {
enumerable: true,
get: () => {
if (
globalThis.origin.includes(globalThis.__args.config.meta_bundle_identifier) ||
globalThis.origin.includes(globalThis.__args.config.meta_bundle_identifier.toLowerCase()) ||
globalThis.origin.includes(globalThis.__args.client.host + ':' + globalThis.__args.client.port)
) {
return globalThis.window && globalThis.top !== globalThis.window
Expand Down Expand Up @@ -282,7 +282,7 @@ namespace SSC::IPC {
enumerable: true,
get: () => {
if (
globalThis.origin.includes(globalThis.__args.config.meta_bundle_identifier) ||
globalThis.origin.includes(globalThis.__args.config.meta_bundle_identifier.toLowerCase()) ||
globalThis.origin.includes(globalThis.__args.client.host + ':' + globalThis.__args.client.port)
) {
return globalThis.parent !== globalThis
Expand Down Expand Up @@ -314,7 +314,7 @@ namespace SSC::IPC {
enumerable: true,
get: () => {
if (
globalThis.origin.includes(globalThis.__args.config.meta_bundle_identifier) ||
globalThis.origin.includes(globalThis.__args.config.meta_bundle_identifier.toLowerCase()) ||
globalThis.origin.includes(globalThis.__args.client.host + ':' + globalThis.__args.client.port)
) {
return globalThis.window && globalThis.top !== globalThis.window
Expand Down
5 changes: 5 additions & 0 deletions src/window/win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,11 @@ namespace SSC {
}
}

if (!options.resizable) {
style &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_SYSMENU);
style &= ~(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE);
}

this->window = CreateWindowEx(
options.headless
? WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE
Expand Down
4 changes: 2 additions & 2 deletions src/window/window.hh
Original file line number Diff line number Diff line change
Expand Up @@ -492,11 +492,11 @@ namespace SSC {
if (sizeInPercent.size() > 0) {
if (sizeInPercent.back() == '%') {
sizeInPercent.pop_back();
return screenSize * std::stof(sizeInPercent) / 100;
return ((float) screenSize) * std::stof(sizeInPercent) / 100.0f;
}
return std::stof(sizeInPercent);
}
return 0;
return 0.0f;
}
};

Expand Down
Loading