Skip to content

Commit

Permalink
fix: consider surface rotation when reporting surface overflows grid #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Jan 17, 2025
1 parent d91f612 commit 7de0ca5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions companion/lib/Surface/Controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ export class SurfaceController extends EventEmitter<SurfaceControllerEvents> {
hasFirmwareUpdates: null,

size: config.gridSize || null,
rotation: config.config.rotation,
offset: { columns: config?.config?.xOffset ?? 0, rows: config?.config?.yOffset ?? 0 },
}

Expand Down
1 change: 1 addition & 0 deletions shared-lib/lib/Model/Surfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface ClientSurfaceItem {
hasFirmwareUpdates: SurfaceFirmwareUpdateInfo | null

size: RowsAndColumns | null
rotation: SurfaceRotation | null
offset: RowsAndColumns | null
}

Expand Down
12 changes: 10 additions & 2 deletions webui/src/Stores/SurfacesStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,18 @@ export class SurfacesStore {
for (const surface of group.surfaces) {
if (!surface.size || !surface.offset) continue

// Determine the size, after rotation
let { rows, columns } = surface.size
if (surface.rotation === 'surface-90' || surface.rotation === 'surface90') {
const tmp = rows
rows = columns
columns = tmp
}

const minX = surface.offset.columns
const minY = surface.offset.rows
const maxX = minX + surface.size.columns - 1
const maxY = minY + surface.size.rows - 1
const maxX = minX + columns - 1
const maxY = minY + rows - 1

if (minX < bounds.minColumn || minY < bounds.minRow || maxX > bounds.maxColumn || maxY > bounds.maxRow) {
overflowingSurfaces.push(surface)
Expand Down

0 comments on commit 7de0ca5

Please sign in to comment.