From efe4e8fa4b0cd10bd44965275103d14270a88df9 Mon Sep 17 00:00:00 2001 From: Rcmaniac25 Date: Fri, 24 Jan 2014 10:35:22 +0000 Subject: [PATCH] Updated toolchain so that it does a more exact check if this is for PlayBook or BlackBerry 10 Fixed bug with keyboard on PlayBook where keyboard heights only occurred on rotation, and resize would occur twice because of it and resize wouldn't happen for keyboard git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1675 7f0cb862-5218-0410-a997-914c9d46530a --- blackberry.toolchain.cmake | 2 +- src/blackberry/fg_internal_blackberry.h | 16 +++++++----- src/blackberry/fg_main_blackberry.c | 41 ++++++++++++++++++++++++------ src/blackberry/fg_structure_blackberry.c | 3 +++ 4 files changed, 47 insertions(+), 15 deletions(-) diff --git a/blackberry.toolchain.cmake b/blackberry.toolchain.cmake index 47198f9..958e4ba 100644 --- a/blackberry.toolchain.cmake +++ b/blackberry.toolchain.cmake @@ -33,7 +33,7 @@ set( CMAKE_SYSTEM_NAME Linux ) set( CMAKE_SYSTEM_VERSION 1 ) # Check for PlayBook -if( EXISTS "${BLACKBERRY_TARGET_ROOT}/usr/include" ) +if( EXISTS "${BLACKBERRY_TARGET_ROOT}/x86/lib/gcc/4.4.2" ) set( PLAYBOOK True ) endif() diff --git a/src/blackberry/fg_internal_blackberry.h b/src/blackberry/fg_internal_blackberry.h index 0756219..d06f9e1 100644 --- a/src/blackberry/fg_internal_blackberry.h +++ b/src/blackberry/fg_internal_blackberry.h @@ -43,7 +43,7 @@ struct tagSFG_PlatformDisplay { struct tagSFG_PlatformDisplayEGL egl; screen_context_t screenContext; - bps_event_t* event; + bps_event_t* event; EGLNativeWindowType single_native_window; }; @@ -114,11 +114,15 @@ struct tagSFG_PlatformJoystick typedef struct tagSFG_PlatformWindowState SFG_PlatformWindowState; struct tagSFG_PlatformWindowState { - int newWidth; - int newHeight; - int originalRotation; - navigator_window_state_t windowState; - GLboolean windowCovered; + int newWidth; + int newHeight; + int originalRotation; + navigator_window_state_t windowState; + GLboolean windowCovered; +#ifdef __PLAYBOOK__ + int keyboardHeight; + GLboolean keyboardOpen; +#endif }; /* Menu font and color definitions */ diff --git a/src/blackberry/fg_main_blackberry.c b/src/blackberry/fg_main_blackberry.c index 4aa6759..07ec16c 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,12 @@ 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; @@ -626,6 +632,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 +653,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; @@ -770,20 +783,32 @@ void fgPlatformProcessSingleEvent ( void ) } } #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. */ 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: diff --git a/src/blackberry/fg_structure_blackberry.c b/src/blackberry/fg_structure_blackberry.c index 3fe233e..d6eab8f 100644 --- a/src/blackberry/fg_structure_blackberry.c +++ b/src/blackberry/fg_structure_blackberry.c @@ -37,4 +37,7 @@ void fgPlatformCreateWindow ( SFG_Window *window ) memset(&(window->State.pWState), 0, sizeof(SFG_PlatformWindowState)); window->State.pWState.windowCovered = GL_FALSE; +#ifdef __PLAYBOOK__ + window->State.pWState.keyboardOpen = GL_FALSE; +#endif } -- 1.7.10.4