- if (!area.contains(mpos)) return; // not on the window any more
-
- // XXX: run the CLICK guile hook
- printf("GUILE: CLICK: win %lx modifiers %ux button %ud time %lx",
- (long)win, modifiers, button, time);
+ // find the area of the window
+ XWindowAttributes attr;
+ if (!XGetWindowAttributes(otk::Display::display, e.window, &attr)) return;
+
+ // if not on the window any more, it isnt a CLICK
+ if (!(e.same_screen && e.x >= 0 && e.y >= 0 &&
+ e.x < attr.width && e.y < attr.height))
+ return;
+
+ // run the CLICK python hook
+ // kill off the Button1Mask etc, only want the modifiers
+ unsigned int state = e.state & (ControlMask | ShiftMask | Mod1Mask |
+ Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
+ int screen;
+ Client *c = Openbox::instance->findClient(e.window);
+ if (c)
+ screen = c->screen();
+ else
+ screen = otk::Display::findScreen(e.root)->screen();
+ MouseData data(screen, c, e.time, state, e.button, w->mcontext(),
+ MouseClick);
+ Openbox::instance->bindings()->fireButton(&data);
+