~alan-griffiths/mir/fix-1654023

« back to all changes in this revision

Viewing changes to examples/eglapp.c

  • Committer: Daniel van Vugt
  • Date: 2015-04-28 07:54:10 UTC
  • mfrom: (2517 development-branch)
  • mto: This revision was merged to the branch mainline in revision 2673.
  • Revision ID: daniel.van.vugt@canonical.com-20150428075410-rwskshfuar7voesp
Merge latest trunk and fix conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 * Author: Daniel van Vugt <daniel.van.vugt@canonical.com>
17
17
 */
18
18
 
19
 
#define MIR_INCLUDE_DEPRECATED_EVENT_HEADER
20
 
 
21
19
#include "eglapp.h"
22
20
#include "mir_toolkit/mir_client_library.h"
23
21
#include <stdio.h>
96
94
{
97
95
    if (mir_input_event_get_type(event) != mir_input_event_type_key)
98
96
        return;
99
 
    MirKeyInputEvent const* kev = mir_input_event_get_key_input_event(event);
100
 
    if (mir_key_input_event_get_action(kev) != mir_key_input_event_action_up)
 
97
    MirKeyboardEvent const* kev = mir_input_event_get_keyboard_event(event);
 
98
    if (mir_keyboard_event_action(kev) != mir_keyboard_action_up)
101
99
        return;
102
 
    if (mir_key_input_event_get_key_code(kev) != XKB_KEY_q)
 
100
    if (mir_keyboard_event_key_code(kev) != XKB_KEY_q)
103
101
        return;
104
102
    
105
103
    running = 0;
144
142
         * support for event queuing (directing them to another thread) or
145
143
         * full single-threaded callbacks. (LP: #1194384).
146
144
         */
147
 
        printf("Resized to %dx%d\n", ev->resize.width, ev->resize.height);
 
145
        {
 
146
            MirResizeEvent const* resize = mir_event_get_resize_event(ev);
 
147
            printf("Resized to %dx%d\n",
 
148
                   mir_resize_event_get_width(resize),
 
149
                   mir_resize_event_get_height(resize));
 
150
        }
148
151
        break;
149
152
    case mir_event_type_close_surface:
150
153
        printf("Received close event from server.\n");
186
189
        EGL_CONTEXT_CLIENT_VERSION, 2,
187
190
        EGL_NONE
188
191
    };
189
 
    MirEventDelegate delegate = 
190
 
    {
191
 
        mir_eglapp_handle_event,
192
 
        NULL
193
 
    };
194
192
    EGLConfig eglconfig;
195
193
    EGLint neglconfigs;
196
194
    EGLContext eglctx;
388
386
 
389
387
    CHECK(spec != NULL, "Can't create a surface spec");
390
388
 
391
 
    mir_surface_spec_set_name(spec, "eglappsurface");
 
389
    char const* name = argv[0];
 
390
    for (char const* p = name; *p; p++)
 
391
    {
 
392
        if (*p == '/')
 
393
            name = p + 1;
 
394
    }
 
395
    mir_surface_spec_set_name(spec, name);
 
396
 
392
397
    if (output_id != mir_display_output_id_invalid)
393
398
        mir_surface_spec_set_fullscreen_on_output(spec, output_id);
394
399
 
397
402
 
398
403
    CHECK(mir_surface_is_valid(surface), "Can't create a surface");
399
404
 
400
 
    mir_surface_set_event_handler(surface, &delegate);
 
405
    mir_surface_set_event_handler(surface, mir_eglapp_handle_event, NULL);
401
406
    
402
407
    MirCursorConfiguration *conf = mir_cursor_configuration_from_name(cursor_name);
403
408
    mir_surface_configure_cursor(surface, conf);