X11 API partial cleanup
This commit is contained in:
1
packages/sciter/.gitignore
vendored
Normal file
1
packages/sciter/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/sciter-js-sdk
|
||||
@@ -71,8 +71,10 @@ pub fn build(b: *std.Build) void {
|
||||
if (b.args) |args| {
|
||||
run_cmd.addArgs(args);
|
||||
}
|
||||
// TODO It does not look like the cleanest solution, however, the build
|
||||
// system code is too cryptic to come up with a better solution and the
|
||||
// Internet is surprisingly silent about this very basic use case.
|
||||
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);
|
||||
|
||||
@@ -77,7 +77,7 @@ pub fn wWinMain(
|
||||
std.posix.exit(1);
|
||||
};
|
||||
|
||||
_ = sciter_api.SciterSetOption(0, 10, 1);
|
||||
_ = sciter_api.SciterSetOption(null, 10, 1);
|
||||
sciter_api.SciterSetupDebugOutput(hwnd, null, &sciterDebugOutputProc);
|
||||
_ = sciter_api.SciterLoadHtml(hwnd, html, html.len, L("/"));
|
||||
_ = wam.ShowWindow(hwnd, @bitCast(nCmdShow));
|
||||
@@ -140,53 +140,62 @@ pub fn main() void {
|
||||
|
||||
std.debug.print("Sciter API version is: 0x{X:0>8}\n", .{sciter_api.version});
|
||||
|
||||
const display = x11.XOpenDisplay(null) orelse {
|
||||
const display = x11.Display.openDisplay(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);
|
||||
defer _ = display.closeDisplay();
|
||||
|
||||
const window = x11.XCreateSimpleWindow(
|
||||
display,
|
||||
x11.DefaultRootWindow(display),
|
||||
const screen = display.defaultScreen();
|
||||
|
||||
var attributes: x11.XSetWindowAttributes = .{
|
||||
.background_pixel = display.blackPixel(screen),
|
||||
.event_mask = .{
|
||||
.exposure = true,
|
||||
.key_press = true,
|
||||
},
|
||||
};
|
||||
|
||||
const window = display.createWindow(
|
||||
display.rootWindow(screen),
|
||||
0,
|
||||
0,
|
||||
720,
|
||||
480,
|
||||
0,
|
||||
x11.BlackPixel(display, x11.DefaultScreen(display)),
|
||||
x11.BlackPixel(display, x11.DefaultScreen(display)),
|
||||
display.defaultDepth(screen),
|
||||
x11.InputOutput,
|
||||
display.defaultVisual(screen),
|
||||
.{
|
||||
.background_pixel = true,
|
||||
.event_mask = true,
|
||||
},
|
||||
&attributes,
|
||||
);
|
||||
defer _ = x11.XDestroyWindow(display, window);
|
||||
defer _ = display.destroyWindow(window);
|
||||
|
||||
const event_mask = x11.KeyPressMask |
|
||||
x11.KeyReleaseMask |
|
||||
x11.ButtonPressMask |
|
||||
x11.ButtonReleaseMask |
|
||||
x11.EnterWindowMask |
|
||||
x11.LeaveWindowMask |
|
||||
x11.PointerMotionMask;
|
||||
_ = x11.XSelectInput(display, window, event_mask);
|
||||
_ = display.storeName(window, "Sciter Demo");
|
||||
|
||||
_ = x11.XStoreName(display, window, "Sciter Demo");
|
||||
const gc = display.createGC(@enumFromInt(@intFromEnum(window)), .{}, null);
|
||||
_ = display.freeGC(gc);
|
||||
|
||||
const wm_delete_window = x11.XInternAtom(display, "WM_DELETE_WINDOW", x11.False);
|
||||
_ = x11.XSetWMProtocols(display, window, @constCast(&wm_delete_window), 1);
|
||||
const wm_delete_window = display.internAtom("WM_DELETE_WINDOW", false);
|
||||
var protocols = [_]x11.Atom{wm_delete_window};
|
||||
_ = display.setWMProtocols(window, &protocols);
|
||||
|
||||
_ = x11.XMapWindow(display, window);
|
||||
defer _ = x11.XUnmapWindow(display, window);
|
||||
_ = display.mapWindow(window);
|
||||
defer _ = display.unmapWindow(window);
|
||||
|
||||
_ = sciter_api.SciterSetOption(0, 10, 1);
|
||||
_ = sciter_api.SciterSetOption(.null_handle, 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);
|
||||
const event = display.nextEvent();
|
||||
switch (event.type) {
|
||||
x11.ClientMessage => {
|
||||
const atom: x11.Atom = @bitCast(event.xclient.data.l[0]);
|
||||
const atom: x11.Atom = @enumFromInt(event.xclient.data.l[0]);
|
||||
if (atom == wm_delete_window) {
|
||||
running = false;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user