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 21, 2024
1 parent 36fe86e commit bd9bb8e
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 @@ -25,21 +25,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 34 in src/inspect.c

View check run for this annotation

Codecov / codecov/patch

src/inspect.c#L30-L34

Added lines #L30 - L34 were not covered by tests
}

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

Check warning on line 38 in src/inspect.c

View check run for this annotation

Codecov / codecov/patch

src/inspect.c#L37-L38

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

Check warning on line 40 in src/inspect.c

View check run for this annotation

Codecov / codecov/patch

src/inspect.c#L40

Added line #L40 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 42 in src/inspect.c

View check run for this annotation

Codecov / codecov/patch

src/inspect.c#L42

Added line #L42 was not covered by tests
options->frame_opacity);
Expand Down Expand Up @@ -199,9 +197,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 200 in src/inspect.c

View check run for this annotation

Codecov / codecov/patch

src/inspect.c#L200

Added line #L200 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 203 in src/inspect.c

View check run for this annotation

Codecov / codecov/patch

src/inspect.c#L202-L203

Added lines #L202 - L203 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 207 in src/inspect.c

View check run for this annotation

Codecov / codecov/patch

src/inspect.c#L207

Added line #L207 was not covered by tests
struct c2_match_state match_state = {
.state = state,
.w = w,
Expand Down Expand Up @@ -263,6 +266,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 269 in src/inspect.c

View check run for this annotation

Codecov / codecov/patch

src/inspect.c#L269

Added line #L269 was not covered by tests

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

0 comments on commit bd9bb8e

Please sign in to comment.