Add border_size_dirty flag to avoid unnecessary shape queries - #39
Open
jEsuSdA wants to merge 1 commit into
Open
Add border_size_dirty flag to avoid unnecessary shape queries#39jEsuSdA wants to merge 1 commit into
jEsuSdA wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a per-window
border_size_dirtyflag soborder_size()is only called for windows whose shape has actually changed, rather than for all windows wheneverclip_changedis true.Problem
border_size()queries the X server for the window shape (viaXFixesCreateRegionFromWindoworXShapeQueryExtents). This is expensive. Currently, whenclip_changedis true (which happens on map, unmap, restack, and configure events), all windows have theirborder_sizedestroyed and recreated, even if their shape hasn't changed.Solution
Add a
Bool border_size_dirtyfield to thewinstruct. The flag is set:map_win()when a window becomes viewabledo_configure_win()whenconfigure_size_changedis trueIn
paint_all(), the window'sborder_sizeis only destroyed and rebuilt whenclip_changedis true or whenborder_size_dirtyis set for that specific window. The flag is cleared after rebuilding.Scope
cm-window.h— adds oneBoolfield to thewinstructfastcompmgr.c— sets the flag inmap_win()anddo_configure_win(), checks it inpaint_all()make clean && makeproduces zero warnings, zero errorsImpact
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->destroyedguard before callingborder_size(), preventing a potential shape query on a window that has already been destroyed.