Skip to content
Merged
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
48 changes: 27 additions & 21 deletions cmd/tinywl/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func (s *Server) handleOutputRequestState(output wlroots.Output, state wlroots.O
output.CommitState(state)
}

func (s *Server) handleOuptuDestroy(output wlroots.Output) {
func (s *Server) handleOutputDestroy(output wlroots.Output) {
slog.Debug("handleDestroy", "output", output)
}

Expand All @@ -276,7 +276,7 @@ func (s *Server) handleNewOutput(output wlroots.Output) {
* refresh rate), and each monitor supports only a specific set of modes. We
* just pick the monitor's preferred mode, a more sophisticated compositor
* would let the user configure it. */
mode, err := output.PrefferedMode()
mode, err := output.PreferredMode()
if err == nil {
oState.SetMode(mode)
}
Expand All @@ -292,7 +292,7 @@ func (s *Server) handleNewOutput(output wlroots.Output) {
output.OnRequestState(s.handleOutputRequestState)

/* Sets up a listener for the destroy event. */
output.OnDestroy(s.handleOuptuDestroy)
output.OnDestroy(s.handleOutputDestroy)

/* Adds this to the output layout. The add_auto function arranges outputs
* from left-to-right in the order they appear. A more sophisticated
Expand Down Expand Up @@ -477,7 +477,7 @@ func (s *Server) handleCursorAxis(_ wlroots.InputDevice, time uint32, source wlr
* for example when you move the scroll wheel. */

/* Notify the client with pointer focus of the axis event. */
s.seat.NotifyPointerAxis(time, orientation, delta, deltaDiscrete, source)
s.seat.NotifyPointerAxis(time, orientation, delta, deltaDiscrete, source, wlroots.RelativeDirectionIdentical)
}

func (s *Server) handleCursorFrame() {
Expand Down Expand Up @@ -539,29 +539,33 @@ func (s *Server) handleUnMapXDGToplevel(xdgSurface wlroots.XDGSurface) {
}
s.removeTopLevel(&topLevel)
}
func (s *Server) handleNewXDGSurface(xdgSurface wlroots.XDGSurface) {
/* This event is raised when wlr_xdg_shell receives a new xdg xdgSurface from a
* client, either a toplevel (application window) or popup. */

if xdgSurface.Role() == wlroots.XDGSurfaceRolePopup {
func (s *Server) handleNewXDGPopup(popup wlroots.XDGPopup) {
xdgSurface := popup.Base()
parent := popup.Parent()
if parent.Nil() {
panic("xdgSurface popup parent is nil")
}
xdgSurface.SetData(parent.XDGSurface().SceneTree().NewXDGSurface(xdgSurface))

parent := xdgSurface.Popup().Parent()
if parent.Nil() {
panic("xdgSurface popup parent is nil")
xdgSurface.OnCommit(func(surface wlroots.XDGSurface) {
if surface.InitialCommit() {
surface.ScheduleConfigure()
}
xdgSurface.SetData(parent.XDGSurface().SceneTree().NewXDGSurface(xdgSurface))
return
}
if xdgSurface.Role() != wlroots.XDGSurfaceRoleTopLevel {
panic("xdgSurface role is not XDGSurfaceRoleTopLevel")
}
})
}

func (s *Server) handleNewXDGTopLevel(toplevel wlroots.XDGTopLevel) {
xdgSurface := toplevel.Base()
xdgSurface.SetData(s.scene.Tree().NewXDGSurface(xdgSurface.TopLevel().Base()))
xdgSurface.OnMap(s.handleMapXDGToplevel)
xdgSurface.OnUnmap(s.handleUnMapXDGToplevel)
xdgSurface.OnDestroy(func(surface wlroots.XDGSurface) {})
xdgSurface.OnCommit(func(surface wlroots.XDGSurface) {
if surface.InitialCommit() {
surface.ScheduleConfigure()
}
})

toplevel := xdgSurface.TopLevel()
toplevel.OnRequestMove(func(client wlroots.SeatClient, serial uint32) {
s.beginInteractive(&toplevel, CursorModeMove, 0)
})
Expand Down Expand Up @@ -660,7 +664,7 @@ func NewServer() (s *Server, err error) {

/* Creates an output layout, which a wlroots utility for working with an
* arrangement of screens in a physical layout. */
s.outputLayout = wlroots.NewOutputLayout()
s.outputLayout = wlroots.NewOutputLayout(s.display)

/* Configure a listener to be notified when new outputs are available on the
* backend. */
Expand All @@ -681,7 +685,9 @@ func NewServer() (s *Server, err error) {
*/
s.topLevelList.Init()
s.xdgShell = s.display.XDGShellCreate(3)
s.xdgShell.OnNewSurface(s.handleNewXDGSurface)
s.xdgShell.OnNewSurface(func(xdgSurface wlroots.XDGSurface) {})
s.xdgShell.OnNewTopLevel(s.handleNewXDGTopLevel)
s.xdgShell.OnNewPopup(s.handleNewXDGPopup)

/*
* Creates a cursor, which is a wlroots utility for tracking the cursor
Expand Down
71 changes: 8 additions & 63 deletions flake.lock

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

105 changes: 50 additions & 55 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,65 @@
description = "Nix flake for go-wlroots";
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
gomod2nix = {
url = "github:tweag/gomod2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, utils, gomod2nix }:
utils.lib.eachDefaultSystem (system:
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ gomod2nix.overlays.default ];
pkgs = nixpkgs.legacyPackages.${system};
tinywl = pkgs.buildGoModule {
pname = "tinywl";
version = "0.0.0";
src = self;
vendorHash = "sha256-0vsi8q/+H7I5qvyr9sIZFLD30yZivySLWYT6KrJqIcc=";
subPackages = [ "cmd/tinywl" ];
nativeBuildInputs = [
pkgs.pkg-config
pkgs.wayland-scanner
];
buildInputs = [
pkgs.libxkbcommon
pkgs.pixman
pkgs.wlroots
pkgs.wayland
pkgs.libGL
pkgs.udev
pkgs.xorg.libX11
pkgs.xorg.xcbutilwm
];
preBuild = ''
wayland-scanner private-code ${pkgs.wayland-protocols}/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml wlroots/xdg-shell-protocol.c
wayland-scanner server-header ${pkgs.wayland-protocols}/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml wlroots/xdg-shell-protocol.h
'';
};
libxkbcommon =
pkgs.libxkbcommon.overrideAttrs (finalAttrs: prevAttrs: rec {
version = "1.6.0";
src = pkgs.fetchurl {
url = "https://xkbcommon.org/download/${prevAttrs.pname}-${version}.tar.xz";
hash = "sha256-DtwU7M3TkVFEWLxfWkuZhj7S1lHk3XYakKv09G75nCs=";
};
});
in
{
packages = rec {
packages = {
inherit tinywl;
default = tinywl;
tinywl = with pkgs; buildGoApplication {
pname = "tinywl";
version = "v0.0.0";
src = ./.;
subPackages = "cmd/tinywl";
modules = ./gomod2nix.toml;
nativeBuildInputs = [ pkg-config wayland ];
buildInputs = [
libxkbcommon
pixman
wlroots
wayland
libGL
udev
xorg.libX11
xorg.xcbutilwm
];
preBuild = ''
wayland-scanner private-code ${wayland-protocols}/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml wlroots/xdg-shell-protocol.c
wayland-scanner server-header ${wayland-protocols}/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml wlroots/xdg-shell-protocol.h
'';
};
};
devShells.default = with pkgs; mkShell {
devShells.default = pkgs.mkShell {
inputsFrom = [ tinywl ];
buildInputs = [
gcc
go
gopls
gomod2nix.packages.${system}.default
libxkbcommon
wlroots
pkg-config
wayland
udev
libGL
pixman
xorg.libX11
xorg.xcbutilwm
pkgs.gcc
pkgs.go
pkgs.gopls
pkgs.libxkbcommon
pkgs.wlroots
pkgs.pkg-config
pkgs.wayland
pkgs.udev
pkgs.libGL
pkgs.pixman
pkgs.xorg.libX11
pkgs.xorg.xcbutilwm
];
};
}
Expand Down
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module github.com/swaywm/go-wlroots

go 1.21
go 1.23.0

require golang.org/x/sys v0.15.0
toolchain go1.24.2

require golang.org/x/sys v0.33.0
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
6 changes: 0 additions & 6 deletions gomod2nix.toml

This file was deleted.

2 changes: 1 addition & 1 deletion 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 wayland-server
// #cgo pkg-config: wlroots-0.18 wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #include <wlr/backend.h>
// #include <wlr/render/allocator.h>
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 wayland-server
// #cgo pkg-config: wlroots-0.18 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 wayland-server
// #cgo pkg-config: wlroots-0.18 wayland-server
// #cgo CFLAGS: -D_GNU_SOURCE -DWLR_USE_UNSTABLE
// #include <stdlib.h>
// #include <time.h>
Expand Down
Loading