Skip to content

Commit

Permalink
core: disable wayland for now
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-holmes authored and slimsag committed Sep 11, 2024
1 parent d65588b commit 8eb2da1
Showing 1 changed file with 33 additions and 27 deletions.
60 changes: 33 additions & 27 deletions src/core/Linux.zig
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const std = @import("std");
const mach = @import("../main.zig");
const Core = @import("../Core.zig");
const X11 = @import("linux/X11.zig");
const Wayland = @import("linux/Wayland.zig");
// const X11 = @import("linux/X11.zig");
// const Wayland = @import("linux/Wayland.zig");
const gpu = mach.gpu;
const InitOptions = Core.InitOptions;
const Event = Core.Event;
Expand All @@ -21,9 +21,13 @@ const KeyMods = Core.KeyMods;
const log = std.log.scoped(.mach);
const gamemode_log = std.log.scoped(.gamemode);

const Backend = union(enum) {
x11: X11,
wayland: Wayland,
// const Backend = union(enum) {
// x11: X11,
// wayland: Wayland,
// };
const Backend = enum { // dummy backend
x11,
wayland,
};

pub const Linux = @This();
Expand All @@ -47,6 +51,8 @@ pub fn init(
core: *Core.Mod,
options: InitOptions,
) !void {
_ = core;

linux.allocator = options.allocator;

if (!options.is_app and try wantGamemode(linux.allocator)) linux.gamemode = initLinuxGamemode();
Expand Down Expand Up @@ -77,40 +83,40 @@ pub fn init(
// Try to initialize the desired backend, falling back to the other if that one is not supported
switch (desired_backend) {
.x11 => {
const x11 = X11.init(core, options) catch |err| switch (err) {
error.NotSupported => {
log.err("failed to initialize X11 backend, falling back to Wayland", .{});
linux.backend = .{ .wayland = try Wayland.init(linux, core, options) };
},
else => return err,
};
linux.backend = .{ .x11 = x11 };
// const x11 = X11.init(core, options) catch |err| switch (err) {
// error.NotSupported => {
// log.err("failed to initialize X11 backend, falling back to Wayland", .{});
// linux.backend = .{ .wayland = try Wayland.init(linux, core, options) };
// },
// else => return err,
// };
// linux.backend = .{ .x11 = x11 };
},
.wayland => {
const wayland = Wayland.init(core, options) catch |err| switch (err) {
error.NotSupported => {
log.err("failed to initialize Wayland backend, falling back to X11", .{});
linux.backend = .{ .x11 = try X11.init(linux, core, options) };

// TODO(core): support X11 in the future
@panic("X11 is not supported...YET");
},
else => return err,
};
linux.backend = .{ .wayland = wayland };
// const wayland = Wayland.init(core, options) catch |err| switch (err) {
// error.NotSupported => {
// log.err("failed to initialize Wayland backend, falling back to X11", .{});
// linux.backend = .{ .x11 = try X11.init(linux, core, options) };
//
// // TODO(core): support X11 in the future
// @panic("X11 is not supported...YET");
// },
// else => return err,
// };
// linux.backend = .{ .wayland = wayland };
},
}

linux.size = linux.backend.size;
linux.surface_descriptor = linux.backend.surface_descriptor;
// linux.size = linux.backend.size;
// linux.surface_descriptor = linux.backend.surface_descriptor;
linux.refresh_rate = 60; // TODO: set to something meaningful

return;
}

pub fn deinit(linux: *Linux) void {
if (linux.gamemode != null and linux.gamemode.?) deinitLinuxGamemode();
linux.backend.deinit();
// linux.backend.deinit();
return;
}

Expand Down

0 comments on commit 8eb2da1

Please sign in to comment.