Skip to content

Commit

Permalink
cfg, ctl, x11: Added support for negative window coordinates.
Browse files Browse the repository at this point in the history
  • Loading branch information
sathya-pramodh committed Oct 8, 2023
1 parent 9067e72 commit f8ee7a2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion internal/cfg/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ type Group struct {

// Rectangle is a rectangle. That's it.
type Rectangle struct {
X, Y, W, H uint32
X, Y int32
W, H uint32
}

// getCpuCount finds the user's CPU count through /sys.
Expand Down
8 changes: 4 additions & 4 deletions internal/ctl/moving.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ func (m *MovingWall) getHitbox(input Input) (hitbox, bool) {
x, y := m.proj.ToVideo(input.X, input.Y)
var hits []hitbox
for _, hitbox := range m.hitboxes {
a := x >= int(hitbox.box.X) && x <= int(hitbox.box.X+hitbox.box.W)
b := y >= int(hitbox.box.Y) && y <= int(hitbox.box.Y+hitbox.box.H)
a := x >= int(hitbox.box.X) && x <= int(hitbox.box.X)+int(hitbox.box.W)
b := y >= int(hitbox.box.Y) && y <= int(hitbox.box.Y)+int(hitbox.box.H)
if a && b && hitbox.clickable {
hits = append(hits, hitbox)
}
Expand Down Expand Up @@ -304,8 +304,8 @@ func (m *MovingWall) layoutGroup(group cfg.Group, startZ int, instances []int) {
break
}
box := cfg.Rectangle{
X: group.Space.X + (x * instWidth),
Y: group.Space.Y + (y * instHeight),
X: group.Space.X + int32(x*instWidth),
Y: group.Space.Y + int32(y*instHeight),
W: instWidth,
H: instHeight,
}
Expand Down
4 changes: 2 additions & 2 deletions internal/ctl/projector.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (p *ProjectorController) updateProjector(win xproto.Window) error {
}
p.display.W = uint32(p.scale * float64(p.BaseWidth))
p.display.H = uint32(p.scale * float64(p.BaseHeight))
p.display.X = uint32(p.winWidth/2) - (p.display.W / 2)
p.display.Y = uint32(p.winHeight/2) - (p.display.H / 2)
p.display.X = int32(p.winWidth/2) - int32(p.display.W/2)
p.display.Y = int32(p.winHeight/2) - int32(p.display.H/2)
return nil
}
4 changes: 2 additions & 2 deletions internal/x11/x11.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,12 @@ func (c *Client) GrabPointer(win xproto.Window, confine bool) error {
}

// MoveWindow moves and resizes the given window.
func (c *Client) MoveWindow(win xproto.Window, x, y, w, h uint32) {
func (c *Client) MoveWindow(win xproto.Window, x, y int32, w, h uint32) {
xproto.ConfigureWindow(
c.conn,
win,
maskWindow,
[]uint32{x, y, w, h},
[]uint32{uint32(x), uint32(y), w, h},
)
}

Expand Down

0 comments on commit f8ee7a2

Please sign in to comment.