1313#include <GL/osmesa.h>
1414#include "ctxbridges/osmesa_loader.h"
1515#include "driver_helper/nsbypass.h"
16+ #include <android/log.h>
1617
1718#ifdef GLES_TEST
1819#include <GLES2/gl2.h>
@@ -272,7 +273,7 @@ EXTERNAL_API void pojavSwapInterval(int interval) {
272273 br_swap_interval (interval );
273274}
274275
275- EXTERNAL_API void * pojavCreateCursor (GLFWimage * image , int xhot , int yhot ) {
276+ EXTERNAL_API LinkedListNode * pojavCreateCursor (GLFWimage * image , int xhot , int yhot ) {
276277 if (image == NULL ) {
277278 printf ("Passed image is null!\n" );
278279 return NULL ;
@@ -294,43 +295,25 @@ EXTERNAL_API void* pojavCreateCursor(GLFWimage* image, int xhot, int yhot) {
294295 (* env )-> DeleteLocalRef (env , cursor );
295296 (* env )-> DeleteLocalRef (env , buffer );
296297
297- linkedlist_append (pojav_environ -> cursors , globalCursor );
298- return globalCursor ;
298+ return linkedlist_append (pojav_environ -> cursors , globalCursor );
299299}
300300
301- EXTERNAL_API void pojavSetCursor (__attribute__((unused )) void * window , jobject cursor ) {
301+ EXTERNAL_API void pojavSetCursor (__attribute__((unused )) void * window , LinkedListNode * cursor ) {
302+ jobject value = NULL ;
303+ if (cursor ) value = cursor -> value ;
302304 TRY_ATTACH_ENV (env , pojav_environ -> dalvikJavaVMPtr , "failed to attach env from pojavSetCursor!\n" , return ;);
303- (* env )-> CallStaticVoidMethod (env , pojav_environ -> bridgeClazz , pojav_environ -> method_setCursor , cursor );
305+ (* env )-> CallStaticVoidMethod (env , pojav_environ -> bridgeClazz , pojav_environ -> method_setCursor , value );
304306}
305307
306- EXTERNAL_API void pojavDestroyCursor (jobject cursor ) {
307- if (cursor == NULL ) {
308+ EXTERNAL_API void pojavDestroyCursor (LinkedListNode * cursor ) {
309+ if (cursor == NULL || cursor -> value == NULL ) {
308310 printf ("Passed cursor to pojavDestroyCursor is null!\n" );
309311 return ;
310312 }
311313
312314 TRY_ATTACH_ENV (env , pojav_environ -> dalvikJavaVMPtr , "failed to attach env from pojavDestroyCursor!\n" , return ;);
313- (* env )-> CallStaticVoidMethod (env , pojav_environ -> bridgeClazz , pojav_environ -> method_removeCursor , cursor );
315+ (* env )-> CallStaticVoidMethod (env , pojav_environ -> bridgeClazz , pojav_environ -> method_removeCursor , cursor -> value );
314316
315- LinkedListNode * current = pojav_environ -> cursors -> first ;
316- LinkedListNode * prev = NULL ;
317-
318- while (current ) {
319- if (current -> value == cursor ) {
320- if (prev == NULL ) {
321- pojav_environ -> cursors -> first = current -> next ;
322- } else {
323- prev -> next = current -> next ;
324- }
325- if (current == pojav_environ -> cursors -> last ) {
326- pojav_environ -> cursors -> last = prev ;
327- }
328-
329- (* env )-> DeleteGlobalRef (env , current -> value );
330- free (current );
331- break ;
332- }
333- prev = current ;
334- current = current -> next ;
335- }
317+ (* env )-> DeleteGlobalRef (env , cursor -> value );
318+ linkedlist_remove (pojav_environ -> cursors , cursor );
336319}
0 commit comments