core: disable wayland for now

This commit is contained in:
Joshua Holmes 2024-09-10 23:47:57 -07:00 committed by Stephen Gutekanst
parent d65588bc2d
commit 8eb2da1044

View file

@ -1,8 +1,8 @@
const std = @import("std"); const std = @import("std");
const mach = @import("../main.zig"); const mach = @import("../main.zig");
const Core = @import("../Core.zig"); const Core = @import("../Core.zig");
const X11 = @import("linux/X11.zig"); // const X11 = @import("linux/X11.zig");
const Wayland = @import("linux/Wayland.zig"); // const Wayland = @import("linux/Wayland.zig");
const gpu = mach.gpu; const gpu = mach.gpu;
const InitOptions = Core.InitOptions; const InitOptions = Core.InitOptions;
const Event = Core.Event; const Event = Core.Event;
@ -21,9 +21,13 @@ const KeyMods = Core.KeyMods;
const log = std.log.scoped(.mach); const log = std.log.scoped(.mach);
const gamemode_log = std.log.scoped(.gamemode); const gamemode_log = std.log.scoped(.gamemode);
const Backend = union(enum) { // const Backend = union(enum) {
x11: X11, // x11: X11,
wayland: Wayland, // wayland: Wayland,
// };
const Backend = enum { // dummy backend
x11,
wayland,
}; };
pub const Linux = @This(); pub const Linux = @This();
@ -47,6 +51,8 @@ pub fn init(
core: *Core.Mod, core: *Core.Mod,
options: InitOptions, options: InitOptions,
) !void { ) !void {
_ = core;
linux.allocator = options.allocator; linux.allocator = options.allocator;
if (!options.is_app and try wantGamemode(linux.allocator)) linux.gamemode = initLinuxGamemode(); if (!options.is_app and try wantGamemode(linux.allocator)) linux.gamemode = initLinuxGamemode();
@ -77,32 +83,32 @@ pub fn init(
// Try to initialize the desired backend, falling back to the other if that one is not supported // Try to initialize the desired backend, falling back to the other if that one is not supported
switch (desired_backend) { switch (desired_backend) {
.x11 => { .x11 => {
const x11 = X11.init(core, options) catch |err| switch (err) { // const x11 = X11.init(core, options) catch |err| switch (err) {
error.NotSupported => { // error.NotSupported => {
log.err("failed to initialize X11 backend, falling back to Wayland", .{}); // log.err("failed to initialize X11 backend, falling back to Wayland", .{});
linux.backend = .{ .wayland = try Wayland.init(linux, core, options) }; // linux.backend = .{ .wayland = try Wayland.init(linux, core, options) };
}, // },
else => return err, // else => return err,
}; // };
linux.backend = .{ .x11 = x11 }; // linux.backend = .{ .x11 = x11 };
}, },
.wayland => { .wayland => {
const wayland = Wayland.init(core, options) catch |err| switch (err) { // const wayland = Wayland.init(core, options) catch |err| switch (err) {
error.NotSupported => { // error.NotSupported => {
log.err("failed to initialize Wayland backend, falling back to X11", .{}); // log.err("failed to initialize Wayland backend, falling back to X11", .{});
linux.backend = .{ .x11 = try X11.init(linux, core, options) }; // linux.backend = .{ .x11 = try X11.init(linux, core, options) };
//
// TODO(core): support X11 in the future // // TODO(core): support X11 in the future
@panic("X11 is not supported...YET"); // @panic("X11 is not supported...YET");
}, // },
else => return err, // else => return err,
}; // };
linux.backend = .{ .wayland = wayland }; // linux.backend = .{ .wayland = wayland };
}, },
} }
linux.size = linux.backend.size; // linux.size = linux.backend.size;
linux.surface_descriptor = linux.backend.surface_descriptor; // linux.surface_descriptor = linux.backend.surface_descriptor;
linux.refresh_rate = 60; // TODO: set to something meaningful linux.refresh_rate = 60; // TODO: set to something meaningful
return; return;
@ -110,7 +116,7 @@ pub fn init(
pub fn deinit(linux: *Linux) void { pub fn deinit(linux: *Linux) void {
if (linux.gamemode != null and linux.gamemode.?) deinitLinuxGamemode(); if (linux.gamemode != null and linux.gamemode.?) deinitLinuxGamemode();
linux.backend.deinit(); // linux.backend.deinit();
return; return;
} }