apprt/glfw: move darwin enabled const out to top-level
parent
18084a3e61
commit
1f6aa0e90d
|
|
@ -29,6 +29,10 @@ const glfwNative = glfw.Native(.{
|
||||||
.x11 = builtin.os.tag == .linux,
|
.x11 = builtin.os.tag == .linux,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// True if darwin-specific logic is enabled
|
||||||
|
const darwin_enabled = builtin.target.os.tag.isDarwin() and
|
||||||
|
build_config.artifact == .exe;
|
||||||
|
|
||||||
const log = std.log.scoped(.glfw);
|
const log = std.log.scoped(.glfw);
|
||||||
|
|
||||||
pub const App = struct {
|
pub const App = struct {
|
||||||
|
|
@ -40,7 +44,7 @@ pub const App = struct {
|
||||||
quit: bool = false,
|
quit: bool = false,
|
||||||
|
|
||||||
/// Mac-specific state.
|
/// Mac-specific state.
|
||||||
darwin: if (Darwin.enabled) Darwin else void,
|
darwin: if (darwin_enabled) Darwin else void,
|
||||||
|
|
||||||
pub const Options = struct {};
|
pub const Options = struct {};
|
||||||
|
|
||||||
|
|
@ -66,8 +70,8 @@ pub const App = struct {
|
||||||
glfw.setErrorCallback(glfwErrorCallback);
|
glfw.setErrorCallback(glfwErrorCallback);
|
||||||
|
|
||||||
// Mac-specific state. For example, on Mac we enable window tabbing.
|
// Mac-specific state. For example, on Mac we enable window tabbing.
|
||||||
var darwin = if (Darwin.enabled) try Darwin.init() else {};
|
var darwin = if (darwin_enabled) try Darwin.init() else {};
|
||||||
errdefer if (Darwin.enabled) darwin.deinit();
|
errdefer if (darwin_enabled) darwin.deinit();
|
||||||
|
|
||||||
// Load our configuration
|
// Load our configuration
|
||||||
var config = try Config.load(core_app.alloc);
|
var config = try Config.load(core_app.alloc);
|
||||||
|
|
@ -338,7 +342,7 @@ pub const App = struct {
|
||||||
|
|
||||||
/// Create a new tab in the parent surface.
|
/// Create a new tab in the parent surface.
|
||||||
fn newTab(self: *App, parent_: ?*CoreSurface) !void {
|
fn newTab(self: *App, parent_: ?*CoreSurface) !void {
|
||||||
if (!Darwin.enabled) {
|
if (comptime !darwin_enabled) {
|
||||||
log.warn("tabbing is not supported on this platform", .{});
|
log.warn("tabbing is not supported on this platform", .{});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -439,8 +443,6 @@ pub const App = struct {
|
||||||
/// Mac and the artifact is a standalone exe. We don't target libs because
|
/// Mac and the artifact is a standalone exe. We don't target libs because
|
||||||
/// the embedded API doesn't do windowing.
|
/// the embedded API doesn't do windowing.
|
||||||
const Darwin = struct {
|
const Darwin = struct {
|
||||||
const enabled = builtin.target.os.tag.isDarwin() and build_config.artifact == .exe;
|
|
||||||
|
|
||||||
tabbing_id: *macos.foundation.String,
|
tabbing_id: *macos.foundation.String,
|
||||||
|
|
||||||
pub fn init() !Darwin {
|
pub fn init() !Darwin {
|
||||||
|
|
@ -554,7 +556,7 @@ pub const Surface = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// On Mac, enable window tabbing
|
// On Mac, enable window tabbing
|
||||||
if (App.Darwin.enabled) {
|
if (comptime darwin_enabled) {
|
||||||
const NSWindowTabbingMode = enum(usize) { automatic = 0, preferred = 1, disallowed = 2 };
|
const NSWindowTabbingMode = enum(usize) { automatic = 0, preferred = 1, disallowed = 2 };
|
||||||
const nswindow = objc.Object.fromId(glfwNative.getCocoaWindow(win).?);
|
const nswindow = objc.Object.fromId(glfwNative.getCocoaWindow(win).?);
|
||||||
|
|
||||||
|
|
@ -630,7 +632,7 @@ pub const Surface = struct {
|
||||||
// Clean up our core surface so that all the rendering and IO stop.
|
// Clean up our core surface so that all the rendering and IO stop.
|
||||||
self.core_surface.deinit();
|
self.core_surface.deinit();
|
||||||
|
|
||||||
if (App.Darwin.enabled) {
|
if (comptime darwin_enabled) {
|
||||||
const nswindow = objc.Object.fromId(glfwNative.getCocoaWindow(self.window).?);
|
const nswindow = objc.Object.fromId(glfwNative.getCocoaWindow(self.window).?);
|
||||||
const tabgroup = nswindow.getProperty(objc.Object, "tabGroup");
|
const tabgroup = nswindow.getProperty(objc.Object, "tabGroup");
|
||||||
const windows = tabgroup.getProperty(objc.Object, "windows");
|
const windows = tabgroup.getProperty(objc.Object, "windows");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue