Sciter failed Linux update
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -1,2 +1,3 @@
|
||||
*.dll filter=lfs diff=lfs merge=lfs -text
|
||||
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||
*.so filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
@@ -1,39 +1,78 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const target = b.resolveTargetQuery(.{
|
||||
.cpu_arch = .x86_64,
|
||||
.os_tag = .windows,
|
||||
.abi = .msvc,
|
||||
const target = b.standardTargetOptions(.{
|
||||
.whitelist = &.{
|
||||
.{
|
||||
.cpu_arch = .x86_64,
|
||||
.os_tag = .windows,
|
||||
.abi = .msvc,
|
||||
},
|
||||
.{
|
||||
.cpu_arch = .aarch64,
|
||||
.os_tag = .windows,
|
||||
.abi = .msvc,
|
||||
},
|
||||
.{
|
||||
.cpu_arch = .x86_64,
|
||||
.os_tag = .linux,
|
||||
.abi = .gnu,
|
||||
},
|
||||
.{
|
||||
.cpu_arch = .aarch64,
|
||||
.os_tag = .linux,
|
||||
.abi = .gnu,
|
||||
},
|
||||
},
|
||||
});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const zigwin32 = b.dependency("zigwin32", .{});
|
||||
const zigwin32_mod = zigwin32.module("win32");
|
||||
zigwin32_mod.resolved_target = target;
|
||||
zigwin32_mod.optimize = optimize;
|
||||
|
||||
const exe_mod = b.createModule(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
|
||||
exe_mod.addImport("win32", zigwin32_mod);
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "sciter",
|
||||
.root_module = exe_mod,
|
||||
});
|
||||
|
||||
b.installArtifact(exe);
|
||||
b.getInstallStep().dependOn(&b.addInstallBinFile(b.path("vendor/sciter.dll"), "sciter.dll").step);
|
||||
|
||||
switch (target.result.os.tag) {
|
||||
.windows => {
|
||||
const zigwin32 = b.dependency("zigwin32", .{});
|
||||
const zigwin32_mod = zigwin32.module("win32");
|
||||
zigwin32_mod.resolved_target = target;
|
||||
zigwin32_mod.optimize = optimize;
|
||||
|
||||
exe_mod.addImport("win32", zigwin32_mod);
|
||||
|
||||
const dll_source_path = b.path(b.fmt("vendor/windows/{s}/sciter.dll", .{@tagName(target.result.cpu.arch)}));
|
||||
const dll_dest_path = "sciter.dll";
|
||||
|
||||
b.getInstallStep().dependOn(&b.addInstallBinFile(dll_source_path, dll_dest_path).step);
|
||||
},
|
||||
.linux => {
|
||||
exe_mod.linkSystemLibrary("c", .{});
|
||||
exe_mod.linkSystemLibrary("X11", .{});
|
||||
|
||||
const so_source_path = b.path(b.fmt("vendor/linux/{s}/libsciter.so", .{@tagName(target.result.cpu.arch)}));
|
||||
const so_dest_path = "libsciter.so";
|
||||
|
||||
b.getInstallStep().dependOn(&b.addInstallBinFile(so_source_path, so_dest_path).step);
|
||||
},
|
||||
else => unreachable,
|
||||
}
|
||||
|
||||
const run_cmd = b.addRunArtifact(exe);
|
||||
run_cmd.step.dependOn(b.getInstallStep());
|
||||
if (b.args) |args| {
|
||||
run_cmd.addArgs(args);
|
||||
}
|
||||
run_cmd.setCwd(.{ .cwd_relative = b.exe_dir });
|
||||
//run_cmd.setCwd(exe.getEmittedBinDirectory());
|
||||
|
||||
const run_step = b.step("run", "Run the app");
|
||||
run_step.dependOn(&run_cmd.step);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const sciter = @import("sciter.zig");
|
||||
const std = @import("std");
|
||||
const x11 = @import("x11.zig");
|
||||
const wam = @import("win32").ui.windows_and_messaging;
|
||||
const win32 = @import("win32").foundation;
|
||||
|
||||
@@ -76,6 +77,8 @@ pub fn wWinMain(
|
||||
std.posix.exit(1);
|
||||
};
|
||||
|
||||
_ = sciter_api.SciterSetOption(0, 10, 1);
|
||||
sciter_api.SciterSetupDebugOutput(hwnd, null, &sciterDebugOutputProc);
|
||||
_ = sciter_api.SciterLoadHtml(hwnd, html, html.len, L("/"));
|
||||
_ = wam.ShowWindow(hwnd, @bitCast(nCmdShow));
|
||||
|
||||
@@ -113,3 +116,99 @@ fn WindowProc(
|
||||
|
||||
return wam.DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
pub fn main() void {
|
||||
const sciter_module = std.c.dlopen("./libsciter.so", .{ .LAZY = true }) orelse {
|
||||
const err = std.c.dlerror();
|
||||
const nl = "\n";
|
||||
_ = std.posix.writev(std.posix.STDERR_FILENO, &.{
|
||||
.{ .base = err.?, .len = std.mem.indexOfSentinel(u8, 0, err.?) },
|
||||
.{ .base = nl, .len = nl.len },
|
||||
}) catch {};
|
||||
std.posix.exit(1);
|
||||
};
|
||||
|
||||
const sciter_api_fn: *const fn () ?*sciter.API = @ptrCast(std.c.dlsym(sciter_module, "SciterAPI") orelse {
|
||||
_ = std.posix.write(std.posix.STDERR_FILENO, "Couldn't load Sciter API.\n") catch {};
|
||||
std.posix.exit(1);
|
||||
});
|
||||
|
||||
sciter_api = sciter_api_fn() orelse {
|
||||
_ = std.posix.write(std.posix.STDERR_FILENO, "Couldn't load Sciter API.\n") catch {};
|
||||
std.posix.exit(1);
|
||||
};
|
||||
|
||||
std.debug.print("Sciter API version is: 0x{X:0>8}\n", .{sciter_api.version});
|
||||
|
||||
const display = x11.XOpenDisplay(null) orelse {
|
||||
_ = std.posix.write(std.posix.STDERR_FILENO, "Couldn't open connection to X server.\n") catch {};
|
||||
std.posix.exit(1);
|
||||
};
|
||||
defer _ = x11.XCloseDisplay(display);
|
||||
|
||||
const window = x11.XCreateSimpleWindow(
|
||||
display,
|
||||
x11.DefaultRootWindow(display),
|
||||
0,
|
||||
0,
|
||||
720,
|
||||
480,
|
||||
0,
|
||||
x11.BlackPixel(display, x11.DefaultScreen(display)),
|
||||
x11.BlackPixel(display, x11.DefaultScreen(display)),
|
||||
);
|
||||
defer _ = x11.XDestroyWindow(display, window);
|
||||
|
||||
const event_mask = x11.KeyPressMask |
|
||||
x11.KeyReleaseMask |
|
||||
x11.ButtonPressMask |
|
||||
x11.ButtonReleaseMask |
|
||||
x11.EnterWindowMask |
|
||||
x11.LeaveWindowMask |
|
||||
x11.PointerMotionMask;
|
||||
_ = x11.XSelectInput(display, window, event_mask);
|
||||
|
||||
_ = x11.XStoreName(display, window, "Sciter Demo");
|
||||
|
||||
const wm_delete_window = x11.XInternAtom(display, "WM_DELETE_WINDOW", x11.False);
|
||||
_ = x11.XSetWMProtocols(display, window, @constCast(&wm_delete_window), 1);
|
||||
|
||||
_ = x11.XMapWindow(display, window);
|
||||
defer _ = x11.XUnmapWindow(display, window);
|
||||
|
||||
_ = sciter_api.SciterSetOption(0, 10, 1);
|
||||
sciter_api.SciterSetupDebugOutput(window, null, &sciterDebugOutputProc);
|
||||
_ = sciter_api.SciterLoadHtml(window, html, html.len, L("/"));
|
||||
|
||||
var event: x11.XEvent = undefined;
|
||||
var running = true;
|
||||
while (running) {
|
||||
_ = x11.XNextEvent(display, &event);
|
||||
switch (event.type) {
|
||||
x11.ClientMessage => {
|
||||
const atom: x11.Atom = @bitCast(event.xclient.data.l[0]);
|
||||
if (atom == wm_delete_window) {
|
||||
running = false;
|
||||
}
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn sciterDebugOutputProc(
|
||||
_: ?*anyopaque,
|
||||
subsystem: sciter.OutputSubsystems,
|
||||
severity: u32,
|
||||
text: [*]const u16,
|
||||
text_length: u32,
|
||||
) callconv(.c) void {
|
||||
var utf8_buf: [4096]u8 = undefined;
|
||||
|
||||
const text_utf16 = text[0..text_length];
|
||||
const len = std.unicode.wtf16LeToWtf8(&utf8_buf, text_utf16);
|
||||
|
||||
const text_utf8 = utf8_buf[0..len];
|
||||
|
||||
std.debug.print("subsystem: {} | severity: {} | {s}\n", .{ subsystem, severity, text_utf8 });
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub const CStr = [*:0]const u8;
|
||||
pub const CWStr = [*:0]const u16;
|
||||
|
||||
@@ -10,10 +12,16 @@ pub const HNode = *Node;
|
||||
pub const SArchive = opaque {};
|
||||
pub const HSArchive = *SArchive;
|
||||
|
||||
/// - Windows: `HWND`
|
||||
/// - OS X: `NSView*`
|
||||
/// - Linux/GTK: `GtkWidget*`
|
||||
pub const HWindow = *anyopaque;
|
||||
pub const HWindow = switch (@import("builtin").os.tag) {
|
||||
.windows => @import("win32").foundation.HWND,
|
||||
.linux => @import("x11.zig").Window,
|
||||
else => @compileError("System not supported"),
|
||||
};
|
||||
|
||||
pub const HWindowOptional = switch (@typeInfo(HWindow)) {
|
||||
.pointer => @Type(.{ .optional = .{ .child = HWindow } }),
|
||||
else => HWindow,
|
||||
};
|
||||
|
||||
pub const BehaviorEventParams = extern struct {
|
||||
cmd: BehaviorEvents,
|
||||
@@ -447,9 +455,9 @@ pub const API = extern struct {
|
||||
SciterCreateWidget: *anyopaque,
|
||||
SciterCreateWindow: *const fn (creationFlags: u32, frame: *Rect, delegate: *const WindowDelegate, delegateParam: ?*anyopaque, parent: HWindow) callconv(.c) HWindow,
|
||||
|
||||
SciterSetupDebugOutput: *const fn (hwndOrNull: ?HWindow, param: ?*anyopaque, pfOutput: ?*DebugOutputProc) callconv(.c) void,
|
||||
SciterSetupDebugOutput: *const fn (hwndOrNull: HWindowOptional, param: ?*anyopaque, pfOutput: ?*const DebugOutputProc) callconv(.c) void,
|
||||
|
||||
// --- DOM API -------------------------------------------------------------
|
||||
// --- DOM API --------------------------------------------------------------
|
||||
|
||||
Sciter_UseElement: *const fn (he: HElement) callconv(.c) DomResult,
|
||||
Sciter_UnuseElement: *const fn (he: HElement) callconv(.c) DomResult,
|
||||
|
||||
2051
packages/sciter/src/x11.zig
Normal file
2051
packages/sciter/src/x11.zig
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/sciter/vendor/linux/aarch64/libsciter.so
(Stored with Git LFS)
vendored
Normal file
BIN
packages/sciter/vendor/linux/aarch64/libsciter.so
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
BIN
packages/sciter/vendor/linux/x86_64/libsciter.so
(Stored with Git LFS)
vendored
Normal file
BIN
packages/sciter/vendor/linux/x86_64/libsciter.so
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
BIN
packages/sciter/vendor/sciter.dll
(Stored with Git LFS)
vendored
BIN
packages/sciter/vendor/sciter.dll
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
packages/sciter/vendor/windows/aarch64/sciter.dll
(Stored with Git LFS)
vendored
Normal file
BIN
packages/sciter/vendor/windows/aarch64/sciter.dll
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
BIN
packages/sciter/vendor/windows/x86_64/sciter.dll
(Stored with Git LFS)
vendored
Normal file
BIN
packages/sciter/vendor/windows/x86_64/sciter.dll
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
Reference in New Issue
Block a user