glass/test_window_behavior.md
Cursor Agent 181bd2bcc4 Fix window resize and movement issues (#65)
- Fixed resize-header-window handler to properly center window without width increase
- Fixed movement clamping logic to prevent progressive restriction
- Added proper DPI handling to prevent pixelation
- Added comprehensive debug logging for troubleshooting
- Improved position tracking in animation system

Addresses:
- Unexpected width increase during long-press
- Progressive restriction of downward movement
- UI pixelation issues
2025-07-09 00:26:27 +00:00

4.1 KiB

Window Resize and Movement Issue Fix Test

Issues Fixed

1. Resizing Problem

Issue: When long-pressing on the application window, the width increases unexpectedly without user interaction to modify window dimensions.

Root Cause: The resize-header-window handler was using incorrect calculation for centering the window after resize, which caused cumulative positioning errors.

Fix Applied:

  • Improved the centering calculation to use the actual center point of the window
  • Added bounds checking to prevent window from going off-screen
  • Added safeguards to prevent resizing during animations or when already at target size
  • Added debug logging to track resize operations

2. Movement Constraint Problem

Issue: With each click, the downward movement range of the window becomes progressively more restricted. The window's ability to move toward the bottom of the screen decreases with each interaction.

Root Cause: The movement clamping logic was applying restrictive bounds checking that accumulated over multiple moves, progressively limiting the available movement area.

Fix Applied:

  • Replaced the restrictive Math.max/Math.min clamping with conditional clamping that only applies when actually needed
  • Improved the moveStep function to properly calculate bounds and only clamp when necessary
  • Fixed position tracking in the animation system to prevent drift
  • Added debug logging to track movement behavior

3. Pixelation Issue

Issue: UI elements appear pixelated or blurry.

Fix Applied:

  • Added proper DPI handling options in window creation
  • Added useContentSize: true to ensure proper content sizing
  • Added disableAutoHideCursor: true to prevent cursor-related rendering issues
  • Added experimentalFeatures: false for stable rendering

Testing Instructions

Test 1: Resize Behavior

  1. Start the application
  2. Switch between different header states (API key input, main header, permission setup)
  3. Verify that the window resizes smoothly and maintains proper centering
  4. Check that window width doesn't increase unexpectedly during normal operations
  5. Try long-pressing on the window and verify no unexpected width changes occur

Test 2: Movement Behavior

  1. Start the application with main header visible
  2. Use keyboard shortcuts to move the window in all directions (up, down, left, right)
  3. Move the window multiple times in the same direction
  4. Verify that the movement range doesn't become progressively restricted
  5. Test moving to different screen edges and verify consistent behavior
  6. Try dragging the window and verify smooth movement without restrictions

Test 3: Pixelation

  1. Start the application
  2. Check that all UI elements are crisp and clear
  3. Try moving the window between different displays (if available)
  4. Verify that text and icons remain sharp

Debug Information

The following debug logs have been added to help track issues:

  • [WindowManager] Resize request: WIDTHxHEIGHT - Tracks resize requests
  • [WindowManager] Current bounds: WIDTHxHEIGHT at (X, Y) - Shows current window bounds
  • [WindowManager] Already at target size, skipping resize - Prevents unnecessary operations
  • [MovementManager] Moving DIRECTION from (X, Y) - Tracks movement requests
  • [MovementManager] Clamped Y to top/bottom edge - Shows when clamping occurs
  • [MovementManager] Final position: (X, Y), Work area: ... - Shows final calculated position

Expected Behavior After Fix

  1. Window resizing should be smooth and maintain proper centering
  2. Window width should not increase unexpectedly during any operations
  3. Movement should be consistent with full range available at all times
  4. No progressive restriction of movement area should occur
  5. UI elements should appear crisp and clear without pixelation
  6. Debug logs should show proper bounds calculation and movement behavior

Files Modified

  • src/electron/windowManager.js - Fixed resize-header-window handler and added debug logging
  • src/electron/smoothMovementManager.js - Fixed moveStep function and animation position tracking

Branch

  • fix-window-resize-movement-issue

This fix addresses all three issues mentioned in the original GitHub issue #65.