| 1 | package SDL2::quit 0.01 { | ||
| 2 | use SDL2::Utils; | ||
| 3 | use experimental 'signatures'; | ||
| 4 | # | ||
| 5 | define quit => [ | ||
| 6 | [ SDL_QuitRequested => sub () { | ||
| 7 | SDL2::FFI::SDL_PumpEvents(), ( | ||
| 8 | SDL2::FFI::SDL_PeepEvents( | ||
| 9 | undef, 0, | ||
| 10 | SDL2::FFI::SDL_PEEKEVENT, SDL2::FFI::SDL_QUIT, | ||
| 11 | SDL2::FFI::SDL_QUIT | ||
| 12 | ) > 0 | ||
| 13 | ); | ||
| 14 | } | ||
| 15 | ] | ||
| 16 | ]; | ||
| 17 | |||
| 18 | =encoding utf-8 | ||
| 19 | |||
| 20 | =head1 NAME | ||
| 21 | |||
| 22 | SDL2::quit - SDL Quit Event Handling | ||
| 23 | |||
| 24 | =head1 SYNOPSIS | ||
| 25 | |||
| 26 | use SDL2 qw[:quit]; | ||
| 27 | |||
| 28 | =head1 DESCRIPTION | ||
| 29 | |||
| 30 | An C<SDL_QUIT> event is generated when the user tries to close the application | ||
| 31 | window. | ||
| 32 | |||
| 33 | If it is ignored or filtered out, the window will remain open. If it is not | ||
| 34 | ignored or filtered, it is queued normally and the window is allowed to close. | ||
| 35 | When the window is closed, screen updates will complete, but have no effect. | ||
| 36 | |||
| 37 | C<SDL_Init( ... )> installs signal handlers for C<SIGINT> (keyboard interrupt) | ||
| 38 | and C<SIGTERM> (system termination request), if handlers do not already exist, | ||
| 39 | that generate C<SDL_QUIT> events as well. There is no way to determine the | ||
| 40 | cause of an C<SDL_QUIT> event, but setting a signal handler in your application | ||
| 41 | will override the default generation of quit events for that signal. | ||
| 42 | |||
| 43 | =head1 Functions | ||
| 44 | |||
| 45 | The following function may be imported with the C<:quit> tag. | ||
| 46 | |||
| 47 | =head2 C<SDL_QuitRequested( )> | ||
| 48 | |||
| 49 | Use this function to see whether an C<SDL_QUIT> event is queued. | ||
| 50 | |||
| 51 | Returns C<SDL_TRUE> if C<SDL_QUIT> is queued or C<SDL_FALSE> otherwise. | ||
| 52 | |||
| 53 | =head1 LICENSE | ||
| 54 | |||
| 55 | Copyright (C) Sanko Robinson. | ||
| 56 | |||
| 57 | This library is free software; you can redistribute it and/or modify it under | ||
| 58 | the terms found in the Artistic License 2. Other copyrights, terms, and | ||
| 59 | conditions may apply to data transmitted through this module. | ||
| 60 | |||
| 61 | =head1 AUTHOR | ||
| 62 | |||
| 63 | Sanko Robinson E<lt>sanko@cpan.orgE<gt> | ||
| 64 | |||
| 65 | =begin stopwords | ||
| 66 | |||
| 67 | =end stopwords | ||
| 68 | |||
| 69 | =cut | ||
| 70 | |||
| 71 | }; | ||
| 72 | 1; |