io/system: remove resize actions

Allowing clients to initiate resize gestures is a waste: macOS
doesn't support them, and the only reason we added them was to
implement client-side decorations for Wayland. Now all desktop
platforms implement resize gestures as needed, and we no longer
need the system.Action actions.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2022-06-25 18:31:04 +02:00
parent b34dc63531
commit b53cdfef8d
4 changed files with 1 additions and 108 deletions
+1 -5
View File
@@ -983,11 +983,7 @@ func (w *Window) decorate(d driver, e system.FrameEvent, o *op.Ops) (size, offse
w.decorations.Decorations = deco
}
allActions := system.ActionMinimize | system.ActionMaximize | system.ActionUnmaximize |
system.ActionClose | system.ActionMove |
system.ActionResizeNorth | system.ActionResizeSouth |
system.ActionResizeWest | system.ActionResizeEast |
system.ActionResizeNorthWest | system.ActionResizeSouthWest |
system.ActionResizeNorthEast | system.ActionResizeSouthEast
system.ActionClose | system.ActionMove
style := material.Decorations(theme, deco, allActions, w.decorations.Config.Title)
// Update the decorations based on the current window mode.
var actions system.Action
-59
View File
@@ -2,8 +2,6 @@ package system
import (
"strings"
"gioui.org/io/pointer"
)
// Action is a set of window decoration actions.
@@ -31,49 +29,8 @@ const (
ActionClose
// ActionMove moves a window directed by the user.
ActionMove
// ActionResizeNorth resizes the top border of a window (directed by the user).
ActionResizeNorth
// ActionResizeSouth resizes the bottom border of a window (directed by the user).
ActionResizeSouth
// ActionResizeWest resizes the right border of a window (directed by the user).
ActionResizeWest
// ActionResizeEast resizes the left border of a window (directed by the user).
ActionResizeEast
// ActionResizeNorthWest resizes the top-left corner of a window (directed by the user).
ActionResizeNorthWest
// ActionResizeSouthWest resizes the bottom-left corner of a window (directed by the user).
ActionResizeSouthWest
// ActionResizeNorthEast resizes the top-right corner of a window (directed by the user).
ActionResizeNorthEast
// ActionResizeSouthEast resizes the bottom-right corner of a window (directed by the user).
ActionResizeSouthEast
)
// Cursor returns the cursor for the action.
// It must be a single action otherwise the default
// cursor is returned.
func (a Action) Cursor() pointer.Cursor {
switch a {
case ActionResizeNorthWest:
return pointer.CursorNorthWestResize
case ActionResizeSouthEast:
return pointer.CursorSouthEastResize
case ActionResizeNorthEast:
return pointer.CursorNorthEastResize
case ActionResizeSouthWest:
return pointer.CursorSouthWestResize
case ActionResizeWest:
return pointer.CursorWestResize
case ActionResizeEast:
return pointer.CursorEastResize
case ActionResizeNorth:
return pointer.CursorNorthResize
case ActionResizeSouth:
return pointer.CursorSouthResize
}
return pointer.CursorDefault
}
func (a Action) String() string {
var buf strings.Builder
for b := Action(1); a != 0; b <<= 1 {
@@ -100,22 +57,6 @@ func (a Action) string() string {
return "ActionClose"
case ActionMove:
return "ActionMove"
case ActionResizeNorth:
return "ActionResizeNorth"
case ActionResizeSouth:
return "ActionResizeSouth"
case ActionResizeWest:
return "ActionResizeWest"
case ActionResizeEast:
return "ActionResizeEast"
case ActionResizeNorthWest:
return "ActionResizeNorthWest"
case ActionResizeSouthWest:
return "ActionResizeSouthWest"
case ActionResizeNorthEast:
return "ActionResizeNorthEast"
case ActionResizeSouthEast:
return "ActionResizeSouthEast"
}
return ""
}
-41
View File
@@ -2,11 +2,9 @@ package widget
import (
"fmt"
"image"
"math/bits"
"gioui.org/gesture"
"gioui.org/io/pointer"
"gioui.org/io/system"
"gioui.org/layout"
"gioui.org/op/clip"
@@ -63,45 +61,6 @@ func (d *Decorations) Clickable(action system.Action) *Clickable {
return click
}
// LayoutResize lays out the resize actions.
func (d *Decorations) LayoutResize(gtx layout.Context, actions system.Action) {
cs := gtx.Constraints.Max
wh := gtx.Dp(10)
s := []struct {
system.Action
image.Rectangle
}{
{system.ActionResizeNorth, image.Rect(0, 0, cs.X, wh)},
{system.ActionResizeSouth, image.Rect(0, cs.Y-wh, cs.X, cs.Y)},
{system.ActionResizeWest, image.Rect(cs.X-wh, 0, cs.X, cs.Y)},
{system.ActionResizeEast, image.Rect(0, 0, wh, cs.Y)},
{system.ActionResizeNorthWest, image.Rect(0, 0, wh, wh)},
{system.ActionResizeNorthEast, image.Rect(cs.X-wh, 0, cs.X, wh)},
{system.ActionResizeSouthWest, image.Rect(0, cs.Y-wh, wh, cs.Y)},
{system.ActionResizeSouthEast, image.Rect(cs.X-wh, cs.Y-wh, cs.X, cs.Y)},
}
for i, data := range s {
action := data.Action
if actions&action == 0 {
continue
}
rsz := &d.resize[i]
rsz.Events(gtx.Metric, gtx, gesture.Both)
if rsz.Drag.Dragging() {
d.actions |= action
}
st := clip.Rect(data.Rectangle).Push(gtx.Ops)
if rsz.Hover.Hovered(gtx) {
action.Cursor().Add(gtx.Ops)
}
rsz.Drag.Add(gtx.Ops)
pass := pointer.PassOp{}.Push(gtx.Ops)
rsz.Hover.Add(gtx.Ops)
pass.Pop()
st.Pop()
}
}
// Perform updates the decorations as if the specified actions were
// performed by the user.
func (d *Decorations) Perform(actions system.Action) {
-3
View File
@@ -45,9 +45,6 @@ func (d DecorationsStyle) Layout(gtx layout.Context) layout.Dimensions {
r := clip.Rect{Max: dims.Size}
paint.FillShape(gtx.Ops, d.Background, r.Op())
decos.Add(gtx.Ops)
if !d.Decorations.Maximized() {
d.Decorations.LayoutResize(gtx, d.Actions)
}
return dims
}