Skip to content

Refactor#13

Draft
erikinkinen wants to merge 53 commits into
cutiefrom
feature/sid/refactor
Draft

Refactor#13
erikinkinen wants to merge 53 commits into
cutiefrom
feature/sid/refactor

Conversation

@erikinkinen

Copy link
Copy Markdown
Member

This is a WIP effort to refactor the codebase for better maintainability.

- Add setupEnvironmentVariables() method to CwlCompositor class
- Move all environment variable configuration from create() to new method
- Improve code organization and readability by consolidating env setup

This refactoring makes the environment setup more testable and reusable
while keeping the create() method focused on its primary responsibilities.
- Add braces to nested if-else statements in workspace.cpp updateViewList()
- Add braces to nested if-else statements in view.cpp onDestinationSizeChanged()
- Eliminates compiler warnings and improves code clarity
- No functional changes, syntax-only improvements

Fixes compiler warnings about dangling else statements that could lead
to ambiguous code structure.
Consolidate repetitive process launching code into launchCutieComponent()
method, reducing code duplication and improving error handling.
- Extract 18 lines of animation initialization into dedicated setupAnimations() method
- Consolidate blur, unblur, launcher open/close animation configuration
- Improve constructor readability and separation of concerns
- Maintain exact same animation behavior and timing (250ms duration)
Apply consistent code formatting across compositor, gesture handling,
view management, and workspace modules for improved readability
and maintainability.
- Extract handleLeftEdgeGesture() and handleRightEdgeGesture() for home navigation
- Extract handleBottomEdgeGesture() and handleTopEdgeGesture() for launcher control
- Extract handleCornerGesture() for keyboard gesture handling
- Simplify main handleGesture() method to use clean switch statement dispatch
- Reduce cyclomatic complexity from 160+ lines to focused 20-40 line methods
- Improve code maintainability and testability while preserving all functionality
- Add launchCutieComponentWithRetry() with configurable retry logic
- Implement component criticality classification system
- Add comprehensive error reporting and logging levels
- Track failed components for diagnostic purposes
- Use smart retry delays and fallback strategies
- Enhance system robustness for component launch failures
- Differentiate between critical (home, panel) and non-critical components
- Provide detailed error messages for debugging and system administration

BREAKING CHANGE: Component launch behavior now includes automatic retries
… class

- Create CwlProcessManager class to consolidate component lifecycle management
- Move process launching logic from CwlCompositor to dedicated manager
- Add comprehensive error handling and retry mechanisms with signals
- Remove process management code from cutie-wlc.cpp
- Improve separation of concerns and maintainability
- Add support for configurable critical component tracking

This addresses the high code duplication in process launching across the
CwlCompositor::create() method and provides better organization for
component dependency management.
Extract signal/slot connections from constructor and create() method
into dedicated setupSignalConnections() and setupWorkspaceConnections()
methods for better code organization.
…ethods

- Break down complex onLayerSurfaceDataChanged() method into focused helpers
- Add calculateInitialPosition() for default centered positioning
- Add calculateVerticalPosition() for top/bottom anchor handling
- Add calculateHorizontalPosition() for left/right anchor handling
- Improve code readability and maintainability
- Reduce method complexity from 40+ lines to 4 focused functions
- Preserve existing positioning behavior and anchor logic

The complex positioning calculations are now separated into logical units,
making the code easier to understand, test, and maintain while keeping
the same functionality for layer shell surface positioning.
…hods

- Break down complex paintGL() method into logical rendering phases
- Add setupRenderingContext() for OpenGL state initialization
- Add calculateViewOpacity() for view-specific opacity calculations
- Add renderViews() for coordinated view rendering with opacity
- Improve code readability by separating rendering concerns
- Reduce method complexity from 40+ lines to focused functions
- Preserve existing rendering behavior and visual effects

The rendering logic is now organized into clear phases: context setup,
opacity calculation, and view rendering. This makes the rendering
pipeline easier to understand, optimize, and extend with new features.
Create dedicated gesture manager class to extract gesture handling
logic from CwlCompositor. Adds placeholder methods and integration
infrastructure for future gesture logic migration.
- Move handleLeftEdgeGesture, handleRightEdgeGesture, handleTopEdgeGesture,
  and handleBottomEdgeGesture from CwlCompositor to new CwlGestureManager class
- Add compositor accessor methods for animation control and state access
- Implement delegation pattern: CwlCompositor::handleGesture() now routes to gesture manager
- Remove ~120 lines of gesture logic from compositor, improving separation of concerns
- Add required includes for GlWindow and InputMethodManagerV2 access
- Maintain full gesture functionality while achieving cleaner architecture
- Move handleCornerGesture() from CwlCompositor to CwlGestureManager
- Remove gesture handling logic from compositor class
- Maintain functionality through compositor delegation pattern
- Part of gesture refactoring plan

