Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DeterminateSystems/nix-installer-action@de22e16c4711fca50c816cc9081563429d1cf563
- uses: NixOS/nix-installer-action@0dd8719406e061e029989ec91b93d677d9e2bd63
with:
diagnostic-endpoint:
- uses: DeterminateSystems/magic-nix-cache-action@fc6aaceb40b9845a02b91e059ec147e78d1b4e41
- uses: DeterminateSystems/magic-nix-cache-action@20eea2e172f7f7487136e7a1a2f5b37aeb0e67bd
with:
diagnostic-endpoint:
- name: Build tinywl
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
pkgs.wayland
pkgs.libGL
pkgs.udev
pkgs.xorg.libX11
pkgs.xorg.xcbutilwm
pkgs.libx11
pkgs.libxcb-wm
];
preBuild = ''
wayland-scanner private-code ${pkgs.wayland-protocols}/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml wlroots/xdg-shell-protocol.c
Expand All @@ -59,8 +59,8 @@
pkgs.udev
pkgs.libGL
pkgs.pixman
pkgs.xorg.libX11
pkgs.xorg.xcbutilwm
pkgs.libx11
pkgs.libxcb-wm
];
};
}
Expand Down
7 changes: 2 additions & 5 deletions wlroots/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"unsafe"
)

// #cgo pkg-config: wlroots-0.18 wayland-server
// #cgo pkg-config: wlroots-0.19 wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #include <wlr/backend.h>
// #include <wlr/render/allocator.h>
Expand Down Expand Up @@ -50,10 +50,7 @@ func (b Backend) OnNewOutput(cb func(Output)) {
func (b Backend) OnNewInput(cb func(InputDevice)) {
man.add(unsafe.Pointer(b.p), &b.p.events.new_input, func(data unsafe.Pointer) {
dev := wrapInputDevice(data)
man.add(unsafe.Pointer(dev.p), &dev.p.events.destroy, func(data unsafe.Pointer) {
// delete the wlr_input_device
man.delete(unsafe.Pointer(dev.p))
})
man.track(unsafe.Pointer(dev.p), &dev.p.events.destroy)
cb(dev)
})
}
Expand Down
2 changes: 1 addition & 1 deletion wlroots/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package wlroots
* future consistency of this API.
*/

// #cgo pkg-config: wlroots-0.18 wayland-server
// #cgo pkg-config: wlroots-0.19 wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #include <wlr/types/wlr_buffer.h>
import "C"
Expand Down
2 changes: 1 addition & 1 deletion wlroots/compositor.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"golang.org/x/sys/unix"
)

// #cgo pkg-config: wlroots-0.18 wayland-server
// #cgo pkg-config: wlroots-0.19 wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #include <stdlib.h>
// #include <time.h>
Expand Down
4 changes: 2 additions & 2 deletions wlroots/cursor.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package wlroots

import "unsafe"

// #cgo pkg-config: wlroots-0.18 wayland-server
// #cgo pkg-config: wlroots-0.19 wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #include <stdlib.h>
// #include <wlr/types/wlr_cursor.h>
Expand Down Expand Up @@ -35,8 +35,8 @@ func NewCursor() Cursor {
}

func (c Cursor) Destroy() {
C.wlr_cursor_destroy(c.p)
man.delete(unsafe.Pointer(c.p))
C.wlr_cursor_destroy(c.p)
}

func (c Cursor) X() float64 {
Expand Down
2 changes: 1 addition & 1 deletion wlroots/input_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"unsafe"
)

// #cgo pkg-config: wlroots-0.18 wayland-server
// #cgo pkg-config: wlroots-0.19 wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #include <wlr/types/wlr_input_device.h>
// #include <wlr/types/wlr_keyboard.h>
Expand Down
2 changes: 1 addition & 1 deletion wlroots/keyboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/swaywm/go-wlroots/xkb"
)

// #cgo pkg-config: wlroots-0.18 wayland-server
// #cgo pkg-config: wlroots-0.19 wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #include <wlr/types/wlr_input_device.h>
// #include <wlr/types/wlr_keyboard.h>
Expand Down
2 changes: 1 addition & 1 deletion wlroots/listener_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
//
// Send help.

