"Fossies" - the Fresh Open Source Software Archive

Member "wayland-1.18.0/tests/data/example-code.c" (11 Feb 2020, 13923 Bytes) of package /linux/misc/wayland-1.18.0.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "example-code.c": 1.17.0_vs_1.18.0.

    1 /* SCANNER TEST */
    2 
    3 /*
    4  * Copyright © 2008-2011 Kristian Høgsberg
    5  * Copyright © 2010-2011 Intel Corporation
    6  * Copyright © 2012-2013 Collabora, Ltd.
    7  *
    8  * Permission is hereby granted, free of charge, to any person
    9  * obtaining a copy of this software and associated documentation files
   10  * (the "Software"), to deal in the Software without restriction,
   11  * including without limitation the rights to use, copy, modify, merge,
   12  * publish, distribute, sublicense, and/or sell copies of the Software,
   13  * and to permit persons to whom the Software is furnished to do so,
   14  * subject to the following conditions:
   15  *
   16  * The above copyright notice and this permission notice (including the
   17  * next paragraph) shall be included in all copies or substantial
   18  * portions of the Software.
   19  *
   20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
   21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
   23  * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
   24  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
   25  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
   26  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
   27  * SOFTWARE.
   28  */
   29 
   30 #include <stdlib.h>
   31 #include <stdint.h>
   32 #include "wayland-util.h"
   33 
   34 extern const struct wl_interface wl_buffer_interface;
   35 extern const struct wl_interface wl_callback_interface;
   36 extern const struct wl_interface wl_data_device_interface;
   37 extern const struct wl_interface wl_data_offer_interface;
   38 extern const struct wl_interface wl_data_source_interface;
   39 extern const struct wl_interface wl_keyboard_interface;
   40 extern const struct wl_interface wl_output_interface;
   41 extern const struct wl_interface wl_pointer_interface;
   42 extern const struct wl_interface wl_region_interface;
   43 extern const struct wl_interface wl_registry_interface;
   44 extern const struct wl_interface wl_seat_interface;
   45 extern const struct wl_interface wl_shell_surface_interface;
   46 extern const struct wl_interface wl_shm_pool_interface;
   47 extern const struct wl_interface wl_subsurface_interface;
   48 extern const struct wl_interface wl_surface_interface;
   49 extern const struct wl_interface wl_touch_interface;
   50 
   51 static const struct wl_interface *wayland_types[] = {
   52     NULL,
   53     NULL,
   54     NULL,
   55     NULL,
   56     NULL,
   57     NULL,
   58     NULL,
   59     NULL,
   60     &wl_callback_interface,
   61     &wl_registry_interface,
   62     &wl_surface_interface,
   63     &wl_region_interface,
   64     &wl_buffer_interface,
   65     NULL,
   66     NULL,
   67     NULL,
   68     NULL,
   69     NULL,
   70     &wl_shm_pool_interface,
   71     NULL,
   72     NULL,
   73     &wl_data_source_interface,
   74     &wl_surface_interface,
   75     &wl_surface_interface,
   76     NULL,
   77     &wl_data_source_interface,
   78     NULL,
   79     &wl_data_offer_interface,
   80     NULL,
   81     &wl_surface_interface,
   82     NULL,
   83     NULL,
   84     &wl_data_offer_interface,
   85     &wl_data_offer_interface,
   86     &wl_data_source_interface,
   87     &wl_data_device_interface,
   88     &wl_seat_interface,
   89     &wl_shell_surface_interface,
   90     &wl_surface_interface,
   91     &wl_seat_interface,
   92     NULL,
   93     &wl_seat_interface,
   94     NULL,
   95     NULL,
   96     &wl_surface_interface,
   97     NULL,
   98     NULL,
   99     NULL,
  100     NULL,
  101     NULL,
  102     &wl_output_interface,
  103     &wl_seat_interface,
  104     NULL,
  105     &wl_surface_interface,
  106     NULL,
  107     NULL,
  108     NULL,
  109     &wl_output_interface,
  110     &wl_buffer_interface,
  111     NULL,
  112     NULL,
  113     &wl_callback_interface,
  114     &wl_region_interface,
  115     &wl_region_interface,
  116     &wl_output_interface,
  117     &wl_output_interface,
  118     &wl_pointer_interface,
  119     &wl_keyboard_interface,
  120     &wl_touch_interface,
  121     NULL,
  122     &wl_surface_interface,
  123     NULL,
  124     NULL,
  125     NULL,
  126     &wl_surface_interface,
  127     NULL,
  128     NULL,
  129     NULL,
  130     &wl_surface_interface,
  131     NULL,
  132     &wl_surface_interface,
  133     NULL,
  134     NULL,
  135     &wl_surface_interface,
  136     NULL,
  137     NULL,
  138     &wl_surface_interface,
  139     NULL,
  140     NULL,
  141     NULL,
  142     &wl_subsurface_interface,
  143     &wl_surface_interface,
  144     &wl_surface_interface,
  145     &wl_surface_interface,
  146     &wl_surface_interface,
  147 };
  148 
  149 static const struct wl_message wl_display_requests[] = {
  150     { "sync", "n", wayland_types + 8 },
  151     { "get_registry", "n", wayland_types + 9 },
  152 };
  153 
  154 static const struct wl_message wl_display_events[] = {
  155     { "error", "ous", wayland_types + 0 },
  156     { "delete_id", "u", wayland_types + 0 },
  157 };
  158 
  159 WL_EXPORT const struct wl_interface wl_display_interface = {
  160     "wl_display", 1,
  161     2, wl_display_requests,
  162     2, wl_display_events,
  163 };
  164 
  165 static const struct wl_message wl_registry_requests[] = {
  166     { "bind", "usun", wayland_types + 0 },
  167 };
  168 
  169 static const struct wl_message wl_registry_events[] = {
  170     { "global", "usu", wayland_types + 0 },
  171     { "global_remove", "u", wayland_types + 0 },
  172 };
  173 
  174 WL_EXPORT const struct wl_interface wl_registry_interface = {
  175     "wl_registry", 1,
  176     1, wl_registry_requests,
  177     2, wl_registry_events,
  178 };
  179 
  180 static const struct wl_message wl_callback_events[] = {
  181     { "done", "u", wayland_types + 0 },
  182 };
  183 
  184 WL_EXPORT const struct wl_interface wl_callback_interface = {
  185     "wl_callback", 1,
  186     0, NULL,
  187     1, wl_callback_events,
  188 };
  189 
  190 static const struct wl_message wl_compositor_requests[] = {
  191     { "create_surface", "n", wayland_types + 10 },
  192     { "create_region", "n", wayland_types + 11 },
  193 };
  194 
  195 WL_EXPORT const struct wl_interface wl_compositor_interface = {
  196     "wl_compositor", 4,
  197     2, wl_compositor_requests,
  198     0, NULL,
  199 };
  200 
  201 static const struct wl_message wl_shm_pool_requests[] = {
  202     { "create_buffer", "niiiiu", wayland_types + 12 },
  203     { "destroy", "", wayland_types + 0 },
  204     { "resize", "i", wayland_types + 0 },
  205 };
  206 
  207 WL_EXPORT const struct wl_interface wl_shm_pool_interface = {
  208     "wl_shm_pool", 1,
  209     3, wl_shm_pool_requests,
  210     0, NULL,
  211 };
  212 
  213 static const struct wl_message wl_shm_requests[] = {
  214     { "create_pool", "nhi", wayland_types + 18 },
  215 };
  216 
  217 static const struct wl_message wl_shm_events[] = {
  218     { "format", "u", wayland_types + 0 },
  219 };
  220 
  221 WL_EXPORT const struct wl_interface wl_shm_interface = {
  222     "wl_shm", 1,
  223     1, wl_shm_requests,
  224     1, wl_shm_events,
  225 };
  226 
  227 static const struct wl_message wl_buffer_requests[] = {
  228     { "destroy", "", wayland_types + 0 },
  229 };
  230 
  231 static const struct wl_message wl_buffer_events[] = {
  232     { "release", "", wayland_types + 0 },
  233 };
  234 
  235 WL_EXPORT const struct wl_interface wl_buffer_interface = {
  236     "wl_buffer", 1,
  237     1, wl_buffer_requests,
  238     1, wl_buffer_events,
  239 };
  240 
  241 static const struct wl_message wl_data_offer_requests[] = {
  242     { "accept", "u?s", wayland_types + 0 },
  243     { "receive", "sh", wayland_types + 0 },
  244     { "destroy", "", wayland_types + 0 },
  245     { "finish", "3", wayland_types + 0 },
  246     { "set_actions", "3uu", wayland_types + 0 },
  247 };
  248 
  249 static const struct wl_message wl_data_offer_events[] = {
  250     { "offer", "s", wayland_types + 0 },
  251     { "source_actions", "3u", wayland_types + 0 },
  252     { "action", "3u", wayland_types + 0 },
  253 };
  254 
  255 WL_EXPORT const struct wl_interface wl_data_offer_interface = {
  256     "wl_data_offer", 3,
  257     5, wl_data_offer_requests,
  258     3, wl_data_offer_events,
  259 };
  260 
  261 static const struct wl_message wl_data_source_requests[] = {
  262     { "offer", "s", wayland_types + 0 },
  263     { "destroy", "", wayland_types + 0 },
  264     { "set_actions", "3u", wayland_types + 0 },
  265 };
  266 
  267 static const struct wl_message wl_data_source_events[] = {
  268     { "target", "?s", wayland_types + 0 },
  269     { "send", "sh", wayland_types + 0 },
  270     { "cancelled", "", wayland_types + 0 },
  271     { "dnd_drop_performed", "3", wayland_types + 0 },
  272     { "dnd_finished", "3", wayland_types + 0 },
  273     { "action", "3u", wayland_types + 0 },
  274 };
  275 
  276 WL_EXPORT const struct wl_interface wl_data_source_interface = {
  277     "wl_data_source", 3,
  278     3, wl_data_source_requests,
  279     6, wl_data_source_events,
  280 };
  281 
  282 static const struct wl_message wl_data_device_requests[] = {
  283     { "start_drag", "?oo?ou", wayland_types + 21 },
  284     { "set_selection", "?ou", wayland_types + 25 },
  285     { "release", "2", wayland_types + 0 },
  286 };
  287 
  288 static const struct wl_message wl_data_device_events[] = {
  289     { "data_offer", "n", wayland_types + 27 },
  290     { "enter", "uoff?o", wayland_types + 28 },
  291     { "leave", "", wayland_types + 0 },
  292     { "motion", "uff", wayland_types + 0 },
  293     { "drop", "", wayland_types + 0 },
  294     { "selection", "?o", wayland_types + 33 },
  295 };
  296 
  297 WL_EXPORT const struct wl_interface wl_data_device_interface = {
  298     "wl_data_device", 3,
  299     3, wl_data_device_requests,
  300     6, wl_data_device_events,
  301 };
  302 
  303 static const struct wl_message wl_data_device_manager_requests[] = {
  304     { "create_data_source", "n", wayland_types + 34 },
  305     { "get_data_device", "no", wayland_types + 35 },
  306 };
  307 
  308 WL_EXPORT const struct wl_interface wl_data_device_manager_interface = {
  309     "wl_data_device_manager", 3,
  310     2, wl_data_device_manager_requests,
  311     0, NULL,
  312 };
  313 
  314 static const struct wl_message wl_shell_requests[] = {
  315     { "get_shell_surface", "no", wayland_types + 37 },
  316 };
  317 
  318 WL_EXPORT const struct wl_interface wl_shell_interface = {
  319     "wl_shell", 1,
  320     1, wl_shell_requests,
  321     0, NULL,
  322 };
  323 
  324 static const struct wl_message wl_shell_surface_requests[] = {
  325     { "pong", "u", wayland_types + 0 },
  326     { "move", "ou", wayland_types + 39 },
  327     { "resize", "ouu", wayland_types + 41 },
  328     { "set_toplevel", "", wayland_types + 0 },
  329     { "set_transient", "oiiu", wayland_types + 44 },
  330     { "set_fullscreen", "uu?o", wayland_types + 48 },
  331     { "set_popup", "ouoiiu", wayland_types + 51 },
  332     { "set_maximized", "?o", wayland_types + 57 },
  333     { "set_title", "s", wayland_types + 0 },
  334     { "set_class", "s", wayland_types + 0 },
  335 };
  336 
  337 static const struct wl_message wl_shell_surface_events[] = {
  338     { "ping", "u", wayland_types + 0 },
  339     { "configure", "uii", wayland_types + 0 },
  340     { "popup_done", "", wayland_types + 0 },
  341 };
  342 
  343 WL_EXPORT const struct wl_interface wl_shell_surface_interface = {
  344     "wl_shell_surface", 1,
  345     10, wl_shell_surface_requests,
  346     3, wl_shell_surface_events,
  347 };
  348 
  349 static const struct wl_message wl_surface_requests[] = {
  350     { "destroy", "", wayland_types + 0 },
  351     { "attach", "?oii", wayland_types + 58 },
  352     { "damage", "iiii", wayland_types + 0 },
  353     { "frame", "n", wayland_types + 61 },
  354     { "set_opaque_region", "?o", wayland_types + 62 },
  355     { "set_input_region", "?o", wayland_types + 63 },
  356     { "commit", "", wayland_types + 0 },
  357     { "set_buffer_transform", "2i", wayland_types + 0 },
  358     { "set_buffer_scale", "3i", wayland_types + 0 },
  359     { "damage_buffer", "4iiii", wayland_types + 0 },
  360 };
  361 
  362 static const struct wl_message wl_surface_events[] = {
  363     { "enter", "o", wayland_types + 64 },
  364     { "leave", "o", wayland_types + 65 },
  365 };
  366 
  367 WL_EXPORT const struct wl_interface wl_surface_interface = {
  368     "wl_surface", 4,
  369     10, wl_surface_requests,
  370     2, wl_surface_events,
  371 };
  372 
  373 static const struct wl_message wl_seat_requests[] = {
  374     { "get_pointer", "n", wayland_types + 66 },
  375     { "get_keyboard", "n", wayland_types + 67 },
  376     { "get_touch", "n", wayland_types + 68 },
  377     { "release", "5", wayland_types + 0 },
  378 };
  379 
  380 static const struct wl_message wl_seat_events[] = {
  381     { "capabilities", "u", wayland_types + 0 },
  382     { "name", "2s", wayland_types + 0 },
  383 };
  384 
  385 WL_EXPORT const struct wl_interface wl_seat_interface = {
  386     "wl_seat", 6,
  387     4, wl_seat_requests,
  388     2, wl_seat_events,
  389 };
  390 
  391 static const struct wl_message wl_pointer_requests[] = {
  392     { "set_cursor", "u?oii", wayland_types + 69 },
  393     { "release", "3", wayland_types + 0 },
  394 };
  395 
  396 static const struct wl_message wl_pointer_events[] = {
  397     { "enter", "uoff", wayland_types + 73 },
  398     { "leave", "uo", wayland_types + 77 },
  399     { "motion", "uff", wayland_types + 0 },
  400     { "button", "uuuu", wayland_types + 0 },
  401     { "axis", "uuf", wayland_types + 0 },
  402     { "frame", "5", wayland_types + 0 },
  403     { "axis_source", "5u", wayland_types + 0 },
  404     { "axis_stop", "5uu", wayland_types + 0 },
  405     { "axis_discrete", "5ui", wayland_types + 0 },
  406 };
  407 
  408 WL_EXPORT const struct wl_interface wl_pointer_interface = {
  409     "wl_pointer", 6,
  410     2, wl_pointer_requests,
  411     9, wl_pointer_events,
  412 };
  413 
  414 static const struct wl_message wl_keyboard_requests[] = {
  415     { "release", "3", wayland_types + 0 },
  416 };
  417 
  418 static const struct wl_message wl_keyboard_events[] = {
  419     { "keymap", "uhu", wayland_types + 0 },
  420     { "enter", "uoa", wayland_types + 79 },
  421     { "leave", "uo", wayland_types + 82 },
  422     { "key", "uuuu", wayland_types + 0 },
  423     { "modifiers", "uuuuu", wayland_types + 0 },
  424     { "repeat_info", "4ii", wayland_types + 0 },
  425 };
  426 
  427 WL_EXPORT const struct wl_interface wl_keyboard_interface = {
  428     "wl_keyboard", 6,
  429     1, wl_keyboard_requests,
  430     6, wl_keyboard_events,
  431 };
  432 
  433 static const struct wl_message wl_touch_requests[] = {
  434     { "release", "3", wayland_types + 0 },
  435 };
  436 
  437 static const struct wl_message wl_touch_events[] = {
  438     { "down", "uuoiff", wayland_types + 84 },
  439     { "up", "uui", wayland_types + 0 },
  440     { "motion", "uiff", wayland_types + 0 },
  441     { "frame", "", wayland_types + 0 },
  442     { "cancel", "", wayland_types + 0 },
  443     { "shape", "6iff", wayland_types + 0 },
  444     { "orientation", "6if", wayland_types + 0 },
  445 };
  446 
  447 WL_EXPORT const struct wl_interface wl_touch_interface = {
  448     "wl_touch", 6,
  449     1, wl_touch_requests,
  450     7, wl_touch_events,
  451 };
  452 
  453 static const struct wl_message wl_output_requests[] = {
  454     { "release", "3", wayland_types + 0 },
  455 };
  456 
  457 static const struct wl_message wl_output_events[] = {
  458     { "geometry", "iiiiissi", wayland_types + 0 },
  459     { "mode", "uiii", wayland_types + 0 },
  460     { "done", "2", wayland_types + 0 },
  461     { "scale", "2i", wayland_types + 0 },
  462 };
  463 
  464 WL_EXPORT const struct wl_interface wl_output_interface = {
  465     "wl_output", 3,
  466     1, wl_output_requests,
  467     4, wl_output_events,
  468 };
  469 
  470 static const struct wl_message wl_region_requests[] = {
  471     { "destroy", "", wayland_types + 0 },
  472     { "add", "iiii", wayland_types + 0 },
  473     { "subtract", "iiii", wayland_types + 0 },
  474 };
  475 
  476 WL_EXPORT const struct wl_interface wl_region_interface = {
  477     "wl_region", 1,
  478     3, wl_region_requests,
  479     0, NULL,
  480 };
  481 
  482 static const struct wl_message wl_subcompositor_requests[] = {
  483     { "destroy", "", wayland_types + 0 },
  484     { "get_subsurface", "noo", wayland_types + 90 },
  485 };
  486 
  487 WL_EXPORT const struct wl_interface wl_subcompositor_interface = {
  488     "wl_subcompositor", 1,
  489     2, wl_subcompositor_requests,
  490     0, NULL,
  491 };
  492 
  493 static const struct wl_message wl_subsurface_requests[] = {
  494     { "destroy", "", wayland_types + 0 },
  495     { "set_position", "ii", wayland_types + 0 },
  496     { "place_above", "o", wayland_types + 93 },
  497     { "place_below", "o", wayland_types + 94 },
  498     { "set_sync", "", wayland_types + 0 },
  499     { "set_desync", "", wayland_types + 0 },
  500 };
  501 
  502 WL_EXPORT const struct wl_interface wl_subsurface_interface = {
  503     "wl_subsurface", 1,
  504     6, wl_subsurface_requests,
  505     0, NULL,
  506 };
  507