This continues the separation of concerns between gesture detection
and compositor responsibilities, making the codebase more modular
and maintainable.
…ure manager

- Update all handleGesture() calls in gesture.cpp to use gestureManager()
- Add public gestureManager() getter method to CwlCompositor
- Include gesture-manager.h for complete type definitions
…ling

* Create IGestureAction interface with execute/canExecute/actionName methods
* Add EdgeGestureAction and CornerGestureAction base classes for common patterns
* Implement concrete action classes for all gesture types:
  - LeftEdgeGestureAction, RightEdgeGestureAction
  - TopEdgeGestureAction, BottomEdgeGestureAction
  - BottomCornerGestureAction
* Integrate action objects into CwlGestureManager with proper memory management
* Extract all gesture logic from direct implementation to action delegation
* Add comprehensive documentation and Qt object hierarchy support

This establishes the foundation for gesture-to-action mapping and runtime
configuration while achieving loose coupling between gesture detection and
action execution as specified in the refactoring plan.
Add centralized gesture mapping system to CwlGestureManager:
- Introduce GestureType enum for standardized gesture identification
- Create GestureKey struct with custom hash function for QHash compatibility
- Implement gesture registry using QHash<GestureKey, IGestureAction*>
- Add runtime configuration methods for dynamic gesture remapping
- Support both edge and corner gesture mapping with fallback to legacy system
- Enable dynamic gesture configuration through mapping management API
Add comprehensive gesture state tracking and lifecycle management:
- Define GestureState enum with 6 states (IDLE→DETECTING→ACTIVE→COMPLETED/FAILED)
- Implement ActiveGesture struct for tracking gesture instances
- Add state transition methods (startGesture, updateGestureState, cancelGesture)
- Implement priority-based conflict resolution system
- Add automatic cleanup with configurable timeouts
- Provide gesture introspection APIs (getActiveGestures, hasConflicts)

This enhances gesture robustness by preventing conflicts, managing
cancellation scenarios, and providing better lifecycle control.
…system

- Fix include statements to follow project conventions:
  - Use angle brackets for system/framework headers
  - Use quotes for local project headers
- Add comprehensive Doxygen documentation to gesture.h
  - Document enums, classes, methods, and member variables
  - Explain gesture detection flow and coordination with manager
  - Add file-level documentation describing system architecture
- Improve code clarity and maintainability in gesture subsystem
…tory

- Move gesture.{h,cpp}, gesture-manager.{h,cpp}, and gesture-action.{h,cpp} to src/gesture/
- Update CMakeLists.txt to reflect new file locations and add gesture include directory
- Fix include paths in cutie-wlc.cpp and glwindow.h for new directory structure
@erikinkinen erikinkinen force-pushed the feature/sid/refactor branch 3 times, most recently from ede8bd8 to e127a22 Compare September 21, 2025 16:55
…er class

- Create new CwlAnimationController class to centralize animation management
- Move blur and launcher animation logic from CwlCompositor to controller
- Add comprehensive Doxygen documentation for animation controller
- Update CMakeLists.txt to include new animation controller files
- Remove animation-related member variables and methods from CwlCompositor
- Implement delegation pattern for animation control methods
- Maintain existing API compatibility through compositor wrapper methods

This refactoring improves code organization by separating animation concerns
from the main compositor logic, making the codebase more maintainable and
following the single responsibility principle established by the gesture
system reorganization.
…memory safety

- Convert raw pointer members to appropriate smart pointers:
  - std::unique_ptr for owned objects (managers, controllers, components)
  - QScopedPointer for Qt-owned resources (XdgShell, LayerShell, Output)
  - QPointer for safe weak references to QObject instances
- Update constructor initialization to use std::make_unique and proper RAII
- Refactor member access to use .get() for smart pointer dereference
- Eliminate manual memory management and improve resource lifecycle safety
- Add necessary smart pointer includes (<memory>, <QScopedPointer>)

This change significantly improves memory safety by preventing resource
leaks and ensuring proper cleanup without changing existing functionality.
- Add OpenGL RAII wrapper classes in src/opengl/opengl-guards.{h,cpp}
  - OpenGLFramebufferGuard: automatic framebuffer binding/unbinding
  - OpenGLTextureBlitterGuard: texture blitter lifecycle management
  - OpenGLStateGuard: OpenGL state save/restore functionality
- Integrate RAII wrappers throughout rendering pipeline
- Add robust validation across animation, rendering, and protocol layers
- Implement static cast safety and OpenGL context validation
- Enhance process management with exception handling and retry logic
- Add comprehensive null pointer checks and graceful error recovery

Significantly improves compositor stability and prevents crashes from
invalid operations and resource access issues.
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