Utility/X11: Try to fix Linux implementation

This commit is contained in:
Lynix 2017-01-18 23:51:59 +01:00
parent 27b000470d
commit d1b5357504
2 changed files with 12 additions and 7 deletions

View File

@ -162,9 +162,10 @@ namespace Nz
bool CursorImpl::Create(SystemCursor cursor) bool CursorImpl::Create(SystemCursor cursor)
{ {
ScopedXCBConnection connection; ScopedXCBConnection connection;
xcb_screen_t* screen = X11::XCBDefaultScreen(connection);
if (xcb_cursor_context_new(connection, m_screen, &m_cursorContext) >= 0) if (xcb_cursor_context_new(connection, screen, &m_cursorContext) >= 0)
m_cursor = xcb_cursor_load_cursor(ctx, s_systemCursorIds[cursor]); m_cursor = xcb_cursor_load_cursor(m_cursorContext, s_systemCursorIds[cursor]);
return true; return true;
} }
@ -196,12 +197,12 @@ namespace Nz
return false; return false;
} }
hiddenCursor = xcb_generate_id(connection); s_hiddenCursor = xcb_generate_id(connection);
// Create the cursor, using the pixmap as both the shape and the mask of the cursor // Create the cursor, using the pixmap as both the shape and the mask of the cursor
if (!X11::CheckCookie( if (!X11::CheckCookie(
connection, xcb_create_cursor(connection, connection, xcb_create_cursor(connection,
hiddenCursor, s_hiddenCursor,
cursorPixmap, cursorPixmap,
cursorPixmap, cursorPixmap,
0, 0, 0, // Foreground RGB color 0, 0, 0, // Foreground RGB color
@ -226,7 +227,9 @@ namespace Nz
s_hiddenCursor = 0; s_hiddenCursor = 0;
} }
} }
xcb_cursor_t CursorImpl::s_hiddenCursor = 0;
std::array<const char*, SystemCursor_Max + 1> CursorImpl::s_systemCursorIds = std::array<const char*, SystemCursor_Max + 1> CursorImpl::s_systemCursorIds =
{ {
// http://gnome-look.org/content/preview.php?preview=1&id=128170&file1=128170-1.png&file2=&file3=&name=Dummy+X11+cursors&PHPSESSID=6 // http://gnome-look.org/content/preview.php?preview=1&id=128170&file1=128170-1.png&file2=&file3=&name=Dummy+X11+cursors&PHPSESSID=6

View File

@ -10,6 +10,7 @@
#include <Nazara/Prerequesites.hpp> #include <Nazara/Prerequesites.hpp>
#include <Nazara/Utility/Enums.hpp> #include <Nazara/Utility/Enums.hpp>
#include <xcb/xcb_cursor.h> #include <xcb/xcb_cursor.h>
#include <array>
namespace Nz namespace Nz
{ {
@ -22,7 +23,7 @@ namespace Nz
public: public:
bool Create(const Image& image, int hotSpotX, int hotSpotY); bool Create(const Image& image, int hotSpotX, int hotSpotY);
bool Create(SystemCursor cursor); bool Create(SystemCursor cursor);
void Destroy(); void Destroy();
xcb_cursor_t GetCursor(); xcb_cursor_t GetCursor();
@ -33,7 +34,8 @@ namespace Nz
xcb_cursor_t m_cursor = 0; xcb_cursor_t m_cursor = 0;
xcb_cursor_context_t* m_cursorContext = nullptr; xcb_cursor_context_t* m_cursorContext = nullptr;
static xcb_cursor_t s_hiddenCursor;
static std::array<const char*, SystemCursor_Max + 1> s_systemCursorIds; static std::array<const char*, SystemCursor_Max + 1> s_systemCursorIds;
}; };
} }