// #cgo pkg-config: wlroots-0.18 wayland-server
// #cgo pkg-config: wlroots-0.19 wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #include <stdlib.h>
// #include <wayland-server-core.h>
Expand Down
2 changes: 1 addition & 1 deletion wlroots/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package wlroots
* future consistency of this API.
*/

// #cgo pkg-config: wlroots-0.18 wayland-server
// #cgo pkg-config: wlroots-0.19 wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #include <stdlib.h>
// #include <stdio.h>
Expand Down
4 changes: 2 additions & 2 deletions wlroots/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"unsafe"
)

// #cgo pkg-config: wlroots-0.18 wayland-server
// #cgo pkg-config: wlroots-0.19 wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #include <wlr/backend/wayland.h>
// #include <wlr/types/wlr_output.h>
Expand Down Expand Up @@ -98,7 +98,7 @@ func (o Output) EffectiveResolution() (int, int) {
* committed with. A NULL state indicates no change.
*/
func (o Output) BeginRenderPass(state OutputState) (RenderPass, error) {
pass := C.wlr_output_begin_render_pass(o.p, state.p, nil, nil)
pass := C.wlr_output_begin_render_pass(o.p, state.p, nil)
if pass == nil {
return RenderPass{}, errors.New("can't begin render pass")
}
Expand Down
2 changes: 1 addition & 1 deletion wlroots/render_pass.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package wlroots
* future consistency of this API.
*/

// #cgo pkg-config: wlroots-0.18 wayland-server
// #cgo pkg-config: wlroots-0.19 wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #include <wlr/render/wlr_renderer.h>
import "C"
Expand Down
2 changes: 1 addition & 1 deletion wlroots/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package wlroots

import "unsafe"

// #cgo pkg-config: wlroots-0.18 wayland-server
// #cgo pkg-config: wlroots-0.19 wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #include <wlr/render/wlr_renderer.h>
import "C"
Expand Down
2 changes: 1 addition & 1 deletion wlroots/scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"golang.org/x/sys/unix"
)

// #cgo pkg-config: wlroots-0.18 wayland-server
// #cgo pkg-config: wlroots-0.19 wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #include <wlr/types/wlr_scene.h>
import "C"
Expand Down
2 changes: 1 addition & 1 deletion wlroots/seat.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package wlroots

import "unsafe"

// #cgo pkg-config: wlroots-0.18 wayland-server
// #cgo pkg-config: wlroots-0.19 wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #include <wlr/types/wlr_seat.h>
import "C"
Expand Down
2 changes: 1 addition & 1 deletion wlroots/server_decoration.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"unsafe"
)

// #cgo pkg-config: wlroots-0.18 wayland-server
// #cgo pkg-config: wlroots-0.19 wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #include <wlr/types/wlr_server_decoration.h>
import "C"
Expand Down
17 changes: 6 additions & 11 deletions wlroots/wlroots.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"unsafe"
)

