linux: allow title to be changed again
This commit is contained in:
parent
27aee7c036
commit
f39d47e49c
2 changed files with 17 additions and 11 deletions
|
|
@ -63,6 +63,7 @@ pub fn tick(core: *Core) !void {
|
||||||
while (windows.next()) |window_id| {
|
while (windows.next()) |window_id| {
|
||||||
const native_opt: ?Native = core.windows.get(window_id, .native);
|
const native_opt: ?Native = core.windows.get(window_id, .native);
|
||||||
if (native_opt) |native| {
|
if (native_opt) |native| {
|
||||||
|
check_for_mach_updates(core, window_id);
|
||||||
// check for display server events
|
// check for display server events
|
||||||
switch (native) {
|
switch (native) {
|
||||||
.x11 => try X11.tick(window_id),
|
.x11 => try X11.tick(window_id),
|
||||||
|
|
@ -146,16 +147,10 @@ pub fn update(linux: *Linux) !void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setTitle(linux: *Linux, title: [:0]const u8) void {
|
fn setTitle(native: *const Native, title: [:0]const u8) void {
|
||||||
const new_title = linux.allocator.dupeZ(u8, title) catch {
|
switch (native.*) {
|
||||||
log.err("Failed to reallocate memory for new window title", .{});
|
.wayland => |wl| Wayland.setTitle(&wl, title),
|
||||||
return;
|
.x11 => |x| X11.setTitle(&x, title),
|
||||||
};
|
|
||||||
linux.allocator.free(linux.title);
|
|
||||||
linux.title = new_title;
|
|
||||||
switch (linux.backend) {
|
|
||||||
.wayland => linux.backend.wayland.setTitle(linux.title),
|
|
||||||
.x11 => linux.backend.x11.setTitle(linux.title),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -192,6 +187,17 @@ pub fn setCursorShape(_: *Linux, _: CursorShape) void {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Checks for updates in mach object fields. Does nothing if window is not initialized.
|
||||||
|
fn check_for_mach_updates(core: *Core, window_id: mach.ObjectID) void {
|
||||||
|
const core_window = core.windows.getValue(window_id);
|
||||||
|
const native = &core_window.native;
|
||||||
|
if (native.*) |n| {
|
||||||
|
if (core.windows.updated(window_id, .title)) {
|
||||||
|
setTitle(&n, core_window.title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Check if gamemode should be activated
|
/// Check if gamemode should be activated
|
||||||
pub fn wantGamemode(allocator: std.mem.Allocator) error{ OutOfMemory, InvalidWtf8 }!bool {
|
pub fn wantGamemode(allocator: std.mem.Allocator) error{ OutOfMemory, InvalidWtf8 }!bool {
|
||||||
const use_gamemode = std.process.getEnvVarOwned(
|
const use_gamemode = std.process.getEnvVarOwned(
|
||||||
|
|
|
||||||
|
|
@ -243,7 +243,7 @@ pub fn tick(window_id: mach.ObjectID) !void {
|
||||||
_ = libwaylandclient.wl_display_roundtrip(wl.display);
|
_ = libwaylandclient.wl_display_roundtrip(wl.display);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setTitle(wl: *Wayland, title: [:0]const u8) void {
|
pub fn setTitle(wl: *const Native, title: [:0]const u8) void {
|
||||||
c.xdg_toplevel_set_title(wl.toplevel, title);
|
c.xdg_toplevel_set_title(wl.toplevel, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue