Skip to content

Implement focus management for windows #407

@pbalduino

Description

@pbalduino

Summary

Implement window focus management, including click-to-focus, keyboard event routing, and focus visual indicators.

Goals

  • Click-to-focus behavior
  • Keyboard event routing to focused window
  • Focus visual feedback
  • Focus-follows-mouse (optional)
  • Tab cycling between windows

Implementation

Focus Management

```c
struct window *focused_window = NULL;

void wm_focus_window(struct window *w) {
if (focused_window) {
focused_window->focused = 0;
wm_redraw_decoration(focused_window); // Inactive color
}

focused_window = w;
w->focused = 1;
wm_raise_window(w);
wm_redraw_decoration(w);  // Active color

send_focus_event(w);

}

void wm_handle_mouse_click(int x, int y) {
struct window *w = wm_find_window_at(x, y);
if (w && w != focused_window) {
wm_focus_window(w);
}
}
```

Timeline

Total: 1-2 weeks

Definition of Done

  • Click-to-focus works
  • Keyboard events go to focused window
  • Visual focus indicator
  • Tab cycling works
  • Focus events sent to applications

Dependencies

See docs/road/road_to_gui.md for complete roadmap.

Metadata

Metadata

Assignees

Labels

GUIGraphical user interface componentsenhancementNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions