Skip to content

Commit

Permalink
inspect: make it work again after the wm-tree changes
Browse files Browse the repository at this point in the history
Signed-off-by: Yuxuan Shui <[email protected]>
  • Loading branch information
yshui committed Jun 19, 2024
1 parent a267649 commit ca1d54b
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/inspect.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,19 @@

static struct win *
setup_window(struct x_connection *c, struct atom *atoms, struct options *options,
struct c2_state *state, xcb_window_t target) {
struct wm *wm, struct c2_state *state, xcb_window_t target) {
// Pretend we are the compositor, and build up the window state
struct wm *wm = wm_new();
wm_import_incomplete(wm, target, XCB_NONE);
wm_complete_import(wm, c, atoms);

auto cursor = wm_find(wm, target);
if (cursor == NULL) {
log_fatal("Could not find window %#010x", target);
wm_free(wm);
return NULL;

Check warning on line 33 in src/inspect.c

View check run for this annotation

Codecov / codecov/patch

src/inspect.c#L29-L33

Added lines #L29 - L33 were not covered by tests
}

auto toplevel = wm_ref_toplevel_of(cursor);
struct win *w = ccalloc(1, struct win);

Check warning on line 37 in src/inspect.c

View check run for this annotation

Codecov / codecov/patch

src/inspect.c#L36-L37

Added lines #L36 - L37 were not covered by tests
w->state = WSTATE_MAPPED;
w->tree_ref = toplevel;

Check warning on line 39 in src/inspect.c

View check run for this annotation

Codecov / codecov/patch

src/inspect.c#L39

Added line #L39 was not covered by tests
win_update_wintype(c, atoms, w);
win_update_frame_extents(c, atoms, w, win_client_id(w, /*fallback_to_self=*/true),

Check warning on line 41 in src/inspect.c

View check run for this annotation

Codecov / codecov/patch

src/inspect.c#L41

Added line #L41 was not covered by tests
options->frame_opacity);
Expand Down Expand Up @@ -197,9 +195,14 @@ int inspect_main(int argc, char **argv, const char *config_file) {
auto state = c2_state_new(atoms);
options_postprocess_c2_lists(state, &c, &options);

struct wm *wm = wm_new();

Check warning on line 198 in src/inspect.c

View check run for this annotation

Codecov / codecov/patch

src/inspect.c#L198

Added line #L198 was not covered by tests

wm_import_incomplete(wm, c.screen_info->root, XCB_NONE);
wm_complete_import(wm, &c, atoms);

Check warning on line 201 in src/inspect.c

View check run for this annotation

Codecov / codecov/patch

src/inspect.c#L200-L201

Added lines #L200 - L201 were not covered by tests

auto target = select_window(&c);
log_info("Target window: %#x", target);
auto w = setup_window(&c, atoms, &options, state, target);
auto w = setup_window(&c, atoms, &options, wm, state, target);

Check warning on line 205 in src/inspect.c

View check run for this annotation

Codecov / codecov/patch

src/inspect.c#L205

Added line #L205 was not covered by tests
struct c2_match_state match_state = {
.state = state,
.w = w,
Expand Down Expand Up @@ -261,6 +264,8 @@ int inspect_main(int argc, char **argv, const char *config_file) {
c2_window_state_destroy(state, &w->c2_state);
free(w);

wm_free(wm);

Check warning on line 267 in src/inspect.c

View check run for this annotation

Codecov / codecov/patch

src/inspect.c#L267

Added line #L267 was not covered by tests

log_deinit_tls();
c2_state_free(state);
destroy_atoms(atoms);
Expand Down

0 comments on commit ca1d54b

Please sign in to comment.