diff --git a/freeglut/freeglut/CMakeLists.txt b/freeglut/freeglut/CMakeLists.txt index d45b9a5..3ed7d9d 100644 --- a/freeglut/freeglut/CMakeLists.txt +++ b/freeglut/freeglut/CMakeLists.txt @@ -263,15 +263,14 @@ IF(ANDROID) # -llog for native Android logging LIST(APPEND LIBS android log) ELSEIF(BLACKBERRY) - if(PLAYBOOK) - # -lbps for event loop - # -screen for native screen - LIST(APPEND LIBS bps screen) - ELSE() - # -lbps for event loop + # -lbps for event loop + # -screen for native screen + LIST(APPEND LIBS bps screen) + + if(NOT PLAYBOOK) # -lslog2 for logging - # -screen for native screen - LIST(APPEND LIBS bps slog2 screen) + # -pps for low-level screen manipulation + LIST(APPEND LIBS slog2 pps) ENDIF() ENDIF() diff --git a/freeglut/freeglut/src/blackberry/fg_internal_blackberry.h b/freeglut/freeglut/src/blackberry/fg_internal_blackberry.h index d06f9e1..6160f78 100644 --- a/freeglut/freeglut/src/blackberry/fg_internal_blackberry.h +++ b/freeglut/freeglut/src/blackberry/fg_internal_blackberry.h @@ -119,10 +119,8 @@ struct tagSFG_PlatformWindowState int originalRotation; navigator_window_state_t windowState; GLboolean windowCovered; -#ifdef __PLAYBOOK__ int keyboardHeight; GLboolean keyboardOpen; -#endif }; /* Menu font and color definitions */ diff --git a/freeglut/freeglut/src/blackberry/fg_main_blackberry.c b/freeglut/freeglut/src/blackberry/fg_main_blackberry.c index 07ec16c..a1b9cbb 100644 --- a/freeglut/freeglut/src/blackberry/fg_main_blackberry.c +++ b/freeglut/freeglut/src/blackberry/fg_main_blackberry.c @@ -353,12 +353,10 @@ void fgPlatformProcessSingleEvent ( void ) do { SFG_Window* window = fgStructure.CurrentWindow; -#ifdef __PLAYBOOK__ /* 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); } -#endif domain = bps_event_get_domain(fgDisplay.pDisplay.event); if (domain == screen_get_domain()) { int eventType; @@ -674,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; @@ -708,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; @@ -775,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: @@ -782,8 +747,10 @@ void fgPlatformProcessSingleEvent ( void ) break; } } -#ifdef __PLAYBOOK__ - /* While this could be used for non-PlayBook, BlackBerry 10 will still get navigator events, so use those. They are a bit more exact. */ + /* + * 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) { @@ -816,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 */ @@ -828,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); diff --git a/freeglut/freeglut/src/blackberry/fg_window_blackberry.c b/freeglut/freeglut/src/blackberry/fg_window_blackberry.c index a1450d1..86668af 100644 --- a/freeglut/freeglut/src/blackberry/fg_window_blackberry.c +++ b/freeglut/freeglut/src/blackberry/fg_window_blackberry.c @@ -31,7 +31,7 @@ #include #include "fg_internal.h" #include "egl/fg_window_egl.h" -#include +#include /* * Opens a window. Requires a SFG_Window object created and attached @@ -261,9 +261,20 @@ void fgPlatformHideWindow( SFG_Window *window ) */ void fgPlatformIconifyWindow( SFG_Window *window ) { - //XXX This is possible via Cascades, but can't seem to find a C-level API - //XXX bb::Application::instance()->minimize(); +#ifndef __PLAYBOOK__ + pps_encoder_t encoder; + + pps_encoder_initialize(&encoder, false); + pps_encoder_add_string(&encoder, "msg", "minimizeWindow"); + + if (navigator_raw_write(pps_encoder_buffer(&encoder), pps_encoder_length(&encoder)) != BPS_SUCCESS) { + fgWarning("Could not iconify window on BlackBerry"); + } + + pps_encoder_cleanup(&encoder); +#else fprintf(stderr, "fgPlatformGlutIconifyWindow: STUB\n"); +#endif } /* @@ -279,6 +290,7 @@ void fgPlatformGlutSetWindowTitle( const char* title ) */ void fgPlatformGlutSetIconTitle( const char* title ) { + //XXX Possibly a window cover label? fprintf(stderr, "fgPlatformGlutSetIconTitle: STUB\n"); }