Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #29 from mgehre/mouseXY

Mouse xy
  • Loading branch information...
commit 9f24f8f24882b92b223453e3ca864cb192b28ceb 2 parents 13c01a4 + 97ed8c6
@alexp-sssup alexp-sssup authored
View
18 backends/input.cpp
@@ -143,6 +143,12 @@ gboolean InputThread::gtkplug_worker(GtkWidget *widget, GdkEvent *event, InputTh
ret=TRUE;
break;
}
+ case GDK_MOTION_NOTIFY:
+ {
+ th->handleMouseMove(event->motion.x,event->motion.y);
+ ret=TRUE;
+ break;
+ }
default:
//#ifdef EXPENSIVE_DEBUG
// cout << "GDKTYPE " << event->type << endl;
@@ -204,6 +210,13 @@ void InputThread::handleMouseUp(uint32_t x, uint32_t y)
}
}
+void InputThread::handleMouseMove(uint32_t x, uint32_t y)
+{
+ SpinlockLocker locker(inputDataSpinlock);
+ mouseX = x;
+ mouseY = y;
+}
+
void* InputThread::sdl_worker(InputThread* th)
{
sys=th->m_sys;
@@ -255,6 +268,11 @@ void* InputThread::sdl_worker(InputThread* th)
th->handleMouseUp(event.button.x,event.button.y);
break;
}
+ case SDL_MOUSEMOTION:
+ {
+ th->handleMouseMove(event.motion.x,event.motion.y);
+ break;
+ }
case SDL_VIDEORESIZE:
{
th->m_sys->getRenderThread()->requestResize(event.resize.w, event.resize.h);
View
17 backends/input.h
@@ -66,6 +66,11 @@ class InputThread
std::vector<MaskData> maskStack;
void handleMouseDown(uint32_t x, uint32_t y);
void handleMouseUp(uint32_t x, uint32_t y);
+ void handleMouseMove(uint32_t x, uint32_t y);
+
+ Spinlock inputDataSpinlock;
+ number_t mouseX;
+ number_t mouseY;
public:
InputThread(SystemState* s);
~InputThread();
@@ -100,6 +105,18 @@ class InputThread
Checks if the given point in Stage coordinates is currently masked or not
*/
bool isMasked(number_t x, number_t y) const;
+
+ number_t getMouseX()
+ {
+ SpinlockLocker locker(inputDataSpinlock);
+ return mouseX;
+ }
+
+ number_t getMouseY()
+ {
+ SpinlockLocker locker(inputDataSpinlock);
+ return mouseY;
+ }
};
};
View
3  scripting/abc.cpp
@@ -1157,7 +1157,8 @@ void ABCVm::handleEvent(std::pair<_NR<EventDispatcher>, _R<Event> > e)
// Exceptions aren't expected and shouldn't be ignored
else
{
- ev->obj->incRef();
+ if(!ev->obj.isNull())
+ ev->obj->incRef();
ASObject* result = ev->f->call(ev->obj.getPtr(),ev->args,ev->numArgs,ev->thisOverride);
// We should report the function result
if(ev->result != NULL)
View
18 scripting/flashdisplay.cpp
@@ -1162,6 +1162,8 @@ void DisplayObject::sinit(Class_base* c)
c->setGetterByQName("opaqueBackground","",Class<IFunction>::getFunction(undefinedFunction),true);
c->setSetterByQName("opaqueBackground","",Class<IFunction>::getFunction(undefinedFunction),true);
c->setMethodByQName("getBounds","",Class<IFunction>::getFunction(_getBounds),true);
+ c->setGetterByQName("mouseX","",Class<IFunction>::getFunction(_getMouseX),true);
+ c->setGetterByQName("mouseY","",Class<IFunction>::getFunction(_getMouseY),true);
c->setMethodByQName("localToGlobal","",Class<IFunction>::getFunction(localToGlobal),true);
}
@@ -1767,6 +1769,22 @@ ASFUNCTIONBODY(DisplayObject,_setHeight)
return NULL;
}
+ASFUNCTIONBODY(DisplayObject,_getMouseX)
+{
+ DisplayObject* th=static_cast<DisplayObject*>(obj);
+ number_t temp, outX;
+ th->getConcatenatedMatrix().getInverted().multiply2D(sys->getInputThread()->getMouseX(), temp, outX, temp);
+ return abstract_d(outX);
+}
+
+ASFUNCTIONBODY(DisplayObject,_getMouseY)
+{
+ DisplayObject* th=static_cast<DisplayObject*>(obj);
+ number_t temp, outY;
+ th->getConcatenatedMatrix().getInverted().multiply2D(temp, sys->getInputThread()->getMouseY(), temp, outY);
+ return abstract_d(outY);
+}
+
void DisplayObjectContainer::sinit(Class_base* c)
{
c->setConstructor(Class<IFunction>::getFunction(_constructor));
View
2  scripting/flashdisplay.h
@@ -165,6 +165,8 @@ friend class GraphicsContainer;
ASFUNCTION(_getBlendMode);
ASFUNCTION(_getScale9Grid);
ASFUNCTION(_setRotation);
+ ASFUNCTION(_getMouseX);
+ ASFUNCTION(_getMouseY);
ASFUNCTION(localToGlobal);
};
View
15 swf.cpp
@@ -146,6 +146,14 @@ void SystemState::registerTag(Tag* t)
void RootMovieClip::setOnStage(bool staged)
{
Locker l(mutexFrames);
+
+ //Execute the event registered for the first frame, if any
+ if(!frameScripts[0].isNull())
+ {
+ _R<FunctionEvent> funcEvent(new FunctionEvent(_MR(frameScripts[0])));
+ getVm()->addEvent(NullRef, funcEvent);
+ }
+
MovieClip::setOnStage(staged);
}
@@ -1304,13 +1312,6 @@ void RootMovieClip::commitFrame(bool another)
l.unlock();
//Root movie clips are initialized now, after the first frame is really ready
initialize();
- //Now the bindings are effective
- //Execute the event registered for the first frame, if any
- if(!frameScripts[0].isNull())
- {
- _R<FunctionEvent> funcEvent(new FunctionEvent(_MR(frameScripts[0])));
- getVm()->addEvent(NullRef, funcEvent);
- }
//When the first frame is committed the frame rate is known
sys->addTick(1000/frameRate,this);
Please sign in to comment.
Something went wrong with that request. Please try again.