Cursor cleanup
This commit is contained in:
@@ -1064,7 +1064,7 @@ void iron_mouse_get_position(int *x, int *y) {
|
||||
y = 0;
|
||||
}
|
||||
|
||||
void iron_mouse_set_cursor(int cursor_index) {}
|
||||
void iron_mouse_set_cursor(iron_cursor_t cursor_index) {}
|
||||
|
||||
void initAndroidFileReader();
|
||||
// void IronAndroidVideoInit();
|
||||
|
||||
@@ -110,7 +110,7 @@ void iron_mouse_show(void) {}
|
||||
void iron_mouse_hide(void) {}
|
||||
void iron_mouse_set_position(int x, int y) {}
|
||||
void iron_mouse_get_position(int *x, int *y) {}
|
||||
void iron_mouse_set_cursor(int cursor_index) {}
|
||||
void iron_mouse_set_cursor(iron_cursor_t cursor_index) {}
|
||||
|
||||
bool with_autoreleasepool(bool (*f)(void)) {
|
||||
@autoreleasepool {
|
||||
|
||||
@@ -1211,57 +1211,29 @@ void iron_mouse_hide() {
|
||||
}
|
||||
}
|
||||
|
||||
void iron_mouse_set_cursor(int cursor_index) {
|
||||
struct iron_x11_window *window = &x11_ctx.windows[0];
|
||||
if (!mouse_hidden) {
|
||||
Cursor cursor;
|
||||
if (cursor_index == 0) {
|
||||
cursor = xlib.XcursorLibraryLoadCursor(x11_ctx.display, "left_ptr"); // "arrow"
|
||||
}
|
||||
else if (cursor_index == 1) {
|
||||
cursor = xlib.XcursorLibraryLoadCursor(x11_ctx.display, "hand1");
|
||||
}
|
||||
else if (cursor_index == 2) {
|
||||
cursor = xlib.XcursorLibraryLoadCursor(x11_ctx.display, "xterm");
|
||||
}
|
||||
else if (cursor_index == 3) {
|
||||
cursor = xlib.XcursorLibraryLoadCursor(x11_ctx.display, "sb_h_double_arrow");
|
||||
}
|
||||
else if (cursor_index == 4) {
|
||||
cursor = xlib.XcursorLibraryLoadCursor(x11_ctx.display, "sb_v_double_arrow");
|
||||
}
|
||||
else if (cursor_index == 5) {
|
||||
cursor = xlib.XcursorLibraryLoadCursor(x11_ctx.display, "top_right_corner");
|
||||
}
|
||||
else if (cursor_index == 6) {
|
||||
cursor = xlib.XcursorLibraryLoadCursor(x11_ctx.display, "bottom_right_corner");
|
||||
}
|
||||
else if (cursor_index == 7) {
|
||||
cursor = xlib.XcursorLibraryLoadCursor(x11_ctx.display, "top_left_corner");
|
||||
}
|
||||
else if (cursor_index == 8) {
|
||||
cursor = xlib.XcursorLibraryLoadCursor(x11_ctx.display, "bottom_left_corner");
|
||||
}
|
||||
else if (cursor_index == 9) {
|
||||
cursor = xlib.XcursorLibraryLoadCursor(x11_ctx.display, "grab");
|
||||
}
|
||||
else if (cursor_index == 10) {
|
||||
cursor = xlib.XcursorLibraryLoadCursor(x11_ctx.display, "grabbing");
|
||||
}
|
||||
else if (cursor_index == 11) {
|
||||
cursor = xlib.XcursorLibraryLoadCursor(x11_ctx.display, "not-allowed");
|
||||
}
|
||||
else if (cursor_index == 12) {
|
||||
cursor = xlib.XcursorLibraryLoadCursor(x11_ctx.display, "watch");
|
||||
}
|
||||
else if (cursor_index == 13) {
|
||||
cursor = xlib.XcursorLibraryLoadCursor(x11_ctx.display, "crosshair");
|
||||
}
|
||||
else {
|
||||
cursor = xlib.XcursorLibraryLoadCursor(x11_ctx.display, "arrow");
|
||||
}
|
||||
xlib.XDefineCursor(x11_ctx.display, window->window, cursor);
|
||||
void iron_mouse_set_cursor(iron_cursor_t cursor_index) {
|
||||
if (mouse_hidden) {
|
||||
return;
|
||||
}
|
||||
|
||||
Cursor cursor;
|
||||
if (cursor_index == IRON_CURSOR_HAND) {
|
||||
cursor = xlib.XcursorLibraryLoadCursor(x11_ctx.display, "hand1");
|
||||
}
|
||||
else if (cursor_index == IRON_CURSOR_IBEAM) {
|
||||
cursor = xlib.XcursorLibraryLoadCursor(x11_ctx.display, "xterm");
|
||||
}
|
||||
else if (cursor_index == IRON_CURSOR_SIZEWE) {
|
||||
cursor = xlib.XcursorLibraryLoadCursor(x11_ctx.display, "sb_h_double_arrow");
|
||||
}
|
||||
else if (cursor_index == IRON_CURSOR_SIZENS) {
|
||||
cursor = xlib.XcursorLibraryLoadCursor(x11_ctx.display, "sb_v_double_arrow");
|
||||
}
|
||||
else {
|
||||
cursor = xlib.XcursorLibraryLoadCursor(x11_ctx.display, "left_ptr"); // "arrow"
|
||||
}
|
||||
struct iron_x11_window *window = &x11_ctx.windows[0];
|
||||
xlib.XDefineCursor(x11_ctx.display, window->window, cursor);
|
||||
}
|
||||
|
||||
void iron_mouse_set_position(int x, int y) {
|
||||
|
||||
@@ -540,21 +540,21 @@ void iron_mouse_get_position(int *x, int *y) {
|
||||
*y = (int)point.y;
|
||||
}
|
||||
|
||||
void iron_mouse_set_cursor(int cursor_index) {
|
||||
void iron_mouse_set_cursor(iron_cursor_t cursor_index) {
|
||||
if (current_cursor_index == cursor_index) {
|
||||
return;
|
||||
}
|
||||
current_cursor_index = cursor_index;
|
||||
if (cursor_index == 1) {
|
||||
if (cursor_index == IRON_CURSOR_HAND) {
|
||||
[[NSCursor pointingHandCursor] set];
|
||||
}
|
||||
else if (cursor_index == 2) {
|
||||
else if (cursor_index == IRON_CURSOR_IBEAM) {
|
||||
[[NSCursor IBeamCursor] set];
|
||||
}
|
||||
else if (cursor_index == 3) {
|
||||
else if (cursor_index == IRON_CURSOR_SIZEWE) {
|
||||
[[NSCursor resizeLeftRightCursor] set];
|
||||
}
|
||||
else if (cursor_index == 4) {
|
||||
else if (cursor_index == IRON_CURSOR_SIZENS) {
|
||||
[[NSCursor resizeUpDownCursor] set];
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -424,15 +424,18 @@ static bool gamepadFound = false;
|
||||
|
||||
static bool cursors_initialized = false;
|
||||
static int cursor = 0;
|
||||
#define NUM_CURSORS 14
|
||||
static HCURSOR cursors[NUM_CURSORS];
|
||||
static HCURSOR cursors[5];
|
||||
static bool bg_erased = false;
|
||||
|
||||
void iron_mouse_set_cursor(int set_cursor) {
|
||||
cursor = set_cursor >= NUM_CURSORS ? 0 : set_cursor;
|
||||
void iron_mouse_set_cursor(iron_cursor_t set_cursor) {
|
||||
cursor = set_cursor;
|
||||
if (cursors_initialized) {
|
||||
SetCursor(cursors[cursor]);
|
||||
}
|
||||
// Set hand icon for drag even when mouse button is pressed
|
||||
if (set_cursor == IRON_CURSOR_HAND) {
|
||||
SetCursor(LoadCursor(NULL, IDC_HAND));
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT WINAPI IronWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
|
||||
@@ -508,19 +511,7 @@ LRESULT WINAPI IronWindowsMessageProcedure(HWND hWnd, UINT msg, WPARAM wParam, L
|
||||
cursors[2] = LoadCursor(0, IDC_IBEAM);
|
||||
cursors[3] = LoadCursor(0, IDC_SIZEWE);
|
||||
cursors[4] = LoadCursor(0, IDC_SIZENS);
|
||||
cursors[5] = LoadCursor(0, IDC_SIZENESW);
|
||||
cursors[6] = LoadCursor(0, IDC_SIZENWSE);
|
||||
cursors[7] = LoadCursor(0, IDC_SIZENWSE);
|
||||
cursors[8] = LoadCursor(0, IDC_SIZENESW);
|
||||
cursors[9] = LoadCursor(0, IDC_SIZEALL);
|
||||
cursors[10] = LoadCursor(0, IDC_SIZEALL);
|
||||
cursors[11] = LoadCursor(0, IDC_NO);
|
||||
cursors[12] = LoadCursor(0, IDC_WAIT);
|
||||
cursors[13] = LoadCursor(0, IDC_CROSS);
|
||||
cursors_initialized = true;
|
||||
if (cursor != 0) {
|
||||
SetCursor(cursors[cursor]);
|
||||
}
|
||||
return TRUE;
|
||||
case WM_SETCURSOR:
|
||||
if (LOWORD(lParam) == HTCLIENT) {
|
||||
|
||||
Reference in New Issue
Block a user