~afrantzis/mir/fix-1679591-display-config-observer-race

« back to all changes in this revision

Viewing changes to examples/eglapp.c

  • Committer: Tarmac
  • Author(s): Daniel van Vugt
  • Date: 2017-04-03 03:57:59 UTC
  • mfrom: (4132.1.1 toy)
  • Revision ID: tarmac-20170403035759-pby1u5onojcx9awj
eglapp: Go fullscreen properly, using window states.
.

Approved by Alan Griffiths, mir-ci-bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
209
209
    }
210
210
}
211
211
 
212
 
static MirOutput const* find_active_output(
213
 
    MirDisplayConfig const* conf)
214
 
{
215
 
    size_t num_outputs = mir_display_config_get_num_outputs(conf);
216
 
 
217
 
    for (size_t i = 0; i < num_outputs; i++)
218
 
    {
219
 
        MirOutput const* output = mir_display_config_get_output(conf, i);
220
 
        MirOutputConnectionState state = mir_output_get_connection_state(output);
221
 
        if (state == mir_output_connection_state_connected && mir_output_is_enabled(output))
222
 
        {
223
 
            return output;
224
 
        }
225
 
    }
226
 
 
227
 
    return NULL;
228
 
}
229
 
 
230
212
static void show_help(struct mir_eglapp_arg const* const* arg_lists)
231
213
{
232
214
    int const indent = 2, desc_offset = 2;
465
447
    }
466
448
    printf("Using pixel format %d.\n", pixel_format);
467
449
 
468
 
    /* eglapps are interested in the screen size, so
469
 
       use mir_connection_create_display_config */
470
 
    MirDisplayConfig* display_config =
471
 
        mir_connection_create_display_configuration(connection);
472
 
 
473
 
    MirOutput const* output = find_active_output(display_config);
474
 
 
475
 
    if (output == NULL)
476
 
    {
477
 
        printf("No active outputs found.\n");
478
 
        return 0;
479
 
    }
480
 
 
481
 
    MirOutputMode const* mode = mir_output_get_current_mode(output);
482
 
 
483
 
    int pos_x = mir_output_get_position_x(output);
484
 
    int pos_y = mir_output_get_position_y(output);
485
 
 
486
 
    int mode_width  = mir_output_mode_get_width(mode);
487
 
    int mode_height = mir_output_mode_get_height(mode);
488
 
 
489
 
    printf("Current active output is %dx%d %+d%+d\n",
490
 
        mode_width, mode_height,
491
 
        pos_x, pos_y);
492
 
 
493
 
    if (fullscreen)  /* TODO: Use window states for this */
494
 
    {
495
 
        *width  = mode_width;
496
 
        *height = mode_height;
497
 
    }
498
 
 
499
 
    mir_display_config_release(display_config);
500
 
 
501
450
    MirWindowSpec *spec =
502
451
        mir_create_normal_window_spec(connection, *width, *height);
503
452
 
504
453
    CHECK(spec != NULL, "Can't create a window spec");
505
454
 
 
455
    if (fullscreen)
 
456
        mir_window_spec_set_state(spec, mir_window_state_fullscreen);
 
457
 
506
458
    if (new_egl)
507
459
    {
508
460
        surface = mir_connection_create_render_surface_sync(connection, *width, *height);