Skip to content

Add support for canvas layouts and blank spacer zones#110

Open
ChaoticGood007 wants to merge 4 commits into
GnomeSnapExtensions:mainfrom
ChaoticGood007:feature/overlapping-canvas-layouts
Open

Add support for canvas layouts and blank spacer zones#110
ChaoticGood007 wants to merge 4 commits into
GnomeSnapExtensions:mainfrom
ChaoticGood007:feature/overlapping-canvas-layouts

Conversation

@ChaoticGood007

@ChaoticGood007 ChaoticGood007 commented Jun 17, 2026

Copy link
Copy Markdown

Overview

This PR implements support for custom Canvas / Overlapping Layouts (type: 2) in the gSnap layout editor, allowing users to define freely-positioned, overlapping window regions alongside standard Grid layouts. It adds a native dropdown dialog selector to choose the layout type when creating new layouts, drag-and-drop movement, edge/corner resizing, double-click zone creation, standard splitting/editing controls, and customizable overlap snapping preferences.


Key Features Added

1. Canvas / Overlapping Layout Type (type: 2)

  • Extends the layout schema with a canvas layout option (type: 2) supporting absolute coordinates (x, y, w, h) instead of traditional grid constraints.
  • Allows layouts to contain overlapping regions, freely placed anywhere in the work area.

2. Interactive Canvas Editor

  • Drag-and-Drop Moving: Drag anywhere in the center of a canvas zone to move it.
  • Edge/Corner Resizing: Drag borders (ns-resize, ew-resize) or corners (nwse-resize, nesw-resize) to resize zones with appropriate cursor feedback.
  • Double-Click to Spawn: Double-click on any empty space inside the editor background to instantly spawn a new zone.
  • Standard Controls: Left-Click a zone to split it vertically, Middle-Click to split it horizontally, and Right-Click to remove/delete it.

3. Layout Type Selection Dropdown in Creation Dialog

  • Adds a native GNOME Shell PopupMenu dropdown menu selector to the layout creation dialog (where previously only layout naming was supported).
  • When creating a new layout, users can choose between "Grid Layout" and "Canvas Layout".
  • The selector is integrated into the dialog with the label "Layout Type:" on the left and the selector button on the right.
  • Connected a PopupMenuManager to manage overlay focus and prevent pointer/click lockouts.
  • Ensures all popup actors are properly disposed of on cancel/confirm click to avoid memory leaks in Main.uiGroup.

4. Overlap Snapping Strategy Preference Setting

  • Adds a new preference option under the basics settings tab (Overlap Snapping Strategy) to configure how overlapping zones are matched:
    • First Match (default): Snaps to the first matched canvas zone.
    • Closest Center: Snaps to the zone whose center coordinate is mathematically closest to the mouse pointer, avoiding awkward bounding box merges during overlapping zone dragging.

Technical Implementations

  • Cursor Constraints: Clamps drags to keep zones inside the bounds of the work area monitor, ensuring canvas layout items are never moved off-screen.
  • Typings Expansion: Added GObject mapping for cursor_type to StWidget inside gnometypes.ts for clean TypeScript compilation.
  • Documentation: Updated README.md to detail both Grid and Canvas editing controls.

Verification & Testing

  1. Click the gSnap panel indicator and choose Create New Layout.
  2. Select Canvas Layout from the new dropdown selector.
  3. Open the Edit Layout mode:
    • Double-click empty canvas space to add zones.
    • Resize and move zones using mouse drags.
    • Save layout and verify window snapping works correctly.

@ChaoticGood007 ChaoticGood007 marked this pull request as draft June 17, 2026 14:52
@ChaoticGood007 ChaoticGood007 marked this pull request as ready for review June 17, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant