Skip to content

Commit ca20994

Browse files
committed
Center initial Gtk3 window by default to fix odd Rocky Linux 8 placement
1 parent dfd08be commit ca20994

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

Package.swift

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ let package = Package(
7171
.library(name: "DefaultBackend", type: libraryType, targets: ["DefaultBackend"]),
7272
.library(name: "UIKitBackend", type: libraryType, targets: ["UIKitBackend"]),
7373
.library(name: "Gtk", type: libraryType, targets: ["Gtk"]),
74+
.library(name: "Gtk3", type: libraryType, targets: ["Gtk3"]),
7475
.executable(name: "GtkExample", targets: ["GtkExample"]),
7576
// .library(name: "CursesBackend", type: libraryType, targets: ["CursesBackend"]),
7677
// .library(name: "QtBackend", type: libraryType, targets: ["QtBackend"]),

Sources/Gtk3/Extensions/Widget+CastedPointer.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import Foundation
66

77
extension Widget {
8-
func castedPointer<T>() -> UnsafeMutablePointer<T> {
8+
public func castedPointer<T>() -> UnsafeMutablePointer<T> {
99
return widgetPointer.cast()
1010
}
1111
}

Sources/Gtk3/Widgets/Window.swift

+4
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,8 @@ open class Window: Bin {
6868
gint(minimumSize.height)
6969
)
7070
}
71+
72+
public func setPosition(to position: WindowPosition) {
73+
gtk_window_set_position(castedPointer(), position.toGtk())
74+
}
7175
}

Sources/Gtk3Backend/Gtk3Backend.swift

+1
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public final class Gtk3Backend: AppBackend {
9494
if let precreatedWindow = precreatedWindow {
9595
self.precreatedWindow = nil
9696
window = precreatedWindow
97+
window.setPosition(to: .center)
9798
} else {
9899
window = Gtk3.ApplicationWindow(application: gtkApp)
99100
}

0 commit comments

Comments
 (0)