MCPcopy Create free account
hub / github.com/BobdaProgrammer/doWM / resizeTiledX

Method resizeTiledX

wm/window_manager.go:1193–1253  ·  view source on GitHub ↗
(increase bool, ev xproto.KeyPressEvent)

Source from the content-addressed store, hash-verified

1191}
1192
1193func (wm *WindowManager) resizeTiledX(increase bool, ev xproto.KeyPressEvent) bool{
1194 geom, err := xproto.GetGeometry(wm.conn, xproto.Drawable(ev.Child)).Reply()
1195 if err != nil{
1196 return false
1197 }
1198 X := uint16(geom.X - int16(wm.config.Gap)-int16(wm.tilingspace.X))
1199 W := geom.Width + uint16(wm.config.Gap*2)
1200 if math.Abs(float64(uint16(wm.tilingspace.X+wm.tilingspace.Width)-(X+W)))<=10{
1201 return false
1202 }
1203
1204 var resizeLayout ResizeLayout
1205 var ok bool = true
1206 for _, win := range wm.currWorkspace.windowList{
1207 geomwin, err := xproto.GetGeometry(wm.conn, xproto.Drawable(win.id)).Reply()
1208 if err != nil {continue}
1209 winX := uint16(geomwin.X - int16(wm.config.Gap)-int16(wm.tilingspace.X))
1210 winY := uint16(geomwin.Y - int16(wm.config.Gap)-int16(wm.tilingspace.Y))
1211 winH := geomwin.Height + uint16(wm.config.Gap*2)
1212 winW := geomwin.Width + uint16(wm.config.Gap*2)
1213 // if diff between ends of windows it less than five, they are same column
1214 if math.Abs( float64( (X+W)-(winX+winW) ) ) <= 10{
1215 if increase{
1216 winW+=uint16(wm.config.Resize)
1217 }else{
1218 winW-=uint16(wm.config.Resize)
1219 }
1220 fmt.Println(winW)
1221 }else if math.Abs( float64( int(winX)-(int(X)+int(W)) ) ) <= 10 {
1222 if increase{
1223 winX+=uint16(wm.config.Resize)
1224 winW-=uint16(wm.config.Resize)
1225 if winW < 50{
1226 ok = false
1227 break
1228 }
1229 }else{
1230 winX -= uint16(wm.config.Resize)
1231 winW += uint16(wm.config.Resize)
1232 }
1233 }
1234
1235 fmt.Println(winX, winY, winW, winH)
1236 resizeLayout.Windows = append(resizeLayout.Windows, RLayoutWindow{
1237 X: winX,
1238 Y: winY,
1239 Width: winW,
1240 Height: winH,
1241 })
1242
1243 }
1244
1245 if ok{
1246 wm.currWorkspace.resized = true
1247 wm.currWorkspace.resizedLayout = resizeLayout
1248 wm.fitToLayout()
1249 return true
1250 }else{

Callers 1

RunMethod · 0.95

Calls 1

fitToLayoutMethod · 0.95

Tested by

no test coverage detected