Simplified the _removeLastZone() function to be more efficient:
Before:
- Removed last zone from array
- Destroyed and recreated entire editor interface (_cancelEditor + startEditor)
- Recreated all remaining zones from scratch
- Caused visual flicker and was inefficient
- Could leave dangling event listeners
After:
- Remove last zone from zones array
- Remove and destroy only the last zone actor
- No need to update zone numbers (removing last zone doesn't affect other numbers)
- No editor recreation needed
Benefits:
- No visual flicker
- Much more efficient (O(1) instead of O(n))
- Cleaner code (15 lines vs 50+ lines)
- No risk of dangling event listeners from recreation
- Better user experience
Fixes TODO item #2.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fixed JavaScript syntax error that prevented extension from loading.
The outer else block in _onButtonPress (line 205) was missing its
closing brace, causing "expected expression, got ','" error.
Added missing closing brace after the inner if-else block.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implemented comprehensive zone resizing functionality in the zone editor:
Features:
- Detects when mouse is near zone edges/corners (10px threshold)
- Supports all 8 resize handles: N, S, E, W, NE, NW, SE, SW
- Visual feedback with cyan highlight during resize
- Real-time dimension label updates while resizing
- Enforces minimum zone size (20x20 pixels)
- Constrains resizing to monitor boundaries
- Maintains zone data structure integrity during resize
Implementation details:
- Added state tracking: isResizingZone, resizingZoneIndex, resizeEdge, originalZoneBounds
- New method _findResizeEdge() for edge/corner detection
- Enhanced _onButtonPress() to prioritize resize over move
- Extended _onMotion() with resize delta calculations for all 8 directions
- Updated instruction label to include resize guidance
- Updated TODO.md to mark item #17 as completed
The zone editor now supports create, move, and resize operations with
clear visual feedback for each mode (green=normal, yellow=moving, cyan=resizing).
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Feature #15 - Show Zone Dimensions:
- Display real-time dimensions while drawing zones
- Show width x height in both pixels and percentages
- Display position coordinates (x, y)
- Dimension label follows cursor with 15px offset
- Label positioned to stay within monitor bounds
- Automatically cleaned up when zone drawing completes
Feature #16 - Move/Reposition Zones:
- Click on existing zones to select and move them
- Yellow highlight when zone is being moved (vs green for new zones)
- Drag zones to new positions while maintaining size
- Constrain movement to monitor bounds (can't move outside screen)
- Real-time update of zone coordinates in data structure
- Green color restored after move completes
Editor Improvements:
- Added zoneActors array to track zone widgets for moving
- Updated instruction label to mention zone moving
- Enhanced _findZoneAtPosition() helper to detect clicks on zones
- Improved _removeLastZone() to properly clean up zone actors
- Better cleanup in _cancelEditor() to prevent memory leaks
- Track moving state (isMovingZone, movingZoneIndex, moveOffsetX/Y)
UX Enhancements:
- Separate visual feedback for creating (green) vs moving (yellow) zones
- Smooth drag experience with proper offset tracking
- Dimensions update in real-time during zone creation
- Clear visual distinction between zone operations
Fixes TODO items #15 and #16
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
New Features:
- Created settings-schema.json with customizable options:
* Zone appearance (border width, colors, opacity)
* Show/hide zone numbers
* Enable/disable Shift+Drag snapping
* Enable/disable keyboard snapping (Super+Ctrl+1-9)
* Notification on window snap
- Created settings.js with custom UI:
* View all saved custom layouts
* Delete custom layouts with confirmation dialog
* Export layouts to JSON files
* Visual list with layout info (name, zone count, ID)
* Empty state when no custom layouts exist
Extension Integration:
- Integrated Settings API into extension.js
- Zone overlay now respects user-configured colors and opacity
- Border width is customizable
- Zone numbers can be toggled on/off
- Shift-drag and keyboard snap can be disabled via settings
- Optional notifications when windows snap to zones
- Settings properly cleaned up on extension destroy
UI/UX Improvements:
- Professional settings panel accessible from System Settings → Extensions
- Layout management without editing JSON files manually
- Real-time application of visual settings
- Destructive actions (delete) require confirmation
- Export functionality for sharing layouts
Fixes TODO item #12 - Settings Panel
Fixes TODO item #13 - Update Metadata (already done)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Features:
- Custom layouts now saved to ~/.local/share/gridsnap/layouts.json
- Layouts automatically loaded on extension initialization
- Layouts persist across Cinnamon restarts and extension reloads
- Only custom layouts saved to file (default layouts remain in code)
- Added GLib and Gio imports for file operations
- Error handling for file read/write operations
Technical implementation:
- _loadLayouts(): Merges default layouts with saved custom layouts on startup
- _saveLayouts(): Extracts and saves only custom-* layouts to JSON file
- Automatically creates storage directory if it doesn't exist
- Called when user saves a layout in the graphical editor
Fixes TODO item #1 - Custom Layout Persistence
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Major fixes:
- Fix keybinding closure bug causing all zones to map to zone 9
- Change keybindings from Super+Numpad to Super+Ctrl+1-9 for laptop compatibility
- Fix shift-drag detection by implementing continuous modifier polling during window drag
- Fix window object reference by using global.display.focus_window
- Fix window API compatibility (use property checks instead of get_maximized())
- Correct grab-op-begin/end signal handler parameters
Technical improvements:
- Add modifier polling (50ms interval) during window drag to detect Shift key press/release
- Use Mainloop.idle_add to defer window resize operations
- Remove debug logging for production use
- Improve error handling and cleanup in destroy() method
The extension now fully supports:
- Shift-drag window snapping with visual zone overlay
- Keyboard shortcuts for direct zone snapping (Super+Ctrl+1-9)
- Zone overlay toggle (Super+Z)
- Layout cycling (Super+Shift+Z)
- Graphical zone editor (Super+Shift+E)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Implemented visual zone editor (Super+Shift+E)
- Draw zones with mouse click-and-drag
- Ctrl+S to save, Ctrl+C to cancel, Delete to remove last zone
- Updated README with zone editor documentation
- Added CSS styles for editor interface
- Custom layouts are now created without code editing