feat(win32 gui): read initial window placement from config and tweak defaults
This commit is contained in:
parent
9e4e81eb0d
commit
5b2198b313
2 changed files with 15 additions and 9 deletions
|
@ -1,4 +1,7 @@
|
|||
fontface: [] const u8 = "Cascadia Code",
|
||||
fontsize: u8 = 17,
|
||||
fontsize: u8 = 14,
|
||||
|
||||
initial_window_x: u16 = 1087,
|
||||
initial_window_y: u16 = 1014,
|
||||
|
||||
include_files: []const u8 = "",
|
||||
|
|
|
@ -336,7 +336,7 @@ const WindowPlacement = struct {
|
|||
};
|
||||
};
|
||||
|
||||
fn calcWindowPlacement() WindowPlacement {
|
||||
fn calcWindowPlacement(initial_window_x: u16, initial_window_y: u16) WindowPlacement {
|
||||
var result = WindowPlacement.default;
|
||||
|
||||
const monitor = win32.MonitorFromPoint(
|
||||
|
@ -383,8 +383,8 @@ fn calcWindowPlacement() WindowPlacement {
|
|||
);
|
||||
|
||||
const wanted_size: XY(i32) = .{
|
||||
.x = win32.scaleDpi(i32, 800, result.dpi.x),
|
||||
.y = win32.scaleDpi(i32, 1200, result.dpi.y),
|
||||
.x = win32.scaleDpi(i32, @intCast(initial_window_x), result.dpi.x),
|
||||
.y = win32.scaleDpi(i32, @intCast(initial_window_y), result.dpi.y),
|
||||
};
|
||||
result.size = .{
|
||||
.x = @min(wanted_size.x, work_size.x),
|
||||
|
@ -416,7 +416,14 @@ fn entry(pid: thespian.pid) !void {
|
|||
|
||||
const CLASS_NAME = win32.L("Flow");
|
||||
|
||||
const initial_placement = calcWindowPlacement();
|
||||
const conf, _ = root.read_config(gui_config, arena_instance.allocator());
|
||||
root.write_config(conf, arena_instance.allocator()) catch
|
||||
std.log.err("failed to write gui config file", .{});
|
||||
|
||||
const initial_placement = calcWindowPlacement(
|
||||
conf.initial_window_x,
|
||||
conf.initial_window_y,
|
||||
);
|
||||
global.icons = getIcons(initial_placement.dpi);
|
||||
|
||||
// we only need to register the window class once per process
|
||||
|
@ -439,10 +446,6 @@ fn entry(pid: thespian.pid) !void {
|
|||
win32.GetLastError(),
|
||||
);
|
||||
|
||||
const conf, _ = root.read_config(gui_config, arena_instance.allocator());
|
||||
root.write_config(conf, arena_instance.allocator()) catch
|
||||
std.log.err("failed to write gui config file", .{});
|
||||
|
||||
var create_args = CreateWindowArgs{
|
||||
.allocator = arena_instance.allocator(),
|
||||
.pid = pid,
|
||||
|
|
Loading…
Add table
Reference in a new issue