apprt/gtk-ng: toggle fullscreen and maximize
parent
5b37e86391
commit
6cf8007cf7
|
|
@ -509,9 +509,10 @@ pub const Application = extern struct {
|
||||||
|
|
||||||
.show_gtk_inspector => Action.showGtkInspector(),
|
.show_gtk_inspector => Action.showGtkInspector(),
|
||||||
|
|
||||||
|
.toggle_maximize => Action.toggleMaximize(target),
|
||||||
|
.toggle_fullscreen => Action.toggleFullscreen(target),
|
||||||
|
|
||||||
// Unimplemented but todo on gtk-ng branch
|
// Unimplemented but todo on gtk-ng branch
|
||||||
.toggle_maximize,
|
|
||||||
.toggle_fullscreen,
|
|
||||||
.new_tab,
|
.new_tab,
|
||||||
.goto_tab,
|
.goto_tab,
|
||||||
.move_tab,
|
.move_tab,
|
||||||
|
|
@ -1237,6 +1238,20 @@ const Action = struct {
|
||||||
pub fn showGtkInspector() void {
|
pub fn showGtkInspector() void {
|
||||||
gtk.Window.setInteractiveDebugging(@intFromBool(true));
|
gtk.Window.setInteractiveDebugging(@intFromBool(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn toggleFullscreen(target: apprt.Target) void {
|
||||||
|
switch (target) {
|
||||||
|
.app => {},
|
||||||
|
.surface => |v| v.rt_surface.surface.toggleFullscreen(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn toggleMaximize(target: apprt.Target) void {
|
||||||
|
switch (target) {
|
||||||
|
.app => {},
|
||||||
|
.surface => |v| v.rt_surface.surface.toggleMaximize(),
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This sets various GTK-related environment variables as necessary
|
/// This sets various GTK-related environment variables as necessary
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,26 @@ pub const Surface = extern struct {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const zoom = struct {
|
||||||
|
pub const name = "zoom";
|
||||||
|
const impl = gobject.ext.defineProperty(
|
||||||
|
name,
|
||||||
|
Self,
|
||||||
|
bool,
|
||||||
|
.{
|
||||||
|
.nick = "Zoom",
|
||||||
|
.blurb = "Whether the surface should be zoomed.",
|
||||||
|
.default = false,
|
||||||
|
.accessor = gobject.ext.privateFieldAccessor(
|
||||||
|
Self,
|
||||||
|
Private,
|
||||||
|
&Private.offset,
|
||||||
|
"zoom",
|
||||||
|
),
|
||||||
|
},
|
||||||
|
);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const signals = struct {
|
pub const signals = struct {
|
||||||
|
|
@ -271,6 +291,32 @@ pub const Surface = extern struct {
|
||||||
void,
|
void,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Emitted when this surface requests its container to toggle its
|
||||||
|
/// fullscreen state.
|
||||||
|
pub const @"toggle-fullscreen" = struct {
|
||||||
|
pub const name = "toggle-fullscreen";
|
||||||
|
pub const connect = impl.connect;
|
||||||
|
const impl = gobject.ext.defineSignal(
|
||||||
|
name,
|
||||||
|
Self,
|
||||||
|
&.{},
|
||||||
|
void,
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Emitted when this surface requests its container to toggle its
|
||||||
|
/// maximized state.
|
||||||
|
pub const @"toggle-maximize" = struct {
|
||||||
|
pub const name = "toggle-maximize";
|
||||||
|
pub const connect = impl.connect;
|
||||||
|
const impl = gobject.ext.defineSignal(
|
||||||
|
name,
|
||||||
|
Self,
|
||||||
|
&.{},
|
||||||
|
void,
|
||||||
|
);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const Private = struct {
|
const Private = struct {
|
||||||
|
|
@ -310,6 +356,10 @@ pub const Surface = extern struct {
|
||||||
/// focus events.
|
/// focus events.
|
||||||
focused: bool = true,
|
focused: bool = true,
|
||||||
|
|
||||||
|
/// Whether this surface is "zoomed" or not. A zoomed surface
|
||||||
|
/// shows up taking the full bounds of a split view.
|
||||||
|
zoom: bool = false,
|
||||||
|
|
||||||
/// The GLAarea that renders the actual surface. This is a binding
|
/// The GLAarea that renders the actual surface. This is a binding
|
||||||
/// to the template so it doesn't have to be unrefed manually.
|
/// to the template so it doesn't have to be unrefed manually.
|
||||||
gl_area: *gtk.GLArea,
|
gl_area: *gtk.GLArea,
|
||||||
|
|
@ -430,6 +480,24 @@ pub const Surface = extern struct {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn toggleFullscreen(self: *Self) void {
|
||||||
|
signals.@"toggle-fullscreen".impl.emit(
|
||||||
|
self,
|
||||||
|
null,
|
||||||
|
.{},
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn toggleMaximize(self: *Self) void {
|
||||||
|
signals.@"toggle-maximize".impl.emit(
|
||||||
|
self,
|
||||||
|
null,
|
||||||
|
.{},
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// Set the current progress report state.
|
/// Set the current progress report state.
|
||||||
pub fn setProgressReport(
|
pub fn setProgressReport(
|
||||||
self: *Self,
|
self: *Self,
|
||||||
|
|
@ -2076,6 +2144,7 @@ pub const Surface = extern struct {
|
||||||
properties.@"mouse-hover-url".impl,
|
properties.@"mouse-hover-url".impl,
|
||||||
properties.pwd.impl,
|
properties.pwd.impl,
|
||||||
properties.title.impl,
|
properties.title.impl,
|
||||||
|
properties.zoom.impl,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Signals
|
// Signals
|
||||||
|
|
@ -2083,6 +2152,8 @@ pub const Surface = extern struct {
|
||||||
signals.bell.impl.register(.{});
|
signals.bell.impl.register(.{});
|
||||||
signals.@"clipboard-read".impl.register(.{});
|
signals.@"clipboard-read".impl.register(.{});
|
||||||
signals.@"clipboard-write".impl.register(.{});
|
signals.@"clipboard-write".impl.register(.{});
|
||||||
|
signals.@"toggle-fullscreen".impl.register(.{});
|
||||||
|
signals.@"toggle-maximize".impl.register(.{});
|
||||||
|
|
||||||
// Virtual methods
|
// Virtual methods
|
||||||
gobject.Object.virtual_methods.dispose.implement(class, &dispose);
|
gobject.Object.virtual_methods.dispose.implement(class, &dispose);
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,34 @@ pub const Window = extern struct {
|
||||||
self.as(gtk.Window).close();
|
self.as(gtk.Window).close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn surfaceToggleFullscreen(
|
||||||
|
surface: *Surface,
|
||||||
|
self: *Self,
|
||||||
|
) callconv(.c) void {
|
||||||
|
_ = surface;
|
||||||
|
if (self.as(gtk.Window).isMaximized() != 0) {
|
||||||
|
self.as(gtk.Window).unmaximize();
|
||||||
|
} else {
|
||||||
|
self.as(gtk.Window).maximize();
|
||||||
|
}
|
||||||
|
|
||||||
|
// We react to the changes in the propFullscreen callback
|
||||||
|
}
|
||||||
|
|
||||||
|
fn surfaceToggleMaximize(
|
||||||
|
surface: *Surface,
|
||||||
|
self: *Self,
|
||||||
|
) callconv(.c) void {
|
||||||
|
_ = surface;
|
||||||
|
if (self.as(gtk.Window).isMaximized() != 0) {
|
||||||
|
self.as(gtk.Window).unmaximize();
|
||||||
|
} else {
|
||||||
|
self.as(gtk.Window).maximize();
|
||||||
|
}
|
||||||
|
|
||||||
|
// We react to the changes in the propMaximized callback
|
||||||
|
}
|
||||||
|
|
||||||
fn actionAbout(
|
fn actionAbout(
|
||||||
_: *gio.SimpleAction,
|
_: *gio.SimpleAction,
|
||||||
_: ?*glib.Variant,
|
_: ?*glib.Variant,
|
||||||
|
|
@ -219,6 +247,8 @@ pub const Window = extern struct {
|
||||||
|
|
||||||
// Template Callbacks
|
// Template Callbacks
|
||||||
class.bindTemplateCallback("surface_close_request", &surfaceCloseRequest);
|
class.bindTemplateCallback("surface_close_request", &surfaceCloseRequest);
|
||||||
|
class.bindTemplateCallback("surface_toggle_fullscreen", &surfaceToggleFullscreen);
|
||||||
|
class.bindTemplateCallback("surface_toggle_maximize", &surfaceToggleMaximize);
|
||||||
|
|
||||||
// Virtual methods
|
// Virtual methods
|
||||||
gobject.Object.virtual_methods.dispose.implement(class, &dispose);
|
gobject.Object.virtual_methods.dispose.implement(class, &dispose);
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ template $GhosttyWindow: Adw.ApplicationWindow {
|
||||||
|
|
||||||
$GhosttySurface surface {
|
$GhosttySurface surface {
|
||||||
close-request => $surface_close_request();
|
close-request => $surface_close_request();
|
||||||
|
toggle-fullscreen => $surface_toggle_fullscreen();
|
||||||
|
toggle-maximize => $surface_toggle_maximize();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue