Closed dzava closed 11 years ago
Hi,
I've been trying this and a couple of other solutions but nothing seems to work as expected. Some apps at some points wont accept the event, ie geany - open file dialog, or opera - select bookmark, or the menus..
I've tried to XPutBack(..)
the event, but that didnt work at all ..
I've tried XSendEvent(..)
a separate ButtonPress
and then usleep(50)
then XSendEvent(..)
a ButtonRelease
, but that doesnt work either.
It doesn't matter if I XFlush(dis)
or XSync(dis, False)
.
It doesn't do what it's expected to do in all cases - what it would do if the window was previously focused.. If anyone figures this out, I will probably pull it.
Took a while but i think i got it. There are issues with menus not expanding until you move the mouse to another option and with drop-downs not getting the release event so they remain clicked.
diff --git a/monsterwm.c b/monsterwm.c
index 4673e84..db48f50 100644
--- a/monsterwm.c
+++ b/monsterwm.c
@@ -238,7 +238,12 @@ void buttonpress(XEvent *e) {
Client *c = NULL;
if (wintoclient(e->xbutton.window, &c, &d) && CLICK_TO_FOCUS &&
- c != d->curr && e->xbutton.button == Button1) focus(c, d);
+ c != d->curr && e->xbutton.button == Button1){
+ focus(c, d);
+ XSendEvent(dis, PointerWindow,True,NoEventMask,e);
+ e->type = ButtonRelease;
+ XSendEvent(dis, PointerWindow,True,NoEventMask,e);
+ }
for (unsigned int i = 0; i < LENGTH(buttons); i++)
if (CLEANMASK(buttons[i].mask) == CLEANMASK(e->xbutton.state) &&
What I've seen in i3-wm might be helpful here:
For this to work[1], you shall use GrabModeSync
as pointer_mode
when grabbing:
XGrabButton(dis, FOCUS_BUTTON, AnyModifier, root, False, BUTTONMASK, GrabModeSync, GrabModeAsync, None, None);
Then, the following will replay the pointer event for the underlying client:
XAllowEvents(dis, ReplayPointer, CurrentTime);
XSync(dis, 0);
man xcb_allow_events
.Much better solution.
Thank you.
When you click an unfocused window the event should be send to the window.