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 14, 2024
1 parent df05e4d commit 96769ef
Showing 1 changed file with 34 additions and 32 deletions.
66 changes: 34 additions & 32 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 @@ -25,10 +25,10 @@ const BackendEnum = enum {
x11,
wayland,
};
const Backend = union(BackendEnum) {
x11: X11,
wayland: Wayland,
};
// const Backend = union(BackendEnum) {
// x11: X11,
// wayland: Wayland,
// };

pub const Linux = @This();

Expand All @@ -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 Down

0 comments on commit 96769ef

Please sign in to comment.