We now initialize/destroy the display in Xlib::init/shutdown that is called in UnixApplication::init/shutdown and therefore is valid through the whole lifetime. So no need for classes to keep references.
45 lines
776 B
C++
45 lines
776 B
C++
|
|
#ifndef PLATFORM_UNIX_X11MOUSE_H
|
|
#define PLATFORM_UNIX_X11MOUSE_H
|
|
|
|
#include <Spectre/Input/Mouse.h>
|
|
#include <X11/Xlib.h>
|
|
|
|
namespace sp {
|
|
|
|
class X11Mouse : public Mouse
|
|
{
|
|
public :
|
|
X11Mouse();
|
|
|
|
virtual void init();
|
|
|
|
// Get mouse position
|
|
virtual Vector2f getPosition() const;
|
|
|
|
virtual Vector2f getAbsPosition() const;
|
|
|
|
virtual bool isButtonDown(Mouse::Button button) const;
|
|
|
|
// Translate a XEvent to sp::Event, Called from X11EventQueue
|
|
static bool handleMessage(XEvent* xevent, Event& event);
|
|
|
|
protected :
|
|
|
|
virtual void update(InputModule *input);
|
|
|
|
void updateFocusedWindow();
|
|
|
|
protected :
|
|
::Window m_win; // Focused window.
|
|
|
|
Vector2f m_position;
|
|
|
|
Vector2f m_abs_position;
|
|
|
|
unsigned int m_btn_state;
|
|
};
|
|
|
|
} // namespace sp
|
|
|
|
#endif /* PLATFORM_UNIX_X11MOUSE_H */
|