mirror of
https://github.com/aseprite/aseprite.git
synced 2024-10-04 05:50:15 +00:00
Add jmouse_release/capture functions.
This commit is contained in:
parent
7341d3b091
commit
51e558e1be
@ -7,8 +7,10 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <allegro.h>
|
||||
#ifdef ALLEGRO_WINDOWS
|
||||
#include <winalleg.h>
|
||||
#if defined(ALLEGRO_WINDOWS)
|
||||
#include <winalleg.h>
|
||||
#elif defined(ALLEGRO_UNIX)
|
||||
#include <xalleg.h>
|
||||
#endif
|
||||
|
||||
#include "gui/jintern.h"
|
||||
@ -362,6 +364,35 @@ void jmouse_set_position(int x, int y)
|
||||
}
|
||||
}
|
||||
|
||||
void jmouse_capture()
|
||||
{
|
||||
#if defined(ALLEGRO_WINDOWS)
|
||||
|
||||
SetCapture(win_get_window());
|
||||
|
||||
#elif defined(ALLEGRO_UNIX)
|
||||
|
||||
XGrabPointer(_xwin.display, _xwin.window, False,
|
||||
PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
|
||||
GrabModeAsync, GrabModeAsync,
|
||||
None, None, CurrentTime);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void jmouse_release()
|
||||
{
|
||||
#if defined(ALLEGRO_WINDOWS)
|
||||
|
||||
::ReleaseCapture();
|
||||
|
||||
#elif defined(ALLEGRO_UNIX)
|
||||
|
||||
XUngrabPointer(_xwin.display, CurrentTime);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
int jmouse_x(int antique) { return m_x[antique & 1]; }
|
||||
int jmouse_y(int antique) { return m_y[antique & 1]; }
|
||||
int jmouse_z(int antique) { return m_z[antique & 1]; }
|
||||
@ -407,10 +438,10 @@ static void update_mouse_position()
|
||||
m_y[0] = JI_SCREEN_H * mouse_y / SCREEN_H;
|
||||
}
|
||||
|
||||
if (is_windowed_mode()) {
|
||||
#ifdef ALLEGRO_WINDOWS
|
||||
/* this help us (in windows) to get mouse feedback when we capture
|
||||
the mouse but we are outside the Allegro window */
|
||||
if (is_windowed_mode()) {
|
||||
POINT pt;
|
||||
RECT rc;
|
||||
|
||||
@ -443,8 +474,8 @@ static void update_mouse_position()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static void capture_covered_area()
|
||||
|
@ -70,6 +70,9 @@ bool jmouse_is_shown();
|
||||
bool jmouse_poll();
|
||||
void jmouse_set_position(int x, int y);
|
||||
|
||||
void jmouse_capture();
|
||||
void jmouse_release();
|
||||
|
||||
int jmouse_b(int antique);
|
||||
int jmouse_x(int antique);
|
||||
int jmouse_y(int antique);
|
||||
|
@ -17,9 +17,6 @@
|
||||
# include <cstdio>
|
||||
#endif
|
||||
#include <allegro.h>
|
||||
#ifdef ALLEGRO_WINDOWS
|
||||
#include <winalleg.h>
|
||||
#endif
|
||||
|
||||
#include "gui/jinete.h"
|
||||
#include "gui/jintern.h"
|
||||
@ -1401,10 +1398,7 @@ void Widget::captureMouse()
|
||||
{
|
||||
if (!jmanager_get_capture()) {
|
||||
jmanager_set_capture(this);
|
||||
|
||||
#ifdef ALLEGRO_WINDOWS
|
||||
SetCapture(win_get_window());
|
||||
#endif
|
||||
jmouse_capture();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1415,10 +1409,7 @@ void Widget::releaseMouse()
|
||||
{
|
||||
if (jmanager_get_capture() == this) {
|
||||
jmanager_free_capture();
|
||||
|
||||
#ifdef ALLEGRO_WINDOWS
|
||||
::ReleaseCapture(); // Win32 API
|
||||
#endif
|
||||
jmouse_release();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user