Skip to content

Commit

Permalink
core: disable wayland
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-holmes committed Sep 16, 2024
1 parent fb51725 commit 2945f4a
Showing 1 changed file with 32 additions and 30 deletions.
62 changes: 32 additions & 30 deletions src/core/Linux.zig
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ refresh_rate: u32,
size: Size,
surface_descriptor: gpu.Surface.Descriptor,
gamemode: ?bool = null,
backend: Backend,
backend: BackendEnum,

pub fn init(
linux: *Linux,
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 @@ -81,36 +83,36 @@ 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(linux, 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(linux, 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(linux, core, options) catch |err| switch (err) {
error.LibraryNotFound => {
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(linux, core, options) catch |err| switch (err) {
// error.LibraryNotFound => {
// 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 };
},
}

switch (linux.backend) {
.wayland => |be| {
linux.surface_descriptor = .{ .next_in_chain = .{ .from_wayland_surface = be.surface_descriptor } };
},
.x11 => {}, // TODO: setup surface descriptor
}
// switch (linux.backend) {
// .wayland => |be| {
// linux.surface_descriptor = .{ .next_in_chain = .{ .from_wayland_surface = be.surface_descriptor } };
// },
// .x11 => {}, // TODO: setup surface descriptor
// }

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

Expand All @@ -119,10 +121,10 @@ pub fn init(

pub fn deinit(linux: *Linux) void {
if (linux.gamemode != null and linux.gamemode.?) deinitLinuxGamemode();
switch (linux.backend) {
.wayland => linux.backend.wayland.deinit(linux),
.x11 => {}, // TODO: set to something meaningful
}
// switch (linux.backend) {
// .wayland => linux.backend.wayland.deinit(linux),
// .x11 => {}, // TODO: set to something meaningful
// }

return;
}
Expand Down

0 comments on commit 2945f4a

Please sign in to comment.