]> Dogcows Code - chaz/openbox/blobdiff - src/actions.cc
clarify an incorrect comment, and make some funcs const
[chaz/openbox] / src / actions.cc
index 00d4c1bffe8a5aaa65b87880f7e4dfd265293909..79b31a27630630d99adccdaccafde555c34fdf8e 100644 (file)
@@ -23,9 +23,6 @@ OBActions::OBActions()
 {
   for (int i=0; i<BUTTONS; ++i)
     _posqueue[i] = new ButtonPressAction();
-
-  for (int i = 0; i < NUM_EVENTS; ++i)
-    _callback[i] = 0;
 }
 
 
@@ -74,10 +71,13 @@ void OBActions::buttonPressHandler(const XButtonEvent &e)
     (Openbox::instance->findHandler(e.window));
   assert(w); // everything should be a widget
 
+  // kill off the Button1Mask etc, only want the modifiers
   unsigned int state = e.state & (ControlMask | ShiftMask | Mod1Mask |
                                   Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
-  ButtonData *data = new_button_data(e.window, e.time, state, e.button,
-                                     w->mcontext(), MousePress);
+  ButtonData *data =
+    new_button_data(otk::OBDisplay::findScreen(e.root)->screen(),
+                    e.window, e.time, state, e.button, w->mcontext(),
+                    MousePress);
   Openbox::instance->bindings()->fireButton(data);
   Py_DECREF((PyObject*)data);
     
@@ -111,10 +111,13 @@ void OBActions::buttonReleaseHandler(const XButtonEvent &e)
     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);
-  ButtonData *data = new_button_data(e.window, e.time, state, e.button,
-                                     w->mcontext(), MouseClick);
+  ButtonData *data =
+    new_button_data(otk::OBDisplay::findScreen(e.root)->screen(),
+                    e.window, e.time, state, e.button, w->mcontext(),
+                    MouseClick);
   Openbox::instance->bindings()->fireButton(data);
     
 
@@ -150,11 +153,11 @@ void OBActions::enterHandler(const XCrossingEvent &e)
   OtkEventHandler::enterHandler(e);
   
   // run the ENTER python hook
-  if (_callback[EventEnterWindow]) {
-    EventData *data = new_event_data(e.window, EventEnterWindow, e.state);
-    python_callback(_callback[EventEnterWindow], (PyObject*)data);
-    Py_DECREF((PyObject*)data);
-  }
+  EventData *data =
+    new_event_data(otk::OBDisplay::findScreen(e.root)->screen(),
+                   e.window, EventEnterWindow, e.state);
+  Openbox::instance->bindings()->fireEvent(data);
+  Py_DECREF((PyObject*)data);
 }
 
 
@@ -163,11 +166,11 @@ void OBActions::leaveHandler(const XCrossingEvent &e)
   OtkEventHandler::leaveHandler(e);
 
   // run the LEAVE python hook
-  if (_callback[EventLeaveWindow]) {
-    EventData *data = new_event_data(e.window, EventLeaveWindow, e.state);
-    python_callback(_callback[EventLeaveWindow], (PyObject*)data);
-    Py_DECREF((PyObject*)data);
-  }
+  EventData *data =
+    new_event_data(otk::OBDisplay::findScreen(e.root)->screen(),
+                   e.window, EventLeaveWindow, e.state);
+  Openbox::instance->bindings()->fireEvent(data);
+  Py_DECREF((PyObject*)data);
 }
 
 
@@ -175,9 +178,12 @@ void OBActions::keyPressHandler(const XKeyEvent &e)
 {
   OtkEventHandler::keyPressHandler(e);
 
+  // kill off the Button1Mask etc, only want the modifiers
   unsigned int state = e.state & (ControlMask | ShiftMask | Mod1Mask |
                                   Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
-  Openbox::instance->bindings()->fireKey(state, e.keycode, e.time);
+  Openbox::instance->bindings()->
+    fireKey(otk::OBDisplay::findScreen(e.root)->screen(),
+            state, e.keycode, e.time);
 }
 
 
@@ -206,13 +212,15 @@ void OBActions::motionHandler(const XMotionEvent &e)
   assert(w); // everything should be a widget
 
   // run the MOTION python hook
+  // kill off the Button1Mask etc, only want the modifiers
   unsigned int state = e.state & (ControlMask | ShiftMask | Mod1Mask |
                                   Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask);
   unsigned int button = _posqueue[0]->button;
-  MotionData *data = new_motion_data(e.window, e.time, state, button,
-                                     w->mcontext(), MouseMotion,
-                                     x_root, y_root, _posqueue[0]->pos,
-                                     _posqueue[0]->clientarea);
+  MotionData *data =
+    new_motion_data(otk::OBDisplay::findScreen(e.root)->screen(),
+                    e.window, e.time, state, button, w->mcontext(),
+                    MouseMotion, x_root, y_root, _posqueue[0]->pos,
+                    _posqueue[0]->clientarea);
   Openbox::instance->bindings()->fireButton((ButtonData*)data);
   Py_DECREF((PyObject*)data);
 }
@@ -220,65 +228,19 @@ void OBActions::motionHandler(const XMotionEvent &e)
 void OBActions::mapRequestHandler(const XMapRequestEvent &e)
 {
   OtkEventHandler::mapRequestHandler(e);
-
-  if (_callback[EventNewWindow]) {
-    EventData *data = new_event_data(e.window, EventNewWindow, 0);
-    python_callback(_callback[EventNewWindow], (PyObject*)data);
-    Py_DECREF((PyObject*)data);
-  }
+  // do this in OBScreen::manageWindow
 }
 
 void OBActions::unmapHandler(const XUnmapEvent &e)
 {
   OtkEventHandler::unmapHandler(e);
-
-  if (_callback[EventCloseWindow]) {
-    EventData *data = new_event_data(e.window, EventCloseWindow, 0);
-    python_callback(_callback[EventCloseWindow], (PyObject*)data);
-    Py_DECREF((PyObject*)data);
-  }
+  // do this in OBScreen::unmanageWindow
 }
 
 void OBActions::destroyHandler(const XDestroyWindowEvent &e)
 {
   OtkEventHandler::destroyHandler(e);
-
-  if (_callback[EventCloseWindow]) {
-    EventData *data = new_event_data(e.window, EventCloseWindow, 0);
-    python_callback(_callback[EventCloseWindow], (PyObject*)data);
-    Py_DECREF((PyObject*)data);
-  }
-}
-
-bool OBActions::bind(EventAction action, PyObject *func)
-{
-  if (action < 0 || action >= NUM_EVENTS) {
-    return false;
-  }
-
-  Py_XDECREF(_callback[action]);
-  _callback[action] = func;
-  Py_INCREF(func);
-  return true;
-}
-
-bool OBActions::unbind(EventAction action)
-{
-  if (action < 0 || action >= NUM_EVENTS) {
-    return false;
-  }
-  
-  Py_XDECREF(_callback[action]);
-  _callback[action] = 0;
-  return true;
-}
-
-void OBActions::unbindAll()
-{
-  for (int i = 0; i < NUM_EVENTS; ++i) {
-    Py_XDECREF(_callback[i]);
-    _callback[i] = 0;
-  }
+  // do this in OBScreen::unmanageWindow
 }
 
 }
This page took 0.023559 seconds and 4 git commands to generate.