Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf7f27db

Browse files
committed
c2: add new predefined targetwm_state to match against_NET_WM_STATE in string
New predefined target `wm_state` for rule-based matching. Matchesagainst the cached `_NET_WM_STATE` property of a window in stringrepresentation.NOTE: `wm_state = 'fullscreen'` is not neccessarily identical to`fullscreen`, and `wm_state = 'focused'` is not identical to `focused`.
1 parent9125693 commitf7f27db

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

‎man/picom.1.asciidoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ With greater-than/less-than operators it looks like:
274274

275275
'NEGATION' (optional) is one or more exclamation marks;
276276

277-
'TARGET' is either a predefined target name, or the name of a window property to match. Supported predefined targets are `id`, `x`, `y`, `x2` (`x` + `widthb`), `y2` (like `x2`), `width`, `height`, `widthb` (`width` + 2 * `border_width`), `heightb` (like `widthb`), `border_width`, `fullscreen`, `override_redirect`, `argb` (whether the window has an ARGB visual), `focused`, `wmwin` (whether the window looks like a WM window, i.e. has no child window with `WM_STATE` and is not override-redirected), `bounding_shaped`, `rounded_corners` (requires *--detect-rounded-corners*), `client` (ID of client window), `window_type` (window type in string), `leader` (ID of window leader), `name`, `class_g` (= `WM_CLASS[1]`), `class_i` (= `WM_CLASS[0]`), and `role`.
277+
'TARGET' is either a predefined target name, or the name of a window property to match. Supported predefined targets are `id`, `x`, `y`, `x2` (`x` + `widthb`), `y2` (like `x2`), `width`, `height`, `widthb` (`width` + 2 * `border_width`), `heightb` (like `widthb`), `border_width`, `fullscreen`, `override_redirect`, `argb` (whether the window has an ARGB visual), `focused`, `wmwin` (whether the window looks like a WM window, i.e. has no child window with `WM_STATE` and is not override-redirected), `bounding_shaped`, `rounded_corners` (requires *--detect-rounded-corners*), `client` (ID of client window), `window_type` (window type in string), `leader` (ID of window leader), `name`, `class_g` (= `WM_CLASS[1]`), `class_i` (= `WM_CLASS[0]`),`role`,and `wm_state` (window manager state hint in string).
278278

279279
'CLIENT/FRAME' is a single `@` if the window attribute should be be looked up on client window, nothing if on frame window;
280280

@@ -307,6 +307,9 @@ Examples:
307307
# If the window is a menu
308308
window_type *= "menu"
309309
_NET_WM_WINDOW_TYPE@:a *= "MENU"
310+
# If the window is marked hidden
311+
wm_state *= "hidden"
312+
_NET_WM_STATE@:a *= "HIDDEN"
310313
# If the window name contains "Firefox", ignore case
311314
name *?= "Firefox"
312315
_NET_WM_NAME@:s *?= "Firefox"

‎src/c2.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ struct _c2_l {
133133
C2_L_PCLASSG,
134134
C2_L_PCLASSI,
135135
C2_L_PROLE,
136+
C2_L_PWMSTATE,
136137
}predef;
137138
enumc2_l_type {
138139
C2_L_TUNDEFINED,
@@ -210,6 +211,7 @@ static const c2_predef_t C2_PREDEFS[] = {
210211
[C2_L_PCLASSG]= {"class_g",C2_L_TSTRING,0},
211212
[C2_L_PCLASSI]= {"class_i",C2_L_TSTRING,0},
212213
[C2_L_PROLE]= {"role",C2_L_TSTRING,0},
214+
[C2_L_PWMSTATE]= {"wm_state",C2_L_TSTRING,0},
213215
};
214216

215217
/**
@@ -1395,10 +1397,21 @@ static inline void c2_match_once_leaf(session_t *ps, const struct managed_win *w
13951397
caseC2_L_PCLASSG:tgt=w->class_general;break;
13961398
caseC2_L_PCLASSI:tgt=w->class_instance;break;
13971399
caseC2_L_PROLE:tgt=w->role;break;
1400+
caseC2_L_PWMSTATE: {
1401+
ntargets=0;
1402+
for (enumwm_statei=1;i<NUM_WMSTATES;++i) {
1403+
if (win_check_wm_state(w,i)) {
1404+
targets[ntargets++]=WMSTATES[i];
1405+
}
1406+
}
1407+
break;
1408+
}
13981409
default:assert(0);break;
13991410
}
1400-
ntargets=1;
1401-
targets[0]=tgt;
1411+
if (tgt) {
1412+
ntargets=1;
1413+
targets[0]=tgt;
1414+
}
14021415
}
14031416
// An atom type property, convert it to string
14041417
elseif (pleaf->type==C2_L_TATOM) {

‎src/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ typedef struct session {
386386
typedefenum {WIN_EVMODE_UNKNOWN,WIN_EVMODE_FRAME,WIN_EVMODE_CLIENT }win_evmode_t;
387387

388388
externconstchar*constWINTYPES[NUM_WINTYPES];
389+
externconstchar*constWMSTATES[NUM_WMSTATES];
389390
externsession_t*ps_g;
390391

391392
voidev_xcb_error(session_t*ps,xcb_generic_error_t*err);

‎src/picom.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ const char *const WINTYPES[NUM_WINTYPES] = {
8484
"popup_menu","tooltip","notification","combo","dnd",
8585
};
8686

87+
/// Name string for window wm_states.
88+
constchar*constWMSTATES[NUM_WMSTATES]= {
89+
"unknown","modal","sticky",
90+
"maximized_vert","maximized_horz","shaded",
91+
"skip_taskbar","skip_pager","hidden",
92+
"fullscreen","above","below",
93+
"demands_attention","focused",
94+
};
95+
8796
// clang-format off
8897
/// Names of backends.
8998
constchar*constBACKEND_STRS[]= {[BKEND_XRENDER]="xrender",

‎src/win.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,9 @@ bool attr_pure win_is_fullscreen(const session_t *ps, const struct managed_win *
410410
*/
411411
boolattr_purewin_is_focused_raw(constsession_t*ps,conststructmanaged_win*w);
412412

413+
/// check if window has specific wm_state.
414+
boolattr_purewin_check_wm_state(conststructmanaged_win*w,enumwm_statestate);
415+
413416
/// check if window has ARGB visual
414417
boolattr_purewin_has_alpha(conststructmanaged_win*w);
415418

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp