-
Notifications
You must be signed in to change notification settings - Fork 1
/
slim.go
119 lines (93 loc) · 2.06 KB
/
slim.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// Copyright (c) 2018, Mark "Happy-Ferret" Bauermeister
//
// This software may be modified and distributed under the terms
// of the BSD license. See the LICENSE file for details.
package frame
import (
"github.com/BurntSushi/xgb/xproto"
"github.com/BurntSushi/xgbutil"
"github.com/Anima-OS/Wonderland/render"
)
type Slim struct {
*frame
theme *SlimTheme
}
func NewSlim(X *xgbutil.XUtil,
t *SlimTheme, p *Parent, c Client) (*Slim, error) {
f, err := newFrame(X, p, c)
if err != nil {
return nil, err
}
return &Slim{frame: f, theme: t}, nil
}
func (f *Slim) Current() bool {
return f.client.Frame() == f
}
func (f *Slim) Off() {}
func (f *Slim) On() {
Reset(f)
if f.client.State() == Active {
f.Active()
} else {
f.Inactive()
}
}
func (f *Slim) Active() {
f.State = Active
f.parent.Change(xproto.CwBackPixel, f.theme.ABorderColor.Uint32())
f.parent.ClearAll()
}
func (f *Slim) Inactive() {
f.State = Inactive
f.parent.Change(xproto.CwBackPixel, f.theme.IBorderColor.Uint32())
f.parent.ClearAll()
}
func (f *Slim) Maximize() {}
func (f *Slim) Unmaximize() {}
func (f *Slim) Top() int {
if f.client.IsMaximized() {
return 0
}
return f.theme.BorderSize
}
func (f *Slim) Bottom() int {
if f.client.IsMaximized() {
return 0
}
return f.theme.BorderSize
}
func (f *Slim) Left() int {
if f.client.IsMaximized() {
return 0
}
return f.theme.BorderSize
}
func (f *Slim) Right() int {
if f.client.IsMaximized() {
return 0
}
return f.theme.BorderSize
}
func (f *Slim) MROpt(validate bool, flags, x, y, w, h int) {
mropt(f, validate, flags, x, y, w, h)
}
func (f *Slim) MoveResize(validate bool, x, y, w, h int) {
moveresize(f, validate, x, y, w, h)
}
func (f *Slim) Move(x, y int) {
move(f, x, y)
}
func (f *Slim) Resize(validate bool, w, h int) {
resize(f, validate, w, h)
}
type SlimTheme struct {
BorderSize int
ABorderColor, IBorderColor render.Color
}
func DefaultSlimTheme() *SlimTheme {
return &SlimTheme{
BorderSize: 10,
ABorderColor: render.NewColor(0x3366ff),
IBorderColor: render.NewColor(0xdfdcdf),
}
}