Swallow focusing clicks?
Kai Grossjohann
kai at emptydomain.de
Sun Oct 31 13:24:18 EST 2004
Kai Grossjohann <kai at emptydomain.de> writes:
> I would like to configure things such that clicking mouse-3 inside the
> client window EITHER focuses and raises the window OR passes the click
> through to the application, but not both.
>
> Is this possible? If not, could it be added (by me, perhaps)?
Duh. It turns out that I'm too stupid to do this. I found the
function mouse_event in mouse.c which replays events in the client
context. So I thought if I replay fewer events, then Bob's my uncle.
As a first test, I thought that I could swallow all events inside
client windows that didn't have focus.
gboolean has_focus = ( client == focus_client );
This line seems to do the right thing, as I discovered via
printf-debugging.
Then I extended the condition guarding the replaying to only replay if
the window had focus. This, however, makes OpenBox hang. And I have
no idea what I might have done wrong.
Any help?
Kai
--- mouse.c 21 Mar 2004 02:03:00 +0100 1.30
+++ mouse.c 31 Oct 2004 19:20:39 +0100
@@ -27,6 +27,8 @@
#include "frame.h"
#include "translate.h"
#include "mouse.h"
+/* For focus_client variable. */
+#include "focus.h"
#include <glib.h>
typedef struct {
@@ -181,6 +183,8 @@
ObFrameContext context;
gboolean click = FALSE;
gboolean dclick = FALSE;
+ gboolean has_focus = ( client == focus_client );
+ printf("has_focus = %d\n", has_focus);
switch (e->type) {
case ButtonPress:
@@ -191,13 +195,14 @@
py = e->xbutton.y_root;
button = e->xbutton.button;
state = e->xbutton.state;
+ printf("button %d\n", button);
fire_binding(OB_MOUSE_ACTION_PRESS, context,
client, e->xbutton.state,
e->xbutton.button,
e->xbutton.x_root, e->xbutton.y_root);
- if (CLIENT_CONTEXT(context, client)) {
+ if (CLIENT_CONTEXT(context, client) && (has_focus == 1)) {
/* Replay the event, so it goes to the client*/
XAllowEvents(ob_display, ReplayPointer, event_lasttime);
/* Fall through to the release case! */
More information about the openbox
mailing list