Added support for minimizing window.

Fixed issue where reshape callback would be called multiple times due to conflicting window size messages on keyboard closure.
Fixed issue where changing orientation with the keyboard open would cause multiple reshape events.

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1728 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
dcnieho 2014-11-03 04:19:10 +00:00
parent 9089d1c682
commit 84695da2d0
4 changed files with 35 additions and 62 deletions

View File

@ -268,15 +268,14 @@ IF(ANDROID)
# -llog for native Android logging # -llog for native Android logging
LIST(APPEND LIBS android log) LIST(APPEND LIBS android log)
ELSEIF(BLACKBERRY) ELSEIF(BLACKBERRY)
if(PLAYBOOK) # -lbps for event loop
# -lbps for event loop # -screen for native screen
# -screen for native screen LIST(APPEND LIBS bps screen)
LIST(APPEND LIBS bps screen)
ELSE() if(NOT PLAYBOOK)
# -lbps for event loop
# -lslog2 for logging # -lslog2 for logging
# -screen for native screen # -pps for low-level screen manipulation
LIST(APPEND LIBS bps slog2 screen) LIST(APPEND LIBS slog2 pps)
ENDIF() ENDIF()
ENDIF() ENDIF()

View File

@ -119,10 +119,8 @@ struct tagSFG_PlatformWindowState
int originalRotation; int originalRotation;
navigator_window_state_t windowState; navigator_window_state_t windowState;
GLboolean windowCovered; GLboolean windowCovered;
#ifdef __PLAYBOOK__
int keyboardHeight; int keyboardHeight;
GLboolean keyboardOpen; GLboolean keyboardOpen;
#endif
}; };
/* Menu font and color definitions */ /* Menu font and color definitions */

View File

@ -353,12 +353,10 @@ void fgPlatformProcessSingleEvent ( void )
do do
{ {
SFG_Window* window = fgStructure.CurrentWindow; SFG_Window* window = fgStructure.CurrentWindow;
#ifdef __PLAYBOOK__
/* Get the keyboard height before doing anything since we otherwise don't get it until it changes */ /* Get the keyboard height before doing anything since we otherwise don't get it until it changes */
if(window->State.pWState.keyboardHeight == 0) { if(window->State.pWState.keyboardHeight == 0) {
virtualkeyboard_get_height(&window->State.pWState.keyboardHeight); virtualkeyboard_get_height(&window->State.pWState.keyboardHeight);
} }
#endif
domain = bps_event_get_domain(fgDisplay.pDisplay.event); domain = bps_event_get_domain(fgDisplay.pDisplay.event);
if (domain == screen_get_domain()) { if (domain == screen_get_domain()) {
int eventType; 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 */ /* 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.newWidth = glutGet(GLUT_WINDOW_WIDTH);
window->State.pWState.newHeight = glutGet(GLUT_WINDOW_HEIGHT); window->State.pWState.newHeight = glutGet(GLUT_WINDOW_HEIGHT);
#endif
fghOnReshapeNotify(window, window->State.pWState.newWidth, window->State.pWState.newHeight, GL_FALSE); 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 */ /* Reset sizes */
window->State.pWState.newWidth = 0; window->State.pWState.newWidth = 0;
@ -708,48 +711,9 @@ void fgPlatformProcessSingleEvent ( void )
#ifndef __PLAYBOOK__ #ifndef __PLAYBOOK__
case NAVIGATOR_KEYBOARD_STATE: 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: case NAVIGATOR_KEYBOARD_POSITION:
{ /* See virtual keyboard handling for info on why this is not used. */
/* 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);
}
break; break;
}
case NAVIGATOR_DEVICE_LOCK_STATE: case NAVIGATOR_DEVICE_LOCK_STATE:
break; break;
@ -775,6 +739,7 @@ void fgPlatformProcessSingleEvent ( void )
#endif #endif
case 0: //Doesn't exist in header, but shows up when keyboard shows and resizes case 0: //Doesn't exist in header, but shows up when keyboard shows and resizes
case NAVIGATOR_OTHER:
break; break;
default: default:
@ -782,8 +747,10 @@ void fgPlatformProcessSingleEvent ( void )
break; 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()) { else if(domain == virtualkeyboard_get_domain()) {
unsigned int eventType = bps_event_get_code(fgDisplay.pDisplay.event); unsigned int eventType = bps_event_get_code(fgDisplay.pDisplay.event);
switch (eventType) { switch (eventType) {
@ -816,7 +783,6 @@ void fgPlatformProcessSingleEvent ( void )
break; break;
} }
} }
#endif
} while(bps_get_event(&fgDisplay.pDisplay.event, 1) == BPS_SUCCESS && fgDisplay.pDisplay.event != NULL); } while(bps_get_event(&fgDisplay.pDisplay.event, 1) == BPS_SUCCESS && fgDisplay.pDisplay.event != NULL);
/* Reset event to reduce chances of triggering something */ /* Reset event to reduce chances of triggering something */
@ -828,15 +794,13 @@ void fgPlatformMainLoopPreliminaryWork ( void )
LOGI("fgPlatformMainLoopPreliminaryWork"); LOGI("fgPlatformMainLoopPreliminaryWork");
/* Request navigator events */ /* Request navigator events */
navigator_request_events(0); navigator_request_events(NAVIGATOR_EXTENDED_DATA);
/* Allow rotation */ /* Allow rotation */
navigator_rotation_lock(false); navigator_rotation_lock(false);
#ifdef __PLAYBOOK__
/* Request keyboard events */ /* Request keyboard events */
virtualkeyboard_request_events(0); virtualkeyboard_request_events(0);
#endif
/* Request window events */ /* Request window events */
screen_request_events(fgDisplay.pDisplay.screenContext); screen_request_events(fgDisplay.pDisplay.screenContext);

View File

@ -31,7 +31,7 @@
#include <GL/freeglut.h> #include <GL/freeglut.h>
#include "fg_internal.h" #include "fg_internal.h"
#include "egl/fg_window_egl.h" #include "egl/fg_window_egl.h"
#include <screen/screen.h> #include <sys/pps.h>
/* /*
* Opens a window. Requires a SFG_Window object created and attached * 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 ) void fgPlatformIconifyWindow( SFG_Window *window )
{ {
//XXX This is possible via Cascades, but can't seem to find a C-level API #ifndef __PLAYBOOK__
//XXX bb::Application::instance()->minimize(); 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"); fprintf(stderr, "fgPlatformGlutIconifyWindow: STUB\n");
#endif
} }
/* /*
@ -279,6 +290,7 @@ void fgPlatformGlutSetWindowTitle( const char* title )
*/ */
void fgPlatformGlutSetIconTitle( const char* title ) void fgPlatformGlutSetIconTitle( const char* title )
{ {
//XXX Possibly a window cover label?
fprintf(stderr, "fgPlatformGlutSetIconTitle: STUB\n"); fprintf(stderr, "fgPlatformGlutSetIconTitle: STUB\n");
} }