- // XXX: run the PRESS guile hook
- printf("GUILE: PRESS: win %lx modifiers %u button %u time %lx\n",
- (long)e.window, e.state, e.button, e.time);
+ otk::EventHandler::buttonPressHandler(e);
+
+ MouseContext::MC context;
+ EventHandler *h = openbox->findHandler(e.window);
+ Frame *f = dynamic_cast<Frame*>(h);
+ if (f)
+ context= f->mouseContext(e.window);
+ else if (dynamic_cast<Client*>(h))
+ context = MouseContext::Window;
+ else if (dynamic_cast<Screen*>(h))
+ context = MouseContext::Root;
+ else
+ return; // not a valid mouse context
+
+ if (_press.button) {
+ unsigned int mask;
+ switch(_press.button) {
+ case Button1: mask = Button1Mask; break;
+ case Button2: mask = Button2Mask; break;
+ case Button3: mask = Button3Mask; break;
+ case Button4: mask = Button4Mask; break;
+ case Button5: mask = Button5Mask; break;
+ default: mask = 0; // on other buttons we have to assume its not pressed...
+ }
+ // was the button released but we didnt get the event? (pointergrabs cause
+ // this)
+ if (!(e.state & mask))
+ _press.button = 0;
+ }
+
+ // run the PRESS 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->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, context,
+ MouseAction::Press);
+ openbox->bindings()->fireButton(&data);