-
Notifications
You must be signed in to change notification settings - Fork 282
Description
I think most people that use a wm dont like these annoying white bars, but you cant really turn them of, or can you (without just removing all decorations icluding the rounded corners)? I managed to write some Odin code to get rid of the on the few apps that I use that actually have them, however it would be really convenient to have this be feature of glaze, wich is a really good wm btw, big thanks to everyone who participates in this project. Anyway here is my code, you could probably use it as a starting point for a c# implemenation, or maybe this at least helps someone out. I would implement this myself, but Im just not good at c#.
Further reading:
- https://learn.microsoft.com/en-us/windows/apps/desktop/modernize/apply-rounded-corners
- https://learn.microsoft.com/en-us/windows/win32/winmsg/window-styles
package title_remover
import "core:fmt"
import "core:os"
import "core:runtime"
import "core:slice"
import "core:strings"
import win "core:sys/windows"
// if any title _CONTAINS_ one of these strings it will get its borders removed
MANAGE :: []string{"CactusViewer", "Minecraft"}
enum_windows_proc :: proc "stdcall" (hWnd: win.HWND, lParam: win.LPARAM) -> win.BOOL {
context = runtime.default_context()
handles := transmute(^[dynamic]win.HWND)lParam
append(handles, hWnd)
return true
}
main :: proc() {
handles := make([dynamic]win.HWND)
win.EnumWindows(enum_windows_proc, transmute(win.LPARAM)&handles)
for handle in handles {
str := make([]u16, 1024)
n := win.GetWindowTextW(handle, raw_data(str), 1023)
manageable := true
title, _ := win.utf16_to_utf8(str[:n])
if manageable {
for m in MANAGE {
if strings.contains(title, m) {
remove_window_title_bar(handle)
break
}
}
}
}
}
remove_window_title_bar :: proc(hWnd: win.HWND) -> bool {
if hWnd == nil {
return false
}
preference: i32 = 2
result := win.DwmSetWindowAttribute(
hWnd,
auto_cast win.DWMWINDOWATTRIBUTE.DWMWA_WINDOW_CORNER_PREFERENCE,
&preference,
size_of(preference),
)
return(
win.SUCCEEDED(result) &&
win.SetWindowLongW(hWnd, win.GWL_STYLE, transmute(i32)win.WS_POPUPWINDOW) != 0 \
)
}
PS: command: "resize borders 0px -7px -7px -7px", as a window rule in your config fixes the size of most windows without titlebars