Skip to content

Commit

Permalink
Update event coordinates in offset windows
Browse files Browse the repository at this point in the history
Signed-off-by: Tin Švagelj <[email protected]>
  • Loading branch information
Caellian committed Apr 8, 2024
1 parent 94f04b2 commit 2bfe8bb
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/x11.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1385,22 +1385,30 @@ void propagate_x11_event(XEvent &ev) {
}

i_ev->common.window = window.desktop;
i_ev->common.x = i_ev->common.x_root;
i_ev->common.y = i_ev->common.y_root;
i_ev->common.time = CurrentTime;

/* forward the event to the window below conky (e.g. caja) or desktop */
{
std::vector<Window> below = query_x11_windows_at_pos(
display, i_ev->common.x_root, i_ev->common.y_root,
[](XWindowAttributes &a) { return a.map_state == IsViewable; });
auto it = std::remove_if(below.begin(), below.end(),
[](Window w) { return w == window.window; });
below.erase(it, below.end());
if (!below.empty()) { i_ev->common.window = below.back(); }
if (!below.empty()) {
i_ev->common.window = below.back();

Window _ignore;
// Update event x and y coordinates to be target window relative
XTranslateCoordinates(display, window.root, i_ev->common.window,
i_ev->common.x_root, i_ev->common.y_root,
&i_ev->common.x, &i_ev->common.y, &_ignore);
}
// drop below vector
}

/* forward the event to the window below conky (e.g. caja) or desktop */
i_ev->common.x = i_ev->common.x_root;
i_ev->common.y = i_ev->common.y_root;
i_ev->common.time = CurrentTime;

XUngrabPointer(display, CurrentTime);
XSendEvent(display, i_ev->common.window, False, ev_to_mask(i_ev->type), &ev);
}
Expand Down

0 comments on commit 2bfe8bb

Please sign in to comment.