X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fblackberry%2Ffg_main_blackberry.c;h=a1b9cbbd7b666f4441d577544cbd6f80b68a1f26;hb=002dae879eda329f38fe65cb6f99d4f481a2eb47;hp=4aa6759c72cdc7eefdba487d4ea7d02eca9e0d3f;hpb=265a4c1c07f001dce197024c77ecad3d6aa9b111;p=freeglut diff --git a/src/blackberry/fg_main_blackberry.c b/src/blackberry/fg_main_blackberry.c index 4aa6759..a1b9cbb 100644 --- a/src/blackberry/fg_main_blackberry.c +++ b/src/blackberry/fg_main_blackberry.c @@ -31,11 +31,13 @@ #include "fg_internal.h" #include "egl/fg_window_egl.h" -#ifdef __PLAYBOOK__ -#include #ifdef NDEBUG #define LOGI(...) -#else +#endif + +#ifdef __PLAYBOOK__ +#include +#ifndef LOGI #define LOGI(...) ((void)slogf(1337, _SLOG_INFO, __VA_ARGS__)) #endif #define LOGW(...) ((void)slogf(1337, _SLOG_WARNING, __VA_ARGS__)) @@ -44,9 +46,7 @@ #endif #else #include -#ifdef NDEBUG -#define LOGI(...) -#else +#ifndef LOGI #define LOGI(...) ((void)slog2fa(NULL, 1337, SLOG2_INFO, __VA_ARGS__, SLOG2_FA_END)) #endif #define LOGW(...) ((void)slog2fa(NULL, 1337, SLOG2_WARNING, __VA_ARGS__, SLOG2_FA_END)) @@ -353,6 +353,10 @@ void fgPlatformProcessSingleEvent ( void ) do { SFG_Window* window = fgStructure.CurrentWindow; + /* Get the keyboard height before doing anything since we otherwise don't get it until it changes */ + if(window->State.pWState.keyboardHeight == 0) { + virtualkeyboard_get_height(&window->State.pWState.keyboardHeight); + } domain = bps_event_get_domain(fgDisplay.pDisplay.event); if (domain == screen_get_domain()) { int eventType; @@ -626,6 +630,8 @@ void fgPlatformProcessSingleEvent ( void ) } else { LOGW("NAVIGATOR_EXIT: No current window"); } + + //XXX Should this be a bit more "forceful" so that it doesn't continue to loop through events? break; } @@ -645,6 +651,11 @@ void fgPlatformProcessSingleEvent ( void ) window->State.pWState.newWidth = 0; window->State.pWState.newHeight = 0; +#ifdef __PLAYBOOK__ + /* On rotation, the keyboard is closed. This prevents two resize calls */ + window->State.pWState.keyboardOpen = GL_FALSE; +#endif + /* Notify that we want to rotate */ navigator_orientation_check_response(fgDisplay.pDisplay.event, true); break; @@ -661,8 +672,13 @@ void fgPlatformProcessSingleEvent ( void ) /* PlayBook doesn't indicate what the new size will be, so we need to retrieve it from the window itself */ window->State.pWState.newWidth = glutGet(GLUT_WINDOW_WIDTH); window->State.pWState.newHeight = glutGet(GLUT_WINDOW_HEIGHT); -#endif fghOnReshapeNotify(window, window->State.pWState.newWidth, window->State.pWState.newHeight, GL_FALSE); +#else + if(window->State.pWState.keyboardOpen == GL_FALSE) { + /* On rotation, if the keyboard is open, it will get the keyboard resize events anyway. Otherwise, handle the resize. */ + fghOnReshapeNotify(window, window->State.pWState.newWidth, window->State.pWState.newHeight, GL_FALSE); + } +#endif /* Reset sizes */ window->State.pWState.newWidth = 0; @@ -695,48 +711,9 @@ void fgPlatformProcessSingleEvent ( void ) #ifndef __PLAYBOOK__ case NAVIGATOR_KEYBOARD_STATE: - { - LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_KEYBOARD_STATE"); - - navigator_keyboard_state_t state = navigator_event_get_keyboard_state(fgDisplay.pDisplay.event); - switch (state) - { - case NAVIGATOR_KEYBOARD_CLOSED: - LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_KEYBOARD_STATE-NAVIGATOR_KEYBOARD_CLOSED"); - /* NAVIGATOR_KEYBOARD_POSITION only occurs on open, so on keyboard close we need to reset the keyboard height */ - fgPlatformHandleKeyboardHeight(window, 0); - break; - case NAVIGATOR_KEYBOARD_OPENING: - case NAVIGATOR_KEYBOARD_OPENED: - case NAVIGATOR_KEYBOARD_CLOSING: - break; - case NAVIGATOR_KEYBOARD_UNRECOGNIZED: - LOGW("fgPlatformProcessSingleEvent: NAVIGATOR_KEYBOARD_STATE-NAVIGATOR_KEYBOARD_UNRECOGNIZED"); - break; - default: - LOGW("fgPlatformProcessSingleEvent: NAVIGATOR_KEYBOARD_STATE unknown: 0x%X", SLOG2_FA_SIGNED(state)); - break; - } - break; - } - case NAVIGATOR_KEYBOARD_POSITION: - { - /* Occurs only when keyboard has opened or resizes */ - LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_KEYBOARD_POSITION"); - - int keyboardOffset = navigator_event_get_keyboard_position(fgDisplay.pDisplay.event); - if(keyboardOffset == BPS_FAILURE) { - LOGW("fgPlatformProcessSingleEvent: NAVIGATOR_KEYBOARD_POSITION: getting keyboard offset failed"); - } else { - /* keyboardOffset is the offset from the top of the screen to the top of the keyboard, AKA the size of the uncovered screen - We want the height of the keyboard. So instead of determining the orientation, getting the right display size, and subtracting; - we just get the keyboard height which may be slower but easier to understand and work with */ - virtualkeyboard_get_height(&keyboardOffset); - fgPlatformHandleKeyboardHeight(window, keyboardOffset); - } + /* See virtual keyboard handling for info on why this is not used. */ break; - } case NAVIGATOR_DEVICE_LOCK_STATE: break; @@ -762,6 +739,7 @@ void fgPlatformProcessSingleEvent ( void ) #endif case 0: //Doesn't exist in header, but shows up when keyboard shows and resizes + case NAVIGATOR_OTHER: break; default: @@ -769,21 +747,35 @@ void fgPlatformProcessSingleEvent ( void ) break; } } -#ifdef __PLAYBOOK__ + /* + * BlackBerry 10 navigator provides keyboard events, but they conflict with how we handle keyboard events. + * Causing multiple reshape messages and can leave window state incorrectly setup. + */ else if(domain == virtualkeyboard_get_domain()) { unsigned int eventType = bps_event_get_code(fgDisplay.pDisplay.event); switch (eventType) { case VIRTUALKEYBOARD_EVENT_VISIBLE: + LOGI("fgPlatformProcessSingleEvent: VIRTUALKEYBOARD_EVENT_VISIBLE"); + if(window->State.pWState.keyboardOpen != GL_TRUE) { + window->State.pWState.keyboardOpen = GL_TRUE; + fgPlatformHandleKeyboardHeight(window, window->State.pWState.keyboardHeight); + } break; case VIRTUALKEYBOARD_EVENT_HIDDEN: LOGI("fgPlatformProcessSingleEvent: VIRTUALKEYBOARD_EVENT_HIDDEN"); - fgPlatformHandleKeyboardHeight(window, 0); + if(window->State.pWState.keyboardOpen != GL_FALSE) { + window->State.pWState.keyboardOpen = GL_FALSE; + fgPlatformHandleKeyboardHeight(window, 0); + } break; case VIRTUALKEYBOARD_EVENT_INFO: LOGI("fgPlatformProcessSingleEvent: VIRTUALKEYBOARD_EVENT_INFO"); - fgPlatformHandleKeyboardHeight(window, virtualkeyboard_event_get_height(fgDisplay.pDisplay.event)); + window->State.pWState.keyboardHeight = virtualkeyboard_event_get_height(fgDisplay.pDisplay.event); + if(window->State.pWState.keyboardOpen == GL_TRUE) { + fgPlatformHandleKeyboardHeight(window, window->State.pWState.keyboardHeight); + } break; default: @@ -791,7 +783,6 @@ void fgPlatformProcessSingleEvent ( void ) break; } } -#endif } while(bps_get_event(&fgDisplay.pDisplay.event, 1) == BPS_SUCCESS && fgDisplay.pDisplay.event != NULL); /* Reset event to reduce chances of triggering something */ @@ -803,15 +794,13 @@ void fgPlatformMainLoopPreliminaryWork ( void ) LOGI("fgPlatformMainLoopPreliminaryWork"); /* Request navigator events */ - navigator_request_events(0); + navigator_request_events(NAVIGATOR_EXTENDED_DATA); /* Allow rotation */ navigator_rotation_lock(false); -#ifdef __PLAYBOOK__ /* Request keyboard events */ virtualkeyboard_request_events(0); -#endif /* Request window events */ screen_request_events(fgDisplay.pDisplay.screenContext);