Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CFLAGS := -arch $(ARCH) -mmacosx-version-min=$(MIN_VER) $(AVAIL) \
LDFLAGS := -arch $(ARCH) -mmacosx-version-min=$(MIN_VER) \
-dynamiclib -install_name @rpath/notproton.dylib

FRAMEWORKS := -framework CoreFoundation -framework CoreGraphics
FRAMEWORKS := -framework AppKit -framework CoreFoundation -framework CoreGraphics -framework QuartzCore

DOBBY_DIR := build/dobby
DOBBY_LIBS := $(DOBBY_DIR)/libdobby.a \
Expand Down Expand Up @@ -69,7 +69,7 @@ ARM64_DYLIB := $(OUT_DIR)/notproton.arm64.dylib
X86_STUB := $(OUT_DIR)/notproton.x86_64.dylib
TARGET := $(OUT_DIR)/notproton.dylib

OBJS := $(patsubst %.c,$(OUT_DIR)/%.o,$(SRCS))
OBJS := $(patsubst %.c,$(OUT_DIR)/%.o,$(SRCS)) $(OUT_DIR)/dylib/feats/rounded_windows.o
DEPS := $(OBJS:.o=.d)

.PHONY: all clean rebuild dobby deploy dylib dylib-install sigcheck fonts fonts-install app-payload app app-zip \
Expand Down Expand Up @@ -545,6 +545,10 @@ $(OUT_DIR)/%.o: %.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@

$(OUT_DIR)/%.o: %.m
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -fobjc-arc -c $< -o $@

