1
0
Fork 0
mirror of https://github.com/yshui/picom.git synced 2024-11-18 13:55:36 -05:00

inspect: add --monitor for continguous monitoring

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2024-08-09 03:18:03 +01:00
parent 6ae1e7e7dd
commit 0c5188e4b9
No known key found for this signature in database
GPG key ID: D3A4405BE6CC17F4
5 changed files with 37 additions and 3 deletions

View file

@ -19,12 +19,16 @@ DESCRIPTION
OPTIONS
-------
*picom-inspect* accept the exact same set of options as *picom*. Naturally, most of those options will not be relevant.
*picom-inspect* accepts all options that *picom* does. Naturally, most of those options will not be relevant.
These are some of the options you might find useful (See *picom*(1) for descriptions of what they do):
*--config*, *--log-level*, *--log-file*, all the options related to rules.
*picom-inspect* also accepts some extra options: :::
*--monitor*:: Keep *picom-inspect* running in a loop, and dump information every time something changed about a window.
NOTES
-----
*picom-inspect* is prototype right now. If you find any bug, for example, if rules are matched differently compared to *picom*, please submit bug reports to:

View file

@ -241,6 +241,8 @@ typedef struct options {
bool print_diagnostics;
/// Render to a separate window instead of taking over the screen
bool debug_mode;
/// For picom-inspect only, dump windows in a loop
bool inspect_monitor;
xcb_window_t inspect_win;
// === General ===
/// Use the legacy backends?

View file

@ -59,6 +59,7 @@ struct picom_option {
int has_arg;
struct picom_arg arg;
const char *help;
const char *argv0;
};
static bool set_flag(const struct picom_option * /*opt*/, const struct picom_arg *arg,
@ -452,6 +453,8 @@ static const struct picom_option picom_options[] = {
"window is fullscreen based only on its size and coordinates."},
[804] = {"realtime" , ENABLE(use_realtime_scheduling) , "Enable realtime scheduling. This might reduce latency, but might also cause "
"other issues. Disable this if you see the compositor being killed."},
[805] = {"monitor" , ENABLE(inspect_monitor) , "For picom-inspect, run in a loop and dump information every time something "
"changed about a window.", "picom-inspect"},
// Flags that takes an argument
['r'] = {"shadow-radius" , INTEGER(shadow_radius, 0, INT_MAX) , "The blur radius for shadows. (default 12)"},
@ -634,12 +637,19 @@ static void usage(const char *argv0, int ret) {
line_wrap = window_size.ws_col;
}
const char *basename = strrchr(argv0, '/') ? strrchr(argv0, '/') + 1 : argv0;
size_t help_indent = 0;
for (size_t i = 0; i < ARR_SIZE(picom_options); i++) {
if (picom_options[i].help == NULL) {
// Hide options with no help message.
continue;
}
if (picom_options[i].argv0 != NULL &&
strcmp(picom_options[i].argv0, basename) != 0) {
// Hide options that are not for this program.
continue;
}
auto option_len = strlen(picom_options[i].long_name) + 2 + 4;
if (picom_options[i].arg.name) {
option_len += strlen(picom_options[i].arg.name) + 1;
@ -654,6 +664,11 @@ static void usage(const char *argv0, int ret) {
if (picom_options[i].help == NULL) {
continue;
}
if (picom_options[i].argv0 != NULL &&
strcmp(picom_options[i].argv0, basename) != 0) {
// Hide options that are not for this program.
continue;
}
size_t option_len = 8;
fprintf(f, " ");
if ((i > 'a' && i < 'z') || (i > 'A' && i < 'Z')) {
@ -943,10 +958,15 @@ bool get_cfg(options_t *opt, int argc, char *const *argv) {
int o = 0, longopt_idx = -1;
bool failed = false;
optind = 1;
const char *basename = strrchr(argv[0], '/') ? strrchr(argv[0], '/') + 1 : argv[0];
while (-1 != (o = getopt_long(argc, argv, shortopts, longopts, &longopt_idx))) {
if (o == '?' || o == ':' || picom_options[o].arg.handler == NULL) {
usage(argv[0], 1);
failed = true;
} else if (picom_options[o].argv0 != NULL &&
strcmp(picom_options[o].argv0, basename) != 0) {
log_error("Invalid option %s", argv[optind - 1]);
failed = true;
} else if (!picom_options[o].arg.handler(
&picom_options[o], &picom_options[o].arg, optarg, opt)) {
failed = true;

View file

@ -2199,7 +2199,9 @@ static session_t *session_init(int argc, char **argv, Display *dpy,
ps->o.backend = backend_find("dummy");
ps->o.print_diagnostics = false;
ps->o.dbus = false;
ps->o.inspect_win = inspect_select_window(&ps->c);
if (!ps->o.inspect_monitor) {
ps->o.inspect_win = inspect_select_window(&ps->c);
}
}
ps->window_options_default = win_options_from_config(&ps->o);

View file

@ -1119,9 +1119,15 @@ void win_on_factor_change(session_t *ps, struct win *w) {
if ((ps->o.inspect_win != XCB_NONE && win_id(w) == ps->o.inspect_win) ||
ps->o.inspect_monitor) {
if (ps->o.inspect_monitor) {
printf("Window %#010x (Client %#010x):\n\n", win_id(w),
win_client_id(w, /*fallback_to_self=*/true));
}
inspect_dump_window(ps->c2_state, &ps->o, w);
printf("\n");
quit(ps);
if (!ps->o.inspect_monitor) {
quit(ps);
}
}
}