mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-06 21:39:57 +00:00
Move capture/release mouse function to she layer
This commit is contained in:
parent
33706ce6ff
commit
4d4958bf35
@ -34,6 +34,8 @@
|
|||||||
#ifndef WM_MOUSEHWHEEL
|
#ifndef WM_MOUSEHWHEEL
|
||||||
#define WM_MOUSEHWHEEL 0x020E
|
#define WM_MOUSEHWHEEL 0x020E
|
||||||
#endif
|
#endif
|
||||||
|
#elif defined(ALLEGRO_UNIX)
|
||||||
|
#include <xalleg.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@ -537,6 +539,33 @@ public:
|
|||||||
m_scale * position.y);
|
m_scale * position.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void captureMouse() {
|
||||||
|
#ifdef WIN32
|
||||||
|
|
||||||
|
SetCapture((HWND)nativeHandle());
|
||||||
|
|
||||||
|
#elif defined(ALLEGRO_UNIX)
|
||||||
|
|
||||||
|
XGrabPointer(_xwin.display, _xwin.window, False,
|
||||||
|
PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
|
||||||
|
GrabModeAsync, GrabModeAsync,
|
||||||
|
None, None, CurrentTime);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void releaseMouse() {
|
||||||
|
#ifdef WIN32
|
||||||
|
|
||||||
|
ReleaseCapture();
|
||||||
|
|
||||||
|
#elif defined(ALLEGRO_UNIX)
|
||||||
|
|
||||||
|
XUngrabPointer(_xwin.display, CurrentTime);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void* nativeHandle() OVERRIDE {
|
void* nativeHandle() OVERRIDE {
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
return reinterpret_cast<void*>(win_get_window());
|
return reinterpret_cast<void*>(win_get_window());
|
||||||
|
@ -52,6 +52,8 @@ namespace she {
|
|||||||
virtual EventQueue* getEventQueue() = 0;
|
virtual EventQueue* getEventQueue() = 0;
|
||||||
|
|
||||||
virtual void setMousePosition(const gfx::Point& position) = 0;
|
virtual void setMousePosition(const gfx::Point& position) = 0;
|
||||||
|
virtual void captureMouse() = 0;
|
||||||
|
virtual void releaseMouse() = 0;
|
||||||
|
|
||||||
// Returns the HWND on Windows.
|
// Returns the HWND on Windows.
|
||||||
virtual void* nativeHandle() = 0;
|
virtual void* nativeHandle() = 0;
|
||||||
|
@ -891,6 +891,8 @@ void Manager::setCapture(Widget* widget)
|
|||||||
{
|
{
|
||||||
widget->flags |= JI_HASCAPTURE;
|
widget->flags |= JI_HASCAPTURE;
|
||||||
capture_widget = widget;
|
capture_widget = widget;
|
||||||
|
|
||||||
|
m_display->captureMouse();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets the focus to the "magnetic" widget inside the window
|
// Sets the focus to the "magnetic" widget inside the window
|
||||||
@ -929,6 +931,8 @@ void Manager::freeCapture()
|
|||||||
if (capture_widget) {
|
if (capture_widget) {
|
||||||
capture_widget->flags &= ~JI_HASCAPTURE;
|
capture_widget->flags &= ~JI_HASCAPTURE;
|
||||||
capture_widget = NULL;
|
capture_widget = NULL;
|
||||||
|
|
||||||
|
m_display->releaseMouse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,8 +24,6 @@
|
|||||||
#include <allegro.h>
|
#include <allegro.h>
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
#include <winalleg.h>
|
#include <winalleg.h>
|
||||||
#elif defined(ALLEGRO_UNIX)
|
|
||||||
#include <xalleg.h>
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
@ -301,27 +299,6 @@ void set_mouse_position(const gfx::Point& newPos)
|
|||||||
m_y[1] = m_y[0];
|
m_y[1] = m_y[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
void jmouse_capture()
|
|
||||||
{
|
|
||||||
#if defined(ALLEGRO_UNIX)
|
|
||||||
|
|
||||||
XGrabPointer(_xwin.display, _xwin.window, False,
|
|
||||||
PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
|
|
||||||
GrabModeAsync, GrabModeAsync,
|
|
||||||
None, None, CurrentTime);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void jmouse_release()
|
|
||||||
{
|
|
||||||
#if defined(ALLEGRO_UNIX)
|
|
||||||
|
|
||||||
XUngrabPointer(_xwin.display, CurrentTime);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseButtons jmouse_b(int antique)
|
MouseButtons jmouse_b(int antique)
|
||||||
{
|
{
|
||||||
return (MouseButtons)m_b[antique & 1];
|
return (MouseButtons)m_b[antique & 1];
|
||||||
|
@ -64,9 +64,6 @@ namespace ui {
|
|||||||
gfx::Point get_mouse_position();
|
gfx::Point get_mouse_position();
|
||||||
void set_mouse_position(const gfx::Point& newPos);
|
void set_mouse_position(const gfx::Point& newPos);
|
||||||
|
|
||||||
void jmouse_capture();
|
|
||||||
void jmouse_release();
|
|
||||||
|
|
||||||
MouseButtons jmouse_b(int antique);
|
MouseButtons jmouse_b(int antique);
|
||||||
int jmouse_x(int antique);
|
int jmouse_x(int antique);
|
||||||
int jmouse_y(int antique);
|
int jmouse_y(int antique);
|
||||||
|
@ -1224,7 +1224,6 @@ void Widget::captureMouse()
|
|||||||
{
|
{
|
||||||
if (!getManager()->getCapture()) {
|
if (!getManager()->getCapture()) {
|
||||||
getManager()->setCapture(this);
|
getManager()->setCapture(this);
|
||||||
jmouse_capture();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1235,7 +1234,6 @@ void Widget::releaseMouse()
|
|||||||
{
|
{
|
||||||
if (getManager()->getCapture() == this) {
|
if (getManager()->getCapture() == this) {
|
||||||
getManager()->freeCapture();
|
getManager()->freeCapture();
|
||||||
jmouse_release();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user