On Sun, May 29, 2022 at 07:26:29PM +0200 I heard the voice of
Rhialto, and lo! it spake thus:
>
> The problem is probably that, in practice, you can ignore only one
> modifier. "Ignoring" a modifier is done by adding an extra
> GrabKeyboard or GrabPointer for every key or button you specify.
> [...]
For those not so blessed as to have had X take over their brain, a
little elaboration. Key bindings (and mouse pointer; sameish thing)
_don't_ happen by the keypressing coming in to ctwm, then we go over
our list of bindings to figure out what to do with it, then passing it
on to the app if it's not one of ours. I mean, strictly speaking,
that would be _a_ way to do it, but it means the WM would be involved
in every key press and every mouse movement, which... might actually
work non-lousily most of the time, on lightly loaded multi-core
multi-GHz systems. But that's a lotta caveats, and it's now things
work anyway.
What _actually_ happens is that ctwm makes special calls into X
(XGrabButton()) that say "Look, when you get this keypress, always
send it to me, never the focused window that would normally get it";
we _steal_ specifically named events from the apps that would
otherwise be getting them. And part of that name is the modifier;
click is wholly different from control-click is different from
shift-click is different from num-lock-click, etc. In X terms,
they're not the same event with different modifiers; they're different
events (x-ref below). So there's no such statement we can make as
"give me all the left-clicks, no matter what modifiers they have".
Except, maybe? In principal, we _can_ pass AnyModifier into
XGrabButton... more below.
Now, looking at this particular case:
On Sun, May 29, 2022 at 01:16:29PM +0100 I heard the voice of
Chris Syntichakis, and lo! it spake thus:
>
> I just realized that I did a mistake, I m talking about the RaiseOnClick
> function, not the Clicktofocus, so if I have the caps+numlock activated
> at the same time : nothing happens when I click on a window to be
> raised, those windows can be raised only by clicking on their
> titlebars, something is broken then on that function "RaiseOnClick".
This gets setup a little below where Olaf references above, at
https://bazaar.launchpad.net/~ctwm/ctwm/trunk/view/head:/add_window.c#L1868
--------
unsigned int ModifierMask[8] = { ShiftMask, ControlMask, LockMask,
Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask,
Mod5Mask
};
[...]
if(Scr->ClickToFocus) {
grabbutton(AnyButton, None, tmp_win->w, GrabModeSync);
for(i = 0 ; i < 8 ; i++) {
grabbutton(AnyButton, ModifierMask [i], tmp_win->w,
GrabModeSync);
}
}
--------
So, when ClickToFocus is set, we grab any button press in the window.
And we also loop oevr the 8 modifiers, and grab any of _those_
<mod>-click's, so shift-click and mod2-click (which earlier messages
suggested is how num-lock shows up) get caught as well. So
num-lock-click still works like normal.
However, that's a _single_ modifier. If you've got
shift-num-lock-click that's a whole different event from X's
perspective, and we never grabbed that, so we don't get it; it goes to
whichever window has focus. And trying to grab all the
combinations... well, that's a power set of the modifiers, so with 8
modifiers that's 2**8 grabs you need. (in the current scheme)
Now, XGrabButton _does_ specify that it can take AnyModifier for the
modifier. I'm not sure why we don't do that; it may be (as with so
many things) that there are actually surprising events generated that
we shouldn't do anything with, and AnyModifier would wind up getting
them somehow. I struggle to think of what that might be here, but X
has never ceased to surprise and dishearten me. It may just as well
be that whoever wrote the code didn't know or think about it when they
added it (in ctwm 3.6; changelog credits DINH V. Hoa).
So if that's the case, something like the attached patch (compiles,
but untested) may pull it off. If so, we should probably look at an
expanded variant of it.
--
Matthew Fuller (MF4839) | [email protected]
Systems/Network Administrator | http://www.over-yonder.net/~fullermd/
On the Internet, nobody can hear you scream.
=== modified file 'add_window.c'
--- add_window.c 2021-07-14 00:09:12 +0000
+++ add_window.c 2022-05-29 20:29:21 +0000
@@ -1866,17 +1866,10 @@
}
}
if(Scr->ClickToFocus) {
- grabbutton(AnyButton, None, tmp_win->w, GrabModeSync);
- for(i = 0 ; i < 8 ; i++) {
- grabbutton(AnyButton, ModifierMask [i], tmp_win->w, GrabModeSync);
- }
+ grabbutton(AnyButton, AnyModifier, tmp_win->w, GrabModeSync);
}
else if(Scr->RaiseOnClick) {
- grabbutton(Scr->RaiseOnClickButton, None, tmp_win->w, GrabModeSync);
- for(i = 0 ; i < 8 ; i++) {
- grabbutton(Scr->RaiseOnClickButton,
- ModifierMask [i], tmp_win->w, GrabModeSync);
- }
+ grabbutton(Scr->RaiseOnClickButton, AnyModifier, tmp_win->w, GrabModeSync);
}
}
#undef grabbutton