Restructuring of when screen context and events are started stopped, created and destroyed
This commit is contained in:
parent
8c2c8d138c
commit
9f930856ab
@ -29,17 +29,24 @@
|
|||||||
#include "fg_init.h"
|
#include "fg_init.h"
|
||||||
#include "egl/fg_init_egl.h"
|
#include "egl/fg_init_egl.h"
|
||||||
#include <bps/bps.h>
|
#include <bps/bps.h>
|
||||||
#include <bps/navigator.h>
|
#include <screen/screen.h>
|
||||||
|
|
||||||
void fgPlatformInitialize()
|
void fgPlatformInitialize()
|
||||||
{
|
{
|
||||||
bps_initialize();
|
bps_initialize();
|
||||||
|
|
||||||
navigator_request_events(0);
|
|
||||||
//XXX rotation lock? navigator_rotation_lock(true);
|
|
||||||
|
|
||||||
fghPlatformInitializeEGL();
|
fghPlatformInitializeEGL();
|
||||||
|
|
||||||
|
/* Prepare for screen events */
|
||||||
|
fgDisplay.pDisplay.event = NULL;
|
||||||
|
fgDisplay.pDisplay.screenContext = NULL;
|
||||||
|
|
||||||
|
/* Create window */
|
||||||
|
if (screen_create_context(&fgDisplay.pDisplay.screenContext, 0)) {
|
||||||
|
fgError("Could not create screen context");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get start time */
|
/* Get start time */
|
||||||
fgState.Time = fgSystemTime();
|
fgState.Time = fgSystemTime();
|
||||||
|
|
||||||
@ -50,7 +57,8 @@ void fgPlatformCloseDisplay()
|
|||||||
{
|
{
|
||||||
fghPlatformCloseDisplayEGL();
|
fghPlatformCloseDisplayEGL();
|
||||||
|
|
||||||
navigator_stop_events(0);
|
screen_destroy_context(fgDisplay.pDisplay.screenContext);
|
||||||
|
fgDisplay.pDisplay.screenContext = NULL;
|
||||||
|
|
||||||
bps_shutdown();
|
bps_shutdown();
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,8 @@ typedef struct tagSFG_PlatformDisplay SFG_PlatformDisplay;
|
|||||||
struct tagSFG_PlatformDisplay
|
struct tagSFG_PlatformDisplay
|
||||||
{
|
{
|
||||||
struct tagSFG_PlatformDisplayEGL egl;
|
struct tagSFG_PlatformDisplayEGL egl;
|
||||||
|
screen_context_t screenContext;
|
||||||
|
bps_event_t* event;
|
||||||
EGLNativeWindowType single_native_window;
|
EGLNativeWindowType single_native_window;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -49,8 +51,6 @@ typedef struct tagSFG_PlatformContext SFG_PlatformContext;
|
|||||||
struct tagSFG_PlatformContext
|
struct tagSFG_PlatformContext
|
||||||
{
|
{
|
||||||
struct tagSFG_PlatformContextEGL egl;
|
struct tagSFG_PlatformContextEGL egl;
|
||||||
screen_context_t screenContext;
|
|
||||||
bps_event_t* event;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ extern void fgPlatformPopWindow( SFG_Window *window );
|
|||||||
extern void fgPlatformHideWindow( SFG_Window *window );
|
extern void fgPlatformHideWindow( SFG_Window *window );
|
||||||
extern void fgPlatformIconifyWindow( SFG_Window *window );
|
extern void fgPlatformIconifyWindow( SFG_Window *window );
|
||||||
extern void fgPlatformShowWindow( SFG_Window *window );
|
extern void fgPlatformShowWindow( SFG_Window *window );
|
||||||
|
extern void fgPlatformMainLoopPostWork ( void );
|
||||||
|
|
||||||
static struct touchscreen touchscreen;
|
static struct touchscreen touchscreen;
|
||||||
|
|
||||||
@ -160,7 +161,7 @@ fg_time_t fgPlatformSystemTime ( void )
|
|||||||
void fgPlatformSleepForEvents( fg_time_t msec )
|
void fgPlatformSleepForEvents( fg_time_t msec )
|
||||||
{
|
{
|
||||||
//XXX: Is this right? Is there a more direct way to access the context?
|
//XXX: Is this right? Is there a more direct way to access the context?
|
||||||
if(fgStructure.CurrentWindow && bps_get_event(&fgStructure.CurrentWindow->Window.pContext.event, (int)msec) != BPS_SUCCESS) {
|
if(fgStructure.CurrentWindow && bps_get_event(&fgDisplay.pDisplay.event, (int)msec) != BPS_SUCCESS) {
|
||||||
LOGW("BPS couldn't get event");
|
LOGW("BPS couldn't get event");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -256,11 +257,9 @@ void handle_left_mouse(int x, int y, int height, int eventType, SFG_Window* wind
|
|||||||
void fgPlatformProcessSingleEvent ( void )
|
void fgPlatformProcessSingleEvent ( void )
|
||||||
{
|
{
|
||||||
int domain;
|
int domain;
|
||||||
bps_event_t** eventPtr = &fgStructure.CurrentWindow->Window.pContext.event; //XXX Is there a more direct way to access the context?
|
|
||||||
bps_event_t* event;
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if(*eventPtr != NULL) {
|
if(fgDisplay.pDisplay.event != NULL) {
|
||||||
SFG_Window* window = fgStructure.CurrentWindow;
|
SFG_Window* window = fgStructure.CurrentWindow;
|
||||||
if (window != NULL && window->Window.Handle != NULL) {
|
if (window != NULL && window->Window.Handle != NULL) {
|
||||||
int size[2];
|
int size[2];
|
||||||
@ -268,11 +267,10 @@ void fgPlatformProcessSingleEvent ( void )
|
|||||||
fghOnReshapeNotify(window,size[0],size[1],GL_FALSE);
|
fghOnReshapeNotify(window,size[0],size[1],GL_FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
event = *eventPtr;
|
domain = bps_event_get_domain(fgDisplay.pDisplay.event);
|
||||||
domain = bps_event_get_domain(event);
|
|
||||||
if (domain == screen_get_domain()) {
|
if (domain == screen_get_domain()) {
|
||||||
int eventType;
|
int eventType;
|
||||||
screen_event_t screenEvent = screen_event_get_event(event);
|
screen_event_t screenEvent = screen_event_get_event(fgDisplay.pDisplay.event);
|
||||||
screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_TYPE, &eventType);
|
screen_get_event_property_iv(screenEvent, SCREEN_PROPERTY_TYPE, &eventType);
|
||||||
switch (eventType) {
|
switch (eventType) {
|
||||||
|
|
||||||
@ -416,13 +414,13 @@ void fgPlatformProcessSingleEvent ( void )
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (domain == navigator_get_domain()) {
|
} else if (domain == navigator_get_domain()) {
|
||||||
int eventType = bps_event_get_code(event);
|
int eventType = bps_event_get_code(fgDisplay.pDisplay.event);
|
||||||
switch (eventType) {
|
switch (eventType) {
|
||||||
|
|
||||||
case NAVIGATOR_WINDOW_STATE:
|
case NAVIGATOR_WINDOW_STATE:
|
||||||
{
|
{
|
||||||
LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE");
|
LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_WINDOW_STATE");
|
||||||
navigator_window_state_t state = navigator_event_get_window_state(event);
|
navigator_window_state_t state = navigator_event_get_window_state(fgDisplay.pDisplay.event);
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case NAVIGATOR_WINDOW_FULLSCREEN:
|
case NAVIGATOR_WINDOW_FULLSCREEN:
|
||||||
@ -444,6 +442,9 @@ void fgPlatformProcessSingleEvent ( void )
|
|||||||
case NAVIGATOR_EXIT:
|
case NAVIGATOR_EXIT:
|
||||||
{
|
{
|
||||||
LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_EXIT");
|
LOGI("fgPlatformProcessSingleEvent: NAVIGATOR_EXIT");
|
||||||
|
|
||||||
|
fgPlatformMainLoopPostWork();
|
||||||
|
|
||||||
/* User closed the application for good, let's kill the window */
|
/* User closed the application for good, let's kill the window */
|
||||||
SFG_Window* window = fgStructure.CurrentWindow;
|
SFG_Window* window = fgStructure.CurrentWindow;
|
||||||
if (window != NULL) {
|
if (window != NULL) {
|
||||||
@ -474,17 +475,32 @@ void fgPlatformProcessSingleEvent ( void )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while(bps_get_event(eventPtr, 1) == BPS_SUCCESS && *eventPtr != 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 */
|
||||||
*eventPtr = NULL;
|
fgDisplay.pDisplay.event = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fgPlatformMainLoopPreliminaryWork ( void )
|
void fgPlatformMainLoopPreliminaryWork ( void )
|
||||||
{
|
{
|
||||||
LOGI("fgPlatformMainLoopPreliminaryWork");
|
LOGI("fgPlatformMainLoopPreliminaryWork");
|
||||||
|
|
||||||
|
/* Request navigator events */
|
||||||
|
navigator_request_events(0);
|
||||||
|
//XXX rotation lock? navigator_rotation_lock(true);
|
||||||
|
|
||||||
|
/* Request window events */
|
||||||
|
screen_request_events(fgDisplay.pDisplay.screenContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fgPlatformMainLoopPostWork ( void )
|
||||||
|
{
|
||||||
|
LOGI("fgPlatformMainLoopPostWork");
|
||||||
|
|
||||||
|
screen_stop_events(fgDisplay.pDisplay.screenContext);
|
||||||
|
|
||||||
|
navigator_stop_events(0);
|
||||||
|
}
|
||||||
|
|
||||||
/* deal with work list items */
|
/* deal with work list items */
|
||||||
void fgPlatformInitWork(SFG_Window* window)
|
void fgPlatformInitWork(SFG_Window* window)
|
||||||
@ -542,4 +558,3 @@ void fgPlatformVisibilityWork(SFG_Window* window)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,16 +48,10 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
|
|||||||
fgWarning("You can't have more than one window on BlackBerry");
|
fgWarning("You can't have more than one window on BlackBerry");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
window->Window.pContext.event = NULL; //XXX Should probably be done elsewhere. Done here so there is no event at the moment
|
|
||||||
|
|
||||||
/* Create window */
|
/* Create window */
|
||||||
if (screen_create_context(&window->Window.pContext.screenContext, 0)) {
|
|
||||||
fgError("Could not create screen context");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
screen_window_t sWindow;
|
screen_window_t sWindow;
|
||||||
if (screen_create_window(&sWindow, window->Window.pContext.screenContext)) {
|
if (screen_create_window(&sWindow, fgDisplay.pDisplay.screenContext)) {
|
||||||
screen_destroy_context(window->Window.pContext.screenContext);
|
|
||||||
fgError("Could not create window");
|
fgError("Could not create window");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,13 +69,11 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
|
|||||||
#endif
|
#endif
|
||||||
if (screen_set_window_property_iv(sWindow, SCREEN_PROPERTY_FORMAT, &screenFormat)) {
|
if (screen_set_window_property_iv(sWindow, SCREEN_PROPERTY_FORMAT, &screenFormat)) {
|
||||||
screen_destroy_window(sWindow);
|
screen_destroy_window(sWindow);
|
||||||
screen_destroy_context(window->Window.pContext.screenContext);
|
|
||||||
fgError("Could not set window format");
|
fgError("Could not set window format");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (screen_set_window_property_iv(sWindow, SCREEN_PROPERTY_USAGE, &screenUsage)) {
|
if (screen_set_window_property_iv(sWindow, SCREEN_PROPERTY_USAGE, &screenUsage)) {
|
||||||
screen_destroy_window(sWindow);
|
screen_destroy_window(sWindow);
|
||||||
screen_destroy_context(window->Window.pContext.screenContext);
|
|
||||||
fgError("Could not set window usage");
|
fgError("Could not set window usage");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -92,7 +84,6 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
|
|||||||
size[1] = h;
|
size[1] = h;
|
||||||
if (screen_set_window_property_iv(sWindow, SCREEN_PROPERTY_BUFFER_SIZE, size)) {
|
if (screen_set_window_property_iv(sWindow, SCREEN_PROPERTY_BUFFER_SIZE, size)) {
|
||||||
screen_destroy_window(sWindow);
|
screen_destroy_window(sWindow);
|
||||||
screen_destroy_context(window->Window.pContext.screenContext);
|
|
||||||
fgError("Could not set window buffer size");
|
fgError("Could not set window buffer size");
|
||||||
return;
|
return;
|
||||||
}*/
|
}*/
|
||||||
@ -100,14 +91,10 @@ void fgPlatformOpenWindow( SFG_Window* window, const char* title,
|
|||||||
/* Create window buffers */
|
/* Create window buffers */
|
||||||
if (screen_create_window_buffers(sWindow, (fgState.DisplayMode & GLUT_DOUBLE) ? 2 : 1)) {
|
if (screen_create_window_buffers(sWindow, (fgState.DisplayMode & GLUT_DOUBLE) ? 2 : 1)) {
|
||||||
screen_destroy_window(sWindow);
|
screen_destroy_window(sWindow);
|
||||||
screen_destroy_context(window->Window.pContext.screenContext);
|
|
||||||
fgError("Could not create window buffers");
|
fgError("Could not create window buffers");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Request window events */
|
|
||||||
screen_request_events(window->Window.pContext.screenContext); //XXX When multiple screens are supported, this needs to be moved to wherever the screen context is actually created
|
|
||||||
|
|
||||||
/* Save window and set state */
|
/* Save window and set state */
|
||||||
window->Window.Handle = fgDisplay.pDisplay.single_native_window;
|
window->Window.Handle = fgDisplay.pDisplay.single_native_window;
|
||||||
window->State.WorkMask |= GLUT_INIT_WORK;
|
window->State.WorkMask |= GLUT_INIT_WORK;
|
||||||
@ -138,11 +125,7 @@ void fgPlatformCloseWindow( SFG_Window* window )
|
|||||||
{
|
{
|
||||||
fghPlatformCloseWindowEGL(window);
|
fghPlatformCloseWindowEGL(window);
|
||||||
|
|
||||||
screen_stop_events(window->Window.pContext.screenContext);
|
|
||||||
|
|
||||||
screen_destroy_window((screen_window_t)window->Window.Handle);
|
screen_destroy_window((screen_window_t)window->Window.Handle);
|
||||||
|
|
||||||
screen_destroy_context(window->Window.pContext.screenContext);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user