// #cgo pkg-config: wlroots-0.18 wayland-server
// #cgo pkg-config: wlroots-0.19 wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #include <stdlib.h>
// #include <time.h>
Expand All @@ -19,7 +19,6 @@ import (
// #include <wlr/types/wlr_xdg_shell.h>
// #include <wlr/render/wlr_texture.h>
// #include <wlr/types/wlr_linux_dmabuf_v1.h>
// #include <wlr/types/wlr_matrix.h>
// #include <wlr/util/box.h>
// #include <wlr/util/edges.h>
import "C"
Expand Down Expand Up @@ -97,14 +96,6 @@ func (l OutputLayout) Coords(output Output) (x float64, y float64) {

type Matrix [9]float32

func (m *Matrix) ProjectBox(box *GeoBox, transform uint32, rotation float32, projection *Matrix) {
cm := m.toC()
b := box.toC()
pm := projection.toC()
C.wlr_matrix_project_box(&cm[0], &b, C.enum_wl_output_transform(transform), C.float(rotation), &pm[0])
m.fromC(&cm)
}

func (m *Matrix) toC() [9]C.float {
var cm [9]C.float
for i := range m {
Expand Down Expand Up @@ -214,7 +205,11 @@ func (d Display) NewXDGShell(version int) XDGShell {
func (d Display) XDGShellCreate(version int) XDGShell {
p := C.wlr_xdg_shell_create(d.p, C.uint(version))
man.track(unsafe.Pointer(p), &p.events.destroy)
return XDGShell{p: p}
xdgShell := XDGShell{p: p}
xdgShell.OnDestroy(func(XDGShell) {
man.delete(unsafe.Pointer(p))
})
return xdgShell
}

func (d Display) Destroy() {
Expand Down
2 changes: 1 addition & 1 deletion wlroots/xcursor.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package wlroots

import "unsafe"

// #cgo pkg-config: wlroots-0.18 wayland-server
// #cgo pkg-config: wlroots-0.19 wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #include <stdlib.h>
// #include <wlr/xcursor.h>
Expand Down
18 changes: 9 additions & 9 deletions wlroots/xdg_shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"unsafe"
)

// #cgo pkg-config: wlroots-0.18 wayland-server
// #cgo pkg-config: wlroots-0.19 wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #include <wlr/types/wlr_xdg_shell.h>
//
Expand Down Expand Up @@ -77,16 +77,19 @@ func (s XDGShell) OnNewSurface(cb func(XDGSurface)) {
man.delete(unsafe.Pointer(surface.p))
man.delete(unsafe.Pointer(surface.TopLevel().p))
})
man.add(unsafe.Pointer(surface.p.surface), &surface.p.surface.events.destroy, func(data unsafe.Pointer) {
man.delete(unsafe.Pointer(surface.p.surface))
})
man.track(unsafe.Pointer(surface.p.surface), &surface.p.surface.events.destroy)
cb(surface)
})
}

func (s XDGShell) OnNewTopLevel(cb func(XDGTopLevel)) {
man.add(unsafe.Pointer(s.p), &s.p.events.new_toplevel, func(data unsafe.Pointer) {
cb(XDGTopLevel{p: (*C.struct_wlr_xdg_toplevel)(data)})
xdgTopLevel := XDGTopLevel{p: (*C.struct_wlr_xdg_toplevel)(data)}
man.add(unsafe.Pointer(xdgTopLevel.p), &xdgTopLevel.p.events.destroy, func(data unsafe.Pointer) {
man.delete(unsafe.Pointer(xdgTopLevel.p))
man.delete(unsafe.Pointer(xdgTopLevel.Base().p))
})
cb(xdgTopLevel)
})
}

Expand Down Expand Up @@ -227,11 +230,8 @@ func (x XDGSurface) OnNewPopup(cb func(XDGSurface, XDGPopup)) {
}

func (x XDGSurface) Geometry() GeoBox {
var cb C.struct_wlr_box
C.wlr_xdg_surface_get_geometry(x.p, &cb)

var b GeoBox
b.fromC(&cb)
b.fromC(&x.p.geometry)
return b
}

Expand Down
6 changes: 2 additions & 4 deletions wlroots/xwayland.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package wlroots

import "unsafe"

// #cgo pkg-config: wlroots-0.18 wayland-server
// #cgo pkg-config: wlroots-0.19 wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #include <stdlib.h>
// #include <time.h>
Expand Down Expand Up @@ -39,9 +39,7 @@ func (x XWayland) OnNewSurface(cb func(XWaylandSurface)) {
man.add(unsafe.Pointer(x.p), &x.p.events.new_surface, func(data unsafe.Pointer) {
surface := XWaylandSurface{p: (*C.struct_wlr_xwayland_surface)(data)}
man.track(unsafe.Pointer(surface.p), &surface.p.events.destroy)
man.add(unsafe.Pointer(surface.p.surface), &surface.p.surface.events.destroy, func(data unsafe.Pointer) {
man.delete(unsafe.Pointer(surface.p.surface))
})
man.track(unsafe.Pointer(surface.p.surface), &surface.p.surface.events.destroy)
cb(surface)
})
}
Expand Down
Loading