()
| 1454 | } |
| 1455 | |
| 1456 | func (wm *WindowManager) createTilingSpace() { |
| 1457 | // look at all windows and if it has the property _NET_WM_STRUT_PARTIAL (what most bars have) it means that it should be worked around |
| 1458 | windows, _ := xproto.QueryTree(wm.conn, wm.root).Reply() |
| 1459 | X := 0 |
| 1460 | Y := 0 |
| 1461 | width := wm.width |
| 1462 | height := wm.height |
| 1463 | |
| 1464 | for _, window := range windows.Children { |
| 1465 | attributes, err := xproto.GetWindowAttributes(wm.conn, window).Reply() |
| 1466 | if err != nil { |
| 1467 | continue |
| 1468 | } |
| 1469 | if attributes.MapState == xproto.MapStateViewable { |
| 1470 | atom := wm.atoms["_NET_WM_STRUT_PARTIAL"] |
| 1471 | prop, err := xproto.GetProperty(wm.conn, false, window, atom, xproto.AtomCardinal, 0, 12).Reply() |
| 1472 | |
| 1473 | if err != nil || prop == nil || prop.ValueLen < 4 { |
| 1474 | continue |
| 1475 | } |
| 1476 | |
| 1477 | vals := prop.Value |
| 1478 | if len(vals) < 16 { |
| 1479 | continue // need at least 4 uint32s |
| 1480 | } |
| 1481 | left, right, top, bottom := wm.getBar(vals) |
| 1482 | |
| 1483 | // create space to work around bar (if there is one) |
| 1484 | X = left |
| 1485 | Y = top |
| 1486 | width = wm.width - left - right |
| 1487 | height = wm.height - top - bottom |
| 1488 | |
| 1489 | // TODO: support multiple bars |
| 1490 | break |
| 1491 | } |
| 1492 | } |
| 1493 | |
| 1494 | fmt.Println("tiling container:", "X:", X, "Y:", Y, "Width:", width, "Height:", height) |
| 1495 | wm.tilingspace = Space{ |
| 1496 | X: X + int(wm.config.OuterGap), |
| 1497 | Y: Y + int(wm.config.OuterGap), |
| 1498 | Width: (width - 6) - (int(wm.config.OuterGap) * 2), |
| 1499 | Height: (height - 6) - (int(wm.config.OuterGap) * 2), |
| 1500 | } |
| 1501 | } |
| 1502 | |
| 1503 | func (wm *WindowManager) fitToLayout() { |
| 1504 | if !wm.currWorkspace.tiling { |
no test coverage detected