Permalink
Browse files

Fix native screen initialization for BB10 for Samples that use dialogs

Screen initialization has simplified from PlayBook.  Update samples that use
dialogs to reflect the proper way.

Also, stop calling navigator_rotation_lock().  It is rarely needed as long as
the proper rotation behaviour is specified in the bar-descriptor.xml file.
  • Loading branch information...
1 parent f48c504 commit bbfbaa46489279753b63c3d32ef85693b7b47e5b @jhoffmannrim jhoffmannrim committed Nov 2, 2012
View
@@ -25,6 +25,8 @@ AudioControl/arm/o.le-v7-g/AudioControl
AudioControl/arm/o.le-v7/AudioControl
AudioControl/x86/o-g/AudioControl
AudioControl/x86/o/AudioControl
+Camera/arm/o.le-v7-g/Camera
+Camera/arm/o.le-v7/Camera
Channels/arm/o.le-v7-g/Channels
Channels/arm/o.le-v7/Channels
Channels/x86/o-g/Channels
View
@@ -49,12 +49,6 @@ setup_screen()
return EXIT_FAILURE;
}
- //Signal BPS library that navigator orientation is to be locked
- if (BPS_SUCCESS != navigator_rotation_lock(true)) {
- screen_destroy_context(screen_ctx);
- return EXIT_FAILURE;
- }
-
if (screen_create_window(&screen_win, screen_ctx) != 0) {
screen_destroy_context(screen_ctx);
return EXIT_FAILURE;
@@ -65,37 +59,16 @@ setup_screen()
int usage = SCREEN_USAGE_NATIVE;
if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage) != 0) goto fail;
- int size[2];
- if (screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size) != 0) goto fail;
-
- screen_display_t screen_disp;
- screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&screen_disp);
-
- screen_display_mode_t screen_mode;
- if (screen_get_display_property_pv(screen_disp, SCREEN_PROPERTY_MODE, (void**)&screen_mode) != 0) goto fail;
-
- int buffer_size[2] = {size[0], size[1]};
-
- int angle = atoi(getenv("ORIENTATION"));
- if ((angle == 0) || (angle == 180)) {
- if (((screen_mode.width > screen_mode.height) && (size[0] < size[1])) ||
- ((screen_mode.width < screen_mode.height) && (size[0] > size[1]))) {
- buffer_size[1] = size[0];
- buffer_size[0] = size[1];
- }
- } else if ((angle == 90) || (angle == 270)){
- if (((screen_mode.width > screen_mode.height) && (size[0] > size[1])) ||
- ((screen_mode.width < screen_mode.height && size[0] < size[1]))) {
- buffer_size[1] = size[0];
- buffer_size[0] = size[1];
- }
- } else {
- goto fail;
- }
+ const char *env = getenv("WIDTH");
+ if (0 == env) goto fail;
+ int width = atoi(env);
- if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, buffer_size) != 0) goto fail;
+ env = getenv("HEIGHT");
+ if (0 == env) goto fail;
+ int height = atoi(env);
+ int size[2] = { width, height };
- if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ROTATION, &angle) != 0) goto fail;
+ if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size) != 0) goto fail;
if (screen_create_window_buffers(screen_win, 1) != 0) goto fail;
@@ -105,7 +78,7 @@ setup_screen()
int attribs[1] = {SCREEN_BLIT_END};
if (screen_fill(screen_ctx, buff, attribs) != 0) goto fail;
- int dirty_rects[4] = {0, 0, buffer_size[0], buffer_size[1]};
+ int dirty_rects[4] = {0, 0, width, height};
if (screen_post_window(screen_win, buff, 1, (const int*)dirty_rects, 0) != 0) goto fail;
return EXIT_SUCCESS;
View
@@ -49,12 +49,6 @@ setup_screen()
return EXIT_FAILURE;
}
- //Signal BPS library that navigator orientation is to be locked
- if (BPS_SUCCESS != navigator_rotation_lock(true)) {
- screen_destroy_context(screen_ctx);
- return EXIT_FAILURE;
- }
-
if (screen_create_window(&screen_win, screen_ctx) != 0) {
screen_destroy_context(screen_ctx);
return EXIT_FAILURE;
@@ -65,37 +59,16 @@ setup_screen()
int usage = SCREEN_USAGE_NATIVE;
if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage) != 0) goto fail;
- int size[2];
- if (screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size) != 0) goto fail;
-
- screen_display_t screen_disp;
- screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&screen_disp);
-
- screen_display_mode_t screen_mode;
- if (screen_get_display_property_pv(screen_disp, SCREEN_PROPERTY_MODE, (void**)&screen_mode) != 0) goto fail;
-
- int buffer_size[2] = {size[0], size[1]};
-
- int angle = atoi(getenv("ORIENTATION"));
- if ((angle == 0) || (angle == 180)) {
- if (((screen_mode.width > screen_mode.height) && (size[0] < size[1])) ||
- ((screen_mode.width < screen_mode.height) && (size[0] > size[1]))) {
- buffer_size[1] = size[0];
- buffer_size[0] = size[1];
- }
- } else if ((angle == 90) || (angle == 270)){
- if (((screen_mode.width > screen_mode.height) && (size[0] > size[1])) ||
- ((screen_mode.width < screen_mode.height && size[0] < size[1]))) {
- buffer_size[1] = size[0];
- buffer_size[0] = size[1];
- }
- } else {
- goto fail;
- }
+ const char *env = getenv("WIDTH");
+ if (0 == env) goto fail;
+ int width = atoi(env);
- if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, buffer_size) != 0) goto fail;
+ env = getenv("HEIGHT");
+ if (0 == env) goto fail;
+ int height = atoi(env);
+ int size[2] = { width, height };
- if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ROTATION, &angle) != 0) goto fail;
+ if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size) != 0) goto fail;
if (screen_create_window_buffers(screen_win, 1) != 0) goto fail;
@@ -105,7 +78,7 @@ setup_screen()
int attribs[1] = {SCREEN_BLIT_END};
if (screen_fill(screen_ctx, buff, attribs) != 0) goto fail;
- int dirty_rects[4] = {0, 0, buffer_size[0], buffer_size[1]};
+ int dirty_rects[4] = {0, 0, width, height};
if (screen_post_window(screen_win, buff, 1, (const int*)dirty_rects, 0) != 0) goto fail;
return EXIT_SUCCESS;
View
@@ -51,12 +51,6 @@ setup_screen()
return EXIT_FAILURE;
}
- //Signal BPS library that navigator orientation is to be locked
- if (BPS_SUCCESS != navigator_rotation_lock(true)) {
- screen_destroy_context(screen_ctx);
- return EXIT_FAILURE;
- }
-
if (screen_create_window(&screen_win, screen_ctx) != 0) {
screen_destroy_context(screen_ctx);
return EXIT_FAILURE;
@@ -67,37 +61,16 @@ setup_screen()
int usage = SCREEN_USAGE_NATIVE;
if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage) != 0) goto fail;
- int size[2];
- if (screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size) != 0) goto fail;
-
- screen_display_t screen_disp;
- screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&screen_disp);
-
- screen_display_mode_t screen_mode;
- if (screen_get_display_property_pv(screen_disp, SCREEN_PROPERTY_MODE, (void**)&screen_mode) != 0) goto fail;
-
- int buffer_size[2] = {size[0], size[1]};
-
- int angle = atoi(getenv("ORIENTATION"));
- if ((angle == 0) || (angle == 180)) {
- if (((screen_mode.width > screen_mode.height) && (size[0] < size[1])) ||
- ((screen_mode.width < screen_mode.height) && (size[0] > size[1]))) {
- buffer_size[1] = size[0];
- buffer_size[0] = size[1];
- }
- } else if ((angle == 90) || (angle == 270)){
- if (((screen_mode.width > screen_mode.height) && (size[0] > size[1])) ||
- ((screen_mode.width < screen_mode.height && size[0] < size[1]))) {
- buffer_size[1] = size[0];
- buffer_size[0] = size[1];
- }
- } else {
- goto fail;
- }
+ const char *env = getenv("WIDTH");
+ if (0 == env) goto fail;
+ int width = atoi(env);
- if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, buffer_size) != 0) goto fail;
+ env = getenv("HEIGHT");
+ if (0 == env) goto fail;
+ int height = atoi(env);
+ int size[2] = { width, height };
- if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ROTATION, &angle) != 0) goto fail;
+ if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size) != 0) goto fail;
if (screen_create_window_buffers(screen_win, 1) != 0) goto fail;
@@ -107,7 +80,7 @@ setup_screen()
int attribs[1] = {SCREEN_BLIT_END};
if (screen_fill(screen_ctx, buff, attribs) != 0) goto fail;
- int dirty_rects[4] = {0, 0, buffer_size[0], buffer_size[1]};
+ int dirty_rects[4] = {0, 0, width, height};
if (screen_post_window(screen_win, buff, 1, (const int*)dirty_rects, 0) != 0) goto fail;
return EXIT_SUCCESS;
@@ -179,8 +152,6 @@ show_geolocation_dialog_message(const char * msg) {
fprintf(stderr, "%s\n", msg);
}
-
-
void
show_accelerometer_dialog_message(const char * msg) {
dialog_set_alert_message_text(accelerometer_dialog, msg);
View
@@ -49,12 +49,6 @@ setup_screen()
return EXIT_FAILURE;
}
- //Signal BPS library that navigator orientation is to be locked
- if (BPS_SUCCESS != navigator_rotation_lock(true)) {
- screen_destroy_context(screen_ctx);
- return EXIT_FAILURE;
- }
-
if (screen_create_window(&screen_win, screen_ctx) != 0) {
screen_destroy_context(screen_ctx);
return EXIT_FAILURE;
@@ -65,37 +59,16 @@ setup_screen()
int usage = SCREEN_USAGE_NATIVE;
if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage) != 0) goto fail;
- int size[2];
- if (screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size) != 0) goto fail;
-
- screen_display_t screen_disp;
- screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&screen_disp);
-
- screen_display_mode_t screen_mode;
- if (screen_get_display_property_pv(screen_disp, SCREEN_PROPERTY_MODE, (void**)&screen_mode) != 0) goto fail;
-
- int buffer_size[2] = {size[0], size[1]};
-
- int angle = atoi(getenv("ORIENTATION"));
- if ((angle == 0) || (angle == 180)) {
- if (((screen_mode.width > screen_mode.height) && (size[0] < size[1])) ||
- ((screen_mode.width < screen_mode.height) && (size[0] > size[1]))) {
- buffer_size[1] = size[0];
- buffer_size[0] = size[1];
- }
- } else if ((angle == 90) || (angle == 270)){
- if (((screen_mode.width > screen_mode.height) && (size[0] > size[1])) ||
- ((screen_mode.width < screen_mode.height && size[0] < size[1]))) {
- buffer_size[1] = size[0];
- buffer_size[0] = size[1];
- }
- } else {
- goto fail;
- }
+ const char *env = getenv("WIDTH");
+ if (0 == env) goto fail;
+ int width = atoi(env);
- if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, buffer_size) != 0) goto fail;
+ env = getenv("HEIGHT");
+ if (0 == env) goto fail;
+ int height = atoi(env);
+ int size[2] = { width, height };
- if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ROTATION, &angle) != 0) goto fail;
+ if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size) != 0) goto fail;
if (screen_create_window_buffers(screen_win, 1) != 0) goto fail;
@@ -105,7 +78,7 @@ setup_screen()
int attribs[1] = {SCREEN_BLIT_END};
if (screen_fill(screen_ctx, buff, attribs) != 0) goto fail;
- int dirty_rects[4] = {0, 0, buffer_size[0], buffer_size[1]};
+ int dirty_rects[4] = {0, 0, width, height};
if (screen_post_window(screen_win, buff, 1, (const int*)dirty_rects, 0) != 0) goto fail;
return EXIT_SUCCESS;
View
@@ -49,12 +49,6 @@ setup_screen()
return EXIT_FAILURE;
}
- //Signal BPS library that navigator orientation is to be locked
- if (BPS_SUCCESS != navigator_rotation_lock(true)) {
- screen_destroy_context(screen_ctx);
- return EXIT_FAILURE;
- }
-
if (screen_create_window(&screen_win, screen_ctx) != 0) {
screen_destroy_context(screen_ctx);
return EXIT_FAILURE;
@@ -65,37 +59,16 @@ setup_screen()
int usage = SCREEN_USAGE_NATIVE;
if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_USAGE, &usage) != 0) goto fail;
- int size[2];
- if (screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size) != 0) goto fail;
-
- screen_display_t screen_disp;
- screen_get_window_property_pv(screen_win, SCREEN_PROPERTY_DISPLAY, (void **)&screen_disp);
-
- screen_display_mode_t screen_mode;
- if (screen_get_display_property_pv(screen_disp, SCREEN_PROPERTY_MODE, (void**)&screen_mode) != 0) goto fail;
-
- int buffer_size[2] = {size[0], size[1]};
-
- int angle = atoi(getenv("ORIENTATION"));
- if ((angle == 0) || (angle == 180)) {
- if (((screen_mode.width > screen_mode.height) && (size[0] < size[1])) ||
- ((screen_mode.width < screen_mode.height) && (size[0] > size[1]))) {
- buffer_size[1] = size[0];
- buffer_size[0] = size[1];
- }
- } else if ((angle == 90) || (angle == 270)){
- if (((screen_mode.width > screen_mode.height) && (size[0] > size[1])) ||
- ((screen_mode.width < screen_mode.height && size[0] < size[1]))) {
- buffer_size[1] = size[0];
- buffer_size[0] = size[1];
- }
- } else {
- goto fail;
- }
+ const char *env = getenv("WIDTH");
+ if (0 == env) goto fail;
+ int width = atoi(env);
- if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, buffer_size) != 0) goto fail;
+ env = getenv("HEIGHT");
+ if (0 == env) goto fail;
+ int height = atoi(env);
+ int size[2] = { width, height };
- if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ROTATION, &angle) != 0) goto fail;
+ if (screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size) != 0) goto fail;
if (screen_create_window_buffers(screen_win, 1) != 0) goto fail;
@@ -105,7 +78,7 @@ setup_screen()
int attribs[1] = {SCREEN_BLIT_END};
if (screen_fill(screen_ctx, buff, attribs) != 0) goto fail;
- int dirty_rects[4] = {0, 0, buffer_size[0], buffer_size[1]};
+ int dirty_rects[4] = {0, 0, width, height};
if (screen_post_window(screen_win, buff, 1, (const int*)dirty_rects, 0) != 0) goto fail;
return EXIT_SUCCESS;
Oops, something went wrong.

0 comments on commit bbfbaa4

Please sign in to comment.