Skip to content

Commit

Permalink
Focus window when clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
iacore committed Jun 17, 2022
1 parent 403a952 commit 085c1a0
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion gui-daemon/xside.c
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,21 @@ static void dump_mapped(Ghandles * g)
}
#endif

static void process_xievent_focus(Ghandles * g, const XILeaveEvent * ev);

static void focus_if_not_focused(Ghandles * g, const XButtonEvent * ev) {
Window focused;
int revertTo;
XGetInputFocus(g->display, &focused, &revertTo);
if (focused != ev->window) {
XILeaveEvent mock;
mock.type = XI_FocusIn;
mock.mode = NotifyNormal;
mock.detail = NotifyNonlinear;
process_xievent_focus(g, &mock);
}
}

/* handle local Xserver event: XButtonEvent
* same as XKeyEvent - send to relevant window in VM */
static void process_xevent_button(Ghandles * g, const XButtonEvent * ev)
Expand All @@ -1408,8 +1423,11 @@ static void process_xevent_button(Ghandles * g, const XButtonEvent * ev)
CHECK_NONMANAGED_WINDOW(g, ev->window);
update_wm_user_time(g, ev->window, ev->time);

k.type = ev->type;
if (ev->type == ButtonPress) {
focus_if_not_focused(g, ev);
}

k.type = ev->type;
k.x = ev->x;
k.y = ev->y;
k.state = ev->state;
Expand Down

0 comments on commit 085c1a0

Please sign in to comment.