mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 16:26:08 +03:00
apprt/gtk: handle surface scale changes
This commit is contained in:
@ -354,10 +354,12 @@ pub fn shouldClose(self: *const Surface) bool {
|
||||
}
|
||||
|
||||
pub fn getContentScale(self: *const Surface) !apprt.ContentScale {
|
||||
_ = self;
|
||||
const monitor = glfw.Monitor.getPrimary() orelse return error.NoMonitor;
|
||||
const scale = monitor.getContentScale();
|
||||
return apprt.ContentScale{ .x = scale.x_scale, .y = scale.y_scale };
|
||||
const window_scale: f32 = scale: {
|
||||
const window = @as(*c.GtkNative, @ptrCast(self.window.window));
|
||||
const gdk_surface = c.gtk_native_get_surface(window);
|
||||
break :scale @floatCast(c.gdk_surface_get_scale(gdk_surface));
|
||||
};
|
||||
return apprt.ContentScale{ .x = window_scale, .y = window_scale };
|
||||
}
|
||||
|
||||
pub fn getSize(self: *const Surface) !apprt.SurfaceSize {
|
||||
@ -625,6 +627,13 @@ fn gtkResize(area: *c.GtkGLArea, width: c.gint, height: c.gint, ud: ?*anyopaque)
|
||||
.height = @intCast(height),
|
||||
};
|
||||
|
||||
if (self.getContentScale()) |scale| {
|
||||
self.core_surface.contentScaleCallback(scale) catch |err| {
|
||||
log.err("error in content scale callback err={}", .{err});
|
||||
return;
|
||||
};
|
||||
} else |_|{}
|
||||
|
||||
// Call the primary callback.
|
||||
if (self.realized) {
|
||||
self.core_surface.sizeCallback(self.size) catch |err| {
|
||||
|
Reference in New Issue
Block a user