Skip to content

Commit

Permalink
Merge pull request #815 from zshoals/window_styles_fix
Browse files Browse the repository at this point in the history
[Windows] Make "borderless" and "on top" window styles function as expected
  • Loading branch information
RobDangerous authored Oct 3, 2023
2 parents a2f5e87 + 4472d1f commit 25e1e6b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions Backends/System/Windows/Sources/kinc/backend/window.c.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ static void RegisterWindowClass(HINSTANCE hInstance, const wchar_t *className) {
}

static DWORD getStyle(int features) {
DWORD style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
DWORD style = WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_POPUP;

if (features & KINC_WINDOW_FEATURE_RESIZEABLE) {
if ((features & KINC_WINDOW_FEATURE_RESIZEABLE) && ((features & KINC_WINDOW_FEATURE_BORDERLESS) == 0)) {
style |= WS_SIZEBOX;
}

Expand All @@ -101,10 +101,6 @@ static DWORD getStyle(int features) {
style |= WS_CAPTION | WS_SYSMENU;
}

if (features & KINC_WINDOW_FEATURE_ON_TOP) {
style |= WS_POPUP;
}

return style;
}

Expand All @@ -115,6 +111,10 @@ static DWORD getExStyle(int features) {
exStyle |= WS_EX_WINDOWEDGE;
}

if (features & KINC_WINDOW_FEATURE_ON_TOP) {
exStyle |= WS_EX_TOPMOST;
}

return exStyle;
}

Expand Down Expand Up @@ -316,6 +316,10 @@ void kinc_window_change_features(int window_index, int features) {
win->features = features;
SetWindowLong(win->handle, GWL_STYLE, getStyle(features));
SetWindowLong(win->handle, GWL_EXSTYLE, getExStyle(features));

HWND on_top = (features & KINC_WINDOW_FEATURE_ON_TOP) ? HWND_TOPMOST : HWND_NOTOPMOST;
SetWindowPos(win->handle, on_top, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);

kinc_window_show(window_index);
}

Expand Down

0 comments on commit 25e1e6b

Please sign in to comment.