-
Notifications
You must be signed in to change notification settings - Fork 0
/
decoration.go
77 lines (69 loc) · 1.85 KB
/
decoration.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package system
import (
"strings"
"github.com/utopiagio/gio/internal/ops"
"github.com/utopiagio/gio/op"
)
// ActionAreaOp makes the current clip area available for
// system gestures.
//
// Note: only ActionMove is supported.
type ActionInputOp Action
// Action is a set of window decoration actions.
type Action uint
const (
// ActionMinimize minimizes a window.
ActionMinimize Action = 1 << iota
// ActionMaximize maximizes a window.
ActionMaximize
// ActionUnmaximize restores a maximized window.
ActionUnmaximize
// ActionFullscreen makes a window fullscreen.
ActionFullscreen
// ActionRaise requests that the platform bring this window to the top of all open windows.
// Some platforms do not allow this except under certain circumstances, such as when
// a window from the same application already has focus. If the platform does not
// support it, this method will do nothing.
ActionRaise
// ActionCenter centers the window on the screen.
// It is ignored in Fullscreen mode and on Wayland.
ActionCenter
// ActionClose closes a window.
// Only applicable on macOS, Windows, X11 and Wayland.
ActionClose
// ActionMove moves a window directed by the user.
ActionMove
)
func (op ActionInputOp) Add(o *op.Ops) {
data := ops.Write(&o.Internal, ops.TypeActionInputLen)
data[0] = byte(ops.TypeActionInput)
data[1] = byte(op)
}
func (a Action) String() string {
var buf strings.Builder
for b := Action(1); a != 0; b <<= 1 {
if a&b != 0 {
if buf.Len() > 0 {
buf.WriteByte('|')
}
buf.WriteString(b.string())
a &^= b
}
}
return buf.String()
}
func (a Action) string() string {
switch a {
case ActionMinimize:
return "ActionMinimize"
case ActionMaximize:
return "ActionMaximize"
case ActionUnmaximize:
return "ActionUnmaximize"
case ActionClose:
return "ActionClose"
case ActionMove:
return "ActionMove"
}
return ""
}