mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-31 08:52:49 -05:00
Compare commits
7 Commits
62bd6e41ef
...
5b7302b46d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b7302b46d | ||
|
|
34c0bba130 | ||
|
|
5a53447272 | ||
|
|
b6847289ff | ||
|
|
d22c43e08b | ||
|
|
d9deaa8d74 | ||
|
|
6c7776a9a6 |
@@ -16,6 +16,9 @@ Distribution-aware installer with TUI for deploying DMS and compositor configura
|
|||||||
|
|
||||||
**Wayland Protocols**
|
**Wayland Protocols**
|
||||||
- `wlr-gamma-control-unstable-v1` - Night mode and gamma control
|
- `wlr-gamma-control-unstable-v1` - Night mode and gamma control
|
||||||
|
- `wlr-screencopy-unstable-v1` - Screen capture for color picker
|
||||||
|
- `wlr-layer-shell-unstable-v1` - Overlay surfaces for color picker
|
||||||
|
- `wp-viewporter` - Fractional scaling support
|
||||||
- `dwl-ipc-unstable-v2` - dwl/MangoWC workspace integration
|
- `dwl-ipc-unstable-v2` - dwl/MangoWC workspace integration
|
||||||
- `ext-workspace-v1` - Workspace protocol support
|
- `ext-workspace-v1` - Workspace protocol support
|
||||||
- `wlr-output-management-unstable-v1` - Display configuration
|
- `wlr-output-management-unstable-v1` - Display configuration
|
||||||
@@ -44,9 +47,24 @@ Distribution-aware installer with TUI for deploying DMS and compositor configura
|
|||||||
- `dms ipc <command>` - Send IPC commands (toggle launcher, notifications, etc.)
|
- `dms ipc <command>` - Send IPC commands (toggle launcher, notifications, etc.)
|
||||||
- `dms plugins [install|browse|search]` - Plugin management
|
- `dms plugins [install|browse|search]` - Plugin management
|
||||||
- `dms brightness [list|set]` - Control display/monitor brightness
|
- `dms brightness [list|set]` - Control display/monitor brightness
|
||||||
|
- `dms color pick` - Native color picker (see below)
|
||||||
- `dms update` - Update DMS and dependencies (disabled in distro packages)
|
- `dms update` - Update DMS and dependencies (disabled in distro packages)
|
||||||
- `dms greeter install` - Install greetd greeter (disabled in distro packages)
|
- `dms greeter install` - Install greetd greeter (disabled in distro packages)
|
||||||
|
|
||||||
|
### Color Picker
|
||||||
|
|
||||||
|
Native Wayland color picker with magnifier, no external dependencies. Supports HiDPI and fractional scaling.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
dms color pick # Pick color, output hex
|
||||||
|
dms color pick --rgb # Output as RGB (255 128 64)
|
||||||
|
dms color pick --hsv # Output as HSV (24 75% 100%)
|
||||||
|
dms color pick --json # Output all formats as JSON
|
||||||
|
dms color pick -a # Auto-copy to clipboard
|
||||||
|
```
|
||||||
|
|
||||||
|
The on-screen preview displays the selected format. JSON output includes hex, RGB, HSL, HSV, and CMYK values.
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
Requires Go 1.24+
|
Requires Go 1.24+
|
||||||
|
|||||||
133
core/cmd/dms/commands_colorpicker.go
Normal file
133
core/cmd/dms/commands_colorpicker.go
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
|
||||||
|
"github.com/AvengeMedia/DankMaterialShell/core/internal/colorpicker"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
colorOutputFmt string
|
||||||
|
colorAutocopy bool
|
||||||
|
colorNotify bool
|
||||||
|
colorLowercase bool
|
||||||
|
)
|
||||||
|
|
||||||
|
var colorCmd = &cobra.Command{
|
||||||
|
Use: "color",
|
||||||
|
Short: "Color utilities",
|
||||||
|
Long: "Color utilities including picking colors from the screen",
|
||||||
|
}
|
||||||
|
|
||||||
|
var colorPickCmd = &cobra.Command{
|
||||||
|
Use: "pick",
|
||||||
|
Short: "Pick a color from the screen",
|
||||||
|
Long: `Pick a color from anywhere on your screen using an interactive color picker.
|
||||||
|
|
||||||
|
Click on any pixel to capture its color, or press Escape to cancel.
|
||||||
|
|
||||||
|
Output format flags (mutually exclusive, default: --hex):
|
||||||
|
--hex - Hexadecimal (#RRGGBB)
|
||||||
|
--rgb - RGB values (R G B)
|
||||||
|
--hsl - HSL values (H S% L%)
|
||||||
|
--hsv - HSV values (H S% V%)
|
||||||
|
--cmyk - CMYK values (C% M% Y% K%)
|
||||||
|
--json - JSON with all formats
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
dms color pick # Pick color, output as hex
|
||||||
|
dms color pick --rgb # Output as RGB
|
||||||
|
dms color pick --json # Output all formats as JSON
|
||||||
|
dms color pick --hex -l # Output hex in lowercase
|
||||||
|
dms color pick -a # Auto-copy result to clipboard`,
|
||||||
|
Run: runColorPick,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
colorPickCmd.Flags().Bool("hex", false, "Output as hexadecimal (#RRGGBB)")
|
||||||
|
colorPickCmd.Flags().Bool("rgb", false, "Output as RGB (R G B)")
|
||||||
|
colorPickCmd.Flags().Bool("hsl", false, "Output as HSL (H S% L%)")
|
||||||
|
colorPickCmd.Flags().Bool("hsv", false, "Output as HSV (H S% V%)")
|
||||||
|
colorPickCmd.Flags().Bool("cmyk", false, "Output as CMYK (C% M% Y% K%)")
|
||||||
|
colorPickCmd.Flags().Bool("json", false, "Output all formats as JSON")
|
||||||
|
colorPickCmd.Flags().StringVarP(&colorOutputFmt, "output-format", "o", "", "Custom output format template")
|
||||||
|
colorPickCmd.Flags().BoolVarP(&colorAutocopy, "autocopy", "a", false, "Copy result to clipboard")
|
||||||
|
colorPickCmd.Flags().BoolVarP(&colorLowercase, "lowercase", "l", false, "Output hex in lowercase")
|
||||||
|
|
||||||
|
colorPickCmd.MarkFlagsMutuallyExclusive("hex", "rgb", "hsl", "hsv", "cmyk", "json")
|
||||||
|
|
||||||
|
colorCmd.AddCommand(colorPickCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func runColorPick(cmd *cobra.Command, args []string) {
|
||||||
|
format := colorpicker.FormatHex // default
|
||||||
|
jsonOutput, _ := cmd.Flags().GetBool("json")
|
||||||
|
|
||||||
|
if rgb, _ := cmd.Flags().GetBool("rgb"); rgb {
|
||||||
|
format = colorpicker.FormatRGB
|
||||||
|
} else if hsl, _ := cmd.Flags().GetBool("hsl"); hsl {
|
||||||
|
format = colorpicker.FormatHSL
|
||||||
|
} else if hsv, _ := cmd.Flags().GetBool("hsv"); hsv {
|
||||||
|
format = colorpicker.FormatHSV
|
||||||
|
} else if cmyk, _ := cmd.Flags().GetBool("cmyk"); cmyk {
|
||||||
|
format = colorpicker.FormatCMYK
|
||||||
|
}
|
||||||
|
|
||||||
|
config := colorpicker.Config{
|
||||||
|
Format: format,
|
||||||
|
CustomFormat: colorOutputFmt,
|
||||||
|
Lowercase: colorLowercase,
|
||||||
|
Autocopy: colorAutocopy,
|
||||||
|
Notify: colorNotify,
|
||||||
|
}
|
||||||
|
|
||||||
|
picker := colorpicker.New(config)
|
||||||
|
color, err := picker.Run()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if color == nil {
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
var output string
|
||||||
|
if jsonOutput {
|
||||||
|
jsonStr, err := color.ToJSON()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
output = jsonStr
|
||||||
|
} else {
|
||||||
|
output = color.Format(config.Format, config.Lowercase, config.CustomFormat)
|
||||||
|
}
|
||||||
|
|
||||||
|
if colorAutocopy {
|
||||||
|
copyToClipboard(output)
|
||||||
|
}
|
||||||
|
|
||||||
|
if jsonOutput {
|
||||||
|
fmt.Println(output)
|
||||||
|
} else if color.IsDark() {
|
||||||
|
fmt.Printf("\033[48;2;%d;%d;%dm\033[97m %s \033[0m\n", color.R, color.G, color.B, output)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("\033[48;2;%d;%d;%dm\033[30m %s \033[0m\n", color.R, color.G, color.B, output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func copyToClipboard(text string) {
|
||||||
|
var cmd *exec.Cmd
|
||||||
|
if _, err := exec.LookPath("wl-copy"); err == nil {
|
||||||
|
cmd = exec.Command("wl-copy", text)
|
||||||
|
} else {
|
||||||
|
fmt.Fprintln(os.Stderr, "wl-copy not found, cannot copy to clipboard")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = cmd.Run()
|
||||||
|
}
|
||||||
@@ -471,5 +471,6 @@ func getCommonCommands() []*cobra.Command {
|
|||||||
keybindsCmd,
|
keybindsCmd,
|
||||||
greeterCmd,
|
greeterCmd,
|
||||||
setupCmd,
|
setupCmd,
|
||||||
|
colorCmd,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
306
core/internal/colorpicker/color.go
Normal file
306
core/internal/colorpicker/color.go
Normal file
@@ -0,0 +1,306 @@
|
|||||||
|
package colorpicker
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Color struct {
|
||||||
|
R, G, B, A uint8
|
||||||
|
}
|
||||||
|
|
||||||
|
type OutputFormat int
|
||||||
|
|
||||||
|
const (
|
||||||
|
FormatHex OutputFormat = iota
|
||||||
|
FormatRGB
|
||||||
|
FormatHSL
|
||||||
|
FormatHSV
|
||||||
|
FormatCMYK
|
||||||
|
)
|
||||||
|
|
||||||
|
func ParseFormat(s string) OutputFormat {
|
||||||
|
switch strings.ToLower(s) {
|
||||||
|
case "rgb":
|
||||||
|
return FormatRGB
|
||||||
|
case "hsl":
|
||||||
|
return FormatHSL
|
||||||
|
case "hsv":
|
||||||
|
return FormatHSV
|
||||||
|
case "cmyk":
|
||||||
|
return FormatCMYK
|
||||||
|
default:
|
||||||
|
return FormatHex
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Color) ToHex(lowercase bool) string {
|
||||||
|
if lowercase {
|
||||||
|
return fmt.Sprintf("#%02x%02x%02x", c.R, c.G, c.B)
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("#%02X%02X%02X", c.R, c.G, c.B)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Color) ToRGB() string {
|
||||||
|
return fmt.Sprintf("%d %d %d", c.R, c.G, c.B)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Color) ToHSL() string {
|
||||||
|
h, s, l := rgbToHSL(c.R, c.G, c.B)
|
||||||
|
return fmt.Sprintf("%d %d%% %d%%", h, s, l)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Color) ToHSV() string {
|
||||||
|
h, s, v := rgbToHSV(c.R, c.G, c.B)
|
||||||
|
return fmt.Sprintf("%d %d%% %d%%", h, s, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Color) ToCMYK() string {
|
||||||
|
cy, m, y, k := rgbToCMYK(c.R, c.G, c.B)
|
||||||
|
return fmt.Sprintf("%d%% %d%% %d%% %d%%", cy, m, y, k)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Color) Format(format OutputFormat, lowercase bool, customFmt string) string {
|
||||||
|
if customFmt != "" {
|
||||||
|
return c.formatCustom(format, customFmt)
|
||||||
|
}
|
||||||
|
|
||||||
|
switch format {
|
||||||
|
case FormatRGB:
|
||||||
|
return c.ToRGB()
|
||||||
|
case FormatHSL:
|
||||||
|
return c.ToHSL()
|
||||||
|
case FormatHSV:
|
||||||
|
return c.ToHSV()
|
||||||
|
case FormatCMYK:
|
||||||
|
return c.ToCMYK()
|
||||||
|
default:
|
||||||
|
return c.ToHex(lowercase)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Color) formatCustom(format OutputFormat, customFmt string) string {
|
||||||
|
switch format {
|
||||||
|
case FormatRGB:
|
||||||
|
return replaceArgs(customFmt, c.R, c.G, c.B)
|
||||||
|
case FormatHSL:
|
||||||
|
h, s, l := rgbToHSL(c.R, c.G, c.B)
|
||||||
|
return replaceArgs(customFmt, h, s, l)
|
||||||
|
case FormatHSV:
|
||||||
|
h, s, v := rgbToHSV(c.R, c.G, c.B)
|
||||||
|
return replaceArgs(customFmt, h, s, v)
|
||||||
|
case FormatCMYK:
|
||||||
|
cy, m, y, k := rgbToCMYK(c.R, c.G, c.B)
|
||||||
|
return replaceArgs4(customFmt, cy, m, y, k)
|
||||||
|
default:
|
||||||
|
if strings.Contains(customFmt, "{0}") {
|
||||||
|
r := fmt.Sprintf("%02X", c.R)
|
||||||
|
g := fmt.Sprintf("%02X", c.G)
|
||||||
|
b := fmt.Sprintf("%02X", c.B)
|
||||||
|
return replaceArgsStr(customFmt, r, g, b)
|
||||||
|
}
|
||||||
|
return c.ToHex(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func replaceArgs[T any](format string, a, b, c T) string {
|
||||||
|
result := format
|
||||||
|
result = strings.ReplaceAll(result, "{0}", fmt.Sprintf("%v", a))
|
||||||
|
result = strings.ReplaceAll(result, "{1}", fmt.Sprintf("%v", b))
|
||||||
|
result = strings.ReplaceAll(result, "{2}", fmt.Sprintf("%v", c))
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func replaceArgs4[T any](format string, a, b, c, d T) string {
|
||||||
|
result := format
|
||||||
|
result = strings.ReplaceAll(result, "{0}", fmt.Sprintf("%v", a))
|
||||||
|
result = strings.ReplaceAll(result, "{1}", fmt.Sprintf("%v", b))
|
||||||
|
result = strings.ReplaceAll(result, "{2}", fmt.Sprintf("%v", c))
|
||||||
|
result = strings.ReplaceAll(result, "{3}", fmt.Sprintf("%v", d))
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func replaceArgsStr(format, a, b, c string) string {
|
||||||
|
result := format
|
||||||
|
result = strings.ReplaceAll(result, "{0}", a)
|
||||||
|
result = strings.ReplaceAll(result, "{1}", b)
|
||||||
|
result = strings.ReplaceAll(result, "{2}", c)
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func rgbToHSL(r, g, b uint8) (int, int, int) {
|
||||||
|
rf := float64(r) / 255.0
|
||||||
|
gf := float64(g) / 255.0
|
||||||
|
bf := float64(b) / 255.0
|
||||||
|
|
||||||
|
maxVal := math.Max(rf, math.Max(gf, bf))
|
||||||
|
minVal := math.Min(rf, math.Min(gf, bf))
|
||||||
|
l := (maxVal + minVal) / 2
|
||||||
|
|
||||||
|
if maxVal == minVal {
|
||||||
|
return 0, 0, int(math.Round(l * 100))
|
||||||
|
}
|
||||||
|
|
||||||
|
d := maxVal - minVal
|
||||||
|
var s float64
|
||||||
|
if l > 0.5 {
|
||||||
|
s = d / (2 - maxVal - minVal)
|
||||||
|
} else {
|
||||||
|
s = d / (maxVal + minVal)
|
||||||
|
}
|
||||||
|
|
||||||
|
var h float64
|
||||||
|
switch maxVal {
|
||||||
|
case rf:
|
||||||
|
h = (gf - bf) / d
|
||||||
|
if gf < bf {
|
||||||
|
h += 6
|
||||||
|
}
|
||||||
|
case gf:
|
||||||
|
h = (bf-rf)/d + 2
|
||||||
|
case bf:
|
||||||
|
h = (rf-gf)/d + 4
|
||||||
|
}
|
||||||
|
h /= 6
|
||||||
|
|
||||||
|
return int(math.Round(h * 360)), int(math.Round(s * 100)), int(math.Round(l * 100))
|
||||||
|
}
|
||||||
|
|
||||||
|
func rgbToHSV(r, g, b uint8) (int, int, int) {
|
||||||
|
rf := float64(r) / 255.0
|
||||||
|
gf := float64(g) / 255.0
|
||||||
|
bf := float64(b) / 255.0
|
||||||
|
|
||||||
|
maxVal := math.Max(rf, math.Max(gf, bf))
|
||||||
|
minVal := math.Min(rf, math.Min(gf, bf))
|
||||||
|
v := maxVal
|
||||||
|
d := maxVal - minVal
|
||||||
|
|
||||||
|
var s float64
|
||||||
|
if maxVal != 0 {
|
||||||
|
s = d / maxVal
|
||||||
|
}
|
||||||
|
|
||||||
|
if maxVal == minVal {
|
||||||
|
return 0, int(math.Round(s * 100)), int(math.Round(v * 100))
|
||||||
|
}
|
||||||
|
|
||||||
|
var h float64
|
||||||
|
switch maxVal {
|
||||||
|
case rf:
|
||||||
|
h = (gf - bf) / d
|
||||||
|
if gf < bf {
|
||||||
|
h += 6
|
||||||
|
}
|
||||||
|
case gf:
|
||||||
|
h = (bf-rf)/d + 2
|
||||||
|
case bf:
|
||||||
|
h = (rf-gf)/d + 4
|
||||||
|
}
|
||||||
|
h /= 6
|
||||||
|
|
||||||
|
return int(math.Round(h * 360)), int(math.Round(s * 100)), int(math.Round(v * 100))
|
||||||
|
}
|
||||||
|
|
||||||
|
func rgbToCMYK(r, g, b uint8) (int, int, int, int) {
|
||||||
|
if r == 0 && g == 0 && b == 0 {
|
||||||
|
return 0, 0, 0, 100
|
||||||
|
}
|
||||||
|
|
||||||
|
rf := float64(r) / 255.0
|
||||||
|
gf := float64(g) / 255.0
|
||||||
|
bf := float64(b) / 255.0
|
||||||
|
|
||||||
|
k := 1 - math.Max(rf, math.Max(gf, bf))
|
||||||
|
c := (1 - rf - k) / (1 - k)
|
||||||
|
m := (1 - gf - k) / (1 - k)
|
||||||
|
y := (1 - bf - k) / (1 - k)
|
||||||
|
|
||||||
|
return int(math.Round(c * 100)), int(math.Round(m * 100)), int(math.Round(y * 100)), int(math.Round(k * 100))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Color) Luminance() float64 {
|
||||||
|
r := float64(c.R) / 255.0
|
||||||
|
g := float64(c.G) / 255.0
|
||||||
|
b := float64(c.B) / 255.0
|
||||||
|
|
||||||
|
if r <= 0.03928 {
|
||||||
|
r = r / 12.92
|
||||||
|
} else {
|
||||||
|
r = math.Pow((r+0.055)/1.055, 2.4)
|
||||||
|
}
|
||||||
|
|
||||||
|
if g <= 0.03928 {
|
||||||
|
g = g / 12.92
|
||||||
|
} else {
|
||||||
|
g = math.Pow((g+0.055)/1.055, 2.4)
|
||||||
|
}
|
||||||
|
|
||||||
|
if b <= 0.03928 {
|
||||||
|
b = b / 12.92
|
||||||
|
} else {
|
||||||
|
b = math.Pow((b+0.055)/1.055, 2.4)
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0.2126*r + 0.7152*g + 0.0722*b
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Color) IsDark() bool {
|
||||||
|
return c.Luminance() < 0.179
|
||||||
|
}
|
||||||
|
|
||||||
|
type ColorJSON struct {
|
||||||
|
Hex string `json:"hex"`
|
||||||
|
RGB struct {
|
||||||
|
R int `json:"r"`
|
||||||
|
G int `json:"g"`
|
||||||
|
B int `json:"b"`
|
||||||
|
} `json:"rgb"`
|
||||||
|
HSL struct {
|
||||||
|
H int `json:"h"`
|
||||||
|
S int `json:"s"`
|
||||||
|
L int `json:"l"`
|
||||||
|
} `json:"hsl"`
|
||||||
|
HSV struct {
|
||||||
|
H int `json:"h"`
|
||||||
|
S int `json:"s"`
|
||||||
|
V int `json:"v"`
|
||||||
|
} `json:"hsv"`
|
||||||
|
CMYK struct {
|
||||||
|
C int `json:"c"`
|
||||||
|
M int `json:"m"`
|
||||||
|
Y int `json:"y"`
|
||||||
|
K int `json:"k"`
|
||||||
|
} `json:"cmyk"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c Color) ToJSON() (string, error) {
|
||||||
|
h, s, l := rgbToHSL(c.R, c.G, c.B)
|
||||||
|
hv, sv, v := rgbToHSV(c.R, c.G, c.B)
|
||||||
|
cy, m, y, k := rgbToCMYK(c.R, c.G, c.B)
|
||||||
|
|
||||||
|
data := ColorJSON{
|
||||||
|
Hex: c.ToHex(false),
|
||||||
|
}
|
||||||
|
data.RGB.R = int(c.R)
|
||||||
|
data.RGB.G = int(c.G)
|
||||||
|
data.RGB.B = int(c.B)
|
||||||
|
data.HSL.H = h
|
||||||
|
data.HSL.S = s
|
||||||
|
data.HSL.L = l
|
||||||
|
data.HSV.H = hv
|
||||||
|
data.HSV.S = sv
|
||||||
|
data.HSV.V = v
|
||||||
|
data.CMYK.C = cy
|
||||||
|
data.CMYK.M = m
|
||||||
|
data.CMYK.Y = y
|
||||||
|
data.CMYK.K = k
|
||||||
|
|
||||||
|
bytes, err := json.MarshalIndent(data, "", " ")
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return string(bytes), nil
|
||||||
|
}
|
||||||
702
core/internal/colorpicker/picker.go
Normal file
702
core/internal/colorpicker/picker.go
Normal file
@@ -0,0 +1,702 @@
|
|||||||
|
package colorpicker
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/AvengeMedia/DankMaterialShell/core/internal/log"
|
||||||
|
"github.com/AvengeMedia/DankMaterialShell/core/internal/proto/keyboard_shortcuts_inhibit"
|
||||||
|
"github.com/AvengeMedia/DankMaterialShell/core/internal/proto/wlr_layer_shell"
|
||||||
|
"github.com/AvengeMedia/DankMaterialShell/core/internal/proto/wlr_screencopy"
|
||||||
|
"github.com/AvengeMedia/DankMaterialShell/core/internal/proto/wp_viewporter"
|
||||||
|
"github.com/AvengeMedia/DankMaterialShell/core/pkg/go-wayland/wayland/client"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Config struct {
|
||||||
|
Format OutputFormat
|
||||||
|
CustomFormat string
|
||||||
|
Lowercase bool
|
||||||
|
Autocopy bool
|
||||||
|
Notify bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type Output struct {
|
||||||
|
wlOutput *client.Output
|
||||||
|
name string
|
||||||
|
globalName uint32
|
||||||
|
x, y int32
|
||||||
|
width int32
|
||||||
|
height int32
|
||||||
|
scale int32
|
||||||
|
fractionalScale float64
|
||||||
|
}
|
||||||
|
|
||||||
|
type LayerSurface struct {
|
||||||
|
output *Output
|
||||||
|
state *SurfaceState
|
||||||
|
wlSurface *client.Surface
|
||||||
|
layerSurf *wlr_layer_shell.ZwlrLayerSurfaceV1
|
||||||
|
viewport *wp_viewporter.WpViewport
|
||||||
|
wlPool *client.ShmPool
|
||||||
|
wlBuffer *client.Buffer
|
||||||
|
configured bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type Picker struct {
|
||||||
|
config Config
|
||||||
|
|
||||||
|
display *client.Display
|
||||||
|
registry *client.Registry
|
||||||
|
ctx *client.Context
|
||||||
|
|
||||||
|
compositor *client.Compositor
|
||||||
|
shm *client.Shm
|
||||||
|
seat *client.Seat
|
||||||
|
pointer *client.Pointer
|
||||||
|
keyboard *client.Keyboard
|
||||||
|
layerShell *wlr_layer_shell.ZwlrLayerShellV1
|
||||||
|
screencopy *wlr_screencopy.ZwlrScreencopyManagerV1
|
||||||
|
viewporter *wp_viewporter.WpViewporter
|
||||||
|
|
||||||
|
shortcutsInhibitMgr *keyboard_shortcuts_inhibit.ZwpKeyboardShortcutsInhibitManagerV1
|
||||||
|
shortcutsInhibitor *keyboard_shortcuts_inhibit.ZwpKeyboardShortcutsInhibitorV1
|
||||||
|
|
||||||
|
outputs map[uint32]*Output
|
||||||
|
outputsMu sync.Mutex
|
||||||
|
|
||||||
|
surfaces []*LayerSurface
|
||||||
|
activeSurface *LayerSurface
|
||||||
|
|
||||||
|
running bool
|
||||||
|
pickedColor *Color
|
||||||
|
err error
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(config Config) *Picker {
|
||||||
|
return &Picker{
|
||||||
|
config: config,
|
||||||
|
outputs: make(map[uint32]*Output),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Picker) Run() (*Color, error) {
|
||||||
|
if err := p.connect(); err != nil {
|
||||||
|
return nil, fmt.Errorf("wayland connect: %w", err)
|
||||||
|
}
|
||||||
|
defer p.cleanup()
|
||||||
|
|
||||||
|
if err := p.setupRegistry(); err != nil {
|
||||||
|
return nil, fmt.Errorf("registry setup: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := p.roundtrip(); err != nil {
|
||||||
|
return nil, fmt.Errorf("roundtrip: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.screencopy == nil {
|
||||||
|
return nil, fmt.Errorf("compositor does not support wlr-screencopy-unstable-v1")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.layerShell == nil {
|
||||||
|
return nil, fmt.Errorf("compositor does not support wlr-layer-shell-unstable-v1")
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.seat == nil {
|
||||||
|
return nil, fmt.Errorf("no seat available")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := p.roundtrip(); err != nil {
|
||||||
|
return nil, fmt.Errorf("roundtrip: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := p.createSurfaces(); err != nil {
|
||||||
|
return nil, fmt.Errorf("create surfaces: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := p.roundtrip(); err != nil {
|
||||||
|
return nil, fmt.Errorf("roundtrip: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
p.running = true
|
||||||
|
for p.running {
|
||||||
|
if err := p.ctx.Dispatch(); err != nil {
|
||||||
|
p.err = err
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
p.checkDone()
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.err != nil {
|
||||||
|
return nil, p.err
|
||||||
|
}
|
||||||
|
|
||||||
|
return p.pickedColor, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Picker) checkDone() {
|
||||||
|
for _, ls := range p.surfaces {
|
||||||
|
picked, cancelled := ls.state.IsDone()
|
||||||
|
switch {
|
||||||
|
case cancelled:
|
||||||
|
p.running = false
|
||||||
|
return
|
||||||
|
case picked:
|
||||||
|
color, ok := ls.state.PickColor()
|
||||||
|
if ok {
|
||||||
|
p.pickedColor = &color
|
||||||
|
}
|
||||||
|
p.running = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Picker) connect() error {
|
||||||
|
display, err := client.Connect("")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
p.display = display
|
||||||
|
p.ctx = display.Context()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Picker) roundtrip() error {
|
||||||
|
callback, err := p.display.Sync()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
done := make(chan struct{})
|
||||||
|
callback.SetDoneHandler(func(e client.CallbackDoneEvent) {
|
||||||
|
close(done)
|
||||||
|
})
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-done:
|
||||||
|
return nil
|
||||||
|
default:
|
||||||
|
if err := p.ctx.Dispatch(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Picker) setupRegistry() error {
|
||||||
|
registry, err := p.display.GetRegistry()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
p.registry = registry
|
||||||
|
|
||||||
|
registry.SetGlobalHandler(func(e client.RegistryGlobalEvent) {
|
||||||
|
p.handleGlobal(e)
|
||||||
|
})
|
||||||
|
|
||||||
|
registry.SetGlobalRemoveHandler(func(e client.RegistryGlobalRemoveEvent) {
|
||||||
|
p.outputsMu.Lock()
|
||||||
|
delete(p.outputs, e.Name)
|
||||||
|
p.outputsMu.Unlock()
|
||||||
|
})
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Picker) handleGlobal(e client.RegistryGlobalEvent) {
|
||||||
|
switch e.Interface {
|
||||||
|
case client.CompositorInterfaceName:
|
||||||
|
compositor := client.NewCompositor(p.ctx)
|
||||||
|
if err := p.registry.Bind(e.Name, e.Interface, e.Version, compositor); err == nil {
|
||||||
|
p.compositor = compositor
|
||||||
|
}
|
||||||
|
|
||||||
|
case client.ShmInterfaceName:
|
||||||
|
shm := client.NewShm(p.ctx)
|
||||||
|
if err := p.registry.Bind(e.Name, e.Interface, e.Version, shm); err == nil {
|
||||||
|
p.shm = shm
|
||||||
|
}
|
||||||
|
|
||||||
|
case client.SeatInterfaceName:
|
||||||
|
seat := client.NewSeat(p.ctx)
|
||||||
|
if err := p.registry.Bind(e.Name, e.Interface, e.Version, seat); err == nil {
|
||||||
|
p.seat = seat
|
||||||
|
p.setupInput()
|
||||||
|
}
|
||||||
|
|
||||||
|
case client.OutputInterfaceName:
|
||||||
|
output := client.NewOutput(p.ctx)
|
||||||
|
version := e.Version
|
||||||
|
if version > 4 {
|
||||||
|
version = 4
|
||||||
|
}
|
||||||
|
if err := p.registry.Bind(e.Name, e.Interface, version, output); err == nil {
|
||||||
|
p.outputsMu.Lock()
|
||||||
|
p.outputs[e.Name] = &Output{
|
||||||
|
wlOutput: output,
|
||||||
|
globalName: e.Name,
|
||||||
|
scale: 1,
|
||||||
|
fractionalScale: 1.0,
|
||||||
|
}
|
||||||
|
p.outputsMu.Unlock()
|
||||||
|
p.setupOutputHandlers(e.Name, output)
|
||||||
|
}
|
||||||
|
|
||||||
|
case wlr_layer_shell.ZwlrLayerShellV1InterfaceName:
|
||||||
|
layerShell := wlr_layer_shell.NewZwlrLayerShellV1(p.ctx)
|
||||||
|
version := e.Version
|
||||||
|
if version > 4 {
|
||||||
|
version = 4
|
||||||
|
}
|
||||||
|
if err := p.registry.Bind(e.Name, e.Interface, version, layerShell); err == nil {
|
||||||
|
p.layerShell = layerShell
|
||||||
|
}
|
||||||
|
|
||||||
|
case wlr_screencopy.ZwlrScreencopyManagerV1InterfaceName:
|
||||||
|
screencopy := wlr_screencopy.NewZwlrScreencopyManagerV1(p.ctx)
|
||||||
|
version := e.Version
|
||||||
|
if version > 3 {
|
||||||
|
version = 3
|
||||||
|
}
|
||||||
|
if err := p.registry.Bind(e.Name, e.Interface, version, screencopy); err == nil {
|
||||||
|
p.screencopy = screencopy
|
||||||
|
}
|
||||||
|
|
||||||
|
case wp_viewporter.WpViewporterInterfaceName:
|
||||||
|
viewporter := wp_viewporter.NewWpViewporter(p.ctx)
|
||||||
|
if err := p.registry.Bind(e.Name, e.Interface, e.Version, viewporter); err == nil {
|
||||||
|
p.viewporter = viewporter
|
||||||
|
}
|
||||||
|
|
||||||
|
case keyboard_shortcuts_inhibit.ZwpKeyboardShortcutsInhibitManagerV1InterfaceName:
|
||||||
|
mgr := keyboard_shortcuts_inhibit.NewZwpKeyboardShortcutsInhibitManagerV1(p.ctx)
|
||||||
|
if err := p.registry.Bind(e.Name, e.Interface, e.Version, mgr); err == nil {
|
||||||
|
p.shortcutsInhibitMgr = mgr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Picker) setupOutputHandlers(name uint32, output *client.Output) {
|
||||||
|
output.SetGeometryHandler(func(e client.OutputGeometryEvent) {
|
||||||
|
p.outputsMu.Lock()
|
||||||
|
if o, ok := p.outputs[name]; ok {
|
||||||
|
o.x = e.X
|
||||||
|
o.y = e.Y
|
||||||
|
}
|
||||||
|
p.outputsMu.Unlock()
|
||||||
|
})
|
||||||
|
|
||||||
|
output.SetModeHandler(func(e client.OutputModeEvent) {
|
||||||
|
if e.Flags&uint32(client.OutputModeCurrent) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
p.outputsMu.Lock()
|
||||||
|
if o, ok := p.outputs[name]; ok {
|
||||||
|
o.width = e.Width
|
||||||
|
o.height = e.Height
|
||||||
|
}
|
||||||
|
p.outputsMu.Unlock()
|
||||||
|
})
|
||||||
|
|
||||||
|
output.SetScaleHandler(func(e client.OutputScaleEvent) {
|
||||||
|
p.outputsMu.Lock()
|
||||||
|
if o, ok := p.outputs[name]; ok {
|
||||||
|
o.scale = e.Factor
|
||||||
|
o.fractionalScale = float64(e.Factor)
|
||||||
|
}
|
||||||
|
p.outputsMu.Unlock()
|
||||||
|
})
|
||||||
|
|
||||||
|
output.SetNameHandler(func(e client.OutputNameEvent) {
|
||||||
|
p.outputsMu.Lock()
|
||||||
|
if o, ok := p.outputs[name]; ok {
|
||||||
|
o.name = e.Name
|
||||||
|
}
|
||||||
|
p.outputsMu.Unlock()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Picker) createSurfaces() error {
|
||||||
|
p.outputsMu.Lock()
|
||||||
|
outputs := make([]*Output, 0, len(p.outputs))
|
||||||
|
for _, o := range p.outputs {
|
||||||
|
outputs = append(outputs, o)
|
||||||
|
}
|
||||||
|
p.outputsMu.Unlock()
|
||||||
|
|
||||||
|
for _, output := range outputs {
|
||||||
|
ls, err := p.createLayerSurface(output)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("output %s: %w", output.name, err)
|
||||||
|
}
|
||||||
|
p.surfaces = append(p.surfaces, ls)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Picker) createLayerSurface(output *Output) (*LayerSurface, error) {
|
||||||
|
surface, err := p.compositor.CreateSurface()
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("create surface: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
layerSurf, err := p.layerShell.GetLayerSurface(
|
||||||
|
surface,
|
||||||
|
output.wlOutput,
|
||||||
|
uint32(wlr_layer_shell.ZwlrLayerShellV1LayerOverlay),
|
||||||
|
"dms-colorpicker",
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("get layer surface: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
ls := &LayerSurface{
|
||||||
|
output: output,
|
||||||
|
state: NewSurfaceState(p.config.Format, p.config.Lowercase),
|
||||||
|
wlSurface: surface,
|
||||||
|
layerSurf: layerSurf,
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.viewporter != nil {
|
||||||
|
vp, err := p.viewporter.GetViewport(surface)
|
||||||
|
if err == nil {
|
||||||
|
ls.viewport = vp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := layerSurf.SetAnchor(
|
||||||
|
uint32(wlr_layer_shell.ZwlrLayerSurfaceV1AnchorTop) |
|
||||||
|
uint32(wlr_layer_shell.ZwlrLayerSurfaceV1AnchorBottom) |
|
||||||
|
uint32(wlr_layer_shell.ZwlrLayerSurfaceV1AnchorLeft) |
|
||||||
|
uint32(wlr_layer_shell.ZwlrLayerSurfaceV1AnchorRight),
|
||||||
|
); err != nil {
|
||||||
|
log.Warn("failed to set layer anchor", "err", err)
|
||||||
|
}
|
||||||
|
if err := layerSurf.SetExclusiveZone(-1); err != nil {
|
||||||
|
log.Warn("failed to set exclusive zone", "err", err)
|
||||||
|
}
|
||||||
|
if err := layerSurf.SetKeyboardInteractivity(uint32(wlr_layer_shell.ZwlrLayerSurfaceV1KeyboardInteractivityExclusive)); err != nil {
|
||||||
|
log.Warn("failed to set keyboard interactivity", "err", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
layerSurf.SetConfigureHandler(func(e wlr_layer_shell.ZwlrLayerSurfaceV1ConfigureEvent) {
|
||||||
|
if err := layerSurf.AckConfigure(e.Serial); err != nil {
|
||||||
|
log.Warn("failed to ack configure", "err", err)
|
||||||
|
}
|
||||||
|
if err := ls.state.OnLayerConfigure(int(e.Width), int(e.Height)); err != nil {
|
||||||
|
log.Warn("failed to handle layer configure", "err", err)
|
||||||
|
}
|
||||||
|
ls.configured = true
|
||||||
|
|
||||||
|
scale := p.computeSurfaceScale(ls)
|
||||||
|
ls.state.SetScale(scale)
|
||||||
|
|
||||||
|
if !ls.state.IsReady() {
|
||||||
|
p.captureForSurface(ls)
|
||||||
|
} else {
|
||||||
|
p.redrawSurface(ls)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request shortcut inhibition once surface is configured
|
||||||
|
p.ensureShortcutsInhibitor(ls)
|
||||||
|
})
|
||||||
|
|
||||||
|
layerSurf.SetClosedHandler(func(e wlr_layer_shell.ZwlrLayerSurfaceV1ClosedEvent) {
|
||||||
|
p.running = false
|
||||||
|
})
|
||||||
|
|
||||||
|
if err := surface.Commit(); err != nil {
|
||||||
|
log.Warn("failed to commit surface", "err", err)
|
||||||
|
}
|
||||||
|
return ls, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Picker) computeSurfaceScale(ls *LayerSurface) int32 {
|
||||||
|
out := ls.output
|
||||||
|
if out == nil || out.fractionalScale <= 0 {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
scale := int32(math.Ceil(out.fractionalScale))
|
||||||
|
if scale <= 0 {
|
||||||
|
scale = 1
|
||||||
|
}
|
||||||
|
return scale
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Picker) ensureShortcutsInhibitor(ls *LayerSurface) {
|
||||||
|
if p.shortcutsInhibitMgr == nil || p.seat == nil || p.shortcutsInhibitor != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
inhibitor, err := p.shortcutsInhibitMgr.InhibitShortcuts(ls.wlSurface, p.seat)
|
||||||
|
if err != nil {
|
||||||
|
log.Debug("failed to create shortcuts inhibitor", "err", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
p.shortcutsInhibitor = inhibitor
|
||||||
|
|
||||||
|
inhibitor.SetActiveHandler(func(e keyboard_shortcuts_inhibit.ZwpKeyboardShortcutsInhibitorV1ActiveEvent) {
|
||||||
|
log.Debug("shortcuts inhibitor active")
|
||||||
|
})
|
||||||
|
|
||||||
|
inhibitor.SetInactiveHandler(func(e keyboard_shortcuts_inhibit.ZwpKeyboardShortcutsInhibitorV1InactiveEvent) {
|
||||||
|
log.Debug("shortcuts inhibitor deactivated by compositor")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Picker) captureForSurface(ls *LayerSurface) {
|
||||||
|
frame, err := p.screencopy.CaptureOutput(0, ls.output.wlOutput)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
frame.SetBufferHandler(func(e wlr_screencopy.ZwlrScreencopyFrameV1BufferEvent) {
|
||||||
|
if err := ls.state.OnScreencopyBuffer(PixelFormat(e.Format), int(e.Width), int(e.Height), int(e.Stride)); err != nil {
|
||||||
|
log.Error("failed to create screencopy buffer", "err", err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
frame.SetBufferDoneHandler(func(e wlr_screencopy.ZwlrScreencopyFrameV1BufferDoneEvent) {
|
||||||
|
screenBuf := ls.state.ScreenBuffer()
|
||||||
|
if screenBuf == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
pool, err := p.shm.CreatePool(screenBuf.Fd(), int32(screenBuf.Size()))
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
wlBuffer, err := pool.CreateBuffer(0, int32(screenBuf.Width), int32(screenBuf.Height), int32(screenBuf.Stride), uint32(ls.state.screenFormat))
|
||||||
|
if err != nil {
|
||||||
|
pool.Destroy()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := frame.Copy(wlBuffer); err != nil {
|
||||||
|
log.Error("failed to copy frame", "err", err)
|
||||||
|
}
|
||||||
|
pool.Destroy()
|
||||||
|
})
|
||||||
|
|
||||||
|
frame.SetFlagsHandler(func(e wlr_screencopy.ZwlrScreencopyFrameV1FlagsEvent) {
|
||||||
|
ls.state.OnScreencopyFlags(e.Flags)
|
||||||
|
})
|
||||||
|
|
||||||
|
frame.SetReadyHandler(func(e wlr_screencopy.ZwlrScreencopyFrameV1ReadyEvent) {
|
||||||
|
ls.state.OnScreencopyReady()
|
||||||
|
scale := p.computeSurfaceScale(ls)
|
||||||
|
ls.state.SetScale(scale)
|
||||||
|
frame.Destroy()
|
||||||
|
p.redrawSurface(ls)
|
||||||
|
})
|
||||||
|
|
||||||
|
frame.SetFailedHandler(func(e wlr_screencopy.ZwlrScreencopyFrameV1FailedEvent) {
|
||||||
|
frame.Destroy()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Picker) redrawSurface(ls *LayerSurface) {
|
||||||
|
renderBuf := ls.state.Redraw()
|
||||||
|
if renderBuf == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ls.wlPool != nil {
|
||||||
|
ls.wlPool.Destroy()
|
||||||
|
ls.wlPool = nil
|
||||||
|
}
|
||||||
|
if ls.wlBuffer != nil {
|
||||||
|
ls.wlBuffer.Destroy()
|
||||||
|
ls.wlBuffer = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
pool, err := p.shm.CreatePool(renderBuf.Fd(), int32(renderBuf.Size()))
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ls.wlPool = pool
|
||||||
|
|
||||||
|
wlBuffer, err := pool.CreateBuffer(0, int32(renderBuf.Width), int32(renderBuf.Height), int32(renderBuf.Stride), uint32(FormatARGB8888))
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ls.wlBuffer = wlBuffer
|
||||||
|
|
||||||
|
logicalW, logicalH := ls.state.LogicalSize()
|
||||||
|
if logicalW == 0 || logicalH == 0 {
|
||||||
|
logicalW = int(ls.output.width)
|
||||||
|
logicalH = int(ls.output.height)
|
||||||
|
}
|
||||||
|
|
||||||
|
scale := ls.state.Scale()
|
||||||
|
if scale <= 0 {
|
||||||
|
scale = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if ls.viewport != nil {
|
||||||
|
srcW := float64(renderBuf.Width) / float64(scale)
|
||||||
|
srcH := float64(renderBuf.Height) / float64(scale)
|
||||||
|
if err := ls.viewport.SetSource(0, 0, srcW, srcH); err != nil {
|
||||||
|
log.Warn("failed to set viewport source", "err", err)
|
||||||
|
}
|
||||||
|
if err := ls.viewport.SetDestination(int32(logicalW), int32(logicalH)); err != nil {
|
||||||
|
log.Warn("failed to set viewport destination", "err", err)
|
||||||
|
}
|
||||||
|
if err := ls.wlSurface.SetBufferScale(scale); err != nil {
|
||||||
|
log.Warn("failed to set buffer scale", "err", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := ls.wlSurface.SetBufferScale(scale); err != nil {
|
||||||
|
log.Warn("failed to set buffer scale", "err", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := ls.wlSurface.Attach(wlBuffer, 0, 0); err != nil {
|
||||||
|
log.Warn("failed to attach buffer", "err", err)
|
||||||
|
}
|
||||||
|
if err := ls.wlSurface.Damage(0, 0, int32(logicalW), int32(logicalH)); err != nil {
|
||||||
|
log.Warn("failed to damage surface", "err", err)
|
||||||
|
}
|
||||||
|
if err := ls.wlSurface.Commit(); err != nil {
|
||||||
|
log.Warn("failed to commit surface", "err", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
ls.state.SwapBuffers()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Picker) setupInput() {
|
||||||
|
if p.seat == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
p.seat.SetCapabilitiesHandler(func(e client.SeatCapabilitiesEvent) {
|
||||||
|
if e.Capabilities&uint32(client.SeatCapabilityPointer) != 0 && p.pointer == nil {
|
||||||
|
pointer, err := p.seat.GetPointer()
|
||||||
|
if err == nil {
|
||||||
|
p.pointer = pointer
|
||||||
|
p.setupPointerHandlers()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if e.Capabilities&uint32(client.SeatCapabilityKeyboard) != 0 && p.keyboard == nil {
|
||||||
|
keyboard, err := p.seat.GetKeyboard()
|
||||||
|
if err == nil {
|
||||||
|
p.keyboard = keyboard
|
||||||
|
p.setupKeyboardHandlers()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Picker) setupPointerHandlers() {
|
||||||
|
p.pointer.SetEnterHandler(func(e client.PointerEnterEvent) {
|
||||||
|
if err := p.pointer.SetCursor(e.Serial, nil, 0, 0); err != nil {
|
||||||
|
log.Debug("failed to hide cursor", "err", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
p.activeSurface = nil
|
||||||
|
for _, ls := range p.surfaces {
|
||||||
|
if ls.wlSurface.ID() == e.Surface.ID() {
|
||||||
|
p.activeSurface = ls
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if p.activeSurface == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
p.activeSurface.state.OnPointerMotion(e.SurfaceX, e.SurfaceY)
|
||||||
|
p.redrawSurface(p.activeSurface)
|
||||||
|
})
|
||||||
|
|
||||||
|
p.pointer.SetLeaveHandler(func(e client.PointerLeaveEvent) {
|
||||||
|
if p.activeSurface != nil && p.activeSurface.wlSurface.ID() == e.Surface.ID() {
|
||||||
|
p.activeSurface = nil
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
p.pointer.SetMotionHandler(func(e client.PointerMotionEvent) {
|
||||||
|
if p.activeSurface == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
p.activeSurface.state.OnPointerMotion(e.SurfaceX, e.SurfaceY)
|
||||||
|
p.redrawSurface(p.activeSurface)
|
||||||
|
})
|
||||||
|
|
||||||
|
p.pointer.SetButtonHandler(func(e client.PointerButtonEvent) {
|
||||||
|
if p.activeSurface == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
p.activeSurface.state.OnPointerButton(e.Button, e.State)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Picker) setupKeyboardHandlers() {
|
||||||
|
p.keyboard.SetKeyHandler(func(e client.KeyboardKeyEvent) {
|
||||||
|
for _, ls := range p.surfaces {
|
||||||
|
ls.state.OnKey(e.Key, e.State)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Picker) cleanup() {
|
||||||
|
for _, ls := range p.surfaces {
|
||||||
|
if ls.wlBuffer != nil {
|
||||||
|
ls.wlBuffer.Destroy()
|
||||||
|
}
|
||||||
|
if ls.wlPool != nil {
|
||||||
|
ls.wlPool.Destroy()
|
||||||
|
}
|
||||||
|
if ls.viewport != nil {
|
||||||
|
ls.viewport.Destroy()
|
||||||
|
}
|
||||||
|
if ls.layerSurf != nil {
|
||||||
|
ls.layerSurf.Destroy()
|
||||||
|
}
|
||||||
|
if ls.wlSurface != nil {
|
||||||
|
ls.wlSurface.Destroy()
|
||||||
|
}
|
||||||
|
if ls.state != nil {
|
||||||
|
ls.state.Destroy()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.shortcutsInhibitor != nil {
|
||||||
|
if err := p.shortcutsInhibitor.Destroy(); err != nil {
|
||||||
|
log.Debug("failed to destroy shortcuts inhibitor", "err", err)
|
||||||
|
}
|
||||||
|
p.shortcutsInhibitor = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.shortcutsInhibitMgr != nil {
|
||||||
|
if err := p.shortcutsInhibitMgr.Destroy(); err != nil {
|
||||||
|
log.Debug("failed to destroy shortcuts inhibit manager", "err", err)
|
||||||
|
}
|
||||||
|
p.shortcutsInhibitMgr = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.viewporter != nil {
|
||||||
|
p.viewporter.Destroy()
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.screencopy != nil {
|
||||||
|
p.screencopy.Destroy()
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.pointer != nil {
|
||||||
|
p.pointer.Release()
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.keyboard != nil {
|
||||||
|
p.keyboard.Release()
|
||||||
|
}
|
||||||
|
|
||||||
|
if p.display != nil {
|
||||||
|
p.ctx.Close()
|
||||||
|
}
|
||||||
|
}
|
||||||
93
core/internal/colorpicker/shm.go
Normal file
93
core/internal/colorpicker/shm.go
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
package colorpicker
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ShmBuffer struct {
|
||||||
|
fd int
|
||||||
|
data []byte
|
||||||
|
size int
|
||||||
|
Width int
|
||||||
|
Height int
|
||||||
|
Stride int
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateShmBuffer(width, height, stride int) (*ShmBuffer, error) {
|
||||||
|
size := stride * height
|
||||||
|
|
||||||
|
fd, err := unix.MemfdCreate("dms-colorpicker", 0)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("failed to create memfd: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := unix.Ftruncate(fd, int64(size)); err != nil {
|
||||||
|
unix.Close(fd)
|
||||||
|
return nil, fmt.Errorf("ftruncate failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
data, err := unix.Mmap(fd, 0, size, unix.PROT_READ|unix.PROT_WRITE, unix.MAP_SHARED)
|
||||||
|
if err != nil {
|
||||||
|
unix.Close(fd)
|
||||||
|
return nil, fmt.Errorf("mmap failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return &ShmBuffer{
|
||||||
|
fd: fd,
|
||||||
|
data: data,
|
||||||
|
size: size,
|
||||||
|
Width: width,
|
||||||
|
Height: height,
|
||||||
|
Stride: stride,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ShmBuffer) Fd() int {
|
||||||
|
return s.fd
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ShmBuffer) Size() int {
|
||||||
|
return s.size
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ShmBuffer) Data() []byte {
|
||||||
|
return s.data
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ShmBuffer) GetPixel(x, y int) Color {
|
||||||
|
if x < 0 || x >= s.Width || y < 0 || y >= s.Height {
|
||||||
|
return Color{}
|
||||||
|
}
|
||||||
|
|
||||||
|
offset := y*s.Stride + x*4
|
||||||
|
|
||||||
|
if offset+3 >= len(s.data) {
|
||||||
|
return Color{}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Color{
|
||||||
|
B: s.data[offset],
|
||||||
|
G: s.data[offset+1],
|
||||||
|
R: s.data[offset+2],
|
||||||
|
A: s.data[offset+3],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *ShmBuffer) Close() error {
|
||||||
|
var firstErr error
|
||||||
|
if s.data != nil {
|
||||||
|
if err := unix.Munmap(s.data); err != nil && firstErr == nil {
|
||||||
|
firstErr = fmt.Errorf("munmap failed: %w", err)
|
||||||
|
}
|
||||||
|
s.data = nil
|
||||||
|
}
|
||||||
|
if s.fd >= 0 {
|
||||||
|
if err := unix.Close(s.fd); err != nil && firstErr == nil {
|
||||||
|
firstErr = fmt.Errorf("close fd failed: %w", err)
|
||||||
|
}
|
||||||
|
s.fd = -1
|
||||||
|
}
|
||||||
|
return firstErr
|
||||||
|
}
|
||||||
1092
core/internal/colorpicker/state.go
Normal file
1092
core/internal/colorpicker/state.go
Normal file
File diff suppressed because it is too large
Load Diff
@@ -70,7 +70,6 @@ func (d *DebianDistribution) DetectDependenciesWithTerminal(ctx context.Context,
|
|||||||
|
|
||||||
dependencies = append(dependencies, d.detectMatugen())
|
dependencies = append(dependencies, d.detectMatugen())
|
||||||
dependencies = append(dependencies, d.detectDgop())
|
dependencies = append(dependencies, d.detectDgop())
|
||||||
dependencies = append(dependencies, d.detectHyprpicker())
|
|
||||||
dependencies = append(dependencies, d.detectClipboardTools()...)
|
dependencies = append(dependencies, d.detectClipboardTools()...)
|
||||||
|
|
||||||
return dependencies, nil
|
return dependencies, nil
|
||||||
@@ -139,7 +138,12 @@ func (d *DebianDistribution) packageInstalled(pkg string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *DebianDistribution) GetPackageMapping(wm deps.WindowManager) map[string]PackageMapping {
|
func (d *DebianDistribution) GetPackageMapping(wm deps.WindowManager) map[string]PackageMapping {
|
||||||
|
return d.GetPackageMappingWithVariants(wm, make(map[string]deps.PackageVariant))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DebianDistribution) GetPackageMappingWithVariants(wm deps.WindowManager, variants map[string]deps.PackageVariant) map[string]PackageMapping {
|
||||||
packages := map[string]PackageMapping{
|
packages := map[string]PackageMapping{
|
||||||
|
// Standard APT packages
|
||||||
"git": {Name: "git", Repository: RepoTypeSystem},
|
"git": {Name: "git", Repository: RepoTypeSystem},
|
||||||
"kitty": {Name: "kitty", Repository: RepoTypeSystem},
|
"kitty": {Name: "kitty", Repository: RepoTypeSystem},
|
||||||
"alacritty": {Name: "alacritty", Repository: RepoTypeSystem},
|
"alacritty": {Name: "alacritty", Repository: RepoTypeSystem},
|
||||||
@@ -148,24 +152,54 @@ func (d *DebianDistribution) GetPackageMapping(wm deps.WindowManager) map[string
|
|||||||
"mate-polkit": {Name: "mate-polkit", Repository: RepoTypeSystem},
|
"mate-polkit": {Name: "mate-polkit", Repository: RepoTypeSystem},
|
||||||
"accountsservice": {Name: "accountsservice", Repository: RepoTypeSystem},
|
"accountsservice": {Name: "accountsservice", Repository: RepoTypeSystem},
|
||||||
|
|
||||||
"dms (DankMaterialShell)": {Name: "dms", Repository: RepoTypeManual, BuildFunc: "installDankMaterialShell"},
|
// DMS packages from OBS with variant support
|
||||||
"niri": {Name: "niri", Repository: RepoTypeManual, BuildFunc: "installNiri"},
|
"dms (DankMaterialShell)": d.getDmsMapping(variants["dms (DankMaterialShell)"]),
|
||||||
"quickshell": {Name: "quickshell", Repository: RepoTypeManual, BuildFunc: "installQuickshell"},
|
"quickshell": d.getQuickshellMapping(variants["quickshell"]),
|
||||||
|
"matugen": {Name: "matugen", Repository: RepoTypeOBS, RepoURL: "home:AvengeMedia:danklinux"},
|
||||||
|
"dgop": {Name: "dgop", Repository: RepoTypeOBS, RepoURL: "home:AvengeMedia:danklinux"},
|
||||||
|
"cliphist": {Name: "cliphist", Repository: RepoTypeOBS, RepoURL: "home:AvengeMedia:danklinux"},
|
||||||
|
|
||||||
|
// Keep ghostty as manual (no OBS package yet)
|
||||||
"ghostty": {Name: "ghostty", Repository: RepoTypeManual, BuildFunc: "installGhostty"},
|
"ghostty": {Name: "ghostty", Repository: RepoTypeManual, BuildFunc: "installGhostty"},
|
||||||
"matugen": {Name: "matugen", Repository: RepoTypeManual, BuildFunc: "installMatugen"},
|
|
||||||
"dgop": {Name: "dgop", Repository: RepoTypeManual, BuildFunc: "installDgop"},
|
|
||||||
"cliphist": {Name: "cliphist", Repository: RepoTypeManual, BuildFunc: "installCliphist"},
|
|
||||||
"hyprpicker": {Name: "hyprpicker", Repository: RepoTypeManual, BuildFunc: "installHyprpicker"},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if wm == deps.WindowManagerNiri {
|
if wm == deps.WindowManagerNiri {
|
||||||
packages["niri"] = PackageMapping{Name: "niri", Repository: RepoTypeManual, BuildFunc: "installNiri"}
|
niriVariant := variants["niri"]
|
||||||
packages["xwayland-satellite"] = PackageMapping{Name: "xwayland-satellite", Repository: RepoTypeManual, BuildFunc: "installXwaylandSatellite"}
|
packages["niri"] = d.getNiriMapping(niriVariant)
|
||||||
|
packages["xwayland-satellite"] = d.getXwaylandSatelliteMapping(niriVariant)
|
||||||
}
|
}
|
||||||
|
|
||||||
return packages
|
return packages
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *DebianDistribution) getDmsMapping(variant deps.PackageVariant) PackageMapping {
|
||||||
|
if variant == deps.VariantGit {
|
||||||
|
return PackageMapping{Name: "dms-git", Repository: RepoTypeOBS, RepoURL: "home:AvengeMedia:dms-git"}
|
||||||
|
}
|
||||||
|
return PackageMapping{Name: "dms", Repository: RepoTypeOBS, RepoURL: "home:AvengeMedia:dms"}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DebianDistribution) getQuickshellMapping(variant deps.PackageVariant) PackageMapping {
|
||||||
|
if forceQuickshellGit || variant == deps.VariantGit {
|
||||||
|
return PackageMapping{Name: "quickshell-git", Repository: RepoTypeOBS, RepoURL: "home:AvengeMedia:danklinux"}
|
||||||
|
}
|
||||||
|
return PackageMapping{Name: "quickshell", Repository: RepoTypeOBS, RepoURL: "home:AvengeMedia:danklinux"}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DebianDistribution) getNiriMapping(variant deps.PackageVariant) PackageMapping {
|
||||||
|
if variant == deps.VariantGit {
|
||||||
|
return PackageMapping{Name: "niri-git", Repository: RepoTypeOBS, RepoURL: "home:AvengeMedia:danklinux"}
|
||||||
|
}
|
||||||
|
return PackageMapping{Name: "niri", Repository: RepoTypeOBS, RepoURL: "home:AvengeMedia:danklinux"}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DebianDistribution) getXwaylandSatelliteMapping(variant deps.PackageVariant) PackageMapping {
|
||||||
|
if variant == deps.VariantGit {
|
||||||
|
return PackageMapping{Name: "xwayland-satellite-git", Repository: RepoTypeOBS, RepoURL: "home:AvengeMedia:danklinux"}
|
||||||
|
}
|
||||||
|
return PackageMapping{Name: "xwayland-satellite", Repository: RepoTypeOBS, RepoURL: "home:AvengeMedia:danklinux"}
|
||||||
|
}
|
||||||
|
|
||||||
func (d *DebianDistribution) InstallPrerequisites(ctx context.Context, sudoPassword string, progressChan chan<- InstallProgressMsg) error {
|
func (d *DebianDistribution) InstallPrerequisites(ctx context.Context, sudoPassword string, progressChan chan<- InstallProgressMsg) error {
|
||||||
progressChan <- InstallProgressMsg{
|
progressChan <- InstallProgressMsg{
|
||||||
Phase: PhasePrerequisites,
|
Phase: PhasePrerequisites,
|
||||||
@@ -238,8 +272,23 @@ func (d *DebianDistribution) InstallPackages(ctx context.Context, dependencies [
|
|||||||
return fmt.Errorf("failed to install prerequisites: %w", err)
|
return fmt.Errorf("failed to install prerequisites: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
systemPkgs, manualPkgs, variantMap := d.categorizePackages(dependencies, wm, reinstallFlags, disabledFlags)
|
systemPkgs, obsPkgs, manualPkgs, variantMap := d.categorizePackages(dependencies, wm, reinstallFlags, disabledFlags)
|
||||||
|
|
||||||
|
// Enable OBS repositories
|
||||||
|
if len(obsPkgs) > 0 {
|
||||||
|
progressChan <- InstallProgressMsg{
|
||||||
|
Phase: PhaseSystemPackages,
|
||||||
|
Progress: 0.15,
|
||||||
|
Step: "Enabling OBS repositories...",
|
||||||
|
IsComplete: false,
|
||||||
|
LogOutput: "Setting up OBS repositories for additional packages",
|
||||||
|
}
|
||||||
|
if err := d.enableOBSRepos(ctx, obsPkgs, sudoPassword, progressChan); err != nil {
|
||||||
|
return fmt.Errorf("failed to enable OBS repositories: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// System Packages
|
||||||
if len(systemPkgs) > 0 {
|
if len(systemPkgs) > 0 {
|
||||||
progressChan <- InstallProgressMsg{
|
progressChan <- InstallProgressMsg{
|
||||||
Phase: PhaseSystemPackages,
|
Phase: PhaseSystemPackages,
|
||||||
@@ -254,6 +303,22 @@ func (d *DebianDistribution) InstallPackages(ctx context.Context, dependencies [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OBS Packages
|
||||||
|
obsPkgNames := d.extractPackageNames(obsPkgs)
|
||||||
|
if len(obsPkgNames) > 0 {
|
||||||
|
progressChan <- InstallProgressMsg{
|
||||||
|
Phase: PhaseAURPackages,
|
||||||
|
Progress: 0.65,
|
||||||
|
Step: fmt.Sprintf("Installing %d OBS packages...", len(obsPkgNames)),
|
||||||
|
IsComplete: false,
|
||||||
|
LogOutput: fmt.Sprintf("Installing OBS packages: %s", strings.Join(obsPkgNames, ", ")),
|
||||||
|
}
|
||||||
|
if err := d.installAPTPackages(ctx, obsPkgNames, sudoPassword, progressChan); err != nil {
|
||||||
|
return fmt.Errorf("failed to install OBS packages: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Manual Builds
|
||||||
if len(manualPkgs) > 0 {
|
if len(manualPkgs) > 0 {
|
||||||
progressChan <- InstallProgressMsg{
|
progressChan <- InstallProgressMsg{
|
||||||
Phase: PhaseSystemPackages,
|
Phase: PhaseSystemPackages,
|
||||||
@@ -297,8 +362,9 @@ func (d *DebianDistribution) InstallPackages(ctx context.Context, dependencies [
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DebianDistribution) categorizePackages(dependencies []deps.Dependency, wm deps.WindowManager, reinstallFlags map[string]bool, disabledFlags map[string]bool) ([]string, []string, map[string]deps.PackageVariant) {
|
func (d *DebianDistribution) categorizePackages(dependencies []deps.Dependency, wm deps.WindowManager, reinstallFlags map[string]bool, disabledFlags map[string]bool) ([]string, []PackageMapping, []string, map[string]deps.PackageVariant) {
|
||||||
systemPkgs := []string{}
|
systemPkgs := []string{}
|
||||||
|
obsPkgs := []PackageMapping{}
|
||||||
manualPkgs := []string{}
|
manualPkgs := []string{}
|
||||||
|
|
||||||
variantMap := make(map[string]deps.PackageVariant)
|
variantMap := make(map[string]deps.PackageVariant)
|
||||||
@@ -306,7 +372,7 @@ func (d *DebianDistribution) categorizePackages(dependencies []deps.Dependency,
|
|||||||
variantMap[dep.Name] = dep.Variant
|
variantMap[dep.Name] = dep.Variant
|
||||||
}
|
}
|
||||||
|
|
||||||
packageMap := d.GetPackageMapping(wm)
|
packageMap := d.GetPackageMappingWithVariants(wm, variantMap)
|
||||||
|
|
||||||
for _, dep := range dependencies {
|
for _, dep := range dependencies {
|
||||||
if disabledFlags[dep.Name] {
|
if disabledFlags[dep.Name] {
|
||||||
@@ -326,12 +392,116 @@ func (d *DebianDistribution) categorizePackages(dependencies []deps.Dependency,
|
|||||||
switch pkgInfo.Repository {
|
switch pkgInfo.Repository {
|
||||||
case RepoTypeSystem:
|
case RepoTypeSystem:
|
||||||
systemPkgs = append(systemPkgs, pkgInfo.Name)
|
systemPkgs = append(systemPkgs, pkgInfo.Name)
|
||||||
|
case RepoTypeOBS:
|
||||||
|
obsPkgs = append(obsPkgs, pkgInfo)
|
||||||
case RepoTypeManual:
|
case RepoTypeManual:
|
||||||
manualPkgs = append(manualPkgs, dep.Name)
|
manualPkgs = append(manualPkgs, dep.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return systemPkgs, manualPkgs, variantMap
|
return systemPkgs, obsPkgs, manualPkgs, variantMap
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DebianDistribution) extractPackageNames(packages []PackageMapping) []string {
|
||||||
|
names := make([]string, len(packages))
|
||||||
|
for i, pkg := range packages {
|
||||||
|
names[i] = pkg.Name
|
||||||
|
}
|
||||||
|
return names
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *DebianDistribution) enableOBSRepos(ctx context.Context, obsPkgs []PackageMapping, sudoPassword string, progressChan chan<- InstallProgressMsg) error {
|
||||||
|
enabledRepos := make(map[string]bool)
|
||||||
|
|
||||||
|
osInfo, err := GetOSInfo()
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to get OS info: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine Debian version for OBS repository URL
|
||||||
|
debianVersion := "Debian_13"
|
||||||
|
if osInfo.VersionID == "testing" {
|
||||||
|
debianVersion = "Debian_Testing"
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, pkg := range obsPkgs {
|
||||||
|
if pkg.RepoURL != "" && !enabledRepos[pkg.RepoURL] {
|
||||||
|
d.log(fmt.Sprintf("Enabling OBS repository: %s", pkg.RepoURL))
|
||||||
|
|
||||||
|
// RepoURL format: "home:AvengeMedia:danklinux"
|
||||||
|
repoPath := strings.ReplaceAll(pkg.RepoURL, ":", ":/")
|
||||||
|
repoName := strings.ReplaceAll(pkg.RepoURL, ":", "-")
|
||||||
|
baseURL := fmt.Sprintf("https://download.opensuse.org/repositories/%s/%s", repoPath, debianVersion)
|
||||||
|
|
||||||
|
// Check if repository already exists
|
||||||
|
listFile := fmt.Sprintf("/etc/apt/sources.list.d/%s.list", repoName)
|
||||||
|
checkCmd := exec.CommandContext(ctx, "test", "-f", listFile)
|
||||||
|
if checkCmd.Run() == nil {
|
||||||
|
d.log(fmt.Sprintf("OBS repo %s already exists, skipping", pkg.RepoURL))
|
||||||
|
enabledRepos[pkg.RepoURL] = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
keyringPath := fmt.Sprintf("/etc/apt/keyrings/%s.gpg", repoName)
|
||||||
|
|
||||||
|
// Create keyrings directory if it doesn't exist
|
||||||
|
mkdirCmd := ExecSudoCommand(ctx, sudoPassword, "mkdir -p /etc/apt/keyrings")
|
||||||
|
if err := mkdirCmd.Run(); err != nil {
|
||||||
|
d.log(fmt.Sprintf("Warning: failed to create keyrings directory: %v", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
progressChan <- InstallProgressMsg{
|
||||||
|
Phase: PhaseSystemPackages,
|
||||||
|
Progress: 0.18,
|
||||||
|
Step: fmt.Sprintf("Adding OBS GPG key for %s...", pkg.RepoURL),
|
||||||
|
NeedsSudo: true,
|
||||||
|
CommandInfo: fmt.Sprintf("curl & gpg to add key for %s", pkg.RepoURL),
|
||||||
|
}
|
||||||
|
|
||||||
|
keyCmd := fmt.Sprintf("curl -fsSL %s/Release.key | gpg --dearmor -o %s", baseURL, keyringPath)
|
||||||
|
cmd := ExecSudoCommand(ctx, sudoPassword, keyCmd)
|
||||||
|
if err := d.runWithProgress(cmd, progressChan, PhaseSystemPackages, 0.18, 0.20); err != nil {
|
||||||
|
return fmt.Errorf("failed to add OBS GPG key for %s: %w", pkg.RepoURL, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add repository
|
||||||
|
repoLine := fmt.Sprintf("deb [signed-by=%s] %s/ /", keyringPath, baseURL)
|
||||||
|
|
||||||
|
progressChan <- InstallProgressMsg{
|
||||||
|
Phase: PhaseSystemPackages,
|
||||||
|
Progress: 0.20,
|
||||||
|
Step: fmt.Sprintf("Adding OBS repository %s...", pkg.RepoURL),
|
||||||
|
NeedsSudo: true,
|
||||||
|
CommandInfo: fmt.Sprintf("echo '%s' | sudo tee %s", repoLine, listFile),
|
||||||
|
}
|
||||||
|
|
||||||
|
addRepoCmd := ExecSudoCommand(ctx, sudoPassword,
|
||||||
|
fmt.Sprintf("echo '%s' | tee %s", repoLine, listFile))
|
||||||
|
if err := d.runWithProgress(addRepoCmd, progressChan, PhaseSystemPackages, 0.20, 0.22); err != nil {
|
||||||
|
return fmt.Errorf("failed to add OBS repo %s: %w", pkg.RepoURL, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
enabledRepos[pkg.RepoURL] = true
|
||||||
|
d.log(fmt.Sprintf("OBS repo %s enabled successfully", pkg.RepoURL))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(enabledRepos) > 0 {
|
||||||
|
progressChan <- InstallProgressMsg{
|
||||||
|
Phase: PhaseSystemPackages,
|
||||||
|
Progress: 0.25,
|
||||||
|
Step: "Updating package lists...",
|
||||||
|
NeedsSudo: true,
|
||||||
|
CommandInfo: "sudo apt-get update",
|
||||||
|
}
|
||||||
|
|
||||||
|
updateCmd := ExecSudoCommand(ctx, sudoPassword, "apt-get update")
|
||||||
|
if err := d.runWithProgress(updateCmd, progressChan, PhaseSystemPackages, 0.25, 0.27); err != nil {
|
||||||
|
return fmt.Errorf("failed to update package lists after adding OBS repos: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DebianDistribution) installAPTPackages(ctx context.Context, packages []string, sudoPassword string, progressChan chan<- InstallProgressMsg) error {
|
func (d *DebianDistribution) installAPTPackages(ctx context.Context, packages []string, sudoPassword string, progressChan chan<- InstallProgressMsg) error {
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ const (
|
|||||||
RepoTypeAUR RepositoryType = "aur" // Arch User Repository
|
RepoTypeAUR RepositoryType = "aur" // Arch User Repository
|
||||||
RepoTypeCOPR RepositoryType = "copr" // Fedora COPR
|
RepoTypeCOPR RepositoryType = "copr" // Fedora COPR
|
||||||
RepoTypePPA RepositoryType = "ppa" // Ubuntu PPA
|
RepoTypePPA RepositoryType = "ppa" // Ubuntu PPA
|
||||||
|
RepoTypeOBS RepositoryType = "obs" // OpenBuild Service (Debian/OpenSUSE)
|
||||||
RepoTypeFlake RepositoryType = "flake" // Nix flake
|
RepoTypeFlake RepositoryType = "flake" // Nix flake
|
||||||
RepoTypeGURU RepositoryType = "guru" // Gentoo GURU
|
RepoTypeGURU RepositoryType = "guru" // Gentoo GURU
|
||||||
RepoTypeManual RepositoryType = "manual" // Manual build from source
|
RepoTypeManual RepositoryType = "manual" // Manual build from source
|
||||||
|
|||||||
@@ -82,7 +82,6 @@ func (o *OpenSUSEDistribution) DetectDependenciesWithTerminal(ctx context.Contex
|
|||||||
// Base detections (common across distros)
|
// Base detections (common across distros)
|
||||||
dependencies = append(dependencies, o.detectMatugen())
|
dependencies = append(dependencies, o.detectMatugen())
|
||||||
dependencies = append(dependencies, o.detectDgop())
|
dependencies = append(dependencies, o.detectDgop())
|
||||||
dependencies = append(dependencies, o.detectHyprpicker())
|
|
||||||
dependencies = append(dependencies, o.detectClipboardTools()...)
|
dependencies = append(dependencies, o.detectClipboardTools()...)
|
||||||
|
|
||||||
return dependencies, nil
|
return dependencies, nil
|
||||||
@@ -138,13 +137,12 @@ func (o *OpenSUSEDistribution) GetPackageMappingWithVariants(wm deps.WindowManag
|
|||||||
"mate-polkit": {Name: "mate-polkit", Repository: RepoTypeSystem},
|
"mate-polkit": {Name: "mate-polkit", Repository: RepoTypeSystem},
|
||||||
"accountsservice": {Name: "accountsservice", Repository: RepoTypeSystem},
|
"accountsservice": {Name: "accountsservice", Repository: RepoTypeSystem},
|
||||||
"cliphist": {Name: "cliphist", Repository: RepoTypeSystem},
|
"cliphist": {Name: "cliphist", Repository: RepoTypeSystem},
|
||||||
"hyprpicker": {Name: "hyprpicker", Repository: RepoTypeSystem},
|
|
||||||
|
|
||||||
// Manual builds
|
// DMS packages from OBS
|
||||||
"dms (DankMaterialShell)": {Name: "dms", Repository: RepoTypeManual, BuildFunc: "installDankMaterialShell"},
|
"dms (DankMaterialShell)": o.getDmsMapping(variants["dms (DankMaterialShell)"]),
|
||||||
"dgop": {Name: "dgop", Repository: RepoTypeManual, BuildFunc: "installDgop"},
|
"quickshell": o.getQuickshellMapping(variants["quickshell"]),
|
||||||
"quickshell": {Name: "quickshell", Repository: RepoTypeManual, BuildFunc: "installQuickshell"},
|
"matugen": {Name: "matugen", Repository: RepoTypeOBS, RepoURL: "home:AvengeMedia:danklinux"},
|
||||||
"matugen": {Name: "matugen", Repository: RepoTypeManual, BuildFunc: "installMatugen"},
|
"dgop": {Name: "dgop", Repository: RepoTypeOBS, RepoURL: "home:AvengeMedia:danklinux"},
|
||||||
}
|
}
|
||||||
|
|
||||||
switch wm {
|
switch wm {
|
||||||
@@ -156,13 +154,43 @@ func (o *OpenSUSEDistribution) GetPackageMappingWithVariants(wm deps.WindowManag
|
|||||||
packages["grimblast"] = PackageMapping{Name: "grimblast", Repository: RepoTypeManual, BuildFunc: "installGrimblast"}
|
packages["grimblast"] = PackageMapping{Name: "grimblast", Repository: RepoTypeManual, BuildFunc: "installGrimblast"}
|
||||||
packages["jq"] = PackageMapping{Name: "jq", Repository: RepoTypeSystem}
|
packages["jq"] = PackageMapping{Name: "jq", Repository: RepoTypeSystem}
|
||||||
case deps.WindowManagerNiri:
|
case deps.WindowManagerNiri:
|
||||||
packages["niri"] = PackageMapping{Name: "niri", Repository: RepoTypeSystem}
|
// Niri stable has native package support on openSUSE
|
||||||
packages["xwayland-satellite"] = PackageMapping{Name: "xwayland-satellite", Repository: RepoTypeSystem}
|
niriVariant := variants["niri"]
|
||||||
|
packages["niri"] = o.getNiriMapping(niriVariant)
|
||||||
|
packages["xwayland-satellite"] = o.getXwaylandSatelliteMapping(niriVariant)
|
||||||
}
|
}
|
||||||
|
|
||||||
return packages
|
return packages
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (o *OpenSUSEDistribution) getDmsMapping(variant deps.PackageVariant) PackageMapping {
|
||||||
|
if variant == deps.VariantGit {
|
||||||
|
return PackageMapping{Name: "dms-git", Repository: RepoTypeOBS, RepoURL: "home:AvengeMedia:dms-git"}
|
||||||
|
}
|
||||||
|
return PackageMapping{Name: "dms", Repository: RepoTypeOBS, RepoURL: "home:AvengeMedia:dms"}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *OpenSUSEDistribution) getQuickshellMapping(variant deps.PackageVariant) PackageMapping {
|
||||||
|
if forceQuickshellGit || variant == deps.VariantGit {
|
||||||
|
return PackageMapping{Name: "quickshell-git", Repository: RepoTypeOBS, RepoURL: "home:AvengeMedia:danklinux"}
|
||||||
|
}
|
||||||
|
return PackageMapping{Name: "quickshell", Repository: RepoTypeOBS, RepoURL: "home:AvengeMedia:danklinux"}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *OpenSUSEDistribution) getNiriMapping(variant deps.PackageVariant) PackageMapping {
|
||||||
|
if variant == deps.VariantGit {
|
||||||
|
return PackageMapping{Name: "niri-git", Repository: RepoTypeOBS, RepoURL: "home:AvengeMedia:danklinux"}
|
||||||
|
}
|
||||||
|
return PackageMapping{Name: "niri", Repository: RepoTypeSystem}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *OpenSUSEDistribution) getXwaylandSatelliteMapping(variant deps.PackageVariant) PackageMapping {
|
||||||
|
if variant == deps.VariantGit {
|
||||||
|
return PackageMapping{Name: "xwayland-satellite-git", Repository: RepoTypeOBS, RepoURL: "home:AvengeMedia:danklinux"}
|
||||||
|
}
|
||||||
|
return PackageMapping{Name: "xwayland-satellite", Repository: RepoTypeSystem}
|
||||||
|
}
|
||||||
|
|
||||||
func (o *OpenSUSEDistribution) detectXwaylandSatellite() deps.Dependency {
|
func (o *OpenSUSEDistribution) detectXwaylandSatellite() deps.Dependency {
|
||||||
status := deps.StatusMissing
|
status := deps.StatusMissing
|
||||||
if o.commandExists("xwayland-satellite") {
|
if o.commandExists("xwayland-satellite") {
|
||||||
@@ -294,9 +322,23 @@ func (o *OpenSUSEDistribution) InstallPackages(ctx context.Context, dependencies
|
|||||||
return fmt.Errorf("failed to install prerequisites: %w", err)
|
return fmt.Errorf("failed to install prerequisites: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
systemPkgs, manualPkgs, variantMap := o.categorizePackages(dependencies, wm, reinstallFlags, disabledFlags)
|
systemPkgs, obsPkgs, manualPkgs, variantMap := o.categorizePackages(dependencies, wm, reinstallFlags, disabledFlags)
|
||||||
|
|
||||||
// Phase 2: System Packages (Zypper)
|
// Enable OBS repositories
|
||||||
|
if len(obsPkgs) > 0 {
|
||||||
|
progressChan <- InstallProgressMsg{
|
||||||
|
Phase: PhaseSystemPackages,
|
||||||
|
Progress: 0.15,
|
||||||
|
Step: "Enabling OBS repositories...",
|
||||||
|
IsComplete: false,
|
||||||
|
LogOutput: "Setting up OBS repositories for additional packages",
|
||||||
|
}
|
||||||
|
if err := o.enableOBSRepos(ctx, obsPkgs, sudoPassword, progressChan); err != nil {
|
||||||
|
return fmt.Errorf("failed to enable OBS repositories: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Phase 3: System Packages (Zypper)
|
||||||
if len(systemPkgs) > 0 {
|
if len(systemPkgs) > 0 {
|
||||||
progressChan <- InstallProgressMsg{
|
progressChan <- InstallProgressMsg{
|
||||||
Phase: PhaseSystemPackages,
|
Phase: PhaseSystemPackages,
|
||||||
@@ -311,7 +353,22 @@ func (o *OpenSUSEDistribution) InstallPackages(ctx context.Context, dependencies
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Phase 3: Manual Builds
|
// OBS Packages
|
||||||
|
obsPkgNames := o.extractPackageNames(obsPkgs)
|
||||||
|
if len(obsPkgNames) > 0 {
|
||||||
|
progressChan <- InstallProgressMsg{
|
||||||
|
Phase: PhaseAURPackages,
|
||||||
|
Progress: 0.65,
|
||||||
|
Step: fmt.Sprintf("Installing %d OBS packages...", len(obsPkgNames)),
|
||||||
|
IsComplete: false,
|
||||||
|
LogOutput: fmt.Sprintf("Installing OBS packages: %s", strings.Join(obsPkgNames, ", ")),
|
||||||
|
}
|
||||||
|
if err := o.installZypperPackages(ctx, obsPkgNames, sudoPassword, progressChan); err != nil {
|
||||||
|
return fmt.Errorf("failed to install OBS packages: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Manual Builds
|
||||||
if len(manualPkgs) > 0 {
|
if len(manualPkgs) > 0 {
|
||||||
progressChan <- InstallProgressMsg{
|
progressChan <- InstallProgressMsg{
|
||||||
Phase: PhaseSystemPackages,
|
Phase: PhaseSystemPackages,
|
||||||
@@ -325,7 +382,7 @@ func (o *OpenSUSEDistribution) InstallPackages(ctx context.Context, dependencies
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Phase 4: Configuration
|
// Configuration
|
||||||
progressChan <- InstallProgressMsg{
|
progressChan <- InstallProgressMsg{
|
||||||
Phase: PhaseConfiguration,
|
Phase: PhaseConfiguration,
|
||||||
Progress: 0.90,
|
Progress: 0.90,
|
||||||
@@ -334,7 +391,7 @@ func (o *OpenSUSEDistribution) InstallPackages(ctx context.Context, dependencies
|
|||||||
LogOutput: "Starting post-installation configuration...",
|
LogOutput: "Starting post-installation configuration...",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Phase 5: Complete
|
// Complete
|
||||||
progressChan <- InstallProgressMsg{
|
progressChan <- InstallProgressMsg{
|
||||||
Phase: PhaseComplete,
|
Phase: PhaseComplete,
|
||||||
Progress: 1.0,
|
Progress: 1.0,
|
||||||
@@ -346,8 +403,9 @@ func (o *OpenSUSEDistribution) InstallPackages(ctx context.Context, dependencies
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OpenSUSEDistribution) categorizePackages(dependencies []deps.Dependency, wm deps.WindowManager, reinstallFlags map[string]bool, disabledFlags map[string]bool) ([]string, []string, map[string]deps.PackageVariant) {
|
func (o *OpenSUSEDistribution) categorizePackages(dependencies []deps.Dependency, wm deps.WindowManager, reinstallFlags map[string]bool, disabledFlags map[string]bool) ([]string, []PackageMapping, []string, map[string]deps.PackageVariant) {
|
||||||
systemPkgs := []string{}
|
systemPkgs := []string{}
|
||||||
|
obsPkgs := []PackageMapping{}
|
||||||
manualPkgs := []string{}
|
manualPkgs := []string{}
|
||||||
|
|
||||||
variantMap := make(map[string]deps.PackageVariant)
|
variantMap := make(map[string]deps.PackageVariant)
|
||||||
@@ -375,12 +433,80 @@ func (o *OpenSUSEDistribution) categorizePackages(dependencies []deps.Dependency
|
|||||||
switch pkgInfo.Repository {
|
switch pkgInfo.Repository {
|
||||||
case RepoTypeSystem:
|
case RepoTypeSystem:
|
||||||
systemPkgs = append(systemPkgs, pkgInfo.Name)
|
systemPkgs = append(systemPkgs, pkgInfo.Name)
|
||||||
|
case RepoTypeOBS:
|
||||||
|
obsPkgs = append(obsPkgs, pkgInfo)
|
||||||
case RepoTypeManual:
|
case RepoTypeManual:
|
||||||
manualPkgs = append(manualPkgs, dep.Name)
|
manualPkgs = append(manualPkgs, dep.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return systemPkgs, manualPkgs, variantMap
|
return systemPkgs, obsPkgs, manualPkgs, variantMap
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *OpenSUSEDistribution) extractPackageNames(packages []PackageMapping) []string {
|
||||||
|
names := make([]string, len(packages))
|
||||||
|
for i, pkg := range packages {
|
||||||
|
names[i] = pkg.Name
|
||||||
|
}
|
||||||
|
return names
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o *OpenSUSEDistribution) enableOBSRepos(ctx context.Context, obsPkgs []PackageMapping, sudoPassword string, progressChan chan<- InstallProgressMsg) error {
|
||||||
|
enabledRepos := make(map[string]bool)
|
||||||
|
|
||||||
|
for _, pkg := range obsPkgs {
|
||||||
|
if pkg.RepoURL != "" && !enabledRepos[pkg.RepoURL] {
|
||||||
|
o.log(fmt.Sprintf("Enabling OBS repository: %s", pkg.RepoURL))
|
||||||
|
|
||||||
|
// RepoURL format: "home:AvengeMedia:danklinux"
|
||||||
|
repoPath := strings.ReplaceAll(pkg.RepoURL, ":", ":/")
|
||||||
|
repoName := strings.ReplaceAll(pkg.RepoURL, ":", "-")
|
||||||
|
repoURL := fmt.Sprintf("https://download.opensuse.org/repositories/%s/openSUSE_Tumbleweed/%s.repo",
|
||||||
|
repoPath, pkg.RepoURL)
|
||||||
|
|
||||||
|
checkCmd := exec.CommandContext(ctx, "zypper", "repos", repoName)
|
||||||
|
if checkCmd.Run() == nil {
|
||||||
|
o.log(fmt.Sprintf("OBS repo %s already exists, skipping", pkg.RepoURL))
|
||||||
|
enabledRepos[pkg.RepoURL] = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
progressChan <- InstallProgressMsg{
|
||||||
|
Phase: PhaseSystemPackages,
|
||||||
|
Progress: 0.20,
|
||||||
|
Step: fmt.Sprintf("Enabling OBS repo %s...", pkg.RepoURL),
|
||||||
|
NeedsSudo: true,
|
||||||
|
CommandInfo: fmt.Sprintf("sudo zypper addrepo %s", repoURL),
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd := ExecSudoCommand(ctx, sudoPassword,
|
||||||
|
fmt.Sprintf("zypper addrepo -f %s", repoURL))
|
||||||
|
if err := o.runWithProgress(cmd, progressChan, PhaseSystemPackages, 0.20, 0.22); err != nil {
|
||||||
|
return fmt.Errorf("failed to enable OBS repo %s: %w", pkg.RepoURL, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
enabledRepos[pkg.RepoURL] = true
|
||||||
|
o.log(fmt.Sprintf("OBS repo %s enabled successfully", pkg.RepoURL))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Refresh repositories with GPG auto-import
|
||||||
|
if len(enabledRepos) > 0 {
|
||||||
|
progressChan <- InstallProgressMsg{
|
||||||
|
Phase: PhaseSystemPackages,
|
||||||
|
Progress: 0.25,
|
||||||
|
Step: "Refreshing repositories...",
|
||||||
|
NeedsSudo: true,
|
||||||
|
CommandInfo: "sudo zypper --gpg-auto-import-keys refresh",
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshCmd := ExecSudoCommand(ctx, sudoPassword, "zypper --gpg-auto-import-keys refresh")
|
||||||
|
if err := o.runWithProgress(refreshCmd, progressChan, PhaseSystemPackages, 0.25, 0.27); err != nil {
|
||||||
|
return fmt.Errorf("failed to refresh repositories: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OpenSUSEDistribution) installZypperPackages(ctx context.Context, packages []string, sudoPassword string, progressChan chan<- InstallProgressMsg) error {
|
func (o *OpenSUSEDistribution) installZypperPackages(ctx context.Context, packages []string, sudoPassword string, progressChan chan<- InstallProgressMsg) error {
|
||||||
|
|||||||
@@ -82,7 +82,6 @@ func (u *UbuntuDistribution) DetectDependenciesWithTerminal(ctx context.Context,
|
|||||||
// Base detections (common across distros)
|
// Base detections (common across distros)
|
||||||
dependencies = append(dependencies, u.detectMatugen())
|
dependencies = append(dependencies, u.detectMatugen())
|
||||||
dependencies = append(dependencies, u.detectDgop())
|
dependencies = append(dependencies, u.detectDgop())
|
||||||
dependencies = append(dependencies, u.detectHyprpicker())
|
|
||||||
dependencies = append(dependencies, u.detectClipboardTools()...)
|
dependencies = append(dependencies, u.detectClipboardTools()...)
|
||||||
|
|
||||||
return dependencies, nil
|
return dependencies, nil
|
||||||
@@ -151,6 +150,10 @@ func (u *UbuntuDistribution) packageInstalled(pkg string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *UbuntuDistribution) GetPackageMapping(wm deps.WindowManager) map[string]PackageMapping {
|
func (u *UbuntuDistribution) GetPackageMapping(wm deps.WindowManager) map[string]PackageMapping {
|
||||||
|
return u.GetPackageMappingWithVariants(wm, make(map[string]deps.PackageVariant))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *UbuntuDistribution) GetPackageMappingWithVariants(wm deps.WindowManager, variants map[string]deps.PackageVariant) map[string]PackageMapping {
|
||||||
packages := map[string]PackageMapping{
|
packages := map[string]PackageMapping{
|
||||||
// Standard APT packages
|
// Standard APT packages
|
||||||
"git": {Name: "git", Repository: RepoTypeSystem},
|
"git": {Name: "git", Repository: RepoTypeSystem},
|
||||||
@@ -160,16 +163,16 @@ func (u *UbuntuDistribution) GetPackageMapping(wm deps.WindowManager) map[string
|
|||||||
"xdg-desktop-portal-gtk": {Name: "xdg-desktop-portal-gtk", Repository: RepoTypeSystem},
|
"xdg-desktop-portal-gtk": {Name: "xdg-desktop-portal-gtk", Repository: RepoTypeSystem},
|
||||||
"mate-polkit": {Name: "mate-polkit", Repository: RepoTypeSystem},
|
"mate-polkit": {Name: "mate-polkit", Repository: RepoTypeSystem},
|
||||||
"accountsservice": {Name: "accountsservice", Repository: RepoTypeSystem},
|
"accountsservice": {Name: "accountsservice", Repository: RepoTypeSystem},
|
||||||
"hyprpicker": {Name: "hyprpicker", Repository: RepoTypePPA, RepoURL: "ppa:cppiber/hyprland"},
|
|
||||||
|
|
||||||
// Manual builds (niri and quickshell likely not available in Ubuntu repos or PPAs)
|
// DMS packages from PPAs
|
||||||
"dms (DankMaterialShell)": {Name: "dms", Repository: RepoTypeManual, BuildFunc: "installDankMaterialShell"},
|
"dms (DankMaterialShell)": u.getDmsMapping(variants["dms (DankMaterialShell)"]),
|
||||||
"niri": {Name: "niri", Repository: RepoTypeManual, BuildFunc: "installNiri"},
|
"quickshell": u.getQuickshellMapping(variants["quickshell"]),
|
||||||
"quickshell": {Name: "quickshell", Repository: RepoTypeManual, BuildFunc: "installQuickshell"},
|
"matugen": {Name: "matugen", Repository: RepoTypePPA, RepoURL: "ppa:avengemedia/danklinux"},
|
||||||
|
"dgop": {Name: "dgop", Repository: RepoTypePPA, RepoURL: "ppa:avengemedia/danklinux"},
|
||||||
|
"cliphist": {Name: "cliphist", Repository: RepoTypePPA, RepoURL: "ppa:avengemedia/danklinux"},
|
||||||
|
|
||||||
|
// Keep ghostty as manual (no PPA available)
|
||||||
"ghostty": {Name: "ghostty", Repository: RepoTypeManual, BuildFunc: "installGhostty"},
|
"ghostty": {Name: "ghostty", Repository: RepoTypeManual, BuildFunc: "installGhostty"},
|
||||||
"matugen": {Name: "matugen", Repository: RepoTypeManual, BuildFunc: "installMatugen"},
|
|
||||||
"dgop": {Name: "dgop", Repository: RepoTypeManual, BuildFunc: "installDgop"},
|
|
||||||
"cliphist": {Name: "cliphist", Repository: RepoTypeManual, BuildFunc: "installCliphist"},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch wm {
|
switch wm {
|
||||||
@@ -182,13 +185,42 @@ func (u *UbuntuDistribution) GetPackageMapping(wm deps.WindowManager) map[string
|
|||||||
packages["grimblast"] = PackageMapping{Name: "grimblast", Repository: RepoTypeManual, BuildFunc: "installGrimblast"}
|
packages["grimblast"] = PackageMapping{Name: "grimblast", Repository: RepoTypeManual, BuildFunc: "installGrimblast"}
|
||||||
packages["jq"] = PackageMapping{Name: "jq", Repository: RepoTypeSystem}
|
packages["jq"] = PackageMapping{Name: "jq", Repository: RepoTypeSystem}
|
||||||
case deps.WindowManagerNiri:
|
case deps.WindowManagerNiri:
|
||||||
packages["niri"] = PackageMapping{Name: "niri", Repository: RepoTypeManual, BuildFunc: "installNiri"}
|
niriVariant := variants["niri"]
|
||||||
packages["xwayland-satellite"] = PackageMapping{Name: "xwayland-satellite", Repository: RepoTypeManual, BuildFunc: "installXwaylandSatellite"}
|
packages["niri"] = u.getNiriMapping(niriVariant)
|
||||||
|
packages["xwayland-satellite"] = u.getXwaylandSatelliteMapping(niriVariant)
|
||||||
}
|
}
|
||||||
|
|
||||||
return packages
|
return packages
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *UbuntuDistribution) getDmsMapping(variant deps.PackageVariant) PackageMapping {
|
||||||
|
if variant == deps.VariantGit {
|
||||||
|
return PackageMapping{Name: "dms-git", Repository: RepoTypePPA, RepoURL: "ppa:avengemedia/dms-git"}
|
||||||
|
}
|
||||||
|
return PackageMapping{Name: "dms", Repository: RepoTypePPA, RepoURL: "ppa:avengemedia/dms"}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *UbuntuDistribution) getQuickshellMapping(variant deps.PackageVariant) PackageMapping {
|
||||||
|
if forceQuickshellGit || variant == deps.VariantGit {
|
||||||
|
return PackageMapping{Name: "quickshell-git", Repository: RepoTypePPA, RepoURL: "ppa:avengemedia/danklinux"}
|
||||||
|
}
|
||||||
|
return PackageMapping{Name: "quickshell", Repository: RepoTypePPA, RepoURL: "ppa:avengemedia/danklinux"}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *UbuntuDistribution) getNiriMapping(variant deps.PackageVariant) PackageMapping {
|
||||||
|
if variant == deps.VariantGit {
|
||||||
|
return PackageMapping{Name: "niri-git", Repository: RepoTypePPA, RepoURL: "ppa:avengemedia/danklinux"}
|
||||||
|
}
|
||||||
|
return PackageMapping{Name: "niri", Repository: RepoTypePPA, RepoURL: "ppa:avengemedia/danklinux"}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u *UbuntuDistribution) getXwaylandSatelliteMapping(variant deps.PackageVariant) PackageMapping {
|
||||||
|
if variant == deps.VariantGit {
|
||||||
|
return PackageMapping{Name: "xwayland-satellite-git", Repository: RepoTypePPA, RepoURL: "ppa:avengemedia/danklinux"}
|
||||||
|
}
|
||||||
|
return PackageMapping{Name: "xwayland-satellite", Repository: RepoTypePPA, RepoURL: "ppa:avengemedia/danklinux"}
|
||||||
|
}
|
||||||
|
|
||||||
func (u *UbuntuDistribution) InstallPrerequisites(ctx context.Context, sudoPassword string, progressChan chan<- InstallProgressMsg) error {
|
func (u *UbuntuDistribution) InstallPrerequisites(ctx context.Context, sudoPassword string, progressChan chan<- InstallProgressMsg) error {
|
||||||
progressChan <- InstallProgressMsg{
|
progressChan <- InstallProgressMsg{
|
||||||
Phase: PhasePrerequisites,
|
Phase: PhasePrerequisites,
|
||||||
@@ -365,7 +397,7 @@ func (u *UbuntuDistribution) categorizePackages(dependencies []deps.Dependency,
|
|||||||
variantMap[dep.Name] = dep.Variant
|
variantMap[dep.Name] = dep.Variant
|
||||||
}
|
}
|
||||||
|
|
||||||
packageMap := u.GetPackageMapping(wm)
|
packageMap := u.GetPackageMappingWithVariants(wm, variantMap)
|
||||||
|
|
||||||
for _, dep := range dependencies {
|
for _, dep := range dependencies {
|
||||||
if disabledFlags[dep.Name] {
|
if disabledFlags[dep.Name] {
|
||||||
|
|||||||
@@ -0,0 +1,284 @@
|
|||||||
|
// Generated by go-wayland-scanner
|
||||||
|
// https://github.com/yaslama/go-wayland/cmd/go-wayland-scanner
|
||||||
|
// XML file : internal/proto/xml/keyboard-shortcuts-inhibit-unstable-v1.xml
|
||||||
|
//
|
||||||
|
// keyboard_shortcuts_inhibit_unstable_v1 Protocol Copyright:
|
||||||
|
//
|
||||||
|
// Copyright © 2017 Red Hat Inc.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
// and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice (including the next
|
||||||
|
// paragraph) shall be included in all copies or substantial portions of the
|
||||||
|
// Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
package keyboard_shortcuts_inhibit
|
||||||
|
|
||||||
|
import "github.com/AvengeMedia/DankMaterialShell/core/pkg/go-wayland/wayland/client"
|
||||||
|
|
||||||
|
// ZwpKeyboardShortcutsInhibitManagerV1InterfaceName is the name of the interface as it appears in the [client.Registry].
|
||||||
|
// It can be used to match the [client.RegistryGlobalEvent.Interface] in the
|
||||||
|
// [Registry.SetGlobalHandler] and can be used in [Registry.Bind] if this applies.
|
||||||
|
const ZwpKeyboardShortcutsInhibitManagerV1InterfaceName = "zwp_keyboard_shortcuts_inhibit_manager_v1"
|
||||||
|
|
||||||
|
// ZwpKeyboardShortcutsInhibitManagerV1 : context object for keyboard grab_manager
|
||||||
|
//
|
||||||
|
// A global interface used for inhibiting the compositor keyboard shortcuts.
|
||||||
|
type ZwpKeyboardShortcutsInhibitManagerV1 struct {
|
||||||
|
client.BaseProxy
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewZwpKeyboardShortcutsInhibitManagerV1 : context object for keyboard grab_manager
|
||||||
|
//
|
||||||
|
// A global interface used for inhibiting the compositor keyboard shortcuts.
|
||||||
|
func NewZwpKeyboardShortcutsInhibitManagerV1(ctx *client.Context) *ZwpKeyboardShortcutsInhibitManagerV1 {
|
||||||
|
zwpKeyboardShortcutsInhibitManagerV1 := &ZwpKeyboardShortcutsInhibitManagerV1{}
|
||||||
|
ctx.Register(zwpKeyboardShortcutsInhibitManagerV1)
|
||||||
|
return zwpKeyboardShortcutsInhibitManagerV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destroy : destroy the keyboard shortcuts inhibitor object
|
||||||
|
//
|
||||||
|
// Destroy the keyboard shortcuts inhibitor manager.
|
||||||
|
func (i *ZwpKeyboardShortcutsInhibitManagerV1) Destroy() error {
|
||||||
|
defer i.Context().Unregister(i)
|
||||||
|
const opcode = 0
|
||||||
|
const _reqBufLen = 8
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// InhibitShortcuts : create a new keyboard shortcuts inhibitor object
|
||||||
|
//
|
||||||
|
// Create a new keyboard shortcuts inhibitor object associated with
|
||||||
|
// the given surface for the given seat.
|
||||||
|
//
|
||||||
|
// If shortcuts are already inhibited for the specified seat and surface,
|
||||||
|
// a protocol error "already_inhibited" is raised by the compositor.
|
||||||
|
//
|
||||||
|
// surface: the surface that inhibits the keyboard shortcuts behavior
|
||||||
|
// seat: the wl_seat for which keyboard shortcuts should be disabled
|
||||||
|
func (i *ZwpKeyboardShortcutsInhibitManagerV1) InhibitShortcuts(surface *client.Surface, seat *client.Seat) (*ZwpKeyboardShortcutsInhibitorV1, error) {
|
||||||
|
id := NewZwpKeyboardShortcutsInhibitorV1(i.Context())
|
||||||
|
const opcode = 1
|
||||||
|
const _reqBufLen = 8 + 4 + 4 + 4
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], id.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], surface.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], seat.ID())
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return id, err
|
||||||
|
}
|
||||||
|
|
||||||
|
type ZwpKeyboardShortcutsInhibitManagerV1Error uint32
|
||||||
|
|
||||||
|
// ZwpKeyboardShortcutsInhibitManagerV1Error :
|
||||||
|
const (
|
||||||
|
// ZwpKeyboardShortcutsInhibitManagerV1ErrorAlreadyInhibited : the shortcuts are already inhibited for this surface
|
||||||
|
ZwpKeyboardShortcutsInhibitManagerV1ErrorAlreadyInhibited ZwpKeyboardShortcutsInhibitManagerV1Error = 0
|
||||||
|
)
|
||||||
|
|
||||||
|
func (e ZwpKeyboardShortcutsInhibitManagerV1Error) Name() string {
|
||||||
|
switch e {
|
||||||
|
case ZwpKeyboardShortcutsInhibitManagerV1ErrorAlreadyInhibited:
|
||||||
|
return "already_inhibited"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ZwpKeyboardShortcutsInhibitManagerV1Error) Value() string {
|
||||||
|
switch e {
|
||||||
|
case ZwpKeyboardShortcutsInhibitManagerV1ErrorAlreadyInhibited:
|
||||||
|
return "0"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ZwpKeyboardShortcutsInhibitManagerV1Error) String() string {
|
||||||
|
return e.Name() + "=" + e.Value()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZwpKeyboardShortcutsInhibitorV1InterfaceName is the name of the interface as it appears in the [client.Registry].
|
||||||
|
// It can be used to match the [client.RegistryGlobalEvent.Interface] in the
|
||||||
|
// [Registry.SetGlobalHandler] and can be used in [Registry.Bind] if this applies.
|
||||||
|
const ZwpKeyboardShortcutsInhibitorV1InterfaceName = "zwp_keyboard_shortcuts_inhibitor_v1"
|
||||||
|
|
||||||
|
// ZwpKeyboardShortcutsInhibitorV1 : context object for keyboard shortcuts inhibitor
|
||||||
|
//
|
||||||
|
// A keyboard shortcuts inhibitor instructs the compositor to ignore
|
||||||
|
// its own keyboard shortcuts when the associated surface has keyboard
|
||||||
|
// focus. As a result, when the surface has keyboard focus on the given
|
||||||
|
// seat, it will receive all key events originating from the specified
|
||||||
|
// seat, even those which would normally be caught by the compositor for
|
||||||
|
// its own shortcuts.
|
||||||
|
//
|
||||||
|
// The Wayland compositor is however under no obligation to disable
|
||||||
|
// all of its shortcuts, and may keep some special key combo for its own
|
||||||
|
// use, including but not limited to one allowing the user to forcibly
|
||||||
|
// restore normal keyboard events routing in the case of an unwilling
|
||||||
|
// client. The compositor may also use the same key combo to reactivate
|
||||||
|
// an existing shortcut inhibitor that was previously deactivated on
|
||||||
|
// user request.
|
||||||
|
//
|
||||||
|
// When the compositor restores its own keyboard shortcuts, an
|
||||||
|
// "inactive" event is emitted to notify the client that the keyboard
|
||||||
|
// shortcuts inhibitor is not effectively active for the surface and
|
||||||
|
// seat any more, and the client should not expect to receive all
|
||||||
|
// keyboard events.
|
||||||
|
//
|
||||||
|
// When the keyboard shortcuts inhibitor is inactive, the client has
|
||||||
|
// no way to forcibly reactivate the keyboard shortcuts inhibitor.
|
||||||
|
//
|
||||||
|
// The user can chose to re-enable a previously deactivated keyboard
|
||||||
|
// shortcuts inhibitor using any mechanism the compositor may offer,
|
||||||
|
// in which case the compositor will send an "active" event to notify
|
||||||
|
// the client.
|
||||||
|
//
|
||||||
|
// If the surface is destroyed, unmapped, or loses the seat's keyboard
|
||||||
|
// focus, the keyboard shortcuts inhibitor becomes irrelevant and the
|
||||||
|
// compositor will restore its own keyboard shortcuts but no "inactive"
|
||||||
|
// event is emitted in this case.
|
||||||
|
type ZwpKeyboardShortcutsInhibitorV1 struct {
|
||||||
|
client.BaseProxy
|
||||||
|
activeHandler ZwpKeyboardShortcutsInhibitorV1ActiveHandlerFunc
|
||||||
|
inactiveHandler ZwpKeyboardShortcutsInhibitorV1InactiveHandlerFunc
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewZwpKeyboardShortcutsInhibitorV1 : context object for keyboard shortcuts inhibitor
|
||||||
|
//
|
||||||
|
// A keyboard shortcuts inhibitor instructs the compositor to ignore
|
||||||
|
// its own keyboard shortcuts when the associated surface has keyboard
|
||||||
|
// focus. As a result, when the surface has keyboard focus on the given
|
||||||
|
// seat, it will receive all key events originating from the specified
|
||||||
|
// seat, even those which would normally be caught by the compositor for
|
||||||
|
// its own shortcuts.
|
||||||
|
//
|
||||||
|
// The Wayland compositor is however under no obligation to disable
|
||||||
|
// all of its shortcuts, and may keep some special key combo for its own
|
||||||
|
// use, including but not limited to one allowing the user to forcibly
|
||||||
|
// restore normal keyboard events routing in the case of an unwilling
|
||||||
|
// client. The compositor may also use the same key combo to reactivate
|
||||||
|
// an existing shortcut inhibitor that was previously deactivated on
|
||||||
|
// user request.
|
||||||
|
//
|
||||||
|
// When the compositor restores its own keyboard shortcuts, an
|
||||||
|
// "inactive" event is emitted to notify the client that the keyboard
|
||||||
|
// shortcuts inhibitor is not effectively active for the surface and
|
||||||
|
// seat any more, and the client should not expect to receive all
|
||||||
|
// keyboard events.
|
||||||
|
//
|
||||||
|
// When the keyboard shortcuts inhibitor is inactive, the client has
|
||||||
|
// no way to forcibly reactivate the keyboard shortcuts inhibitor.
|
||||||
|
//
|
||||||
|
// The user can chose to re-enable a previously deactivated keyboard
|
||||||
|
// shortcuts inhibitor using any mechanism the compositor may offer,
|
||||||
|
// in which case the compositor will send an "active" event to notify
|
||||||
|
// the client.
|
||||||
|
//
|
||||||
|
// If the surface is destroyed, unmapped, or loses the seat's keyboard
|
||||||
|
// focus, the keyboard shortcuts inhibitor becomes irrelevant and the
|
||||||
|
// compositor will restore its own keyboard shortcuts but no "inactive"
|
||||||
|
// event is emitted in this case.
|
||||||
|
func NewZwpKeyboardShortcutsInhibitorV1(ctx *client.Context) *ZwpKeyboardShortcutsInhibitorV1 {
|
||||||
|
zwpKeyboardShortcutsInhibitorV1 := &ZwpKeyboardShortcutsInhibitorV1{}
|
||||||
|
ctx.Register(zwpKeyboardShortcutsInhibitorV1)
|
||||||
|
return zwpKeyboardShortcutsInhibitorV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destroy : destroy the keyboard shortcuts inhibitor object
|
||||||
|
//
|
||||||
|
// Remove the keyboard shortcuts inhibitor from the associated wl_surface.
|
||||||
|
func (i *ZwpKeyboardShortcutsInhibitorV1) Destroy() error {
|
||||||
|
defer i.Context().Unregister(i)
|
||||||
|
const opcode = 0
|
||||||
|
const _reqBufLen = 8
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZwpKeyboardShortcutsInhibitorV1ActiveEvent : shortcuts are inhibited
|
||||||
|
//
|
||||||
|
// This event indicates that the shortcut inhibitor is active.
|
||||||
|
//
|
||||||
|
// The compositor sends this event every time compositor shortcuts
|
||||||
|
// are inhibited on behalf of the surface. When active, the client
|
||||||
|
// may receive input events normally reserved by the compositor
|
||||||
|
// (see zwp_keyboard_shortcuts_inhibitor_v1).
|
||||||
|
//
|
||||||
|
// This occurs typically when the initial request "inhibit_shortcuts"
|
||||||
|
// first becomes active or when the user instructs the compositor to
|
||||||
|
// re-enable and existing shortcuts inhibitor using any mechanism
|
||||||
|
// offered by the compositor.
|
||||||
|
type ZwpKeyboardShortcutsInhibitorV1ActiveEvent struct{}
|
||||||
|
type ZwpKeyboardShortcutsInhibitorV1ActiveHandlerFunc func(ZwpKeyboardShortcutsInhibitorV1ActiveEvent)
|
||||||
|
|
||||||
|
// SetActiveHandler : sets handler for ZwpKeyboardShortcutsInhibitorV1ActiveEvent
|
||||||
|
func (i *ZwpKeyboardShortcutsInhibitorV1) SetActiveHandler(f ZwpKeyboardShortcutsInhibitorV1ActiveHandlerFunc) {
|
||||||
|
i.activeHandler = f
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZwpKeyboardShortcutsInhibitorV1InactiveEvent : shortcuts are restored
|
||||||
|
//
|
||||||
|
// This event indicates that the shortcuts inhibitor is inactive,
|
||||||
|
// normal shortcuts processing is restored by the compositor.
|
||||||
|
type ZwpKeyboardShortcutsInhibitorV1InactiveEvent struct{}
|
||||||
|
type ZwpKeyboardShortcutsInhibitorV1InactiveHandlerFunc func(ZwpKeyboardShortcutsInhibitorV1InactiveEvent)
|
||||||
|
|
||||||
|
// SetInactiveHandler : sets handler for ZwpKeyboardShortcutsInhibitorV1InactiveEvent
|
||||||
|
func (i *ZwpKeyboardShortcutsInhibitorV1) SetInactiveHandler(f ZwpKeyboardShortcutsInhibitorV1InactiveHandlerFunc) {
|
||||||
|
i.inactiveHandler = f
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *ZwpKeyboardShortcutsInhibitorV1) Dispatch(opcode uint32, fd int, data []byte) {
|
||||||
|
switch opcode {
|
||||||
|
case 0:
|
||||||
|
if i.activeHandler == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var e ZwpKeyboardShortcutsInhibitorV1ActiveEvent
|
||||||
|
|
||||||
|
i.activeHandler(e)
|
||||||
|
case 1:
|
||||||
|
if i.inactiveHandler == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var e ZwpKeyboardShortcutsInhibitorV1InactiveEvent
|
||||||
|
|
||||||
|
i.inactiveHandler(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
792
core/internal/proto/wlr_layer_shell/layer_shell.go
Normal file
792
core/internal/proto/wlr_layer_shell/layer_shell.go
Normal file
@@ -0,0 +1,792 @@
|
|||||||
|
// Generated by go-wayland-scanner
|
||||||
|
// https://github.com/yaslama/go-wayland/cmd/go-wayland-scanner
|
||||||
|
// XML file : internal/proto/xml/wlr-layer-shell-unstable-v1.xml
|
||||||
|
//
|
||||||
|
// wlr_layer_shell_unstable_v1 Protocol Copyright:
|
||||||
|
//
|
||||||
|
// Copyright © 2017 Drew DeVault
|
||||||
|
//
|
||||||
|
// Permission to use, copy, modify, distribute, and sell this
|
||||||
|
// software and its documentation for any purpose is hereby granted
|
||||||
|
// without fee, provided that the above copyright notice appear in
|
||||||
|
// all copies and that both that copyright notice and this permission
|
||||||
|
// notice appear in supporting documentation, and that the name of
|
||||||
|
// the copyright holders not be used in advertising or publicity
|
||||||
|
// pertaining to distribution of the software without specific,
|
||||||
|
// written prior permission. The copyright holders make no
|
||||||
|
// representations about the suitability of this software for any
|
||||||
|
// purpose. It is provided "as is" without express or implied
|
||||||
|
// warranty.
|
||||||
|
//
|
||||||
|
// THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
||||||
|
// SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
// FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
// SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||||
|
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||||
|
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||||
|
// THIS SOFTWARE.
|
||||||
|
|
||||||
|
package wlr_layer_shell
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/AvengeMedia/DankMaterialShell/core/pkg/go-wayland/wayland/client"
|
||||||
|
xdg_shell "github.com/AvengeMedia/DankMaterialShell/core/pkg/go-wayland/wayland/stable/xdg-shell"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ZwlrLayerShellV1InterfaceName is the name of the interface as it appears in the [client.Registry].
|
||||||
|
// It can be used to match the [client.RegistryGlobalEvent.Interface] in the
|
||||||
|
// [Registry.SetGlobalHandler] and can be used in [Registry.Bind] if this applies.
|
||||||
|
const ZwlrLayerShellV1InterfaceName = "zwlr_layer_shell_v1"
|
||||||
|
|
||||||
|
// ZwlrLayerShellV1 : create surfaces that are layers of the desktop
|
||||||
|
//
|
||||||
|
// Clients can use this interface to assign the surface_layer role to
|
||||||
|
// wl_surfaces. Such surfaces are assigned to a "layer" of the output and
|
||||||
|
// rendered with a defined z-depth respective to each other. They may also be
|
||||||
|
// anchored to the edges and corners of a screen and specify input handling
|
||||||
|
// semantics. This interface should be suitable for the implementation of
|
||||||
|
// many desktop shell components, and a broad number of other applications
|
||||||
|
// that interact with the desktop.
|
||||||
|
type ZwlrLayerShellV1 struct {
|
||||||
|
client.BaseProxy
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewZwlrLayerShellV1 : create surfaces that are layers of the desktop
|
||||||
|
//
|
||||||
|
// Clients can use this interface to assign the surface_layer role to
|
||||||
|
// wl_surfaces. Such surfaces are assigned to a "layer" of the output and
|
||||||
|
// rendered with a defined z-depth respective to each other. They may also be
|
||||||
|
// anchored to the edges and corners of a screen and specify input handling
|
||||||
|
// semantics. This interface should be suitable for the implementation of
|
||||||
|
// many desktop shell components, and a broad number of other applications
|
||||||
|
// that interact with the desktop.
|
||||||
|
func NewZwlrLayerShellV1(ctx *client.Context) *ZwlrLayerShellV1 {
|
||||||
|
zwlrLayerShellV1 := &ZwlrLayerShellV1{}
|
||||||
|
ctx.Register(zwlrLayerShellV1)
|
||||||
|
return zwlrLayerShellV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetLayerSurface : create a layer_surface from a surface
|
||||||
|
//
|
||||||
|
// Create a layer surface for an existing surface. This assigns the role of
|
||||||
|
// layer_surface, or raises a protocol error if another role is already
|
||||||
|
// assigned.
|
||||||
|
//
|
||||||
|
// Creating a layer surface from a wl_surface which has a buffer attached
|
||||||
|
// or committed is a client error, and any attempts by a client to attach
|
||||||
|
// or manipulate a buffer prior to the first layer_surface.configure call
|
||||||
|
// must also be treated as errors.
|
||||||
|
//
|
||||||
|
// After creating a layer_surface object and setting it up, the client
|
||||||
|
// must perform an initial commit without any buffer attached.
|
||||||
|
// The compositor will reply with a layer_surface.configure event.
|
||||||
|
// The client must acknowledge it and is then allowed to attach a buffer
|
||||||
|
// to map the surface.
|
||||||
|
//
|
||||||
|
// You may pass NULL for output to allow the compositor to decide which
|
||||||
|
// output to use. Generally this will be the one that the user most
|
||||||
|
// recently interacted with.
|
||||||
|
//
|
||||||
|
// Clients can specify a namespace that defines the purpose of the layer
|
||||||
|
// surface.
|
||||||
|
//
|
||||||
|
// layer: layer to add this surface to
|
||||||
|
// namespace: namespace for the layer surface
|
||||||
|
func (i *ZwlrLayerShellV1) GetLayerSurface(surface *client.Surface, output *client.Output, layer uint32, namespace string) (*ZwlrLayerSurfaceV1, error) {
|
||||||
|
id := NewZwlrLayerSurfaceV1(i.Context())
|
||||||
|
const opcode = 0
|
||||||
|
namespaceLen := client.PaddedLen(len(namespace) + 1)
|
||||||
|
_reqBufLen := 8 + 4 + 4 + 4 + 4 + (4 + namespaceLen)
|
||||||
|
_reqBuf := make([]byte, _reqBufLen)
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], id.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], surface.ID())
|
||||||
|
l += 4
|
||||||
|
if output == nil {
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], 0)
|
||||||
|
l += 4
|
||||||
|
} else {
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], output.ID())
|
||||||
|
l += 4
|
||||||
|
}
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(layer))
|
||||||
|
l += 4
|
||||||
|
client.PutString(_reqBuf[l:l+(4+namespaceLen)], namespace)
|
||||||
|
l += (4 + namespaceLen)
|
||||||
|
err := i.Context().WriteMsg(_reqBuf, nil)
|
||||||
|
return id, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destroy : destroy the layer_shell object
|
||||||
|
//
|
||||||
|
// This request indicates that the client will not use the layer_shell
|
||||||
|
// object any more. Objects that have been created through this instance
|
||||||
|
// are not affected.
|
||||||
|
func (i *ZwlrLayerShellV1) Destroy() error {
|
||||||
|
defer i.Context().Unregister(i)
|
||||||
|
const opcode = 1
|
||||||
|
const _reqBufLen = 8
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
type ZwlrLayerShellV1Error uint32
|
||||||
|
|
||||||
|
// ZwlrLayerShellV1Error :
|
||||||
|
const (
|
||||||
|
// ZwlrLayerShellV1ErrorRole : wl_surface has another role
|
||||||
|
ZwlrLayerShellV1ErrorRole ZwlrLayerShellV1Error = 0
|
||||||
|
// ZwlrLayerShellV1ErrorInvalidLayer : layer value is invalid
|
||||||
|
ZwlrLayerShellV1ErrorInvalidLayer ZwlrLayerShellV1Error = 1
|
||||||
|
// ZwlrLayerShellV1ErrorAlreadyConstructed : wl_surface has a buffer attached or committed
|
||||||
|
ZwlrLayerShellV1ErrorAlreadyConstructed ZwlrLayerShellV1Error = 2
|
||||||
|
)
|
||||||
|
|
||||||
|
func (e ZwlrLayerShellV1Error) Name() string {
|
||||||
|
switch e {
|
||||||
|
case ZwlrLayerShellV1ErrorRole:
|
||||||
|
return "role"
|
||||||
|
case ZwlrLayerShellV1ErrorInvalidLayer:
|
||||||
|
return "invalid_layer"
|
||||||
|
case ZwlrLayerShellV1ErrorAlreadyConstructed:
|
||||||
|
return "already_constructed"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ZwlrLayerShellV1Error) Value() string {
|
||||||
|
switch e {
|
||||||
|
case ZwlrLayerShellV1ErrorRole:
|
||||||
|
return "0"
|
||||||
|
case ZwlrLayerShellV1ErrorInvalidLayer:
|
||||||
|
return "1"
|
||||||
|
case ZwlrLayerShellV1ErrorAlreadyConstructed:
|
||||||
|
return "2"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ZwlrLayerShellV1Error) String() string {
|
||||||
|
return e.Name() + "=" + e.Value()
|
||||||
|
}
|
||||||
|
|
||||||
|
type ZwlrLayerShellV1Layer uint32
|
||||||
|
|
||||||
|
// ZwlrLayerShellV1Layer : available layers for surfaces
|
||||||
|
//
|
||||||
|
// These values indicate which layers a surface can be rendered in. They
|
||||||
|
// are ordered by z depth, bottom-most first. Traditional shell surfaces
|
||||||
|
// will typically be rendered between the bottom and top layers.
|
||||||
|
// Fullscreen shell surfaces are typically rendered at the top layer.
|
||||||
|
// Multiple surfaces can share a single layer, and ordering within a
|
||||||
|
// single layer is undefined.
|
||||||
|
const (
|
||||||
|
ZwlrLayerShellV1LayerBackground ZwlrLayerShellV1Layer = 0
|
||||||
|
ZwlrLayerShellV1LayerBottom ZwlrLayerShellV1Layer = 1
|
||||||
|
ZwlrLayerShellV1LayerTop ZwlrLayerShellV1Layer = 2
|
||||||
|
ZwlrLayerShellV1LayerOverlay ZwlrLayerShellV1Layer = 3
|
||||||
|
)
|
||||||
|
|
||||||
|
func (e ZwlrLayerShellV1Layer) Name() string {
|
||||||
|
switch e {
|
||||||
|
case ZwlrLayerShellV1LayerBackground:
|
||||||
|
return "background"
|
||||||
|
case ZwlrLayerShellV1LayerBottom:
|
||||||
|
return "bottom"
|
||||||
|
case ZwlrLayerShellV1LayerTop:
|
||||||
|
return "top"
|
||||||
|
case ZwlrLayerShellV1LayerOverlay:
|
||||||
|
return "overlay"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ZwlrLayerShellV1Layer) Value() string {
|
||||||
|
switch e {
|
||||||
|
case ZwlrLayerShellV1LayerBackground:
|
||||||
|
return "0"
|
||||||
|
case ZwlrLayerShellV1LayerBottom:
|
||||||
|
return "1"
|
||||||
|
case ZwlrLayerShellV1LayerTop:
|
||||||
|
return "2"
|
||||||
|
case ZwlrLayerShellV1LayerOverlay:
|
||||||
|
return "3"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ZwlrLayerShellV1Layer) String() string {
|
||||||
|
return e.Name() + "=" + e.Value()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZwlrLayerSurfaceV1InterfaceName is the name of the interface as it appears in the [client.Registry].
|
||||||
|
// It can be used to match the [client.RegistryGlobalEvent.Interface] in the
|
||||||
|
// [Registry.SetGlobalHandler] and can be used in [Registry.Bind] if this applies.
|
||||||
|
const ZwlrLayerSurfaceV1InterfaceName = "zwlr_layer_surface_v1"
|
||||||
|
|
||||||
|
// ZwlrLayerSurfaceV1 : layer metadata interface
|
||||||
|
//
|
||||||
|
// An interface that may be implemented by a wl_surface, for surfaces that
|
||||||
|
// are designed to be rendered as a layer of a stacked desktop-like
|
||||||
|
// environment.
|
||||||
|
//
|
||||||
|
// Layer surface state (layer, size, anchor, exclusive zone,
|
||||||
|
// margin, interactivity) is double-buffered, and will be applied at the
|
||||||
|
// time wl_surface.commit of the corresponding wl_surface is called.
|
||||||
|
//
|
||||||
|
// Attaching a null buffer to a layer surface unmaps it.
|
||||||
|
//
|
||||||
|
// Unmapping a layer_surface means that the surface cannot be shown by the
|
||||||
|
// compositor until it is explicitly mapped again. The layer_surface
|
||||||
|
// returns to the state it had right after layer_shell.get_layer_surface.
|
||||||
|
// The client can re-map the surface by performing a commit without any
|
||||||
|
// buffer attached, waiting for a configure event and handling it as usual.
|
||||||
|
type ZwlrLayerSurfaceV1 struct {
|
||||||
|
client.BaseProxy
|
||||||
|
configureHandler ZwlrLayerSurfaceV1ConfigureHandlerFunc
|
||||||
|
closedHandler ZwlrLayerSurfaceV1ClosedHandlerFunc
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewZwlrLayerSurfaceV1 : layer metadata interface
|
||||||
|
//
|
||||||
|
// An interface that may be implemented by a wl_surface, for surfaces that
|
||||||
|
// are designed to be rendered as a layer of a stacked desktop-like
|
||||||
|
// environment.
|
||||||
|
//
|
||||||
|
// Layer surface state (layer, size, anchor, exclusive zone,
|
||||||
|
// margin, interactivity) is double-buffered, and will be applied at the
|
||||||
|
// time wl_surface.commit of the corresponding wl_surface is called.
|
||||||
|
//
|
||||||
|
// Attaching a null buffer to a layer surface unmaps it.
|
||||||
|
//
|
||||||
|
// Unmapping a layer_surface means that the surface cannot be shown by the
|
||||||
|
// compositor until it is explicitly mapped again. The layer_surface
|
||||||
|
// returns to the state it had right after layer_shell.get_layer_surface.
|
||||||
|
// The client can re-map the surface by performing a commit without any
|
||||||
|
// buffer attached, waiting for a configure event and handling it as usual.
|
||||||
|
func NewZwlrLayerSurfaceV1(ctx *client.Context) *ZwlrLayerSurfaceV1 {
|
||||||
|
zwlrLayerSurfaceV1 := &ZwlrLayerSurfaceV1{}
|
||||||
|
ctx.Register(zwlrLayerSurfaceV1)
|
||||||
|
return zwlrLayerSurfaceV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSize : sets the size of the surface
|
||||||
|
//
|
||||||
|
// Sets the size of the surface in surface-local coordinates. The
|
||||||
|
// compositor will display the surface centered with respect to its
|
||||||
|
// anchors.
|
||||||
|
//
|
||||||
|
// If you pass 0 for either value, the compositor will assign it and
|
||||||
|
// inform you of the assignment in the configure event. You must set your
|
||||||
|
// anchor to opposite edges in the dimensions you omit; not doing so is a
|
||||||
|
// protocol error. Both values are 0 by default.
|
||||||
|
//
|
||||||
|
// Size is double-buffered, see wl_surface.commit.
|
||||||
|
func (i *ZwlrLayerSurfaceV1) SetSize(width, height uint32) error {
|
||||||
|
const opcode = 0
|
||||||
|
const _reqBufLen = 8 + 4 + 4
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(width))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(height))
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAnchor : configures the anchor point of the surface
|
||||||
|
//
|
||||||
|
// Requests that the compositor anchor the surface to the specified edges
|
||||||
|
// and corners. If two orthogonal edges are specified (e.g. 'top' and
|
||||||
|
// 'left'), then the anchor point will be the intersection of the edges
|
||||||
|
// (e.g. the top left corner of the output); otherwise the anchor point
|
||||||
|
// will be centered on that edge, or in the center if none is specified.
|
||||||
|
//
|
||||||
|
// Anchor is double-buffered, see wl_surface.commit.
|
||||||
|
func (i *ZwlrLayerSurfaceV1) SetAnchor(anchor uint32) error {
|
||||||
|
const opcode = 1
|
||||||
|
const _reqBufLen = 8 + 4
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(anchor))
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetExclusiveZone : configures the exclusive geometry of this surface
|
||||||
|
//
|
||||||
|
// Requests that the compositor avoids occluding an area with other
|
||||||
|
// surfaces. The compositor's use of this information is
|
||||||
|
// implementation-dependent - do not assume that this region will not
|
||||||
|
// actually be occluded.
|
||||||
|
//
|
||||||
|
// A positive value is only meaningful if the surface is anchored to one
|
||||||
|
// edge or an edge and both perpendicular edges. If the surface is not
|
||||||
|
// anchored, anchored to only two perpendicular edges (a corner), anchored
|
||||||
|
// to only two parallel edges or anchored to all edges, a positive value
|
||||||
|
// will be treated the same as zero.
|
||||||
|
//
|
||||||
|
// A positive zone is the distance from the edge in surface-local
|
||||||
|
// coordinates to consider exclusive.
|
||||||
|
//
|
||||||
|
// Surfaces that do not wish to have an exclusive zone may instead specify
|
||||||
|
// how they should interact with surfaces that do. If set to zero, the
|
||||||
|
// surface indicates that it would like to be moved to avoid occluding
|
||||||
|
// surfaces with a positive exclusive zone. If set to -1, the surface
|
||||||
|
// indicates that it would not like to be moved to accommodate for other
|
||||||
|
// surfaces, and the compositor should extend it all the way to the edges
|
||||||
|
// it is anchored to.
|
||||||
|
//
|
||||||
|
// For example, a panel might set its exclusive zone to 10, so that
|
||||||
|
// maximized shell surfaces are not shown on top of it. A notification
|
||||||
|
// might set its exclusive zone to 0, so that it is moved to avoid
|
||||||
|
// occluding the panel, but shell surfaces are shown underneath it. A
|
||||||
|
// wallpaper or lock screen might set their exclusive zone to -1, so that
|
||||||
|
// they stretch below or over the panel.
|
||||||
|
//
|
||||||
|
// The default value is 0.
|
||||||
|
//
|
||||||
|
// Exclusive zone is double-buffered, see wl_surface.commit.
|
||||||
|
func (i *ZwlrLayerSurfaceV1) SetExclusiveZone(zone int32) error {
|
||||||
|
const opcode = 2
|
||||||
|
const _reqBufLen = 8 + 4
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(zone))
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetMargin : sets a margin from the anchor point
|
||||||
|
//
|
||||||
|
// Requests that the surface be placed some distance away from the anchor
|
||||||
|
// point on the output, in surface-local coordinates. Setting this value
|
||||||
|
// for edges you are not anchored to has no effect.
|
||||||
|
//
|
||||||
|
// The exclusive zone includes the margin.
|
||||||
|
//
|
||||||
|
// Margin is double-buffered, see wl_surface.commit.
|
||||||
|
func (i *ZwlrLayerSurfaceV1) SetMargin(top, right, bottom, left int32) error {
|
||||||
|
const opcode = 3
|
||||||
|
const _reqBufLen = 8 + 4 + 4 + 4 + 4
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(top))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(right))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(bottom))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(left))
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetKeyboardInteractivity : requests keyboard events
|
||||||
|
//
|
||||||
|
// Set how keyboard events are delivered to this surface. By default,
|
||||||
|
// layer shell surfaces do not receive keyboard events; this request can
|
||||||
|
// be used to change this.
|
||||||
|
//
|
||||||
|
// This setting is inherited by child surfaces set by the get_popup
|
||||||
|
// request.
|
||||||
|
//
|
||||||
|
// Layer surfaces receive pointer, touch, and tablet events normally. If
|
||||||
|
// you do not want to receive them, set the input region on your surface
|
||||||
|
// to an empty region.
|
||||||
|
//
|
||||||
|
// Keyboard interactivity is double-buffered, see wl_surface.commit.
|
||||||
|
func (i *ZwlrLayerSurfaceV1) SetKeyboardInteractivity(keyboardInteractivity uint32) error {
|
||||||
|
const opcode = 4
|
||||||
|
const _reqBufLen = 8 + 4
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(keyboardInteractivity))
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPopup : assign this layer_surface as an xdg_popup parent
|
||||||
|
//
|
||||||
|
// This assigns an xdg_popup's parent to this layer_surface. This popup
|
||||||
|
// should have been created via xdg_surface::get_popup with the parent set
|
||||||
|
// to NULL, and this request must be invoked before committing the popup's
|
||||||
|
// initial state.
|
||||||
|
//
|
||||||
|
// See the documentation of xdg_popup for more details about what an
|
||||||
|
// xdg_popup is and how it is used.
|
||||||
|
func (i *ZwlrLayerSurfaceV1) GetPopup(popup *xdg_shell.Popup) error {
|
||||||
|
const opcode = 5
|
||||||
|
const _reqBufLen = 8 + 4
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], popup.ID())
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// AckConfigure : ack a configure event
|
||||||
|
//
|
||||||
|
// When a configure event is received, if a client commits the
|
||||||
|
// surface in response to the configure event, then the client
|
||||||
|
// must make an ack_configure request sometime before the commit
|
||||||
|
// request, passing along the serial of the configure event.
|
||||||
|
//
|
||||||
|
// If the client receives multiple configure events before it
|
||||||
|
// can respond to one, it only has to ack the last configure event.
|
||||||
|
//
|
||||||
|
// A client is not required to commit immediately after sending
|
||||||
|
// an ack_configure request - it may even ack_configure several times
|
||||||
|
// before its next surface commit.
|
||||||
|
//
|
||||||
|
// A client may send multiple ack_configure requests before committing, but
|
||||||
|
// only the last request sent before a commit indicates which configure
|
||||||
|
// event the client really is responding to.
|
||||||
|
//
|
||||||
|
// serial: the serial from the configure event
|
||||||
|
func (i *ZwlrLayerSurfaceV1) AckConfigure(serial uint32) error {
|
||||||
|
const opcode = 6
|
||||||
|
const _reqBufLen = 8 + 4
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(serial))
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destroy : destroy the layer_surface
|
||||||
|
//
|
||||||
|
// This request destroys the layer surface.
|
||||||
|
func (i *ZwlrLayerSurfaceV1) Destroy() error {
|
||||||
|
defer i.Context().Unregister(i)
|
||||||
|
const opcode = 7
|
||||||
|
const _reqBufLen = 8
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetLayer : change the layer of the surface
|
||||||
|
//
|
||||||
|
// Change the layer that the surface is rendered on.
|
||||||
|
//
|
||||||
|
// Layer is double-buffered, see wl_surface.commit.
|
||||||
|
//
|
||||||
|
// layer: layer to move this surface to
|
||||||
|
func (i *ZwlrLayerSurfaceV1) SetLayer(layer uint32) error {
|
||||||
|
const opcode = 8
|
||||||
|
const _reqBufLen = 8 + 4
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(layer))
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetExclusiveEdge : set the edge the exclusive zone will be applied to
|
||||||
|
//
|
||||||
|
// Requests an edge for the exclusive zone to apply. The exclusive
|
||||||
|
// edge will be automatically deduced from anchor points when possible,
|
||||||
|
// but when the surface is anchored to a corner, it will be necessary
|
||||||
|
// to set it explicitly to disambiguate, as it is not possible to deduce
|
||||||
|
// which one of the two corner edges should be used.
|
||||||
|
//
|
||||||
|
// The edge must be one the surface is anchored to, otherwise the
|
||||||
|
// invalid_exclusive_edge protocol error will be raised.
|
||||||
|
func (i *ZwlrLayerSurfaceV1) SetExclusiveEdge(edge uint32) error {
|
||||||
|
const opcode = 9
|
||||||
|
const _reqBufLen = 8 + 4
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(edge))
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
type ZwlrLayerSurfaceV1KeyboardInteractivity uint32
|
||||||
|
|
||||||
|
// ZwlrLayerSurfaceV1KeyboardInteractivity : types of keyboard interaction possible for a layer shell surface
|
||||||
|
//
|
||||||
|
// Types of keyboard interaction possible for layer shell surfaces. The
|
||||||
|
// rationale for this is twofold: (1) some applications are not interested
|
||||||
|
// in keyboard events and not allowing them to be focused can improve the
|
||||||
|
// desktop experience; (2) some applications will want to take exclusive
|
||||||
|
// keyboard focus.
|
||||||
|
const (
|
||||||
|
ZwlrLayerSurfaceV1KeyboardInteractivityNone ZwlrLayerSurfaceV1KeyboardInteractivity = 0
|
||||||
|
ZwlrLayerSurfaceV1KeyboardInteractivityExclusive ZwlrLayerSurfaceV1KeyboardInteractivity = 1
|
||||||
|
ZwlrLayerSurfaceV1KeyboardInteractivityOnDemand ZwlrLayerSurfaceV1KeyboardInteractivity = 2
|
||||||
|
)
|
||||||
|
|
||||||
|
func (e ZwlrLayerSurfaceV1KeyboardInteractivity) Name() string {
|
||||||
|
switch e {
|
||||||
|
case ZwlrLayerSurfaceV1KeyboardInteractivityNone:
|
||||||
|
return "none"
|
||||||
|
case ZwlrLayerSurfaceV1KeyboardInteractivityExclusive:
|
||||||
|
return "exclusive"
|
||||||
|
case ZwlrLayerSurfaceV1KeyboardInteractivityOnDemand:
|
||||||
|
return "on_demand"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ZwlrLayerSurfaceV1KeyboardInteractivity) Value() string {
|
||||||
|
switch e {
|
||||||
|
case ZwlrLayerSurfaceV1KeyboardInteractivityNone:
|
||||||
|
return "0"
|
||||||
|
case ZwlrLayerSurfaceV1KeyboardInteractivityExclusive:
|
||||||
|
return "1"
|
||||||
|
case ZwlrLayerSurfaceV1KeyboardInteractivityOnDemand:
|
||||||
|
return "2"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ZwlrLayerSurfaceV1KeyboardInteractivity) String() string {
|
||||||
|
return e.Name() + "=" + e.Value()
|
||||||
|
}
|
||||||
|
|
||||||
|
type ZwlrLayerSurfaceV1Error uint32
|
||||||
|
|
||||||
|
// ZwlrLayerSurfaceV1Error :
|
||||||
|
const (
|
||||||
|
// ZwlrLayerSurfaceV1ErrorInvalidSurfaceState : provided surface state is invalid
|
||||||
|
ZwlrLayerSurfaceV1ErrorInvalidSurfaceState ZwlrLayerSurfaceV1Error = 0
|
||||||
|
// ZwlrLayerSurfaceV1ErrorInvalidSize : size is invalid
|
||||||
|
ZwlrLayerSurfaceV1ErrorInvalidSize ZwlrLayerSurfaceV1Error = 1
|
||||||
|
// ZwlrLayerSurfaceV1ErrorInvalidAnchor : anchor bitfield is invalid
|
||||||
|
ZwlrLayerSurfaceV1ErrorInvalidAnchor ZwlrLayerSurfaceV1Error = 2
|
||||||
|
// ZwlrLayerSurfaceV1ErrorInvalidKeyboardInteractivity : keyboard interactivity is invalid
|
||||||
|
ZwlrLayerSurfaceV1ErrorInvalidKeyboardInteractivity ZwlrLayerSurfaceV1Error = 3
|
||||||
|
// ZwlrLayerSurfaceV1ErrorInvalidExclusiveEdge : exclusive edge is invalid given the surface anchors
|
||||||
|
ZwlrLayerSurfaceV1ErrorInvalidExclusiveEdge ZwlrLayerSurfaceV1Error = 4
|
||||||
|
)
|
||||||
|
|
||||||
|
func (e ZwlrLayerSurfaceV1Error) Name() string {
|
||||||
|
switch e {
|
||||||
|
case ZwlrLayerSurfaceV1ErrorInvalidSurfaceState:
|
||||||
|
return "invalid_surface_state"
|
||||||
|
case ZwlrLayerSurfaceV1ErrorInvalidSize:
|
||||||
|
return "invalid_size"
|
||||||
|
case ZwlrLayerSurfaceV1ErrorInvalidAnchor:
|
||||||
|
return "invalid_anchor"
|
||||||
|
case ZwlrLayerSurfaceV1ErrorInvalidKeyboardInteractivity:
|
||||||
|
return "invalid_keyboard_interactivity"
|
||||||
|
case ZwlrLayerSurfaceV1ErrorInvalidExclusiveEdge:
|
||||||
|
return "invalid_exclusive_edge"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ZwlrLayerSurfaceV1Error) Value() string {
|
||||||
|
switch e {
|
||||||
|
case ZwlrLayerSurfaceV1ErrorInvalidSurfaceState:
|
||||||
|
return "0"
|
||||||
|
case ZwlrLayerSurfaceV1ErrorInvalidSize:
|
||||||
|
return "1"
|
||||||
|
case ZwlrLayerSurfaceV1ErrorInvalidAnchor:
|
||||||
|
return "2"
|
||||||
|
case ZwlrLayerSurfaceV1ErrorInvalidKeyboardInteractivity:
|
||||||
|
return "3"
|
||||||
|
case ZwlrLayerSurfaceV1ErrorInvalidExclusiveEdge:
|
||||||
|
return "4"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ZwlrLayerSurfaceV1Error) String() string {
|
||||||
|
return e.Name() + "=" + e.Value()
|
||||||
|
}
|
||||||
|
|
||||||
|
type ZwlrLayerSurfaceV1Anchor uint32
|
||||||
|
|
||||||
|
// ZwlrLayerSurfaceV1Anchor :
|
||||||
|
const (
|
||||||
|
// ZwlrLayerSurfaceV1AnchorTop : the top edge of the anchor rectangle
|
||||||
|
ZwlrLayerSurfaceV1AnchorTop ZwlrLayerSurfaceV1Anchor = 1
|
||||||
|
// ZwlrLayerSurfaceV1AnchorBottom : the bottom edge of the anchor rectangle
|
||||||
|
ZwlrLayerSurfaceV1AnchorBottom ZwlrLayerSurfaceV1Anchor = 2
|
||||||
|
// ZwlrLayerSurfaceV1AnchorLeft : the left edge of the anchor rectangle
|
||||||
|
ZwlrLayerSurfaceV1AnchorLeft ZwlrLayerSurfaceV1Anchor = 4
|
||||||
|
// ZwlrLayerSurfaceV1AnchorRight : the right edge of the anchor rectangle
|
||||||
|
ZwlrLayerSurfaceV1AnchorRight ZwlrLayerSurfaceV1Anchor = 8
|
||||||
|
)
|
||||||
|
|
||||||
|
func (e ZwlrLayerSurfaceV1Anchor) Name() string {
|
||||||
|
switch e {
|
||||||
|
case ZwlrLayerSurfaceV1AnchorTop:
|
||||||
|
return "top"
|
||||||
|
case ZwlrLayerSurfaceV1AnchorBottom:
|
||||||
|
return "bottom"
|
||||||
|
case ZwlrLayerSurfaceV1AnchorLeft:
|
||||||
|
return "left"
|
||||||
|
case ZwlrLayerSurfaceV1AnchorRight:
|
||||||
|
return "right"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ZwlrLayerSurfaceV1Anchor) Value() string {
|
||||||
|
switch e {
|
||||||
|
case ZwlrLayerSurfaceV1AnchorTop:
|
||||||
|
return "1"
|
||||||
|
case ZwlrLayerSurfaceV1AnchorBottom:
|
||||||
|
return "2"
|
||||||
|
case ZwlrLayerSurfaceV1AnchorLeft:
|
||||||
|
return "4"
|
||||||
|
case ZwlrLayerSurfaceV1AnchorRight:
|
||||||
|
return "8"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ZwlrLayerSurfaceV1Anchor) String() string {
|
||||||
|
return e.Name() + "=" + e.Value()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZwlrLayerSurfaceV1ConfigureEvent : suggest a surface change
|
||||||
|
//
|
||||||
|
// The configure event asks the client to resize its surface.
|
||||||
|
//
|
||||||
|
// Clients should arrange their surface for the new states, and then send
|
||||||
|
// an ack_configure request with the serial sent in this configure event at
|
||||||
|
// some point before committing the new surface.
|
||||||
|
//
|
||||||
|
// The client is free to dismiss all but the last configure event it
|
||||||
|
// received.
|
||||||
|
//
|
||||||
|
// The width and height arguments specify the size of the window in
|
||||||
|
// surface-local coordinates.
|
||||||
|
//
|
||||||
|
// The size is a hint, in the sense that the client is free to ignore it if
|
||||||
|
// it doesn't resize, pick a smaller size (to satisfy aspect ratio or
|
||||||
|
// resize in steps of NxM pixels). If the client picks a smaller size and
|
||||||
|
// is anchored to two opposite anchors (e.g. 'top' and 'bottom'), the
|
||||||
|
// surface will be centered on this axis.
|
||||||
|
//
|
||||||
|
// If the width or height arguments are zero, it means the client should
|
||||||
|
// decide its own window dimension.
|
||||||
|
type ZwlrLayerSurfaceV1ConfigureEvent struct {
|
||||||
|
Serial uint32
|
||||||
|
Width uint32
|
||||||
|
Height uint32
|
||||||
|
}
|
||||||
|
type ZwlrLayerSurfaceV1ConfigureHandlerFunc func(ZwlrLayerSurfaceV1ConfigureEvent)
|
||||||
|
|
||||||
|
// SetConfigureHandler : sets handler for ZwlrLayerSurfaceV1ConfigureEvent
|
||||||
|
func (i *ZwlrLayerSurfaceV1) SetConfigureHandler(f ZwlrLayerSurfaceV1ConfigureHandlerFunc) {
|
||||||
|
i.configureHandler = f
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZwlrLayerSurfaceV1ClosedEvent : surface should be closed
|
||||||
|
//
|
||||||
|
// The closed event is sent by the compositor when the surface will no
|
||||||
|
// longer be shown. The output may have been destroyed or the user may
|
||||||
|
// have asked for it to be removed. Further changes to the surface will be
|
||||||
|
// ignored. The client should destroy the resource after receiving this
|
||||||
|
// event, and create a new surface if they so choose.
|
||||||
|
type ZwlrLayerSurfaceV1ClosedEvent struct{}
|
||||||
|
type ZwlrLayerSurfaceV1ClosedHandlerFunc func(ZwlrLayerSurfaceV1ClosedEvent)
|
||||||
|
|
||||||
|
// SetClosedHandler : sets handler for ZwlrLayerSurfaceV1ClosedEvent
|
||||||
|
func (i *ZwlrLayerSurfaceV1) SetClosedHandler(f ZwlrLayerSurfaceV1ClosedHandlerFunc) {
|
||||||
|
i.closedHandler = f
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *ZwlrLayerSurfaceV1) Dispatch(opcode uint32, fd int, data []byte) {
|
||||||
|
switch opcode {
|
||||||
|
case 0:
|
||||||
|
if i.configureHandler == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var e ZwlrLayerSurfaceV1ConfigureEvent
|
||||||
|
l := 0
|
||||||
|
e.Serial = client.Uint32(data[l : l+4])
|
||||||
|
l += 4
|
||||||
|
e.Width = client.Uint32(data[l : l+4])
|
||||||
|
l += 4
|
||||||
|
e.Height = client.Uint32(data[l : l+4])
|
||||||
|
l += 4
|
||||||
|
|
||||||
|
i.configureHandler(e)
|
||||||
|
case 1:
|
||||||
|
if i.closedHandler == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var e ZwlrLayerSurfaceV1ClosedEvent
|
||||||
|
|
||||||
|
i.closedHandler(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
532
core/internal/proto/wlr_screencopy/screencopy.go
Normal file
532
core/internal/proto/wlr_screencopy/screencopy.go
Normal file
@@ -0,0 +1,532 @@
|
|||||||
|
// Generated by go-wayland-scanner
|
||||||
|
// https://github.com/yaslama/go-wayland/cmd/go-wayland-scanner
|
||||||
|
// XML file : internal/proto/xml/wlr-screencopy-unstable-v1.xml
|
||||||
|
//
|
||||||
|
// wlr_screencopy_unstable_v1 Protocol Copyright:
|
||||||
|
//
|
||||||
|
// Copyright © 2018 Simon Ser
|
||||||
|
// Copyright © 2019 Andri Yngvason
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
// and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice (including the next
|
||||||
|
// paragraph) shall be included in all copies or substantial portions of the
|
||||||
|
// Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
package wlr_screencopy
|
||||||
|
|
||||||
|
import "github.com/AvengeMedia/DankMaterialShell/core/pkg/go-wayland/wayland/client"
|
||||||
|
|
||||||
|
// ZwlrScreencopyManagerV1InterfaceName is the name of the interface as it appears in the [client.Registry].
|
||||||
|
// It can be used to match the [client.RegistryGlobalEvent.Interface] in the
|
||||||
|
// [Registry.SetGlobalHandler] and can be used in [Registry.Bind] if this applies.
|
||||||
|
const ZwlrScreencopyManagerV1InterfaceName = "zwlr_screencopy_manager_v1"
|
||||||
|
|
||||||
|
// ZwlrScreencopyManagerV1 : manager to inform clients and begin capturing
|
||||||
|
//
|
||||||
|
// This object is a manager which offers requests to start capturing from a
|
||||||
|
// source.
|
||||||
|
type ZwlrScreencopyManagerV1 struct {
|
||||||
|
client.BaseProxy
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewZwlrScreencopyManagerV1 : manager to inform clients and begin capturing
|
||||||
|
//
|
||||||
|
// This object is a manager which offers requests to start capturing from a
|
||||||
|
// source.
|
||||||
|
func NewZwlrScreencopyManagerV1(ctx *client.Context) *ZwlrScreencopyManagerV1 {
|
||||||
|
zwlrScreencopyManagerV1 := &ZwlrScreencopyManagerV1{}
|
||||||
|
ctx.Register(zwlrScreencopyManagerV1)
|
||||||
|
return zwlrScreencopyManagerV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// CaptureOutput : capture an output
|
||||||
|
//
|
||||||
|
// Capture the next frame of an entire output.
|
||||||
|
//
|
||||||
|
// overlayCursor: composite cursor onto the frame
|
||||||
|
func (i *ZwlrScreencopyManagerV1) CaptureOutput(overlayCursor int32, output *client.Output) (*ZwlrScreencopyFrameV1, error) {
|
||||||
|
frame := NewZwlrScreencopyFrameV1(i.Context())
|
||||||
|
const opcode = 0
|
||||||
|
const _reqBufLen = 8 + 4 + 4 + 4
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], frame.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(overlayCursor))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], output.ID())
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return frame, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// CaptureOutputRegion : capture an output's region
|
||||||
|
//
|
||||||
|
// Capture the next frame of an output's region.
|
||||||
|
//
|
||||||
|
// The region is given in output logical coordinates, see
|
||||||
|
// xdg_output.logical_size. The region will be clipped to the output's
|
||||||
|
// extents.
|
||||||
|
//
|
||||||
|
// overlayCursor: composite cursor onto the frame
|
||||||
|
func (i *ZwlrScreencopyManagerV1) CaptureOutputRegion(overlayCursor int32, output *client.Output, x, y, width, height int32) (*ZwlrScreencopyFrameV1, error) {
|
||||||
|
frame := NewZwlrScreencopyFrameV1(i.Context())
|
||||||
|
const opcode = 1
|
||||||
|
const _reqBufLen = 8 + 4 + 4 + 4 + 4 + 4 + 4 + 4
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], frame.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(overlayCursor))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], output.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(x))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(y))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(width))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(height))
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return frame, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destroy : destroy the manager
|
||||||
|
//
|
||||||
|
// All objects created by the manager will still remain valid, until their
|
||||||
|
// appropriate destroy request has been called.
|
||||||
|
func (i *ZwlrScreencopyManagerV1) Destroy() error {
|
||||||
|
defer i.Context().Unregister(i)
|
||||||
|
const opcode = 2
|
||||||
|
const _reqBufLen = 8
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZwlrScreencopyFrameV1InterfaceName is the name of the interface as it appears in the [client.Registry].
|
||||||
|
// It can be used to match the [client.RegistryGlobalEvent.Interface] in the
|
||||||
|
// [Registry.SetGlobalHandler] and can be used in [Registry.Bind] if this applies.
|
||||||
|
const ZwlrScreencopyFrameV1InterfaceName = "zwlr_screencopy_frame_v1"
|
||||||
|
|
||||||
|
// ZwlrScreencopyFrameV1 : a frame ready for copy
|
||||||
|
//
|
||||||
|
// This object represents a single frame.
|
||||||
|
//
|
||||||
|
// When created, a series of buffer events will be sent, each representing a
|
||||||
|
// supported buffer type. The "buffer_done" event is sent afterwards to
|
||||||
|
// indicate that all supported buffer types have been enumerated. The client
|
||||||
|
// will then be able to send a "copy" request. If the capture is successful,
|
||||||
|
// the compositor will send a "flags" event followed by a "ready" event.
|
||||||
|
//
|
||||||
|
// For objects version 2 or lower, wl_shm buffers are always supported, ie.
|
||||||
|
// the "buffer" event is guaranteed to be sent.
|
||||||
|
//
|
||||||
|
// If the capture failed, the "failed" event is sent. This can happen anytime
|
||||||
|
// before the "ready" event.
|
||||||
|
//
|
||||||
|
// Once either a "ready" or a "failed" event is received, the client should
|
||||||
|
// destroy the frame.
|
||||||
|
type ZwlrScreencopyFrameV1 struct {
|
||||||
|
client.BaseProxy
|
||||||
|
bufferHandler ZwlrScreencopyFrameV1BufferHandlerFunc
|
||||||
|
flagsHandler ZwlrScreencopyFrameV1FlagsHandlerFunc
|
||||||
|
readyHandler ZwlrScreencopyFrameV1ReadyHandlerFunc
|
||||||
|
failedHandler ZwlrScreencopyFrameV1FailedHandlerFunc
|
||||||
|
damageHandler ZwlrScreencopyFrameV1DamageHandlerFunc
|
||||||
|
linuxDmabufHandler ZwlrScreencopyFrameV1LinuxDmabufHandlerFunc
|
||||||
|
bufferDoneHandler ZwlrScreencopyFrameV1BufferDoneHandlerFunc
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewZwlrScreencopyFrameV1 : a frame ready for copy
|
||||||
|
//
|
||||||
|
// This object represents a single frame.
|
||||||
|
//
|
||||||
|
// When created, a series of buffer events will be sent, each representing a
|
||||||
|
// supported buffer type. The "buffer_done" event is sent afterwards to
|
||||||
|
// indicate that all supported buffer types have been enumerated. The client
|
||||||
|
// will then be able to send a "copy" request. If the capture is successful,
|
||||||
|
// the compositor will send a "flags" event followed by a "ready" event.
|
||||||
|
//
|
||||||
|
// For objects version 2 or lower, wl_shm buffers are always supported, ie.
|
||||||
|
// the "buffer" event is guaranteed to be sent.
|
||||||
|
//
|
||||||
|
// If the capture failed, the "failed" event is sent. This can happen anytime
|
||||||
|
// before the "ready" event.
|
||||||
|
//
|
||||||
|
// Once either a "ready" or a "failed" event is received, the client should
|
||||||
|
// destroy the frame.
|
||||||
|
func NewZwlrScreencopyFrameV1(ctx *client.Context) *ZwlrScreencopyFrameV1 {
|
||||||
|
zwlrScreencopyFrameV1 := &ZwlrScreencopyFrameV1{}
|
||||||
|
ctx.Register(zwlrScreencopyFrameV1)
|
||||||
|
return zwlrScreencopyFrameV1
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy : copy the frame
|
||||||
|
//
|
||||||
|
// Copy the frame to the supplied buffer. The buffer must have the
|
||||||
|
// correct size, see zwlr_screencopy_frame_v1.buffer and
|
||||||
|
// zwlr_screencopy_frame_v1.linux_dmabuf. The buffer needs to have a
|
||||||
|
// supported format.
|
||||||
|
//
|
||||||
|
// If the frame is successfully copied, "flags" and "ready" events are
|
||||||
|
// sent. Otherwise, a "failed" event is sent.
|
||||||
|
func (i *ZwlrScreencopyFrameV1) Copy(buffer *client.Buffer) error {
|
||||||
|
const opcode = 0
|
||||||
|
const _reqBufLen = 8 + 4
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], buffer.ID())
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destroy : delete this object, used or not
|
||||||
|
//
|
||||||
|
// Destroys the frame. This request can be sent at any time by the client.
|
||||||
|
func (i *ZwlrScreencopyFrameV1) Destroy() error {
|
||||||
|
defer i.Context().Unregister(i)
|
||||||
|
const opcode = 1
|
||||||
|
const _reqBufLen = 8
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// CopyWithDamage : copy the frame when it's damaged
|
||||||
|
//
|
||||||
|
// Same as copy, except it waits until there is damage to copy.
|
||||||
|
func (i *ZwlrScreencopyFrameV1) CopyWithDamage(buffer *client.Buffer) error {
|
||||||
|
const opcode = 2
|
||||||
|
const _reqBufLen = 8 + 4
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], buffer.ID())
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
type ZwlrScreencopyFrameV1Error uint32
|
||||||
|
|
||||||
|
// ZwlrScreencopyFrameV1Error :
|
||||||
|
const (
|
||||||
|
// ZwlrScreencopyFrameV1ErrorAlreadyUsed : the object has already been used to copy a wl_buffer
|
||||||
|
ZwlrScreencopyFrameV1ErrorAlreadyUsed ZwlrScreencopyFrameV1Error = 0
|
||||||
|
// ZwlrScreencopyFrameV1ErrorInvalidBuffer : buffer attributes are invalid
|
||||||
|
ZwlrScreencopyFrameV1ErrorInvalidBuffer ZwlrScreencopyFrameV1Error = 1
|
||||||
|
)
|
||||||
|
|
||||||
|
func (e ZwlrScreencopyFrameV1Error) Name() string {
|
||||||
|
switch e {
|
||||||
|
case ZwlrScreencopyFrameV1ErrorAlreadyUsed:
|
||||||
|
return "already_used"
|
||||||
|
case ZwlrScreencopyFrameV1ErrorInvalidBuffer:
|
||||||
|
return "invalid_buffer"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ZwlrScreencopyFrameV1Error) Value() string {
|
||||||
|
switch e {
|
||||||
|
case ZwlrScreencopyFrameV1ErrorAlreadyUsed:
|
||||||
|
return "0"
|
||||||
|
case ZwlrScreencopyFrameV1ErrorInvalidBuffer:
|
||||||
|
return "1"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ZwlrScreencopyFrameV1Error) String() string {
|
||||||
|
return e.Name() + "=" + e.Value()
|
||||||
|
}
|
||||||
|
|
||||||
|
type ZwlrScreencopyFrameV1Flags uint32
|
||||||
|
|
||||||
|
// ZwlrScreencopyFrameV1Flags :
|
||||||
|
const (
|
||||||
|
// ZwlrScreencopyFrameV1FlagsYInvert : contents are y-inverted
|
||||||
|
ZwlrScreencopyFrameV1FlagsYInvert ZwlrScreencopyFrameV1Flags = 1
|
||||||
|
)
|
||||||
|
|
||||||
|
func (e ZwlrScreencopyFrameV1Flags) Name() string {
|
||||||
|
switch e {
|
||||||
|
case ZwlrScreencopyFrameV1FlagsYInvert:
|
||||||
|
return "y_invert"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ZwlrScreencopyFrameV1Flags) Value() string {
|
||||||
|
switch e {
|
||||||
|
case ZwlrScreencopyFrameV1FlagsYInvert:
|
||||||
|
return "1"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e ZwlrScreencopyFrameV1Flags) String() string {
|
||||||
|
return e.Name() + "=" + e.Value()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZwlrScreencopyFrameV1BufferEvent : wl_shm buffer information
|
||||||
|
//
|
||||||
|
// Provides information about wl_shm buffer parameters that need to be
|
||||||
|
// used for this frame. This event is sent once after the frame is created
|
||||||
|
// if wl_shm buffers are supported.
|
||||||
|
type ZwlrScreencopyFrameV1BufferEvent struct {
|
||||||
|
Format uint32
|
||||||
|
Width uint32
|
||||||
|
Height uint32
|
||||||
|
Stride uint32
|
||||||
|
}
|
||||||
|
type ZwlrScreencopyFrameV1BufferHandlerFunc func(ZwlrScreencopyFrameV1BufferEvent)
|
||||||
|
|
||||||
|
// SetBufferHandler : sets handler for ZwlrScreencopyFrameV1BufferEvent
|
||||||
|
func (i *ZwlrScreencopyFrameV1) SetBufferHandler(f ZwlrScreencopyFrameV1BufferHandlerFunc) {
|
||||||
|
i.bufferHandler = f
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZwlrScreencopyFrameV1FlagsEvent : frame flags
|
||||||
|
//
|
||||||
|
// Provides flags about the frame. This event is sent once before the
|
||||||
|
// "ready" event.
|
||||||
|
type ZwlrScreencopyFrameV1FlagsEvent struct {
|
||||||
|
Flags uint32
|
||||||
|
}
|
||||||
|
type ZwlrScreencopyFrameV1FlagsHandlerFunc func(ZwlrScreencopyFrameV1FlagsEvent)
|
||||||
|
|
||||||
|
// SetFlagsHandler : sets handler for ZwlrScreencopyFrameV1FlagsEvent
|
||||||
|
func (i *ZwlrScreencopyFrameV1) SetFlagsHandler(f ZwlrScreencopyFrameV1FlagsHandlerFunc) {
|
||||||
|
i.flagsHandler = f
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZwlrScreencopyFrameV1ReadyEvent : indicates frame is available for reading
|
||||||
|
//
|
||||||
|
// Called as soon as the frame is copied, indicating it is available
|
||||||
|
// for reading. This event includes the time at which the presentation took place.
|
||||||
|
//
|
||||||
|
// The timestamp is expressed as tv_sec_hi, tv_sec_lo, tv_nsec triples,
|
||||||
|
// each component being an unsigned 32-bit value. Whole seconds are in
|
||||||
|
// tv_sec which is a 64-bit value combined from tv_sec_hi and tv_sec_lo,
|
||||||
|
// and the additional fractional part in tv_nsec as nanoseconds. Hence,
|
||||||
|
// for valid timestamps tv_nsec must be in [0, 999999999]. The seconds part
|
||||||
|
// may have an arbitrary offset at start.
|
||||||
|
//
|
||||||
|
// After receiving this event, the client should destroy the object.
|
||||||
|
type ZwlrScreencopyFrameV1ReadyEvent struct {
|
||||||
|
TvSecHi uint32
|
||||||
|
TvSecLo uint32
|
||||||
|
TvNsec uint32
|
||||||
|
}
|
||||||
|
type ZwlrScreencopyFrameV1ReadyHandlerFunc func(ZwlrScreencopyFrameV1ReadyEvent)
|
||||||
|
|
||||||
|
// SetReadyHandler : sets handler for ZwlrScreencopyFrameV1ReadyEvent
|
||||||
|
func (i *ZwlrScreencopyFrameV1) SetReadyHandler(f ZwlrScreencopyFrameV1ReadyHandlerFunc) {
|
||||||
|
i.readyHandler = f
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZwlrScreencopyFrameV1FailedEvent : frame copy failed
|
||||||
|
//
|
||||||
|
// This event indicates that the attempted frame copy has failed.
|
||||||
|
//
|
||||||
|
// After receiving this event, the client should destroy the object.
|
||||||
|
type ZwlrScreencopyFrameV1FailedEvent struct{}
|
||||||
|
type ZwlrScreencopyFrameV1FailedHandlerFunc func(ZwlrScreencopyFrameV1FailedEvent)
|
||||||
|
|
||||||
|
// SetFailedHandler : sets handler for ZwlrScreencopyFrameV1FailedEvent
|
||||||
|
func (i *ZwlrScreencopyFrameV1) SetFailedHandler(f ZwlrScreencopyFrameV1FailedHandlerFunc) {
|
||||||
|
i.failedHandler = f
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZwlrScreencopyFrameV1DamageEvent : carries the coordinates of the damaged region
|
||||||
|
//
|
||||||
|
// This event is sent right before the ready event when copy_with_damage is
|
||||||
|
// requested. It may be generated multiple times for each copy_with_damage
|
||||||
|
// request.
|
||||||
|
//
|
||||||
|
// The arguments describe a box around an area that has changed since the
|
||||||
|
// last copy request that was derived from the current screencopy manager
|
||||||
|
// instance.
|
||||||
|
//
|
||||||
|
// The union of all regions received between the call to copy_with_damage
|
||||||
|
// and a ready event is the total damage since the prior ready event.
|
||||||
|
type ZwlrScreencopyFrameV1DamageEvent struct {
|
||||||
|
X uint32
|
||||||
|
Y uint32
|
||||||
|
Width uint32
|
||||||
|
Height uint32
|
||||||
|
}
|
||||||
|
type ZwlrScreencopyFrameV1DamageHandlerFunc func(ZwlrScreencopyFrameV1DamageEvent)
|
||||||
|
|
||||||
|
// SetDamageHandler : sets handler for ZwlrScreencopyFrameV1DamageEvent
|
||||||
|
func (i *ZwlrScreencopyFrameV1) SetDamageHandler(f ZwlrScreencopyFrameV1DamageHandlerFunc) {
|
||||||
|
i.damageHandler = f
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZwlrScreencopyFrameV1LinuxDmabufEvent : linux-dmabuf buffer information
|
||||||
|
//
|
||||||
|
// Provides information about linux-dmabuf buffer parameters that need to
|
||||||
|
// be used for this frame. This event is sent once after the frame is
|
||||||
|
// created if linux-dmabuf buffers are supported.
|
||||||
|
type ZwlrScreencopyFrameV1LinuxDmabufEvent struct {
|
||||||
|
Format uint32
|
||||||
|
Width uint32
|
||||||
|
Height uint32
|
||||||
|
}
|
||||||
|
type ZwlrScreencopyFrameV1LinuxDmabufHandlerFunc func(ZwlrScreencopyFrameV1LinuxDmabufEvent)
|
||||||
|
|
||||||
|
// SetLinuxDmabufHandler : sets handler for ZwlrScreencopyFrameV1LinuxDmabufEvent
|
||||||
|
func (i *ZwlrScreencopyFrameV1) SetLinuxDmabufHandler(f ZwlrScreencopyFrameV1LinuxDmabufHandlerFunc) {
|
||||||
|
i.linuxDmabufHandler = f
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZwlrScreencopyFrameV1BufferDoneEvent : all buffer types reported
|
||||||
|
//
|
||||||
|
// This event is sent once after all buffer events have been sent.
|
||||||
|
//
|
||||||
|
// The client should proceed to create a buffer of one of the supported
|
||||||
|
// types, and send a "copy" request.
|
||||||
|
type ZwlrScreencopyFrameV1BufferDoneEvent struct{}
|
||||||
|
type ZwlrScreencopyFrameV1BufferDoneHandlerFunc func(ZwlrScreencopyFrameV1BufferDoneEvent)
|
||||||
|
|
||||||
|
// SetBufferDoneHandler : sets handler for ZwlrScreencopyFrameV1BufferDoneEvent
|
||||||
|
func (i *ZwlrScreencopyFrameV1) SetBufferDoneHandler(f ZwlrScreencopyFrameV1BufferDoneHandlerFunc) {
|
||||||
|
i.bufferDoneHandler = f
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *ZwlrScreencopyFrameV1) Dispatch(opcode uint32, fd int, data []byte) {
|
||||||
|
switch opcode {
|
||||||
|
case 0:
|
||||||
|
if i.bufferHandler == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var e ZwlrScreencopyFrameV1BufferEvent
|
||||||
|
l := 0
|
||||||
|
e.Format = client.Uint32(data[l : l+4])
|
||||||
|
l += 4
|
||||||
|
e.Width = client.Uint32(data[l : l+4])
|
||||||
|
l += 4
|
||||||
|
e.Height = client.Uint32(data[l : l+4])
|
||||||
|
l += 4
|
||||||
|
e.Stride = client.Uint32(data[l : l+4])
|
||||||
|
l += 4
|
||||||
|
|
||||||
|
i.bufferHandler(e)
|
||||||
|
case 1:
|
||||||
|
if i.flagsHandler == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var e ZwlrScreencopyFrameV1FlagsEvent
|
||||||
|
l := 0
|
||||||
|
e.Flags = client.Uint32(data[l : l+4])
|
||||||
|
l += 4
|
||||||
|
|
||||||
|
i.flagsHandler(e)
|
||||||
|
case 2:
|
||||||
|
if i.readyHandler == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var e ZwlrScreencopyFrameV1ReadyEvent
|
||||||
|
l := 0
|
||||||
|
e.TvSecHi = client.Uint32(data[l : l+4])
|
||||||
|
l += 4
|
||||||
|
e.TvSecLo = client.Uint32(data[l : l+4])
|
||||||
|
l += 4
|
||||||
|
e.TvNsec = client.Uint32(data[l : l+4])
|
||||||
|
l += 4
|
||||||
|
|
||||||
|
i.readyHandler(e)
|
||||||
|
case 3:
|
||||||
|
if i.failedHandler == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var e ZwlrScreencopyFrameV1FailedEvent
|
||||||
|
|
||||||
|
i.failedHandler(e)
|
||||||
|
case 4:
|
||||||
|
if i.damageHandler == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var e ZwlrScreencopyFrameV1DamageEvent
|
||||||
|
l := 0
|
||||||
|
e.X = client.Uint32(data[l : l+4])
|
||||||
|
l += 4
|
||||||
|
e.Y = client.Uint32(data[l : l+4])
|
||||||
|
l += 4
|
||||||
|
e.Width = client.Uint32(data[l : l+4])
|
||||||
|
l += 4
|
||||||
|
e.Height = client.Uint32(data[l : l+4])
|
||||||
|
l += 4
|
||||||
|
|
||||||
|
i.damageHandler(e)
|
||||||
|
case 5:
|
||||||
|
if i.linuxDmabufHandler == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var e ZwlrScreencopyFrameV1LinuxDmabufEvent
|
||||||
|
l := 0
|
||||||
|
e.Format = client.Uint32(data[l : l+4])
|
||||||
|
l += 4
|
||||||
|
e.Width = client.Uint32(data[l : l+4])
|
||||||
|
l += 4
|
||||||
|
e.Height = client.Uint32(data[l : l+4])
|
||||||
|
l += 4
|
||||||
|
|
||||||
|
i.linuxDmabufHandler(e)
|
||||||
|
case 6:
|
||||||
|
if i.bufferDoneHandler == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
var e ZwlrScreencopyFrameV1BufferDoneEvent
|
||||||
|
|
||||||
|
i.bufferDoneHandler(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
399
core/internal/proto/wp_viewporter/viewporter.go
Normal file
399
core/internal/proto/wp_viewporter/viewporter.go
Normal file
@@ -0,0 +1,399 @@
|
|||||||
|
// Generated by go-wayland-scanner
|
||||||
|
// https://github.com/yaslama/go-wayland/cmd/go-wayland-scanner
|
||||||
|
// XML file : /tmp/viewporter.xml
|
||||||
|
//
|
||||||
|
// viewporter Protocol Copyright:
|
||||||
|
//
|
||||||
|
// Copyright © 2013-2016 Collabora, Ltd.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
// and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice (including the next
|
||||||
|
// paragraph) shall be included in all copies or substantial portions of the
|
||||||
|
// Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
package wp_viewporter
|
||||||
|
|
||||||
|
import "github.com/AvengeMedia/DankMaterialShell/core/pkg/go-wayland/wayland/client"
|
||||||
|
|
||||||
|
// WpViewporterInterfaceName is the name of the interface as it appears in the [client.Registry].
|
||||||
|
// It can be used to match the [client.RegistryGlobalEvent.Interface] in the
|
||||||
|
// [Registry.SetGlobalHandler] and can be used in [Registry.Bind] if this applies.
|
||||||
|
const WpViewporterInterfaceName = "wp_viewporter"
|
||||||
|
|
||||||
|
// WpViewporter : surface cropping and scaling
|
||||||
|
//
|
||||||
|
// The global interface exposing surface cropping and scaling
|
||||||
|
// capabilities is used to instantiate an interface extension for a
|
||||||
|
// wl_surface object. This extended interface will then allow
|
||||||
|
// cropping and scaling the surface contents, effectively
|
||||||
|
// disconnecting the direct relationship between the buffer and the
|
||||||
|
// surface size.
|
||||||
|
type WpViewporter struct {
|
||||||
|
client.BaseProxy
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewWpViewporter : surface cropping and scaling
|
||||||
|
//
|
||||||
|
// The global interface exposing surface cropping and scaling
|
||||||
|
// capabilities is used to instantiate an interface extension for a
|
||||||
|
// wl_surface object. This extended interface will then allow
|
||||||
|
// cropping and scaling the surface contents, effectively
|
||||||
|
// disconnecting the direct relationship between the buffer and the
|
||||||
|
// surface size.
|
||||||
|
func NewWpViewporter(ctx *client.Context) *WpViewporter {
|
||||||
|
wpViewporter := &WpViewporter{}
|
||||||
|
ctx.Register(wpViewporter)
|
||||||
|
return wpViewporter
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destroy : unbind from the cropping and scaling interface
|
||||||
|
//
|
||||||
|
// Informs the server that the client will not be using this
|
||||||
|
// protocol object anymore. This does not affect any other objects,
|
||||||
|
// wp_viewport objects included.
|
||||||
|
func (i *WpViewporter) Destroy() error {
|
||||||
|
defer i.Context().Unregister(i)
|
||||||
|
const opcode = 0
|
||||||
|
const _reqBufLen = 8
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetViewport : extend surface interface for crop and scale
|
||||||
|
//
|
||||||
|
// Instantiate an interface extension for the given wl_surface to
|
||||||
|
// crop and scale its content. If the given wl_surface already has
|
||||||
|
// a wp_viewport object associated, the viewport_exists
|
||||||
|
// protocol error is raised.
|
||||||
|
//
|
||||||
|
// surface: the surface
|
||||||
|
func (i *WpViewporter) GetViewport(surface *client.Surface) (*WpViewport, error) {
|
||||||
|
id := NewWpViewport(i.Context())
|
||||||
|
const opcode = 1
|
||||||
|
const _reqBufLen = 8 + 4 + 4
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], id.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], surface.ID())
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return id, err
|
||||||
|
}
|
||||||
|
|
||||||
|
type WpViewporterError uint32
|
||||||
|
|
||||||
|
// WpViewporterError :
|
||||||
|
const (
|
||||||
|
// WpViewporterErrorViewportExists : the surface already has a viewport object associated
|
||||||
|
WpViewporterErrorViewportExists WpViewporterError = 0
|
||||||
|
)
|
||||||
|
|
||||||
|
func (e WpViewporterError) Name() string {
|
||||||
|
switch e {
|
||||||
|
case WpViewporterErrorViewportExists:
|
||||||
|
return "viewport_exists"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e WpViewporterError) Value() string {
|
||||||
|
switch e {
|
||||||
|
case WpViewporterErrorViewportExists:
|
||||||
|
return "0"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e WpViewporterError) String() string {
|
||||||
|
return e.Name() + "=" + e.Value()
|
||||||
|
}
|
||||||
|
|
||||||
|
// WpViewportInterfaceName is the name of the interface as it appears in the [client.Registry].
|
||||||
|
// It can be used to match the [client.RegistryGlobalEvent.Interface] in the
|
||||||
|
// [Registry.SetGlobalHandler] and can be used in [Registry.Bind] if this applies.
|
||||||
|
const WpViewportInterfaceName = "wp_viewport"
|
||||||
|
|
||||||
|
// WpViewport : crop and scale interface to a wl_surface
|
||||||
|
//
|
||||||
|
// An additional interface to a wl_surface object, which allows the
|
||||||
|
// client to specify the cropping and scaling of the surface
|
||||||
|
// contents.
|
||||||
|
//
|
||||||
|
// This interface works with two concepts: the source rectangle (src_x,
|
||||||
|
// src_y, src_width, src_height), and the destination size (dst_width,
|
||||||
|
// dst_height). The contents of the source rectangle are scaled to the
|
||||||
|
// destination size, and content outside the source rectangle is ignored.
|
||||||
|
// This state is double-buffered, see wl_surface.commit.
|
||||||
|
//
|
||||||
|
// The two parts of crop and scale state are independent: the source
|
||||||
|
// rectangle, and the destination size. Initially both are unset, that
|
||||||
|
// is, no scaling is applied. The whole of the current wl_buffer is
|
||||||
|
// used as the source, and the surface size is as defined in
|
||||||
|
// wl_surface.attach.
|
||||||
|
//
|
||||||
|
// If the destination size is set, it causes the surface size to become
|
||||||
|
// dst_width, dst_height. The source (rectangle) is scaled to exactly
|
||||||
|
// this size. This overrides whatever the attached wl_buffer size is,
|
||||||
|
// unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
|
||||||
|
// has no content and therefore no size. Otherwise, the size is always
|
||||||
|
// at least 1x1 in surface local coordinates.
|
||||||
|
//
|
||||||
|
// If the source rectangle is set, it defines what area of the wl_buffer is
|
||||||
|
// taken as the source. If the source rectangle is set and the destination
|
||||||
|
// size is not set, then src_width and src_height must be integers, and the
|
||||||
|
// surface size becomes the source rectangle size. This results in cropping
|
||||||
|
// without scaling. If src_width or src_height are not integers and
|
||||||
|
// destination size is not set, the bad_size protocol error is raised when
|
||||||
|
// the surface state is applied.
|
||||||
|
//
|
||||||
|
// The coordinate transformations from buffer pixel coordinates up to
|
||||||
|
// the surface-local coordinates happen in the following order:
|
||||||
|
// 1. buffer_transform (wl_surface.set_buffer_transform)
|
||||||
|
// 2. buffer_scale (wl_surface.set_buffer_scale)
|
||||||
|
// 3. crop and scale (wp_viewport.set*)
|
||||||
|
// This means, that the source rectangle coordinates of crop and scale
|
||||||
|
// are given in the coordinates after the buffer transform and scale,
|
||||||
|
// i.e. in the coordinates that would be the surface-local coordinates
|
||||||
|
// if the crop and scale was not applied.
|
||||||
|
//
|
||||||
|
// If src_x or src_y are negative, the bad_value protocol error is raised.
|
||||||
|
// Otherwise, if the source rectangle is partially or completely outside of
|
||||||
|
// the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
|
||||||
|
// when the surface state is applied. A NULL wl_buffer does not raise the
|
||||||
|
// out_of_buffer error.
|
||||||
|
//
|
||||||
|
// If the wl_surface associated with the wp_viewport is destroyed,
|
||||||
|
// all wp_viewport requests except 'destroy' raise the protocol error
|
||||||
|
// no_surface.
|
||||||
|
//
|
||||||
|
// If the wp_viewport object is destroyed, the crop and scale
|
||||||
|
// state is removed from the wl_surface. The change will be applied
|
||||||
|
// on the next wl_surface.commit.
|
||||||
|
type WpViewport struct {
|
||||||
|
client.BaseProxy
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewWpViewport : crop and scale interface to a wl_surface
|
||||||
|
//
|
||||||
|
// An additional interface to a wl_surface object, which allows the
|
||||||
|
// client to specify the cropping and scaling of the surface
|
||||||
|
// contents.
|
||||||
|
//
|
||||||
|
// This interface works with two concepts: the source rectangle (src_x,
|
||||||
|
// src_y, src_width, src_height), and the destination size (dst_width,
|
||||||
|
// dst_height). The contents of the source rectangle are scaled to the
|
||||||
|
// destination size, and content outside the source rectangle is ignored.
|
||||||
|
// This state is double-buffered, see wl_surface.commit.
|
||||||
|
//
|
||||||
|
// The two parts of crop and scale state are independent: the source
|
||||||
|
// rectangle, and the destination size. Initially both are unset, that
|
||||||
|
// is, no scaling is applied. The whole of the current wl_buffer is
|
||||||
|
// used as the source, and the surface size is as defined in
|
||||||
|
// wl_surface.attach.
|
||||||
|
//
|
||||||
|
// If the destination size is set, it causes the surface size to become
|
||||||
|
// dst_width, dst_height. The source (rectangle) is scaled to exactly
|
||||||
|
// this size. This overrides whatever the attached wl_buffer size is,
|
||||||
|
// unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface
|
||||||
|
// has no content and therefore no size. Otherwise, the size is always
|
||||||
|
// at least 1x1 in surface local coordinates.
|
||||||
|
//
|
||||||
|
// If the source rectangle is set, it defines what area of the wl_buffer is
|
||||||
|
// taken as the source. If the source rectangle is set and the destination
|
||||||
|
// size is not set, then src_width and src_height must be integers, and the
|
||||||
|
// surface size becomes the source rectangle size. This results in cropping
|
||||||
|
// without scaling. If src_width or src_height are not integers and
|
||||||
|
// destination size is not set, the bad_size protocol error is raised when
|
||||||
|
// the surface state is applied.
|
||||||
|
//
|
||||||
|
// The coordinate transformations from buffer pixel coordinates up to
|
||||||
|
// the surface-local coordinates happen in the following order:
|
||||||
|
// 1. buffer_transform (wl_surface.set_buffer_transform)
|
||||||
|
// 2. buffer_scale (wl_surface.set_buffer_scale)
|
||||||
|
// 3. crop and scale (wp_viewport.set*)
|
||||||
|
// This means, that the source rectangle coordinates of crop and scale
|
||||||
|
// are given in the coordinates after the buffer transform and scale,
|
||||||
|
// i.e. in the coordinates that would be the surface-local coordinates
|
||||||
|
// if the crop and scale was not applied.
|
||||||
|
//
|
||||||
|
// If src_x or src_y are negative, the bad_value protocol error is raised.
|
||||||
|
// Otherwise, if the source rectangle is partially or completely outside of
|
||||||
|
// the non-NULL wl_buffer, then the out_of_buffer protocol error is raised
|
||||||
|
// when the surface state is applied. A NULL wl_buffer does not raise the
|
||||||
|
// out_of_buffer error.
|
||||||
|
//
|
||||||
|
// If the wl_surface associated with the wp_viewport is destroyed,
|
||||||
|
// all wp_viewport requests except 'destroy' raise the protocol error
|
||||||
|
// no_surface.
|
||||||
|
//
|
||||||
|
// If the wp_viewport object is destroyed, the crop and scale
|
||||||
|
// state is removed from the wl_surface. The change will be applied
|
||||||
|
// on the next wl_surface.commit.
|
||||||
|
func NewWpViewport(ctx *client.Context) *WpViewport {
|
||||||
|
wpViewport := &WpViewport{}
|
||||||
|
ctx.Register(wpViewport)
|
||||||
|
return wpViewport
|
||||||
|
}
|
||||||
|
|
||||||
|
// Destroy : remove scaling and cropping from the surface
|
||||||
|
//
|
||||||
|
// The associated wl_surface's crop and scale state is removed.
|
||||||
|
// The change is applied on the next wl_surface.commit.
|
||||||
|
func (i *WpViewport) Destroy() error {
|
||||||
|
defer i.Context().Unregister(i)
|
||||||
|
const opcode = 0
|
||||||
|
const _reqBufLen = 8
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetSource : set the source rectangle for cropping
|
||||||
|
//
|
||||||
|
// Set the source rectangle of the associated wl_surface. See
|
||||||
|
// wp_viewport for the description, and relation to the wl_buffer
|
||||||
|
// size.
|
||||||
|
//
|
||||||
|
// If all of x, y, width and height are -1.0, the source rectangle is
|
||||||
|
// unset instead. Any other set of values where width or height are zero
|
||||||
|
// or negative, or x or y are negative, raise the bad_value protocol
|
||||||
|
// error.
|
||||||
|
//
|
||||||
|
// The crop and scale state is double-buffered, see wl_surface.commit.
|
||||||
|
//
|
||||||
|
// x: source rectangle x
|
||||||
|
// y: source rectangle y
|
||||||
|
// width: source rectangle width
|
||||||
|
// height: source rectangle height
|
||||||
|
func (i *WpViewport) SetSource(x, y, width, height float64) error {
|
||||||
|
const opcode = 1
|
||||||
|
const _reqBufLen = 8 + 4 + 4 + 4 + 4
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
client.PutFixed(_reqBuf[l:l+4], x)
|
||||||
|
l += 4
|
||||||
|
client.PutFixed(_reqBuf[l:l+4], y)
|
||||||
|
l += 4
|
||||||
|
client.PutFixed(_reqBuf[l:l+4], width)
|
||||||
|
l += 4
|
||||||
|
client.PutFixed(_reqBuf[l:l+4], height)
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetDestination : set the surface size for scaling
|
||||||
|
//
|
||||||
|
// Set the destination size of the associated wl_surface. See
|
||||||
|
// wp_viewport for the description, and relation to the wl_buffer
|
||||||
|
// size.
|
||||||
|
//
|
||||||
|
// If width is -1 and height is -1, the destination size is unset
|
||||||
|
// instead. Any other pair of values for width and height that
|
||||||
|
// contains zero or negative values raises the bad_value protocol
|
||||||
|
// error.
|
||||||
|
//
|
||||||
|
// The crop and scale state is double-buffered, see wl_surface.commit.
|
||||||
|
//
|
||||||
|
// width: surface width
|
||||||
|
// height: surface height
|
||||||
|
func (i *WpViewport) SetDestination(width, height int32) error {
|
||||||
|
const opcode = 2
|
||||||
|
const _reqBufLen = 8 + 4 + 4
|
||||||
|
var _reqBuf [_reqBufLen]byte
|
||||||
|
l := 0
|
||||||
|
client.PutUint32(_reqBuf[l:4], i.ID())
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(_reqBufLen<<16|opcode&0x0000ffff))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(width))
|
||||||
|
l += 4
|
||||||
|
client.PutUint32(_reqBuf[l:l+4], uint32(height))
|
||||||
|
l += 4
|
||||||
|
err := i.Context().WriteMsg(_reqBuf[:], nil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
type WpViewportError uint32
|
||||||
|
|
||||||
|
// WpViewportError :
|
||||||
|
const (
|
||||||
|
// WpViewportErrorBadValue : negative or zero values in width or height
|
||||||
|
WpViewportErrorBadValue WpViewportError = 0
|
||||||
|
// WpViewportErrorBadSize : destination size is not integer
|
||||||
|
WpViewportErrorBadSize WpViewportError = 1
|
||||||
|
// WpViewportErrorOutOfBuffer : source rectangle extends outside of the content area
|
||||||
|
WpViewportErrorOutOfBuffer WpViewportError = 2
|
||||||
|
// WpViewportErrorNoSurface : the wl_surface was destroyed
|
||||||
|
WpViewportErrorNoSurface WpViewportError = 3
|
||||||
|
)
|
||||||
|
|
||||||
|
func (e WpViewportError) Name() string {
|
||||||
|
switch e {
|
||||||
|
case WpViewportErrorBadValue:
|
||||||
|
return "bad_value"
|
||||||
|
case WpViewportErrorBadSize:
|
||||||
|
return "bad_size"
|
||||||
|
case WpViewportErrorOutOfBuffer:
|
||||||
|
return "out_of_buffer"
|
||||||
|
case WpViewportErrorNoSurface:
|
||||||
|
return "no_surface"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e WpViewportError) Value() string {
|
||||||
|
switch e {
|
||||||
|
case WpViewportErrorBadValue:
|
||||||
|
return "0"
|
||||||
|
case WpViewportErrorBadSize:
|
||||||
|
return "1"
|
||||||
|
case WpViewportErrorOutOfBuffer:
|
||||||
|
return "2"
|
||||||
|
case WpViewportErrorNoSurface:
|
||||||
|
return "3"
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e WpViewportError) String() string {
|
||||||
|
return e.Name() + "=" + e.Value()
|
||||||
|
}
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<protocol name="keyboard_shortcuts_inhibit_unstable_v1">
|
||||||
|
|
||||||
|
<copyright>
|
||||||
|
Copyright © 2017 Red Hat Inc.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
to deal in the Software without restriction, including without limitation
|
||||||
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice (including the next
|
||||||
|
paragraph) shall be included in all copies or substantial portions of the
|
||||||
|
Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE.
|
||||||
|
</copyright>
|
||||||
|
|
||||||
|
<description summary="Protocol for inhibiting the compositor keyboard shortcuts">
|
||||||
|
This protocol specifies a way for a client to request the compositor
|
||||||
|
to ignore its own keyboard shortcuts for a given seat, so that all
|
||||||
|
key events from that seat get forwarded to a surface.
|
||||||
|
|
||||||
|
Warning! The protocol described in this file is experimental and
|
||||||
|
backward incompatible changes may be made. Backward compatible
|
||||||
|
changes may be added together with the corresponding interface
|
||||||
|
version bump.
|
||||||
|
Backward incompatible changes are done by bumping the version
|
||||||
|
number in the protocol and interface names and resetting the
|
||||||
|
interface version. Once the protocol is to be declared stable,
|
||||||
|
the 'z' prefix and the version number in the protocol and
|
||||||
|
interface names are removed and the interface version number is
|
||||||
|
reset.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<interface name="zwp_keyboard_shortcuts_inhibit_manager_v1" version="1">
|
||||||
|
<description summary="context object for keyboard grab_manager">
|
||||||
|
A global interface used for inhibiting the compositor keyboard shortcuts.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<request name="destroy" type="destructor">
|
||||||
|
<description summary="destroy the keyboard shortcuts inhibitor object">
|
||||||
|
Destroy the keyboard shortcuts inhibitor manager.
|
||||||
|
</description>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<request name="inhibit_shortcuts">
|
||||||
|
<description summary="create a new keyboard shortcuts inhibitor object">
|
||||||
|
Create a new keyboard shortcuts inhibitor object associated with
|
||||||
|
the given surface for the given seat.
|
||||||
|
|
||||||
|
If shortcuts are already inhibited for the specified seat and surface,
|
||||||
|
a protocol error "already_inhibited" is raised by the compositor.
|
||||||
|
</description>
|
||||||
|
<arg name="id" type="new_id" interface="zwp_keyboard_shortcuts_inhibitor_v1"/>
|
||||||
|
<arg name="surface" type="object" interface="wl_surface"
|
||||||
|
summary="the surface that inhibits the keyboard shortcuts behavior"/>
|
||||||
|
<arg name="seat" type="object" interface="wl_seat"
|
||||||
|
summary="the wl_seat for which keyboard shortcuts should be disabled"/>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<enum name="error">
|
||||||
|
<entry name="already_inhibited"
|
||||||
|
value="0"
|
||||||
|
summary="the shortcuts are already inhibited for this surface"/>
|
||||||
|
</enum>
|
||||||
|
</interface>
|
||||||
|
|
||||||
|
<interface name="zwp_keyboard_shortcuts_inhibitor_v1" version="1">
|
||||||
|
<description summary="context object for keyboard shortcuts inhibitor">
|
||||||
|
A keyboard shortcuts inhibitor instructs the compositor to ignore
|
||||||
|
its own keyboard shortcuts when the associated surface has keyboard
|
||||||
|
focus. As a result, when the surface has keyboard focus on the given
|
||||||
|
seat, it will receive all key events originating from the specified
|
||||||
|
seat, even those which would normally be caught by the compositor for
|
||||||
|
its own shortcuts.
|
||||||
|
|
||||||
|
The Wayland compositor is however under no obligation to disable
|
||||||
|
all of its shortcuts, and may keep some special key combo for its own
|
||||||
|
use, including but not limited to one allowing the user to forcibly
|
||||||
|
restore normal keyboard events routing in the case of an unwilling
|
||||||
|
client. The compositor may also use the same key combo to reactivate
|
||||||
|
an existing shortcut inhibitor that was previously deactivated on
|
||||||
|
user request.
|
||||||
|
|
||||||
|
When the compositor restores its own keyboard shortcuts, an
|
||||||
|
"inactive" event is emitted to notify the client that the keyboard
|
||||||
|
shortcuts inhibitor is not effectively active for the surface and
|
||||||
|
seat any more, and the client should not expect to receive all
|
||||||
|
keyboard events.
|
||||||
|
|
||||||
|
When the keyboard shortcuts inhibitor is inactive, the client has
|
||||||
|
no way to forcibly reactivate the keyboard shortcuts inhibitor.
|
||||||
|
|
||||||
|
The user can chose to re-enable a previously deactivated keyboard
|
||||||
|
shortcuts inhibitor using any mechanism the compositor may offer,
|
||||||
|
in which case the compositor will send an "active" event to notify
|
||||||
|
the client.
|
||||||
|
|
||||||
|
If the surface is destroyed, unmapped, or loses the seat's keyboard
|
||||||
|
focus, the keyboard shortcuts inhibitor becomes irrelevant and the
|
||||||
|
compositor will restore its own keyboard shortcuts but no "inactive"
|
||||||
|
event is emitted in this case.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<request name="destroy" type="destructor">
|
||||||
|
<description summary="destroy the keyboard shortcuts inhibitor object">
|
||||||
|
Remove the keyboard shortcuts inhibitor from the associated wl_surface.
|
||||||
|
</description>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<event name="active">
|
||||||
|
<description summary="shortcuts are inhibited">
|
||||||
|
This event indicates that the shortcut inhibitor is active.
|
||||||
|
|
||||||
|
The compositor sends this event every time compositor shortcuts
|
||||||
|
are inhibited on behalf of the surface. When active, the client
|
||||||
|
may receive input events normally reserved by the compositor
|
||||||
|
(see zwp_keyboard_shortcuts_inhibitor_v1).
|
||||||
|
|
||||||
|
This occurs typically when the initial request "inhibit_shortcuts"
|
||||||
|
first becomes active or when the user instructs the compositor to
|
||||||
|
re-enable and existing shortcuts inhibitor using any mechanism
|
||||||
|
offered by the compositor.
|
||||||
|
</description>
|
||||||
|
</event>
|
||||||
|
|
||||||
|
<event name="inactive">
|
||||||
|
<description summary="shortcuts are restored">
|
||||||
|
This event indicates that the shortcuts inhibitor is inactive,
|
||||||
|
normal shortcuts processing is restored by the compositor.
|
||||||
|
</description>
|
||||||
|
</event>
|
||||||
|
</interface>
|
||||||
|
</protocol>
|
||||||
407
core/internal/proto/xml/wlr-layer-shell-unstable-v1.xml
Normal file
407
core/internal/proto/xml/wlr-layer-shell-unstable-v1.xml
Normal file
@@ -0,0 +1,407 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<protocol name="wlr_layer_shell_unstable_v1">
|
||||||
|
<copyright>
|
||||||
|
Copyright © 2017 Drew DeVault
|
||||||
|
|
||||||
|
Permission to use, copy, modify, distribute, and sell this
|
||||||
|
software and its documentation for any purpose is hereby granted
|
||||||
|
without fee, provided that the above copyright notice appear in
|
||||||
|
all copies and that both that copyright notice and this permission
|
||||||
|
notice appear in supporting documentation, and that the name of
|
||||||
|
the copyright holders not be used in advertising or publicity
|
||||||
|
pertaining to distribution of the software without specific,
|
||||||
|
written prior permission. The copyright holders make no
|
||||||
|
representations about the suitability of this software for any
|
||||||
|
purpose. It is provided "as is" without express or implied
|
||||||
|
warranty.
|
||||||
|
|
||||||
|
THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
||||||
|
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||||
|
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||||
|
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||||
|
THIS SOFTWARE.
|
||||||
|
</copyright>
|
||||||
|
|
||||||
|
<interface name="zwlr_layer_shell_v1" version="5">
|
||||||
|
<description summary="create surfaces that are layers of the desktop">
|
||||||
|
Clients can use this interface to assign the surface_layer role to
|
||||||
|
wl_surfaces. Such surfaces are assigned to a "layer" of the output and
|
||||||
|
rendered with a defined z-depth respective to each other. They may also be
|
||||||
|
anchored to the edges and corners of a screen and specify input handling
|
||||||
|
semantics. This interface should be suitable for the implementation of
|
||||||
|
many desktop shell components, and a broad number of other applications
|
||||||
|
that interact with the desktop.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<request name="get_layer_surface">
|
||||||
|
<description summary="create a layer_surface from a surface">
|
||||||
|
Create a layer surface for an existing surface. This assigns the role of
|
||||||
|
layer_surface, or raises a protocol error if another role is already
|
||||||
|
assigned.
|
||||||
|
|
||||||
|
Creating a layer surface from a wl_surface which has a buffer attached
|
||||||
|
or committed is a client error, and any attempts by a client to attach
|
||||||
|
or manipulate a buffer prior to the first layer_surface.configure call
|
||||||
|
must also be treated as errors.
|
||||||
|
|
||||||
|
After creating a layer_surface object and setting it up, the client
|
||||||
|
must perform an initial commit without any buffer attached.
|
||||||
|
The compositor will reply with a layer_surface.configure event.
|
||||||
|
The client must acknowledge it and is then allowed to attach a buffer
|
||||||
|
to map the surface.
|
||||||
|
|
||||||
|
You may pass NULL for output to allow the compositor to decide which
|
||||||
|
output to use. Generally this will be the one that the user most
|
||||||
|
recently interacted with.
|
||||||
|
|
||||||
|
Clients can specify a namespace that defines the purpose of the layer
|
||||||
|
surface.
|
||||||
|
</description>
|
||||||
|
<arg name="id" type="new_id" interface="zwlr_layer_surface_v1"/>
|
||||||
|
<arg name="surface" type="object" interface="wl_surface"/>
|
||||||
|
<arg name="output" type="object" interface="wl_output" allow-null="true"/>
|
||||||
|
<arg name="layer" type="uint" enum="layer" summary="layer to add this surface to"/>
|
||||||
|
<arg name="namespace" type="string" summary="namespace for the layer surface"/>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<enum name="error">
|
||||||
|
<entry name="role" value="0" summary="wl_surface has another role"/>
|
||||||
|
<entry name="invalid_layer" value="1" summary="layer value is invalid"/>
|
||||||
|
<entry name="already_constructed" value="2" summary="wl_surface has a buffer attached or committed"/>
|
||||||
|
</enum>
|
||||||
|
|
||||||
|
<enum name="layer">
|
||||||
|
<description summary="available layers for surfaces">
|
||||||
|
These values indicate which layers a surface can be rendered in. They
|
||||||
|
are ordered by z depth, bottom-most first. Traditional shell surfaces
|
||||||
|
will typically be rendered between the bottom and top layers.
|
||||||
|
Fullscreen shell surfaces are typically rendered at the top layer.
|
||||||
|
Multiple surfaces can share a single layer, and ordering within a
|
||||||
|
single layer is undefined.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<entry name="background" value="0"/>
|
||||||
|
<entry name="bottom" value="1"/>
|
||||||
|
<entry name="top" value="2"/>
|
||||||
|
<entry name="overlay" value="3"/>
|
||||||
|
</enum>
|
||||||
|
|
||||||
|
<!-- Version 3 additions -->
|
||||||
|
|
||||||
|
<request name="destroy" type="destructor" since="3">
|
||||||
|
<description summary="destroy the layer_shell object">
|
||||||
|
This request indicates that the client will not use the layer_shell
|
||||||
|
object any more. Objects that have been created through this instance
|
||||||
|
are not affected.
|
||||||
|
</description>
|
||||||
|
</request>
|
||||||
|
</interface>
|
||||||
|
|
||||||
|
<interface name="zwlr_layer_surface_v1" version="5">
|
||||||
|
<description summary="layer metadata interface">
|
||||||
|
An interface that may be implemented by a wl_surface, for surfaces that
|
||||||
|
are designed to be rendered as a layer of a stacked desktop-like
|
||||||
|
environment.
|
||||||
|
|
||||||
|
Layer surface state (layer, size, anchor, exclusive zone,
|
||||||
|
margin, interactivity) is double-buffered, and will be applied at the
|
||||||
|
time wl_surface.commit of the corresponding wl_surface is called.
|
||||||
|
|
||||||
|
Attaching a null buffer to a layer surface unmaps it.
|
||||||
|
|
||||||
|
Unmapping a layer_surface means that the surface cannot be shown by the
|
||||||
|
compositor until it is explicitly mapped again. The layer_surface
|
||||||
|
returns to the state it had right after layer_shell.get_layer_surface.
|
||||||
|
The client can re-map the surface by performing a commit without any
|
||||||
|
buffer attached, waiting for a configure event and handling it as usual.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<request name="set_size">
|
||||||
|
<description summary="sets the size of the surface">
|
||||||
|
Sets the size of the surface in surface-local coordinates. The
|
||||||
|
compositor will display the surface centered with respect to its
|
||||||
|
anchors.
|
||||||
|
|
||||||
|
If you pass 0 for either value, the compositor will assign it and
|
||||||
|
inform you of the assignment in the configure event. You must set your
|
||||||
|
anchor to opposite edges in the dimensions you omit; not doing so is a
|
||||||
|
protocol error. Both values are 0 by default.
|
||||||
|
|
||||||
|
Size is double-buffered, see wl_surface.commit.
|
||||||
|
</description>
|
||||||
|
<arg name="width" type="uint"/>
|
||||||
|
<arg name="height" type="uint"/>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<request name="set_anchor">
|
||||||
|
<description summary="configures the anchor point of the surface">
|
||||||
|
Requests that the compositor anchor the surface to the specified edges
|
||||||
|
and corners. If two orthogonal edges are specified (e.g. 'top' and
|
||||||
|
'left'), then the anchor point will be the intersection of the edges
|
||||||
|
(e.g. the top left corner of the output); otherwise the anchor point
|
||||||
|
will be centered on that edge, or in the center if none is specified.
|
||||||
|
|
||||||
|
Anchor is double-buffered, see wl_surface.commit.
|
||||||
|
</description>
|
||||||
|
<arg name="anchor" type="uint" enum="anchor"/>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<request name="set_exclusive_zone">
|
||||||
|
<description summary="configures the exclusive geometry of this surface">
|
||||||
|
Requests that the compositor avoids occluding an area with other
|
||||||
|
surfaces. The compositor's use of this information is
|
||||||
|
implementation-dependent - do not assume that this region will not
|
||||||
|
actually be occluded.
|
||||||
|
|
||||||
|
A positive value is only meaningful if the surface is anchored to one
|
||||||
|
edge or an edge and both perpendicular edges. If the surface is not
|
||||||
|
anchored, anchored to only two perpendicular edges (a corner), anchored
|
||||||
|
to only two parallel edges or anchored to all edges, a positive value
|
||||||
|
will be treated the same as zero.
|
||||||
|
|
||||||
|
A positive zone is the distance from the edge in surface-local
|
||||||
|
coordinates to consider exclusive.
|
||||||
|
|
||||||
|
Surfaces that do not wish to have an exclusive zone may instead specify
|
||||||
|
how they should interact with surfaces that do. If set to zero, the
|
||||||
|
surface indicates that it would like to be moved to avoid occluding
|
||||||
|
surfaces with a positive exclusive zone. If set to -1, the surface
|
||||||
|
indicates that it would not like to be moved to accommodate for other
|
||||||
|
surfaces, and the compositor should extend it all the way to the edges
|
||||||
|
it is anchored to.
|
||||||
|
|
||||||
|
For example, a panel might set its exclusive zone to 10, so that
|
||||||
|
maximized shell surfaces are not shown on top of it. A notification
|
||||||
|
might set its exclusive zone to 0, so that it is moved to avoid
|
||||||
|
occluding the panel, but shell surfaces are shown underneath it. A
|
||||||
|
wallpaper or lock screen might set their exclusive zone to -1, so that
|
||||||
|
they stretch below or over the panel.
|
||||||
|
|
||||||
|
The default value is 0.
|
||||||
|
|
||||||
|
Exclusive zone is double-buffered, see wl_surface.commit.
|
||||||
|
</description>
|
||||||
|
<arg name="zone" type="int"/>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<request name="set_margin">
|
||||||
|
<description summary="sets a margin from the anchor point">
|
||||||
|
Requests that the surface be placed some distance away from the anchor
|
||||||
|
point on the output, in surface-local coordinates. Setting this value
|
||||||
|
for edges you are not anchored to has no effect.
|
||||||
|
|
||||||
|
The exclusive zone includes the margin.
|
||||||
|
|
||||||
|
Margin is double-buffered, see wl_surface.commit.
|
||||||
|
</description>
|
||||||
|
<arg name="top" type="int"/>
|
||||||
|
<arg name="right" type="int"/>
|
||||||
|
<arg name="bottom" type="int"/>
|
||||||
|
<arg name="left" type="int"/>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<enum name="keyboard_interactivity">
|
||||||
|
<description summary="types of keyboard interaction possible for a layer shell surface">
|
||||||
|
Types of keyboard interaction possible for layer shell surfaces. The
|
||||||
|
rationale for this is twofold: (1) some applications are not interested
|
||||||
|
in keyboard events and not allowing them to be focused can improve the
|
||||||
|
desktop experience; (2) some applications will want to take exclusive
|
||||||
|
keyboard focus.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<entry name="none" value="0">
|
||||||
|
<description summary="no keyboard focus is possible">
|
||||||
|
This value indicates that this surface is not interested in keyboard
|
||||||
|
events and the compositor should never assign it the keyboard focus.
|
||||||
|
|
||||||
|
This is the default value, set for newly created layer shell surfaces.
|
||||||
|
|
||||||
|
This is useful for e.g. desktop widgets that display information or
|
||||||
|
only have interaction with non-keyboard input devices.
|
||||||
|
</description>
|
||||||
|
</entry>
|
||||||
|
<entry name="exclusive" value="1">
|
||||||
|
<description summary="request exclusive keyboard focus">
|
||||||
|
Request exclusive keyboard focus if this surface is above the shell surface layer.
|
||||||
|
|
||||||
|
For the top and overlay layers, the seat will always give
|
||||||
|
exclusive keyboard focus to the top-most layer which has keyboard
|
||||||
|
interactivity set to exclusive. If this layer contains multiple
|
||||||
|
surfaces with keyboard interactivity set to exclusive, the compositor
|
||||||
|
determines the one receiving keyboard events in an implementation-
|
||||||
|
defined manner. In this case, no guarantee is made when this surface
|
||||||
|
will receive keyboard focus (if ever).
|
||||||
|
|
||||||
|
For the bottom and background layers, the compositor is allowed to use
|
||||||
|
normal focus semantics.
|
||||||
|
|
||||||
|
This setting is mainly intended for applications that need to ensure
|
||||||
|
they receive all keyboard events, such as a lock screen or a password
|
||||||
|
prompt.
|
||||||
|
</description>
|
||||||
|
</entry>
|
||||||
|
<entry name="on_demand" value="2" since="4">
|
||||||
|
<description summary="request regular keyboard focus semantics">
|
||||||
|
This requests the compositor to allow this surface to be focused and
|
||||||
|
unfocused by the user in an implementation-defined manner. The user
|
||||||
|
should be able to unfocus this surface even regardless of the layer
|
||||||
|
it is on.
|
||||||
|
|
||||||
|
Typically, the compositor will want to use its normal mechanism to
|
||||||
|
manage keyboard focus between layer shell surfaces with this setting
|
||||||
|
and regular toplevels on the desktop layer (e.g. click to focus).
|
||||||
|
Nevertheless, it is possible for a compositor to require a special
|
||||||
|
interaction to focus or unfocus layer shell surfaces (e.g. requiring
|
||||||
|
a click even if focus follows the mouse normally, or providing a
|
||||||
|
keybinding to switch focus between layers).
|
||||||
|
|
||||||
|
This setting is mainly intended for desktop shell components (e.g.
|
||||||
|
panels) that allow keyboard interaction. Using this option can allow
|
||||||
|
implementing a desktop shell that can be fully usable without the
|
||||||
|
mouse.
|
||||||
|
</description>
|
||||||
|
</entry>
|
||||||
|
</enum>
|
||||||
|
|
||||||
|
<request name="set_keyboard_interactivity">
|
||||||
|
<description summary="requests keyboard events">
|
||||||
|
Set how keyboard events are delivered to this surface. By default,
|
||||||
|
layer shell surfaces do not receive keyboard events; this request can
|
||||||
|
be used to change this.
|
||||||
|
|
||||||
|
This setting is inherited by child surfaces set by the get_popup
|
||||||
|
request.
|
||||||
|
|
||||||
|
Layer surfaces receive pointer, touch, and tablet events normally. If
|
||||||
|
you do not want to receive them, set the input region on your surface
|
||||||
|
to an empty region.
|
||||||
|
|
||||||
|
Keyboard interactivity is double-buffered, see wl_surface.commit.
|
||||||
|
</description>
|
||||||
|
<arg name="keyboard_interactivity" type="uint" enum="keyboard_interactivity"/>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<request name="get_popup">
|
||||||
|
<description summary="assign this layer_surface as an xdg_popup parent">
|
||||||
|
This assigns an xdg_popup's parent to this layer_surface. This popup
|
||||||
|
should have been created via xdg_surface::get_popup with the parent set
|
||||||
|
to NULL, and this request must be invoked before committing the popup's
|
||||||
|
initial state.
|
||||||
|
|
||||||
|
See the documentation of xdg_popup for more details about what an
|
||||||
|
xdg_popup is and how it is used.
|
||||||
|
</description>
|
||||||
|
<arg name="popup" type="object" interface="xdg_popup"/>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<request name="ack_configure">
|
||||||
|
<description summary="ack a configure event">
|
||||||
|
When a configure event is received, if a client commits the
|
||||||
|
surface in response to the configure event, then the client
|
||||||
|
must make an ack_configure request sometime before the commit
|
||||||
|
request, passing along the serial of the configure event.
|
||||||
|
|
||||||
|
If the client receives multiple configure events before it
|
||||||
|
can respond to one, it only has to ack the last configure event.
|
||||||
|
|
||||||
|
A client is not required to commit immediately after sending
|
||||||
|
an ack_configure request - it may even ack_configure several times
|
||||||
|
before its next surface commit.
|
||||||
|
|
||||||
|
A client may send multiple ack_configure requests before committing, but
|
||||||
|
only the last request sent before a commit indicates which configure
|
||||||
|
event the client really is responding to.
|
||||||
|
</description>
|
||||||
|
<arg name="serial" type="uint" summary="the serial from the configure event"/>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<request name="destroy" type="destructor">
|
||||||
|
<description summary="destroy the layer_surface">
|
||||||
|
This request destroys the layer surface.
|
||||||
|
</description>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<event name="configure">
|
||||||
|
<description summary="suggest a surface change">
|
||||||
|
The configure event asks the client to resize its surface.
|
||||||
|
|
||||||
|
Clients should arrange their surface for the new states, and then send
|
||||||
|
an ack_configure request with the serial sent in this configure event at
|
||||||
|
some point before committing the new surface.
|
||||||
|
|
||||||
|
The client is free to dismiss all but the last configure event it
|
||||||
|
received.
|
||||||
|
|
||||||
|
The width and height arguments specify the size of the window in
|
||||||
|
surface-local coordinates.
|
||||||
|
|
||||||
|
The size is a hint, in the sense that the client is free to ignore it if
|
||||||
|
it doesn't resize, pick a smaller size (to satisfy aspect ratio or
|
||||||
|
resize in steps of NxM pixels). If the client picks a smaller size and
|
||||||
|
is anchored to two opposite anchors (e.g. 'top' and 'bottom'), the
|
||||||
|
surface will be centered on this axis.
|
||||||
|
|
||||||
|
If the width or height arguments are zero, it means the client should
|
||||||
|
decide its own window dimension.
|
||||||
|
</description>
|
||||||
|
<arg name="serial" type="uint"/>
|
||||||
|
<arg name="width" type="uint"/>
|
||||||
|
<arg name="height" type="uint"/>
|
||||||
|
</event>
|
||||||
|
|
||||||
|
<event name="closed">
|
||||||
|
<description summary="surface should be closed">
|
||||||
|
The closed event is sent by the compositor when the surface will no
|
||||||
|
longer be shown. The output may have been destroyed or the user may
|
||||||
|
have asked for it to be removed. Further changes to the surface will be
|
||||||
|
ignored. The client should destroy the resource after receiving this
|
||||||
|
event, and create a new surface if they so choose.
|
||||||
|
</description>
|
||||||
|
</event>
|
||||||
|
|
||||||
|
<enum name="error">
|
||||||
|
<entry name="invalid_surface_state" value="0" summary="provided surface state is invalid"/>
|
||||||
|
<entry name="invalid_size" value="1" summary="size is invalid"/>
|
||||||
|
<entry name="invalid_anchor" value="2" summary="anchor bitfield is invalid"/>
|
||||||
|
<entry name="invalid_keyboard_interactivity" value="3" summary="keyboard interactivity is invalid"/>
|
||||||
|
<entry name="invalid_exclusive_edge" value="4" summary="exclusive edge is invalid given the surface anchors"/>
|
||||||
|
</enum>
|
||||||
|
|
||||||
|
<enum name="anchor" bitfield="true">
|
||||||
|
<entry name="top" value="1" summary="the top edge of the anchor rectangle"/>
|
||||||
|
<entry name="bottom" value="2" summary="the bottom edge of the anchor rectangle"/>
|
||||||
|
<entry name="left" value="4" summary="the left edge of the anchor rectangle"/>
|
||||||
|
<entry name="right" value="8" summary="the right edge of the anchor rectangle"/>
|
||||||
|
</enum>
|
||||||
|
|
||||||
|
<!-- Version 2 additions -->
|
||||||
|
|
||||||
|
<request name="set_layer" since="2">
|
||||||
|
<description summary="change the layer of the surface">
|
||||||
|
Change the layer that the surface is rendered on.
|
||||||
|
|
||||||
|
Layer is double-buffered, see wl_surface.commit.
|
||||||
|
</description>
|
||||||
|
<arg name="layer" type="uint" enum="zwlr_layer_shell_v1.layer" summary="layer to move this surface to"/>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<!-- Version 5 additions -->
|
||||||
|
|
||||||
|
<request name="set_exclusive_edge" since="5">
|
||||||
|
<description summary="set the edge the exclusive zone will be applied to">
|
||||||
|
Requests an edge for the exclusive zone to apply. The exclusive
|
||||||
|
edge will be automatically deduced from anchor points when possible,
|
||||||
|
but when the surface is anchored to a corner, it will be necessary
|
||||||
|
to set it explicitly to disambiguate, as it is not possible to deduce
|
||||||
|
which one of the two corner edges should be used.
|
||||||
|
|
||||||
|
The edge must be one the surface is anchored to, otherwise the
|
||||||
|
invalid_exclusive_edge protocol error will be raised.
|
||||||
|
</description>
|
||||||
|
<arg name="edge" type="uint" enum="anchor"/>
|
||||||
|
</request>
|
||||||
|
</interface>
|
||||||
|
</protocol>
|
||||||
234
core/internal/proto/xml/wlr-screencopy-unstable-v1.xml
Normal file
234
core/internal/proto/xml/wlr-screencopy-unstable-v1.xml
Normal file
@@ -0,0 +1,234 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<protocol name="wlr_screencopy_unstable_v1">
|
||||||
|
<copyright>
|
||||||
|
Copyright © 2018 Simon Ser
|
||||||
|
Copyright © 2019 Andri Yngvason
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
to deal in the Software without restriction, including without limitation
|
||||||
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice (including the next
|
||||||
|
paragraph) shall be included in all copies or substantial portions of the
|
||||||
|
Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE.
|
||||||
|
</copyright>
|
||||||
|
|
||||||
|
<description summary="screen content capturing on client buffers">
|
||||||
|
This protocol allows clients to ask the compositor to copy part of the
|
||||||
|
screen content to a client buffer.
|
||||||
|
|
||||||
|
Warning! The protocol described in this file is experimental and
|
||||||
|
backward incompatible changes may be made. Backward compatible changes
|
||||||
|
may be added together with the corresponding interface version bump.
|
||||||
|
Backward incompatible changes are done by bumping the version number in
|
||||||
|
the protocol and interface names and resetting the interface version.
|
||||||
|
Once the protocol is to be declared stable, the 'z' prefix and the
|
||||||
|
version number in the protocol and interface names are removed and the
|
||||||
|
interface version number is reset.
|
||||||
|
|
||||||
|
Note! This protocol is deprecated and not intended for production use.
|
||||||
|
The ext-image-copy-capture-v1 protocol should be used instead.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<interface name="zwlr_screencopy_manager_v1" version="3">
|
||||||
|
<description summary="manager to inform clients and begin capturing">
|
||||||
|
This object is a manager which offers requests to start capturing from a
|
||||||
|
source.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<request name="capture_output">
|
||||||
|
<description summary="capture an output">
|
||||||
|
Capture the next frame of an entire output.
|
||||||
|
</description>
|
||||||
|
<arg name="frame" type="new_id" interface="zwlr_screencopy_frame_v1"/>
|
||||||
|
<arg name="overlay_cursor" type="int"
|
||||||
|
summary="composite cursor onto the frame"/>
|
||||||
|
<arg name="output" type="object" interface="wl_output"/>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<request name="capture_output_region">
|
||||||
|
<description summary="capture an output's region">
|
||||||
|
Capture the next frame of an output's region.
|
||||||
|
|
||||||
|
The region is given in output logical coordinates, see
|
||||||
|
xdg_output.logical_size. The region will be clipped to the output's
|
||||||
|
extents.
|
||||||
|
</description>
|
||||||
|
<arg name="frame" type="new_id" interface="zwlr_screencopy_frame_v1"/>
|
||||||
|
<arg name="overlay_cursor" type="int"
|
||||||
|
summary="composite cursor onto the frame"/>
|
||||||
|
<arg name="output" type="object" interface="wl_output"/>
|
||||||
|
<arg name="x" type="int"/>
|
||||||
|
<arg name="y" type="int"/>
|
||||||
|
<arg name="width" type="int"/>
|
||||||
|
<arg name="height" type="int"/>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<request name="destroy" type="destructor">
|
||||||
|
<description summary="destroy the manager">
|
||||||
|
All objects created by the manager will still remain valid, until their
|
||||||
|
appropriate destroy request has been called.
|
||||||
|
</description>
|
||||||
|
</request>
|
||||||
|
</interface>
|
||||||
|
|
||||||
|
<interface name="zwlr_screencopy_frame_v1" version="3">
|
||||||
|
<description summary="a frame ready for copy">
|
||||||
|
This object represents a single frame.
|
||||||
|
|
||||||
|
When created, a series of buffer events will be sent, each representing a
|
||||||
|
supported buffer type. The "buffer_done" event is sent afterwards to
|
||||||
|
indicate that all supported buffer types have been enumerated. The client
|
||||||
|
will then be able to send a "copy" request. If the capture is successful,
|
||||||
|
the compositor will send a "flags" event followed by a "ready" event.
|
||||||
|
|
||||||
|
For objects version 2 or lower, wl_shm buffers are always supported, ie.
|
||||||
|
the "buffer" event is guaranteed to be sent.
|
||||||
|
|
||||||
|
If the capture failed, the "failed" event is sent. This can happen anytime
|
||||||
|
before the "ready" event.
|
||||||
|
|
||||||
|
Once either a "ready" or a "failed" event is received, the client should
|
||||||
|
destroy the frame.
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<event name="buffer">
|
||||||
|
<description summary="wl_shm buffer information">
|
||||||
|
Provides information about wl_shm buffer parameters that need to be
|
||||||
|
used for this frame. This event is sent once after the frame is created
|
||||||
|
if wl_shm buffers are supported.
|
||||||
|
</description>
|
||||||
|
<arg name="format" type="uint" enum="wl_shm.format" summary="buffer format"/>
|
||||||
|
<arg name="width" type="uint" summary="buffer width"/>
|
||||||
|
<arg name="height" type="uint" summary="buffer height"/>
|
||||||
|
<arg name="stride" type="uint" summary="buffer stride"/>
|
||||||
|
</event>
|
||||||
|
|
||||||
|
<request name="copy">
|
||||||
|
<description summary="copy the frame">
|
||||||
|
Copy the frame to the supplied buffer. The buffer must have the
|
||||||
|
correct size, see zwlr_screencopy_frame_v1.buffer and
|
||||||
|
zwlr_screencopy_frame_v1.linux_dmabuf. The buffer needs to have a
|
||||||
|
supported format.
|
||||||
|
|
||||||
|
If the frame is successfully copied, "flags" and "ready" events are
|
||||||
|
sent. Otherwise, a "failed" event is sent.
|
||||||
|
</description>
|
||||||
|
<arg name="buffer" type="object" interface="wl_buffer"/>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<enum name="error">
|
||||||
|
<entry name="already_used" value="0"
|
||||||
|
summary="the object has already been used to copy a wl_buffer"/>
|
||||||
|
<entry name="invalid_buffer" value="1"
|
||||||
|
summary="buffer attributes are invalid"/>
|
||||||
|
</enum>
|
||||||
|
|
||||||
|
<enum name="flags" bitfield="true">
|
||||||
|
<entry name="y_invert" value="1" summary="contents are y-inverted"/>
|
||||||
|
</enum>
|
||||||
|
|
||||||
|
<event name="flags">
|
||||||
|
<description summary="frame flags">
|
||||||
|
Provides flags about the frame. This event is sent once before the
|
||||||
|
"ready" event.
|
||||||
|
</description>
|
||||||
|
<arg name="flags" type="uint" enum="flags" summary="frame flags"/>
|
||||||
|
</event>
|
||||||
|
|
||||||
|
<event name="ready">
|
||||||
|
<description summary="indicates frame is available for reading">
|
||||||
|
Called as soon as the frame is copied, indicating it is available
|
||||||
|
for reading. This event includes the time at which the presentation took place.
|
||||||
|
|
||||||
|
The timestamp is expressed as tv_sec_hi, tv_sec_lo, tv_nsec triples,
|
||||||
|
each component being an unsigned 32-bit value. Whole seconds are in
|
||||||
|
tv_sec which is a 64-bit value combined from tv_sec_hi and tv_sec_lo,
|
||||||
|
and the additional fractional part in tv_nsec as nanoseconds. Hence,
|
||||||
|
for valid timestamps tv_nsec must be in [0, 999999999]. The seconds part
|
||||||
|
may have an arbitrary offset at start.
|
||||||
|
|
||||||
|
After receiving this event, the client should destroy the object.
|
||||||
|
</description>
|
||||||
|
<arg name="tv_sec_hi" type="uint"
|
||||||
|
summary="high 32 bits of the seconds part of the timestamp"/>
|
||||||
|
<arg name="tv_sec_lo" type="uint"
|
||||||
|
summary="low 32 bits of the seconds part of the timestamp"/>
|
||||||
|
<arg name="tv_nsec" type="uint"
|
||||||
|
summary="nanoseconds part of the timestamp"/>
|
||||||
|
</event>
|
||||||
|
|
||||||
|
<event name="failed">
|
||||||
|
<description summary="frame copy failed">
|
||||||
|
This event indicates that the attempted frame copy has failed.
|
||||||
|
|
||||||
|
After receiving this event, the client should destroy the object.
|
||||||
|
</description>
|
||||||
|
</event>
|
||||||
|
|
||||||
|
<request name="destroy" type="destructor">
|
||||||
|
<description summary="delete this object, used or not">
|
||||||
|
Destroys the frame. This request can be sent at any time by the client.
|
||||||
|
</description>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<!-- Version 2 additions -->
|
||||||
|
<request name="copy_with_damage" since="2">
|
||||||
|
<description summary="copy the frame when it's damaged">
|
||||||
|
Same as copy, except it waits until there is damage to copy.
|
||||||
|
</description>
|
||||||
|
<arg name="buffer" type="object" interface="wl_buffer"/>
|
||||||
|
</request>
|
||||||
|
|
||||||
|
<event name="damage" since="2">
|
||||||
|
<description summary="carries the coordinates of the damaged region">
|
||||||
|
This event is sent right before the ready event when copy_with_damage is
|
||||||
|
requested. It may be generated multiple times for each copy_with_damage
|
||||||
|
request.
|
||||||
|
|
||||||
|
The arguments describe a box around an area that has changed since the
|
||||||
|
last copy request that was derived from the current screencopy manager
|
||||||
|
instance.
|
||||||
|
|
||||||
|
The union of all regions received between the call to copy_with_damage
|
||||||
|
and a ready event is the total damage since the prior ready event.
|
||||||
|
</description>
|
||||||
|
<arg name="x" type="uint" summary="damaged x coordinates"/>
|
||||||
|
<arg name="y" type="uint" summary="damaged y coordinates"/>
|
||||||
|
<arg name="width" type="uint" summary="current width"/>
|
||||||
|
<arg name="height" type="uint" summary="current height"/>
|
||||||
|
</event>
|
||||||
|
|
||||||
|
<!-- Version 3 additions -->
|
||||||
|
<event name="linux_dmabuf" since="3">
|
||||||
|
<description summary="linux-dmabuf buffer information">
|
||||||
|
Provides information about linux-dmabuf buffer parameters that need to
|
||||||
|
be used for this frame. This event is sent once after the frame is
|
||||||
|
created if linux-dmabuf buffers are supported.
|
||||||
|
</description>
|
||||||
|
<arg name="format" type="uint" summary="fourcc pixel format"/>
|
||||||
|
<arg name="width" type="uint" summary="buffer width"/>
|
||||||
|
<arg name="height" type="uint" summary="buffer height"/>
|
||||||
|
</event>
|
||||||
|
|
||||||
|
<event name="buffer_done" since="3">
|
||||||
|
<description summary="all buffer types reported">
|
||||||
|
This event is sent once after all buffer events have been sent.
|
||||||
|
|
||||||
|
The client should proceed to create a buffer of one of the supported
|
||||||
|
types, and send a "copy" request.
|
||||||
|
</description>
|
||||||
|
</event>
|
||||||
|
</interface>
|
||||||
|
</protocol>
|
||||||
13
core/pkg/go-wayland/wayland/stable/xdg-shell/xdg_shell.go
Normal file
13
core/pkg/go-wayland/wayland/stable/xdg-shell/xdg_shell.go
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package xdg_shell
|
||||||
|
|
||||||
|
import "github.com/AvengeMedia/DankMaterialShell/core/pkg/go-wayland/wayland/client"
|
||||||
|
|
||||||
|
type Popup struct {
|
||||||
|
client.BaseProxy
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewPopup(ctx *client.Context) *Popup {
|
||||||
|
p := &Popup{}
|
||||||
|
ctx.Register(p)
|
||||||
|
return p
|
||||||
|
}
|
||||||
@@ -59,6 +59,7 @@ const DMS_ACTIONS = [
|
|||||||
{ id: "spawn dms ipc call audio decrement 10", label: "Volume Down (10%)" },
|
{ id: "spawn dms ipc call audio decrement 10", label: "Volume Down (10%)" },
|
||||||
{ id: "spawn dms ipc call audio mute", label: "Volume Mute Toggle" },
|
{ id: "spawn dms ipc call audio mute", label: "Volume Mute Toggle" },
|
||||||
{ id: "spawn dms ipc call audio micmute", label: "Microphone Mute Toggle" },
|
{ id: "spawn dms ipc call audio micmute", label: "Microphone Mute Toggle" },
|
||||||
|
{ id: "spawn dms ipc call audio cycleoutput", label: "Audio Output: Cycle" },
|
||||||
{ id: "spawn dms ipc call brightness increment", label: "Brightness Up" },
|
{ id: "spawn dms ipc call brightness increment", label: "Brightness Up" },
|
||||||
{ id: "spawn dms ipc call brightness increment 1", label: "Brightness Up (1%)" },
|
{ id: "spawn dms ipc call brightness increment 1", label: "Brightness Up (1%)" },
|
||||||
{ id: "spawn dms ipc call brightness increment 5", label: "Brightness Up (5%)" },
|
{ id: "spawn dms ipc call brightness increment 5", label: "Brightness Up (5%)" },
|
||||||
|
|||||||
@@ -313,6 +313,7 @@ Singleton {
|
|||||||
property bool osdMicMuteEnabled: true
|
property bool osdMicMuteEnabled: true
|
||||||
property bool osdCapsLockEnabled: true
|
property bool osdCapsLockEnabled: true
|
||||||
property bool osdPowerProfileEnabled: true
|
property bool osdPowerProfileEnabled: true
|
||||||
|
property bool osdAudioOutputEnabled: true
|
||||||
|
|
||||||
property bool powerActionConfirm: true
|
property bool powerActionConfirm: true
|
||||||
property int powerActionHoldDuration: 1
|
property int powerActionHoldDuration: 1
|
||||||
|
|||||||
@@ -212,6 +212,7 @@ var SPEC = {
|
|||||||
osdMicMuteEnabled: { def: true },
|
osdMicMuteEnabled: { def: true },
|
||||||
osdCapsLockEnabled: { def: true },
|
osdCapsLockEnabled: { def: true },
|
||||||
osdPowerProfileEnabled: { def: false },
|
osdPowerProfileEnabled: { def: false },
|
||||||
|
osdAudioOutputEnabled: { def: true },
|
||||||
|
|
||||||
powerActionConfirm: { def: true },
|
powerActionConfirm: { def: true },
|
||||||
powerActionHoldDuration: { def: 1 },
|
powerActionHoldDuration: { def: 1 },
|
||||||
|
|||||||
@@ -700,6 +700,14 @@ Item {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Variants {
|
||||||
|
model: SettingsData.getFilteredScreens("osd")
|
||||||
|
|
||||||
|
delegate: AudioOutputOSD {
|
||||||
|
modelData: item
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LazyLoader {
|
LazyLoader {
|
||||||
id: hyprlandOverviewLoader
|
id: hyprlandOverviewLoader
|
||||||
active: CompositorService.isHyprland
|
active: CompositorService.isHyprland
|
||||||
|
|||||||
@@ -27,10 +27,12 @@ DankModal {
|
|||||||
modalWidth: 520
|
modalWidth: 520
|
||||||
modalHeight: 500
|
modalHeight: 500
|
||||||
|
|
||||||
|
onBackgroundClicked: close()
|
||||||
|
|
||||||
onDialogClosed: {
|
onDialogClosed: {
|
||||||
searchQuery = ""
|
searchQuery = ""
|
||||||
selectedIndex = 0
|
selectedIndex = 0
|
||||||
keyboardNavigationActive: false
|
keyboardNavigationActive = false
|
||||||
}
|
}
|
||||||
|
|
||||||
onOpened: {
|
onOpened: {
|
||||||
|
|||||||
@@ -90,43 +90,26 @@ DankModal {
|
|||||||
root.show();
|
root.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
function runNiriPicker() {
|
|
||||||
Proc.runCommand("niri-pick-color", ["niri", "msg", "pick-color"], (output, exitCode) => {
|
|
||||||
if (exitCode !== 0) {
|
|
||||||
console.warn("niri msg pick-color exited with code:", exitCode);
|
|
||||||
root.show();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const hexMatch = output.match(/Hex:\s*(#[0-9A-Fa-f]{6})/);
|
|
||||||
if (hexMatch) {
|
|
||||||
applyPickedColor(hexMatch[1]);
|
|
||||||
} else {
|
|
||||||
console.warn("Failed to parse niri pick-color output:", output);
|
|
||||||
root.show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function pickColorFromScreen() {
|
function pickColorFromScreen() {
|
||||||
hideInstant();
|
hideInstant();
|
||||||
Proc.runCommand("check-hyprpicker", ["which", "hyprpicker"], (output, exitCode) => {
|
Proc.runCommand("dms-color-pick", ["dms", "color", "pick", "--json"], (output, exitCode) => {
|
||||||
if (exitCode === 0) {
|
if (exitCode !== 0) {
|
||||||
Proc.runCommand("hyprpicker", ["hyprpicker", "--format=hex"], (hpOutput, hpCode) => {
|
console.warn("dms color pick exited with code:", exitCode);
|
||||||
if (hpCode !== 0) {
|
|
||||||
console.warn("hyprpicker exited with code:", hpCode);
|
|
||||||
root.show();
|
root.show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
applyPickedColor(hpOutput.trim());
|
try {
|
||||||
});
|
const result = JSON.parse(output);
|
||||||
return;
|
if (result.hex) {
|
||||||
}
|
applyPickedColor(result.hex);
|
||||||
if (CompositorService.isNiri) {
|
} else {
|
||||||
runNiriPicker();
|
console.warn("Failed to parse dms color pick output: missing hex");
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.warn("No color picker available");
|
|
||||||
root.show();
|
root.show();
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("Failed to parse dms color pick JSON:", e);
|
||||||
|
root.show();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
80
quickshell/Modules/OSD/AudioOutputOSD.qml
Normal file
80
quickshell/Modules/OSD/AudioOutputOSD.qml
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
import QtQuick
|
||||||
|
import qs.Common
|
||||||
|
import qs.Services
|
||||||
|
import qs.Widgets
|
||||||
|
|
||||||
|
DankOSD {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property string deviceName: ""
|
||||||
|
property string deviceIcon: "speaker"
|
||||||
|
|
||||||
|
osdWidth: Math.min(Math.max(120, Theme.iconSize + textMetrics.width + Theme.spacingS * 4), Screen.width - Theme.spacingM * 2)
|
||||||
|
osdHeight: 40 + Theme.spacingS * 2
|
||||||
|
autoHideInterval: 2500
|
||||||
|
enableMouseInteraction: false
|
||||||
|
|
||||||
|
TextMetrics {
|
||||||
|
id: textMetrics
|
||||||
|
font.pixelSize: Theme.fontSizeMedium
|
||||||
|
font.weight: Font.Medium
|
||||||
|
font.family: Theme.fontFamily
|
||||||
|
text: root.deviceName
|
||||||
|
}
|
||||||
|
|
||||||
|
function getIconForSink(sink) {
|
||||||
|
if (!sink)
|
||||||
|
return "speaker";
|
||||||
|
const name = sink.name || "";
|
||||||
|
if (name.includes("bluez"))
|
||||||
|
return "headset";
|
||||||
|
if (name.includes("hdmi"))
|
||||||
|
return "tv";
|
||||||
|
if (name.includes("usb"))
|
||||||
|
return "headset";
|
||||||
|
return "speaker";
|
||||||
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: AudioService
|
||||||
|
|
||||||
|
function onAudioOutputCycled(name) {
|
||||||
|
if (!SettingsData.osdAudioOutputEnabled)
|
||||||
|
return;
|
||||||
|
root.deviceName = name;
|
||||||
|
root.deviceIcon = getIconForSink(AudioService.sink);
|
||||||
|
root.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
content: Item {
|
||||||
|
property int gap: Theme.spacingS
|
||||||
|
|
||||||
|
anchors.centerIn: parent
|
||||||
|
width: parent.width - Theme.spacingS * 2
|
||||||
|
height: 40
|
||||||
|
|
||||||
|
DankIcon {
|
||||||
|
id: iconItem
|
||||||
|
width: Theme.iconSize
|
||||||
|
height: Theme.iconSize
|
||||||
|
x: parent.gap
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
name: root.deviceIcon
|
||||||
|
size: Theme.iconSize
|
||||||
|
color: Theme.primary
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
id: textItem
|
||||||
|
x: parent.gap * 2 + Theme.iconSize
|
||||||
|
width: parent.width - Theme.iconSize - parent.gap * 3
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
text: root.deviceName
|
||||||
|
font.pixelSize: Theme.fontSizeMedium
|
||||||
|
font.weight: Font.Medium
|
||||||
|
color: Theme.surfaceText
|
||||||
|
elide: Text.ElideRight
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -258,20 +258,8 @@ Item {
|
|||||||
readonly property bool showWarning: status.included && status.overriddenBy > 0
|
readonly property bool showWarning: status.included && status.overriddenBy > 0
|
||||||
readonly property bool showSetup: !status.exists
|
readonly property bool showSetup: !status.exists
|
||||||
|
|
||||||
color: {
|
color: (showError || showWarning || showSetup) ? Theme.withAlpha(Theme.primary, 0.15) : "transparent"
|
||||||
if (showError || showSetup)
|
border.color: (showError || showWarning || showSetup) ? Theme.withAlpha(Theme.primary, 0.3) : "transparent"
|
||||||
return Theme.withAlpha(Theme.error, 0.15);
|
|
||||||
if (showWarning)
|
|
||||||
return Theme.withAlpha(Theme.warning ?? Theme.tertiary, 0.15);
|
|
||||||
return "transparent";
|
|
||||||
}
|
|
||||||
border.color: {
|
|
||||||
if (showError || showSetup)
|
|
||||||
return Theme.withAlpha(Theme.error, 0.3);
|
|
||||||
if (showWarning)
|
|
||||||
return Theme.withAlpha(Theme.warning ?? Theme.tertiary, 0.3);
|
|
||||||
return "transparent";
|
|
||||||
}
|
|
||||||
border.width: 1
|
border.width: 1
|
||||||
visible: (showError || showWarning || showSetup) && !KeybindsService.loading
|
visible: (showError || showWarning || showSetup) && !KeybindsService.loading
|
||||||
|
|
||||||
@@ -288,7 +276,7 @@ Item {
|
|||||||
DankIcon {
|
DankIcon {
|
||||||
name: warningBox.showWarning ? "info" : "warning"
|
name: warningBox.showWarning ? "info" : "warning"
|
||||||
size: Theme.iconSize
|
size: Theme.iconSize
|
||||||
color: warningBox.showWarning ? (Theme.warning ?? Theme.tertiary) : Theme.error
|
color: Theme.primary
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,7 +297,7 @@ Item {
|
|||||||
}
|
}
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
font.pixelSize: Theme.fontSizeMedium
|
||||||
font.weight: Font.Medium
|
font.weight: Font.Medium
|
||||||
color: warningBox.showWarning ? (Theme.warning ?? Theme.tertiary) : Theme.error
|
color: Theme.primary
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
|
|||||||
@@ -141,6 +141,13 @@ Item {
|
|||||||
checked: SettingsData.osdPowerProfileEnabled
|
checked: SettingsData.osdPowerProfileEnabled
|
||||||
onToggled: checked => SettingsData.set("osdPowerProfileEnabled", checked)
|
onToggled: checked => SettingsData.set("osdPowerProfileEnabled", checked)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SettingsToggleRow {
|
||||||
|
text: I18n.tr("Audio Output Switch")
|
||||||
|
description: I18n.tr("Show on-screen display when cycling audio output devices")
|
||||||
|
checked: SettingsData.osdAudioOutputEnabled
|
||||||
|
onToggled: checked => SettingsData.set("osdAudioOutputEnabled", checked)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,33 @@ Singleton {
|
|||||||
property var mediaDevicesConnections: null
|
property var mediaDevicesConnections: null
|
||||||
|
|
||||||
signal micMuteChanged
|
signal micMuteChanged
|
||||||
|
signal audioOutputCycled(string deviceName)
|
||||||
|
|
||||||
|
function getAvailableSinks() {
|
||||||
|
return Pipewire.nodes.values.filter(node => node.audio && node.isSink && !node.isStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
function cycleAudioOutput() {
|
||||||
|
const sinks = getAvailableSinks();
|
||||||
|
if (sinks.length < 2)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
const currentSink = root.sink;
|
||||||
|
let currentIndex = -1;
|
||||||
|
for (let i = 0; i < sinks.length; i++) {
|
||||||
|
if (sinks[i] === currentSink) {
|
||||||
|
currentIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const nextIndex = (currentIndex + 1) % sinks.length;
|
||||||
|
const nextSink = sinks[nextIndex];
|
||||||
|
Pipewire.preferredDefaultAudioSink = nextSink;
|
||||||
|
const name = displayName(nextSink);
|
||||||
|
audioOutputCycled(name);
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: root.sink?.audio ?? null
|
target: root.sink?.audio ?? null
|
||||||
@@ -595,6 +622,13 @@ Singleton {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cycleoutput(): string {
|
||||||
|
const result = root.cycleAudioOutput();
|
||||||
|
if (!result)
|
||||||
|
return "Only one audio output available";
|
||||||
|
return `Switched to: ${result}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
|
|||||||
@@ -312,14 +312,14 @@ Item {
|
|||||||
DankIcon {
|
DankIcon {
|
||||||
name: "warning"
|
name: "warning"
|
||||||
size: 14
|
size: 14
|
||||||
color: Theme.warning ?? Theme.tertiary
|
color: Theme.primary
|
||||||
visible: root.hasConfigConflict
|
visible: root.hasConfigConflict
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: I18n.tr("Overridden by config")
|
text: I18n.tr("Overridden by config")
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
color: Theme.warning ?? Theme.tertiary
|
color: Theme.primary
|
||||||
visible: root.hasConfigConflict
|
visible: root.hasConfigConflict
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,8 +382,8 @@ Item {
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.preferredHeight: conflictColumn.implicitHeight + Theme.spacingM * 2
|
Layout.preferredHeight: conflictColumn.implicitHeight + Theme.spacingM * 2
|
||||||
radius: Theme.cornerRadius
|
radius: Theme.cornerRadius
|
||||||
color: Theme.withAlpha(Theme.warning ?? Theme.tertiary, 0.15)
|
color: Theme.withAlpha(Theme.primary, 0.15)
|
||||||
border.color: Theme.withAlpha(Theme.warning ?? Theme.tertiary, 0.3)
|
border.color: Theme.withAlpha(Theme.primary, 0.3)
|
||||||
border.width: 1
|
border.width: 1
|
||||||
visible: root.hasConfigConflict
|
visible: root.hasConfigConflict
|
||||||
|
|
||||||
@@ -400,14 +400,14 @@ Item {
|
|||||||
DankIcon {
|
DankIcon {
|
||||||
name: "warning"
|
name: "warning"
|
||||||
size: 16
|
size: 16
|
||||||
color: Theme.warning ?? Theme.tertiary
|
color: Theme.primary
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: I18n.tr("This bind is overridden by config.kdl")
|
text: I18n.tr("This bind is overridden by config.kdl")
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
font.weight: Font.Medium
|
font.weight: Font.Medium
|
||||||
color: Theme.warning ?? Theme.tertiary
|
color: Theme.primary
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -663,13 +663,13 @@ Item {
|
|||||||
DankIcon {
|
DankIcon {
|
||||||
name: "warning"
|
name: "warning"
|
||||||
size: 16
|
size: 16
|
||||||
color: Theme.warning
|
color: Theme.primary
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
text: I18n.tr("Conflicts with: %1").arg(root._conflicts.map(c => c.desc).join(", "))
|
text: I18n.tr("Conflicts with: %1").arg(root._conflicts.map(c => c.desc).join(", "))
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
color: Theme.warning
|
color: Theme.primary
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user