$(RUN_SCRIPT_H): dylib/feats/compat_run.sh dylib/embed_script.py
@mkdir -p $(GENERATED_DIR)
python3 dylib/embed_script.py $< $@ RUN_SCRIPT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9398,6 +9398,34 @@
}
}
},
"Restart Steam to apply this setting." : {
"localizations" : {
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "Starte Steam neu, um diese Einstellung anzuwenden."
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Redémarrez Steam pour appliquer ce réglage."
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
"value" : "Riavvia Steam per applicare questa impostazione."
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "重启 Steam 后应用此设置。"
}
}
}
},
"Restart Steam to update its list of compatibility tools." : {
"localizations" : {
"de" : {
Expand Down Expand Up @@ -9594,6 +9622,34 @@
}
}
},
"Round Steam windows" : {
"localizations" : {
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "Abgerundete Steam-Fenster"
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
"value" : "Arrondir les fenêtres Steam"
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
"value" : "Arrotonda gli angoli delle finestre di Steam"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
"value" : "Steam 窗口圆角"
}
}
}
},
"Run" : {
"localizations" : {
"de" : {
Expand Down
6 changes: 6 additions & 0 deletions app/Sources/NotProtonApp/Views/StatusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ struct StatusRow: View {

struct StatusView: View {
@Environment(SystemStatus.self) private var status
@AppStorage("roundSteamWindows") private var roundSteamWindows = false

private static let updateBlockPrompt =
String(localized: "Steam client updates may break NotProton. If you don't want to wait for NotProton to be updated to be compatible with future Steam versions at the cost of not getting updates to the Steam client, you can stop the Steam client from updating itself.")
Expand Down Expand Up @@ -331,6 +332,11 @@ struct StatusView: View {
)
}
updateBlockRow(snapshot.updateBlocked)
StatusRow(
title: String(localized: "Round Steam windows"),
value: String(localized: "Restart Steam to apply this setting."),
toggle: $roundSteamWindows
)
StatusRow(
title: String(localized: "Controller permission"),
value: String(localized: "Clear Steam's controller permission so macOS asks for it again."),
Expand Down
2 changes: 2 additions & 0 deletions dylib/core/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "../feats/ceg.h"
#include "../feats/compat.h"
#include "../feats/input_access.h"
#include "../feats/rounded_windows.h"
#include "dobby.h"

#include <stdio.h>
Expand Down Expand Up @@ -337,6 +338,7 @@ static void np_init(void) {
if (is_main_helper(pn)) {
np_log_attach();
np_hooks_spawn_install();
np_rounded_windows_install();
return;
}
if (strcmp(pn, "steam_osx") != 0)
Expand Down
3 changes: 3 additions & 0 deletions dylib/feats/rounded_windows.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

void np_rounded_windows_install(void);
135 changes: 135 additions & 0 deletions dylib/feats/rounded_windows.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#import <AppKit/AppKit.h>
#import <QuartzCore/QuartzCore.h>
#import <objc/runtime.h>
#include <dlfcn.h>
#include <stdint.h>

#include "rounded_windows.h"

// Use the SDL3 already loaded by Steam Helper.
typedef struct SDL_Window SDL_Window;
enum {
SDL_FULLSCREEN = 0x1,
SDL_MODAL = 0x1000,
SDL_ALWAYS_ON_TOP = 0x10000,
SDL_UTILITY = 0x20000,
SDL_TOOLTIP = 0x40000,
SDL_POPUP_MENU = 0x80000,
};
static struct {
SDL_Window **(*windows)(int *);
uint32_t (*properties)(SDL_Window *);
void *(*pointer)(uint32_t, const char *, void *);
uint64_t (*flags)(SDL_Window *);
void (*free)(void *);
} sdl;

static BOOL load_sdl(void) {
sdl.windows = dlsym(RTLD_DEFAULT, "SDL_GetWindows");
sdl.properties = dlsym(RTLD_DEFAULT, "SDL_GetWindowProperties");
sdl.pointer = dlsym(RTLD_DEFAULT, "SDL_GetPointerProperty");
sdl.flags = dlsym(RTLD_DEFAULT, "SDL_GetWindowFlags");
sdl.free = dlsym(RTLD_DEFAULT, "SDL_free");
return sdl.windows && sdl.properties && sdl.pointer && sdl.flags && sdl.free;
}

static BOOL is_desktop_sdl_window(NSWindow *window) {
const uint64_t excluded = SDL_FULLSCREEN | SDL_MODAL | SDL_ALWAYS_ON_TOP |
SDL_UTILITY | SDL_TOOLTIP | SDL_POPUP_MENU;
int count = 0;
SDL_Window **windows = sdl.windows(&count);
if (!windows)
return NO;

BOOL eligible = NO;
for (int i = 0; i < count; ++i) {
uint32_t properties = sdl.properties(windows[i]);
if (properties &&
sdl.pointer(properties, "SDL.window.cocoa.window", NULL) == (__bridge void *)window) {
eligible = (sdl.flags(windows[i]) & excluded) == 0;
break;
}
}
sdl.free(windows);
return eligible;
}

static BOOL can_round(NSWindow *window) {
const NSWindowStyleMask excluded = NSWindowStyleMaskTitled | NSWindowStyleMaskFullScreen |
NSWindowStyleMaskUtilityWindow | NSWindowStyleMaskDocModalWindow | NSWindowStyleMaskNonactivatingPanel;
return !(window.styleMask & excluded) && window.level == NSNormalWindowLevel &&
window.isVisible && !window.isMiniaturized && !window.parentWindow && !window.isSheet &&
![window isKindOfClass:NSPanel.class] && window.contentView != nil;
}

static char restore_corners_key;

static void update_corners(NSWindow *window) {
dispatch_block_t restore = objc_getAssociatedObject(window, &restore_corners_key);
BOOL round = can_round(window) && is_desktop_sdl_window(window);
if (round == (restore != nil))
return;

CALayer *layer = window.contentView.layer;
if (round && (!layer || layer.mask || layer.cornerRadius != 0))
return;

[CATransaction begin];
[CATransaction setDisableActions:YES];
if (restore) {
restore();
objc_setAssociatedObject(window, &restore_corners_key, nil, OBJC_ASSOCIATION_COPY_NONATOMIC);
} else {
__weak NSWindow *weak_window = window;
NSColor *background = window.backgroundColor;
BOOL window_opaque = window.opaque;
BOOL layer_opaque = layer.opaque;
BOOL clips = layer.masksToBounds;
CALayerCornerCurve curve = layer.cornerCurve;
objc_setAssociatedObject(window, &restore_corners_key, ^{
weak_window.backgroundColor = background;
weak_window.opaque = window_opaque;
layer.opaque = layer_opaque;
layer.masksToBounds = clips;
layer.cornerCurve = curve;
layer.cornerRadius = 0;
}, OBJC_ASSOCIATION_COPY_NONATOMIC);

// Keep SDL's borderless window and clip only its composited content.
window.opaque = NO;
window.backgroundColor = NSColor.clearColor;
layer.opaque = NO;
layer.cornerCurve = kCACornerCurveContinuous;
CGFloat radius = 11;
// The macOS 26 window design has larger corners.
if (@available(macOS 26.0, *))
radius = 17;
layer.cornerRadius = radius;
layer.masksToBounds = YES;
}
[CATransaction commit];
[window invalidateShadow];
}

void np_rounded_windows_install(void) {
if (!CFPreferencesGetAppBooleanValue(CFSTR("roundSteamWindows"), CFSTR("com.notproton.NotProton"), NULL))
return;

dispatch_async(dispatch_get_main_queue(), ^{
if (!load_sdl())
return;

NSNotificationCenter *center = NSNotificationCenter.defaultCenter;
for (NSNotificationName name in @[NSWindowDidBecomeKeyNotification, NSWindowDidResizeNotification,
NSWindowDidEnterFullScreenNotification, NSWindowDidExitFullScreenNotification]) {
[center addObserverForName:name object:nil queue:NSOperationQueue.mainQueue usingBlock:^(NSNotification *note) {
NSWindow *window = note.object;
if (!window.inLiveResize)
dispatch_async(dispatch_get_main_queue(), ^{ update_corners(window); });
}];
}

for (NSWindow *window in NSApp.windows)
update_corners(window);
});
}
Loading