Update cursor when visibility is changed
This commit is contained in:
parent
23c428160f
commit
ba39e88680
@ -68,28 +68,8 @@ public:
|
|||||||
|
|
||||||
CIrrDeviceWayland *device = static_cast<CIrrDeviceWayland *>(data);
|
CIrrDeviceWayland *device = static_cast<CIrrDeviceWayland *>(data);
|
||||||
|
|
||||||
//TODO: move it to better place
|
device->enter_serial = serial;
|
||||||
if (!device->getCursorControl()->isVisible() &&
|
device->updateCursor();
|
||||||
device->CreationParams.Fullscreen)
|
|
||||||
{
|
|
||||||
wl_pointer_set_cursor(pointer, serial, NULL, 0, 0);
|
|
||||||
}
|
|
||||||
else if (device->default_cursor)
|
|
||||||
{
|
|
||||||
wl_cursor_image* image = device->default_cursor->images[0];
|
|
||||||
wl_buffer* buffer = wl_cursor_image_get_buffer(image);
|
|
||||||
|
|
||||||
if (!buffer)
|
|
||||||
return;
|
|
||||||
|
|
||||||
wl_pointer_set_cursor(pointer, serial, device->cursor_surface,
|
|
||||||
image->hotspot_x, image->hotspot_y);
|
|
||||||
wl_surface_attach(device->cursor_surface, buffer, 0, 0);
|
|
||||||
wl_surface_damage(device->cursor_surface, 0, 0,
|
|
||||||
image->width, image->height);
|
|
||||||
wl_surface_commit(device->cursor_surface);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -103,7 +83,9 @@ public:
|
|||||||
uint32_t time, wl_fixed_t sx, wl_fixed_t sy)
|
uint32_t time, wl_fixed_t sx, wl_fixed_t sy)
|
||||||
{
|
{
|
||||||
CIrrDeviceWayland *device = static_cast<CIrrDeviceWayland *>(data);
|
CIrrDeviceWayland *device = static_cast<CIrrDeviceWayland *>(data);
|
||||||
|
|
||||||
device->getCursorControl()->setPosition(sx, sy);
|
device->getCursorControl()->setPosition(sx, sy);
|
||||||
|
|
||||||
SEvent irrevent;
|
SEvent irrevent;
|
||||||
irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
|
irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
|
||||||
irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
|
irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
|
||||||
@ -694,6 +676,7 @@ CIrrDeviceWayland::CIrrDeviceWayland(const SIrrlichtCreationParameters& param)
|
|||||||
pointer = 0;
|
pointer = 0;
|
||||||
keyboard = 0;
|
keyboard = 0;
|
||||||
ButtonStates = 0;
|
ButtonStates = 0;
|
||||||
|
enter_serial = 0;
|
||||||
|
|
||||||
wl_seat_add_listener(seat, &WaylandCallbacks::seat_listener, this);
|
wl_seat_add_listener(seat, &WaylandCallbacks::seat_listener, this);
|
||||||
wl_output_add_listener(output, &WaylandCallbacks::output_listener, this);
|
wl_output_add_listener(output, &WaylandCallbacks::output_listener, this);
|
||||||
@ -835,6 +818,7 @@ void CIrrDeviceWayland::createDriver()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CIrrDeviceWayland::swapBuffers()
|
void CIrrDeviceWayland::swapBuffers()
|
||||||
{
|
{
|
||||||
wl_display_dispatch_pending(display);
|
wl_display_dispatch_pending(display);
|
||||||
@ -842,6 +826,30 @@ void CIrrDeviceWayland::swapBuffers()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CIrrDeviceWayland::updateCursor()
|
||||||
|
{
|
||||||
|
if (!getCursorControl()->isVisible() && CreationParams.Fullscreen)
|
||||||
|
{
|
||||||
|
wl_pointer_set_cursor(pointer, enter_serial, NULL, 0, 0);
|
||||||
|
}
|
||||||
|
else if (default_cursor)
|
||||||
|
{
|
||||||
|
wl_cursor_image* image = default_cursor->images[0];
|
||||||
|
wl_buffer* buffer = wl_cursor_image_get_buffer(image);
|
||||||
|
|
||||||
|
if (!buffer)
|
||||||
|
return;
|
||||||
|
|
||||||
|
wl_pointer_set_cursor(pointer, enter_serial, cursor_surface,
|
||||||
|
image->hotspot_x, image->hotspot_y);
|
||||||
|
wl_surface_attach(cursor_surface, buffer, 0, 0);
|
||||||
|
wl_surface_damage(cursor_surface, 0, 0,
|
||||||
|
image->width, image->height);
|
||||||
|
wl_surface_commit(cursor_surface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//! runs the device. Returns false if device wants to be deleted
|
//! runs the device. Returns false if device wants to be deleted
|
||||||
bool CIrrDeviceWayland::run()
|
bool CIrrDeviceWayland::run()
|
||||||
{
|
{
|
||||||
|
@ -139,7 +139,9 @@ namespace irr
|
|||||||
{
|
{
|
||||||
if (visible==IsVisible)
|
if (visible==IsVisible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
IsVisible = visible;
|
IsVisible = visible;
|
||||||
|
Device->updateCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Returns if the cursor is currently visible.
|
//! Returns if the cursor is currently visible.
|
||||||
@ -267,9 +269,11 @@ namespace irr
|
|||||||
wl_egl_window *egl_window;
|
wl_egl_window *egl_window;
|
||||||
|
|
||||||
u32 ButtonStates;
|
u32 ButtonStates;
|
||||||
|
uint32_t enter_serial;
|
||||||
|
|
||||||
ContextManagerEGL* getEGLContext() {return EglContext;}
|
ContextManagerEGL* getEGLContext() {return EglContext;}
|
||||||
void swapBuffers();
|
void swapBuffers();
|
||||||
|
void updateCursor();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// XVisualInfo* visual;
|
// XVisualInfo* visual;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user