From 112d094b9b2b549208d94af372a2526bfac009fd Mon Sep 17 00:00:00 2001 From: tcmal Date: Thu, 27 Jun 2024 00:13:33 +0100 Subject: send take focus event --- src/clients/mod.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/clients') diff --git a/src/clients/mod.rs b/src/clients/mod.rs index 823a501..76c30bb 100644 --- a/src/clients/mod.rs +++ b/src/clients/mod.rs @@ -10,7 +10,8 @@ use xcb::{ x::{ self, ChangeProperty, ConfigWindow, ConfigureNotifyEvent, ConfigureRequestEvent, ConfigureWindow, DeleteProperty, DestroyNotifyEvent, Drawable, EventMask, GetGeometry, - GetWindowAttributes, InputFocus, MapRequestEvent, SetInputFocus, UnmapNotifyEvent, Window, + GetWindowAttributes, InputFocus, MapRequestEvent, PropMode, SetInputFocus, + UnmapNotifyEvent, Window, }, xinerama::{self}, BaseEvent, Extension, @@ -257,16 +258,19 @@ impl ClientState { new.set_border(conn, conn.colours.border_focused()); new.set_urgent(false); if !new.never_focus() { - // XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime); conn.send_request(&SetInputFocus { revert_to: InputFocus::PointerRoot, focus: new.window(), time: x::CURRENT_TIME, }); - // XChangeProperty(dpy, root, netatom[NetActiveWindow], - // XA_WINDOW, 32, PropModeReplace, - // (unsigned char *) &(c->win), 1); - // TODO: sendevent(c, wmatom[WMTakeFocus]); + conn.send_request(&ChangeProperty { + window: conn.root(), + mode: PropMode::Replace, + property: conn.atoms.net_active_window, + r#type: x::ATOM_WINDOW, + data: &[new.window()], + }); + conn.send_event(new.window(), conn.atoms.wm_take_focus); } } else { conn.send_request(&SetInputFocus { -- cgit v1.2.3