Skip to content

Add border_size_dirty flag to avoid unnecessary shape queries - #39

Open
jEsuSdA wants to merge 1 commit into
tycho-kirchner:masterfrom
jEsuSdA:fix/border-size-dirty-flag
Open

Add border_size_dirty flag to avoid unnecessary shape queries#39
jEsuSdA wants to merge 1 commit into
tycho-kirchner:masterfrom
jEsuSdA:fix/border-size-dirty-flag

Conversation

@jEsuSdA

@jEsuSdA jEsuSdA commented Jul 2, 2026

Copy link
Copy Markdown

Summary

Adds a per-window border_size_dirty flag so border_size() is only called for windows whose shape has actually changed, rather than for all windows whenever clip_changed is true.

Problem

border_size() queries the X server for the window shape (via XFixesCreateRegionFromWindow or XShapeQueryExtents). This is expensive. Currently, when clip_changed is true (which happens on map, unmap, restack, and configure events), all windows have their border_size destroyed and recreated, even if their shape hasn't changed.

Solution

Add a Bool border_size_dirty field to the win struct. The flag is set:

  • in map_win() when a window becomes viewable
  • in do_configure_win() when configure_size_changed is true

In paint_all(), the window's border_size is only destroyed and rebuilt when clip_changed is true or when border_size_dirty is set for that specific window. The flag is cleared after rebuilding.

Scope

  • cm-window.h — adds one Bool field to the win struct
  • fastcompmgr.c — sets the flag in map_win() and do_configure_win(), checks it in paint_all()
  • make clean && make produces zero warnings, zero errors

Impact

Reduces the number of expensive X server shape queries, especially when many windows are visible and only one window changes (e.g. a new window is mapped or a single window is resized). The exact reduction depends on the number of visible windows and the frequency of clip changes.

Also includes a !w->destroyed guard before calling border_size(), preventing a potential shape query on a window that has already been destroyed.

…y frame

Currently, when clip_changed is true, ALL windows have their border_size
region destroyed and recreated via border_size(), which queries the X server
for the window shape. This happens on map, unmap, restack, and configure
events, even for windows whose shape hasn't actually changed.

Add a per-window border_size_dirty flag that is set when a window is mapped
or when its size changes (configure_size_changed). In paint_all(), the
border_size is only destroyed and rebuilt for windows whose dirty flag is
set, rather than for all windows whenever clip_changed is true.

This reduces the number of expensive X server shape queries, especially
when many windows are visible and only one window changes (e.g. a new
window is mapped or a single window is resized).

Also adds a !w->destroyed guard before calling border_size(), preventing
a potential shape query on a window that has already been destroyed.
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