Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache _NET_WM_STATE property and add rule target wm_state #549

Open
wants to merge 3 commits into
base: next
Choose a base branch
from

Conversation

tryone144
Copy link
Collaborator

@tryone144 tryone144 commented Nov 29, 2020

Cache all entries of the _NET_WM_STATE property for each window. This allows the addition of a new rule-target wm_state to match against the cached property with a string analogous to window_type:

opacity-rule = [ "0:wm_state = 'hidden'" ];

See #512 (comment) for more details on that.

Resolves #512.
Related: #550

TODO

…cified

When matching against custom window properties or atoms perform the
matching against all available values (currently hardcoded to a max. of 10)
using logical OR if no index is specified.

This should help when an atom has multiple values and you only want to
check against any of these — e.g. hiding windows with state `hidden`:
`--opacity-rule "0:_NET_WM_STATE@32a *= '_NET_WM_STATE_HIDDEN'"` —
without having to explicitly specify each index separately.
Keep track of the `_NET_WM_STATE` property for each managed window. Use
the cached state to determine if window is fullscreen instead of
querying the Xserver every time.
…ATE` in string

New predefined target `wm_state` for rule-based matching. Matches
against the cached `_NET_WM_STATE` property of a window in string
representation.

NOTE: `wm_state = 'fullscreen'` is not neccessarily identical to
`fullscreen`, and `wm_state = 'focused'` is not identical to `focused`.
@codecov
Copy link

codecov bot commented Nov 29, 2020

Codecov Report

Merging #549 (dac6785) into next (fb38bf0) will increase coverage by 0.28%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             next     #549      +/-   ##
==========================================
+ Coverage   38.21%   38.50%   +0.28%     
==========================================
  Files          46       46              
  Lines        9056     9123      +67     
==========================================
+ Hits         3461     3513      +52     
- Misses       5595     5610      +15     
Impacted Files Coverage Δ
src/atom.h 100.00% <ø> (ø)
src/common.h 66.66% <ø> (ø)
src/win.h 50.00% <ø> (ø)
src/c2.c 36.70% <34.16%> (+1.37%) ⬆️
src/win.c 69.51% <95.45%> (+0.39%) ⬆️
src/event.c 69.97% <100.00%> (+0.33%) ⬆️
src/picom.c 68.79% <100.00%> (+0.39%) ⬆️

w->wm_state = wid_get_prop_wm_state(ps, w->client_win);

if (w->wm_state != wmstate_old) {
win_on_factor_change(ps, w);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should set the FACTOR_CHANGE flag instead.

Copy link
Collaborator Author

@tryone144 tryone144 Nov 29, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, missed that one. Same would apply in win_update_wintype() above.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we're at it: I think win_update_opacity_target can be replaced as well.

@yshui
Copy link
Owner

yshui commented Nov 29, 2020

@tryone144 Can you separate the "matching against all indices" commit into a different PR? The other commits look fine, but I want to avoid the 10 properties hard limit if we can.

src/win.c Show resolved Hide resolved
src/c2.c Show resolved Hide resolved
@tryone144
Copy link
Collaborator Author

tryone144 commented Nov 29, 2020

@tryone144 Can you separate the "matching against all indices" commit into a different PR? The other commits look fine, but I want to avoid the 10 properties hard limit if we can.

I wasn't sure if I should split them, since the new rule makes use of that feature.
We can discuss the hardcoded limit in that PR.

EDIT: split into #550.

@yshui
Copy link
Owner

yshui commented Nov 29, 2020

@tryone144 the new rule doesn't have to use that feature, I think?

@tryone144 tryone144 changed the title Cache _NET_WM_STATE property and add rule target; extend rule-matching to any value in property array Cache _NET_WM_STATE property and add rule target wm_state Nov 29, 2020
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.

Feature request: add predefined targets for sticky and hidden
2 participants