Feature: Center window, cycle monitors, and snap to center
Summary
Three related window management features that improve multi-monitor workflows and window positioning:
- Center window on screen (center_window_key) — keybinding to center the active window within the current monitor's workarea, respecting panel struts. Skips fullscreen, maximized, and shaded windows. Uses frameExtent* APIs for correct CSD handling.
- Move window to next/previous monitor (move_window_next_monitor_key, move_window_prev_monitor_key) — keybinding to cycle the active window through monitors in physical left-to-right order (sorted by X position, then Y). Wraps around at the ends. Reuses the existing clientMoveToMonitor() for the actual move, preserving maximized/fullscreen/tiled state.
- Snap to center on drag (snap_to_center) — opt-in magnetic snap that pulls a window to the exact center of the current monitor's workarea when dragged near it. Both axes must be within snap_width * 2 of center to trigger, producing a "pop into place" feel. Off by default. Configurable via a new checkbox in Window Manager Tweaks > Accessibility.
Motivation
Moving windows between monitors currently requires either directional move-to-monitor bindings (which need physical adjacency) or external tools like xdotool/wmctrl scripts. Index-based cycling is simpler for common setups — "send this window to the next screen" without caring about direction.
Centering a window is a common operation with no built-in support. The snap-to-center feature complements edge snapping for users who frequently center windows.
Implementation
All features follow existing xfwm4 patterns:
- Enum in settings.h, parseShortcut() in settings.c, dispatch in events.c
- Center window implemented in placement.c following centerPlacement() patterns
- Monitor cycling implemented in client.c reusing clientMoveToMonitor()
- Snap to center implemented in moveresize.c within clientSnapPosition()
- Settings checkbox added to the tweaks dialog glade file with xfconf_g_property_bind
A companion merge request for libxfce4ui adds the shortcut name entries so the new keybindings appear in the keyboard shortcuts settings editor.
Changes
xfwm4 (11 files):
- src/settings.h — enum values + snap_to_center in XfwmParams
- src/settings.c — parseShortcut() calls, setting load/update
- src/events.c — dispatch cases
- src/client.c, src/client.h — clientMoveToMonitorByIndex()
- src/placement.c, src/placement.h — clientCenter()
- src/moveresize.c — center snap in clientSnapPosition()
- defaults/defaults — snap_to_center=false
- settings-dialogs/tweaks-settings.c, xfwm4-tweaks-dialog.glade — checkbox
libxfce4ui (1 file):
- libxfce4kbd-private/xfce-shortcuts-xfwm4.c — 3 shortcut name entries