]> Dogcows Code - chaz/openbox/blobdiff - src/actions.cc
rm prefixes for all elements in the otk namepsace
[chaz/openbox] / src / actions.cc
index 14fba7db125cd17232708634f69ba2d2ac635490..96290bddc6ab9ac80caf76d0936586036c901c2e 100644 (file)
@@ -5,7 +5,7 @@
 #endif
 
 #include "actions.hh"
-#include "widget.hh"
+#include "widgetbase.hh"
 #include "openbox.hh"
 #include "client.hh"
 #include "screen.hh"
@@ -37,8 +37,10 @@ OBActions::~OBActions()
 void OBActions::insertPress(const XButtonEvent &e)
 {
   ButtonPressAction *a = _posqueue[BUTTONS - 1];
-  for (int i=BUTTONS-1; i>0;)
-    _posqueue[i] = _posqueue[--i];
+  // rm'd the last one, shift them all down one
+  for (int i = BUTTONS-1; i > 0; --i) {
+    _posqueue[i] = _posqueue[i-1];
+  }
   _posqueue[0] = a;
   a->button = e.button;
   a->pos.setPoint(e.x_root, e.y_root);
@@ -49,17 +51,19 @@ void OBActions::insertPress(const XButtonEvent &e)
 
 void OBActions::removePress(const XButtonEvent &e)
 {
+  int i;
   ButtonPressAction *a = 0;
-  for (int i=0; i<BUTTONS; ++i) {
-    if (_posqueue[i]->button == e.button)
+  for (i=0; i<BUTTONS-1; ++i)
+    if (_posqueue[i]->button == e.button) {
       a = _posqueue[i];
-    if (a) // found one and removed it
+      break;
+    }
+  if (a) { // found one, remove it and shift the rest up one
+    for (; i < BUTTONS-1; ++i)
       _posqueue[i] = _posqueue[i+1];
-  }
-  if (a) { // found one
     _posqueue[BUTTONS-1] = a;
-    a->button = 0;
   }
+  _posqueue[BUTTONS-1]->button = 0;
 }
 
 void OBActions::buttonPressHandler(const XButtonEvent &e)
@@ -81,13 +85,24 @@ void OBActions::buttonPressHandler(const XButtonEvent &e)
     screen = c->screen();
   else
     screen = otk::OBDisplay::findScreen(e.root)->screen();
-  ButtonData data(screen, c, e.time, state, e.button, w->mcontext(),
-                  MousePress);
+  MouseData data(screen, c, e.time, state, e.button, w->mcontext(),
+                 MousePress);
   Openbox::instance->bindings()->fireButton(&data);
     
   if (_button) return; // won't count toward CLICK events
 
   _button = e.button;
+
+  if (w->mcontext() == MC_Window) {
+    /*
+      Because of how events are grabbed on the client window, we can't get
+      ButtonRelease events, so instead we simply manufacture them here, so that
+      clicks/doubleclicks etc still work.
+    */
+    //XButtonEvent ev = e;
+    //ev.type = ButtonRelease;
+    buttonReleaseHandler(e);
+  }
 }
   
 
@@ -124,8 +139,8 @@ void OBActions::buttonReleaseHandler(const XButtonEvent &e)
     screen = c->screen();
   else
     screen = otk::OBDisplay::findScreen(e.root)->screen();
-  ButtonData data(screen, c, e.time, state, e.button, w->mcontext(),
-                  MouseClick);
+  MouseData data(screen, c, e.time, state, e.button, w->mcontext(),
+                 MouseClick);
   Openbox::instance->bindings()->fireButton(&data);
     
 
@@ -234,9 +249,9 @@ void OBActions::motionHandler(const XMotionEvent &e)
     screen = c->screen();
   else
     screen = otk::OBDisplay::findScreen(e.root)->screen();
-  MotionData data(screen, c, e.time, state, button, w->mcontext(), MouseMotion,
-                  x_root, y_root, _posqueue[0]->pos, _posqueue[0]->clientarea);
-  Openbox::instance->bindings()->fireButton((ButtonData*)&data);
+  MouseData data(screen, c, e.time, state, button, w->mcontext(), MouseMotion,
+                 x_root, y_root, _posqueue[0]->pos, _posqueue[0]->clientarea);
+  Openbox::instance->bindings()->fireButton(&data);
 }
 
 void OBActions::mapRequestHandler(const XMapRequestEvent &e)
This page took 0.022527 seconds and 4 git commands to generate.