./0000755000004100000410000000000012752376103011251 5ustar www-datawww-data./doc/0000755000004100000410000000000012752376103012016 5ustar www-datawww-data./doc/Makefile.am0000644000004100000410000000221312752376103014050 0ustar www-datawww-data## ## Makefile for the doc subdirectory of libgeis ## ## Copyright (C) 2010 Canonical Ltd. ## ## Process this file with automake to produce Makefile.in. ## ## This file is part of the libgeis project. This library is free ## software; you can redistribute it and/or modify it under the ## terms of the GNU General Public License as published by the ## Free Software Foundation; either version 3, or (at your option) ## any later version. ## ## This library is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License along ## with this library; see the file COPYING3. If not see ## . ## api/html: mkdir -p api/html doc-html: doc-html-doxygen doc-man: doc-man-doxygen doc-html-doxygen: doxygen doc-man-doxygen: doxygen install-data-local: api/html $(INSTALL) -d $(DESTDIR)$(docdir) cp -a api/html $(DESTDIR)$(docdir) clean-local: -rm -rf *.html api EXTRA_DIST = Doxyfile ./doc/Doxyfile0000644000004100000410000022137012752376103013531 0ustar www-datawww-data# Doxyfile 1.7.4 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = Frame # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = 2.0 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer # a quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = "A library to encapsulate touch events" # With the PROJECT_LOGO tag one can specify an logo or icon that is # included in the documentation. The maximum height of the logo should not # exceed 55 pixels and the maximum width should not exceed 200 pixels. # Doxygen will copy the logo to the output directory. PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = api # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = "The $name class" \ "The $name widget" \ "The $name file" \ is \ provides \ specifies \ contains \ represents \ a \ an \ the # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = NO # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful if your file system # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = YES # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = YES # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for # Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given extension. # Doxygen has a built-in mapping, but you can override or extend it using this # tag. The format is ext=language, where ext is a file extension, and language # is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, # C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make # doxygen treat .inc files as Fortran files (default is PHP), and .f files as C # (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions # you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. EXTENSION_MAPPING = # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also makes the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate getter # and setter methods for a property. Setting this option to YES (the default) # will make doxygen replace the get and set methods by a property in the # documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and # unions are shown inside the group in which they are included (e.g. using # @ingroup) instead of on a separate page (for HTML and Man pages) or # section (for LaTeX and RTF). INLINE_GROUPED_CLASSES = YES # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = YES # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to # determine which symbols to keep in memory and which to flush to disk. # When the cache is full, less often used symbols will be written to disk. # For small to medium size projects (<1000 input files) the default value is # probably good enough. For larger projects a too small cache size can cause # doxygen to be busy swapping symbols to and from disk most of the time # causing a significant performance penalty. # If the system has enough physical memory increasing the cache will improve the # performance by keeping more symbols in memory. Note that the value works on # a logarithmic scale so increasing the size by one will roughly double the # memory usage. The cache size is given by this formula: # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols SYMBOL_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base # name of the file that contains the anonymous namespace. By default # anonymous namespaces are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = NO # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = YES # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = NO # If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen # will list include files with double quotes in the documentation # rather than with sharp brackets. FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = NO # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen # will sort the (brief and detailed) documentation of class members so that # constructors and destructors are listed first. If set to NO (the default) # the constructors will appear in the respective orders defined by # SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. # This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO # and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to # do proper type resolution of all parameters of a function it will reject a # match between the prototype and the implementation of a member function even # if there is only one candidate or it is obvious which candidate to choose # by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen # will still accept a match between prototype and implementation in such cases. STRICT_PROTO_MATCHING = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or macro consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and macros in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = NO # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = NO # Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = NO # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. The create the layout file # that represents doxygen's defaults, run doxygen with the -l option. # You can optionally specify a file name after the option, if omitted # DoxygenLayout.xml will be used as the name of the layout file. LAYOUT_FILE = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # The WARN_NO_PARAMDOC option can be enabled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = ../include/oif # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh # *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py # *.f90 *.f *.for *.vhd *.vhdl FILE_PATTERNS = *.c \ *.cc \ *.cxx \ *.cpp \ *.c++ \ *.d \ *.java \ *.ii \ *.ixx \ *.ipp \ *.i++ \ *.inl \ *.h \ *.hh \ *.hxx \ *.hpp \ *.h++ \ *.idl \ *.odl \ *.cs \ *.php \ *.php3 \ *.inc \ *.m \ *.mm \ *.dox \ *.py \ *.f90 \ *.f \ *.for \ *.vhd \ *.vhdl # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = NO # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = * # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty or if # non of the patterns match the file name, INPUT_FILTER is applied. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file # pattern. A pattern will override the setting for FILTER_PATTERN (if any) # and it is also possible to disable source filtering for a specific pattern # using *.ext= (so without naming a filter). This option only has effect when # FILTER_SOURCE_FILES is enabled. FILTER_SOURCE_PATTERNS = #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = NO # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = NO #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. Note that when using a custom header you are responsible # for the proper inclusion of any scripts and style sheets that doxygen # needs, which is dependent on the configuration options used. # It is adviced to generate a default header using "doxygen -w html # header.html footer.html stylesheet.css YourConfigFile" and then modify # that header. Note that the header is subject to change so you typically # have to redo this when upgrading to a newer version of doxygen or when # changing the value of configuration settings such as GENERATE_TREEVIEW! HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the # $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these # files. In the HTML_STYLESHEET file, use the file name only. Also note that # the files will be copied as-is; there are no commands or markers available. HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. # Doxygen will adjust the colors in the stylesheet and background images # according to this color. Hue is specified as an angle on a colorwheel, # see http://en.wikipedia.org/wiki/Hue for more information. # For instance the value 0 represents red, 60 is yellow, 120 is green, # 180 is cyan, 240 is blue, 300 purple, and 360 is red again. # The allowed range is 0 to 359. HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of # the colors in the HTML output. For a value of 0 the output will use # grayscales only. A value of 255 will produce the most vivid colors. HTML_COLORSTYLE_SAT = 100 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to # the luminance component of the colors in the HTML output. Values below # 100 gradually make the output lighter, whereas values above 100 make # the output darker. The value divided by 100 is the actual gamma applied, # so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, # and 100 does not change the gamma. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting # this to NO can help when comparing the output of multiple runs. HTML_TIMESTAMP = YES # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. For this to work a browser that supports # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = NO # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). # To create a documentation set, doxygen will generate a Makefile in the # HTML output directory. Running make will produce the docset in that # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. GENERATE_DOCSET = NO # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project # When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify # the documentation publisher. This should be a reverse domain-name style # string, e.g. com.mycompany.MyDocSet.documentation. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. CHM_INDEX_ENCODING = # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated # that can be used as input for Qt's qhelpgenerator to generate a # Qt Compressed Help (.qch) of the generated HTML documentation. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can # be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to # add. For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters QHP_CUST_FILTER_NAME = # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see # # Qt Help Project / Custom Filters. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's # filter section matches. # # Qt Help Project / Filter Attributes. QHP_SECT_FILTER_ATTRS = # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can # be used to specify the location of Qt's qhelpgenerator. # If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files # will be generated, which together with the HTML files, form an Eclipse help # plugin. To install this plugin and make it available under the help contents # menu in Eclipse, the contents of the directory containing the HTML and XML # files needs to be copied into the plugins directory of eclipse. The name of # the directory within the plugins directory should be the same as # the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before # the help appears. GENERATE_ECLIPSEHELP = NO # A unique identifier for the eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have # this name. ECLIPSE_DOC_ID = org.doxygen.Project # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values # (range [0,1..20]) that doxygen will group on one line in the generated HTML # documentation. Note that a value of 0 will completely suppress the enum # values from appearing in the overview section. ENUM_VALUES_PER_LINE = 1 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to YES, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). # Windows users are probably better off using the HTML help feature. GENERATE_TREEVIEW = YES # By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, # and Class Hierarchy pages using a tree view instead of an ordered list. USE_INLINE_TREES = YES # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 # When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open # links to external symbols imported via tag files in a separate window. EXT_LINKS_IN_WINDOW = NO # Use this tag to change the font size of Latex formulas included # as images in the HTML documentation. The default is 10. Note that # when you change the font size after a successful doxygen run you need # to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are # not supported properly for IE 6.0, but are supported on all modern browsers. # Note that when changing this option you need to delete any form_*.png files # in the HTML output before the changes have effect. FORMULA_TRANSPARENT = YES # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax # (see http://www.mathjax.org) which uses client side Javascript for the # rendering instead of using prerendered bitmaps. Use this if you do not # have LaTeX installed or if you want to formulas look prettier in the HTML # output. When enabled you also need to install MathJax separately and # configure the path to it using the MATHJAX_RELPATH option. USE_MATHJAX = NO # When MathJax is enabled you need to specify the location relative to the # HTML output directory using the MATHJAX_RELPATH option. The destination # directory should contain the MathJax.js script. For instance, if the mathjax # directory is located at the same level as the HTML output directory, then # MATHJAX_RELPATH should be ../mathjax. The default value points to the # mathjax.org site, so you can quickly see the result without installing # MathJax, but it is strongly recommended to install a local copy of MathJax # before deployment. MATHJAX_RELPATH = http://www.mathjax.org/mathjax # When the SEARCHENGINE tag is enabled doxygen will generate a search box # for the HTML output. The underlying search engine uses javascript # and DHTML and should work on any modern browser. Note that when using # HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets # (GENERATE_DOCSET) there is already a search function so this one should # typically be disabled. For large projects the javascript based search engine # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. SEARCHENGINE = NO # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a PHP enabled web server instead of at the web client # using Javascript. Doxygen will generate the search PHP script and index # file to put on the web server. The advantage of the server # based approach is that it scales better to large projects and allows # full text search. The disadvantages are that it is more difficult to setup # and does not have live searching capabilities. SERVER_BASED_SEARCH = NO #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. # Note that when enabling USE_PDFLATEX this option is only used for # generating bitmaps for formulas in the HTML output, but not in the # Makefile that is written to the output directory. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4 # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for # the generated latex document. The footer should contain everything after # the last chapter. If it is left blank doxygen will generate a # standard footer. Notice: only use this tag if you know what you are doing! LATEX_FOOTER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = YES # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = YES # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO # If LATEX_SOURCE_CODE is set to YES then doxygen will include # source code with syntax highlighting in the LaTeX output. # Note that which sources are shown also depends on other settings # such as SOURCE_BROWSER. LATEX_SOURCE_CODE = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = YES # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. This is useful # if you want to understand what is going on. On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # pointed to by INCLUDE_PATH will be searched when a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition that # overrules the definition found in the source code. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all references to function-like macros # that are alone on a line, have an all uppercase name, and do not end with a # semicolon, because these will confuse the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option also works with HAVE_DOT disabled, but it is recommended to # install and use dot, since it yields more powerful graphs. CLASS_DIAGRAMS = NO # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the # documentation. The MSCGEN_PATH tag allows you to specify the directory where # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is # allowed to run in parallel. When set to 0 (the default) doxygen will # base this on the number of processors available in the system. You can set it # explicitly to a value larger than 0 to get control over the balance # between CPU load and processing speed. DOT_NUM_THREADS = 0 # By default doxygen will write a font called Helvetica to the output # directory and reference it in all dot files that doxygen generates. # When you want a differently looking font you can specify the font name # using DOT_FONTNAME. You need to make sure dot is able to find the font, # which can be done by putting it in a standard location or by setting the # DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory # containing the font. DOT_FONTNAME = Helvetica # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 # By default doxygen will tell dot to use the output directory to look for the # FreeSans.ttf font (which doxygen will put there itself). If you specify a # different font using DOT_FONTNAME you can set the path where dot # can find it using this tag. DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will generate a graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are svg, png, jpg, or gif. # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MSCFILE_DIRS tag can be used to specify one or more directories that # contain msc files that are included in the documentation (see the # \mscfile command). MSCFILE_DIRS = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the # number of direct children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, because dot on Windows does not # seem to support this out of the box. Warning: Depending on the platform used, # enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES ./autogen.sh0000755000004100000410000000031312752376103013247 0ustar www-datawww-data#! /bin/sh srcdir=`dirname $0` test -z "$srcdir" && srcdir=. ORIGDIR=`pwd` cd $srcdir autoreconf --force --install || exit 1 cd $ORIGDIR || exit $? test -n "$NOCONFIGURE" || "$srcdir/configure" "$@" ./include/0000755000004100000410000000000012752376103012674 5ustar www-datawww-data./include/oif/0000755000004100000410000000000012752376103013451 5ustar www-datawww-data./include/oif/frame_backend.h0000644000004100000410000002003112752376103016357 0ustar www-datawww-data/** * @file oif/frame_backend.h * API for creating objects. */ #ifndef FRAME_OIF_FRAME_BACKEND_H_ #define FRAME_OIF_FRAME_BACKEND_H_ /* front end definitions */ #include #ifdef __cplusplus extern "C" { #endif /** Handle for a device to be used on the backend API */ typedef struct UFBackendDevice_* UFBackendDevice; /** Handle for a frame to be used on the backend API */ typedef struct UFBackendFrame_* UFBackendFrame; /** Handle for a touch to be used on the backend API */ typedef struct UFBackendTouch_* UFBackendTouch; /******************************************************************** * Event ********************************************************************/ /** * Creates a new event with a reference count of one. */ FRAME_PUBLIC UFEvent frame_event_new(); /** * Sets the type of the given event */ FRAME_PUBLIC void frame_event_set_type(UFEvent event, UFEventType type); /** * Sets the device property of the given event * * It increases the reference count of the corresponding UFDevice by one. */ FRAME_PUBLIC void frame_event_set_device(UFEvent event, UFBackendDevice device); /** * Sets the frame property of the given event * * It increases the reference count of the corresponding UFFrame by one. */ FRAME_PUBLIC void frame_event_set_frame(UFEvent event, UFBackendFrame frame); /** * Sets the time of the given event */ FRAME_PUBLIC void frame_event_set_time(UFEvent event, uint64_t time); /******************************************************************** * Device ********************************************************************/ /** * Creates a new UFDevice and returns its backend handle. */ FRAME_PUBLIC UFBackendDevice frame_backend_device_new(); /** * Returns a UFDevice instance given its backend handle. */ FRAME_PUBLIC UFDevice frame_backend_device_get_device(UFBackendDevice device); /** * Sets the "Name" property of the given device */ FRAME_PUBLIC void frame_backend_device_set_name(UFBackendDevice device, const char *name); /** * Sets the "Direct" property of the given device */ FRAME_PUBLIC void frame_backend_device_set_direct(UFBackendDevice device, int direct); /** * Sets the "Independent" property of the given device */ FRAME_PUBLIC void frame_backend_device_set_independent(UFBackendDevice device, int independent); /** * Sets the "SemiMT" property of the given device */ FRAME_PUBLIC void frame_backend_device_set_semi_mt(UFBackendDevice device, int semi_mt); /** * Sets the "MaxTouches" property of the given device */ FRAME_PUBLIC void frame_backend_device_set_max_touches(UFBackendDevice device, unsigned int max_touches); /** * Sets the "WindowResolutionX" and "WindowResolutionY" properties of the * given device. */ FRAME_PUBLIC void frame_backend_device_set_window_resolution(UFBackendDevice device, float x, float y); /** * Adds an axis to the device */ FRAME_PUBLIC void frame_backend_device_add_axis(UFBackendDevice device, UFAxisType type, float min, float max, float resolution); /** * Deletes the backend handle of a UFDevice, decreasing its reference count by one. */ FRAME_PUBLIC void frame_backend_device_delete(UFBackendDevice device); /******************************************************************** * Frame ********************************************************************/ /** * Creates a new, empty, UFFrame and returns its backend handle. * * Usually you will use this method only for the very first frame. For all * subsequent ones it will be safer and more convinent to use * frame_backend_frame_create_next(). */ FRAME_PUBLIC UFBackendFrame frame_backend_frame_new(); /** * Creates a new UFFrame that is a continuation of the given one. * * Touches that had a "begin" state on the given frame will be hard-copied and * have an "update" state on the new frame. * * Touches that had an "update" state will be lazily copied to the new frame. * * Touches that had a "end" state on the given frame won't be present * on the new frame. * * The "ActiveTouches" property is automatically set to match the number * of UFTouches present or remaining. */ FRAME_PUBLIC UFBackendFrame frame_backend_frame_create_next(UFBackendFrame frame); /** * Returns a UFFrame instance given its backend handle. */ FRAME_PUBLIC UFFrame frame_backend_frame_get_frame(UFBackendFrame frame); /** * Gets a UFBackendTouch for the UFTouch that has the given id. * * The underlying UFTouch is moved from the given frame to the returned UFBackendTouch. * Once done modifying the touch you're expected to return it to the frame via * frame_backend_frame_give_touch(). * * If the underlying UFTouch is a lazy copy (likely from a touch in the previous frame), a hard copy * will be made upon the first change made to it. * * Possible errors: UFStatusErrorInvalidTouch */ FRAME_PUBLIC UFStatus frame_backend_frame_borrow_touch_by_id(UFBackendFrame frame, UFTouchId id, UFBackendTouch *touch); /** * Sets the "Device" property of the given frame */ FRAME_PUBLIC void frame_backend_frame_set_device(UFBackendFrame frame, UFBackendDevice device); /** * Sets the "WindowId" property of the given frame */ FRAME_PUBLIC void frame_backend_frame_set_window_id(UFBackendFrame frame, UFWindowId window_id); /** * Sets the "ActiveTouches" property of the given frame * * If unset this property returns the number of touches. */ FRAME_PUBLIC void frame_backend_frame_set_active_touches(UFBackendFrame frame, unsigned int active_touches); /** * Gives a UFTouch to the specified frame. * * Gives the underlying UFTouch to the specified frame. The UFBackendTouch * is deleted and no longer valid after this call. * * A frame is a snapshot of the state of all touches at a given point in time. * Therefore it must not have multiple UFTouch instances with the same touch ID. * Attempting to do so will result in a UFStatusErrorTouchIdExists being returned. * * Possible errors: UFStatusErrorTouchIdExists */ FRAME_PUBLIC UFStatus frame_backend_frame_give_touch(UFBackendFrame frame, UFBackendTouch *touch); /** * Deletes the backend handle of a UFFrame, * decreasing its reference count by one. */ FRAME_PUBLIC void frame_backend_frame_delete(UFBackendFrame frame); /******************************************************************** * Touch ********************************************************************/ /** * Creates a new UFTouch and returns its backend handle. * * Its state will be set to "Begin". * * After filled out, it should be given to a frame via frame_backend_frame_give_touch() */ FRAME_PUBLIC UFBackendTouch frame_backend_touch_new(); /** * Returns a UFTouch instance given its backend handle. */ FRAME_PUBLIC UFTouch frame_backend_touch_get_touch(UFBackendTouch touch); /** * Sets the "Id" property of the given touch */ FRAME_PUBLIC void frame_backend_touch_set_id(UFBackendTouch touch, UFTouchId id); /** * Sets the "State" property of the given touch to "End" */ FRAME_PUBLIC void frame_backend_touch_set_ended(UFBackendTouch touch); /** * Sets the "WindowX" and "WindowY" properties of the given touch */ FRAME_PUBLIC void frame_backend_touch_set_window_pos(UFBackendTouch touch, float x, float y); /** * Sets the "Time" property of the given touch */ FRAME_PUBLIC void frame_backend_touch_set_time(UFBackendTouch touch, uint64_t time); /** * Sets the "StartTime" property of the given touch */ FRAME_PUBLIC void frame_backend_touch_set_start_time(UFBackendTouch touch, uint64_t start_time); /** * Sets the "Owned" property of the given touch */ FRAME_PUBLIC void frame_backend_touch_set_owned(UFBackendTouch touch, int owned); /** * Sets the "PendingEnd" property of the given touch */ FRAME_PUBLIC void frame_backend_touch_set_pending_end(UFBackendTouch touch, int pending_end); /** * Sets the value of an axis of the given touch */ FRAME_PUBLIC void frame_backend_touch_set_value(UFBackendTouch touch, UFAxisType type, float value); #ifdef __cplusplus } #endif #endif /* FRAME_OIF_FRAME_BACKEND_H_ */ ./include/oif/frame.h.in0000644000004100000410000005611112752376103015325 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2010-2013 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ /** * @file oif/frame.h * Definitions of the main and platform-generic API */ #ifndef FRAME_OIF_FRAME_H_ #define FRAME_OIF_FRAME_H_ /* Macros that set symbol visibilities in shared libraries properly. * Adapted from http://gcc.gnu.org/wiki/Visibility */ #if defined _WIN32 || defined __CYGWIN__ #ifdef BUILDING_FRAME #define FRAME_PUBLIC __declspec(dllexport) #else #define FRAME_PUBLIC __declspec(dllimport) #endif #else #if defined __GNUC__ #define FRAME_PUBLIC __attribute__ ((visibility("default"))) #else #pragma message ("Compiler does not support symbol visibility.") #define FRAME_PUBLIC #endif #endif /* Clang provides __has_feature, but GCC does not */ #ifdef __has_feature #if __has_feature(c_generic_selections) #define HAS_C_GENERIC_SELECTIONS #endif // __has_feature #endif // __has_feature(c_generic_selections) /* Whether the X11 backend (frame_x11.h) is available. FRAME_X11_BACKEND will be defined if it is and FRAME_NO_X11_BACKEND otherwise. */ #define @FRAME_X11_BACKEND@ #ifdef __cplusplus extern "C" { #endif #include /** An object for the context of the frame instance */ typedef struct UFHandle_* UFHandle; /** An object for an event */ typedef struct UFEvent_* UFEvent; /** An object for a frame of touches */ typedef struct UFFrame_* UFFrame; /** An object for a touch */ typedef struct UFTouch_* UFTouch; /** An object for a device */ typedef struct UFDevice_* UFDevice; /** An object for a device axis */ typedef struct UFAxis_* UFAxis; /** An object for a window ID */ typedef uint64_t UFWindowId; /** An object for a touch ID */ typedef uint64_t UFTouchId; /** The status code denoting the result of a function call */ typedef enum UFStatus { UFStatusSuccess = 0, /**< The call was successful */ UFStatusErrorGeneric, /**< A platform-dependent error occurred */ UFStatusErrorResources, /**< An error occurred due to insufficient resources */ UFStatusErrorNoEvent, /**< No events were available to get */ UFStatusErrorUnknownProperty, /**< The requested property value was not set */ UFStatusErrorInvalidTouch, /**< The requested touch does not exist */ UFStatusErrorInvalidAxis, /**< The requested axis does not exist */ UFStatusErrorUnsupported, /**< The requested function is not supported by the window server */ UFStatusErrorInvalidType, /**< The variable type passed as a void pointer into a property getter is invalid for the property */ UFStatusErrorTouchIdExists, /**< A touch with the same ID already exists */ } UFStatus; /** Properties of a device */ typedef enum UFDeviceProperty { /** * The name of the device * * Value type: const char * * * The frame library owns the string. The string is valid until an event * notifying removal of the device is released. */ UFDevicePropertyName = 0, /** * Whether the device is a direct touch device * * Value type: int with boolean semantics * * A direct touch device is a device where there is a direct transformation * from the touch location to the event location on the screen. An indirect * touch device is a device where the touch has meaning relative to a position * on the screen, such as the location of a cursor. A touchscreens is an * example of a direct device, and a trackpad is an example of an indirect * device. */ UFDevicePropertyDirect, /** * Whether the device is an independent touch device * * Value type: int with boolean semantics * * An independent device is an indirect device whose cursor moves * independently of the touches on the device. A mouse with a touch area for * gestures is an example of an independent device, and a trackpad is an * example of a dependent device. */ UFDevicePropertyIndependent, /** * Whether the device is a semi-multitouch device * * Value type: int with boolean semantics * * A semi-multitouch device provides a bounding box of some touches on the * touch surface. In contrast, a full-multitouch device provides accurate * locations of each individual touch. */ UFDevicePropertySemiMT, /** * The maximum number of touches supported by the device * * Value type: unsigned int */ UFDevicePropertyMaxTouches, /** * The number of touch axes provided by the device * * Value type: unsigned int */ UFDevicePropertyNumAxes, /** * The resolution of the window coordinates of the device in the X axis * * Value type: float * * The resolution is provided in pixels per meter. */ UFDevicePropertyWindowResolutionX, /** * The resolution of the window coordinates of the device in the Y axis * * Value type: float * * The resolution is provided in pixels per meter. */ UFDevicePropertyWindowResolutionY, } UFDeviceProperty; /** Device touch axis types */ typedef enum UFAxisType { UFAxisTypeX = 0, /**< X coordinate */ UFAxisTypeY, /**< Y coordinate */ UFAxisTypeTouchMajor, /**< Width along major axis of contact area of touch */ UFAxisTypeTouchMinor, /**< Width along minor axis of contact area of touch */ UFAxisTypeWidthMajor, /**< Width along major axis of touch tool */ UFAxisTypeWidthMinor, /**< Width along minor axis of touch tool */ UFAxisTypeOrientation, /**< Orientation of major axis of contact ellipse */ UFAxisTypeTool, /**< Tool type */ UFAxisTypeBlobId, /**< Blob ID of group of touches */ UFAxisTypeTrackingId, /**< Tracking ID */ UFAxisTypePressure, /**< Pressure */ UFAxisTypeDistance, /**< Hover distance */ } UFAxisType; /** Event properties */ typedef enum UFEventProperty { /** * Type of event * * Value type: UFEventType */ UFEventPropertyType = 0, /** * Device added or removed * * Value type: UFDevice * * This property is set only when the event type is UFEventTypeDeviceAdded * or UFEventTypeDeviceRemoved. The object is owned by the library and is * valid until an event notifying removal of the device is released. */ UFEventPropertyDevice, /** * Touch frame * * Value type: UFFrame * * This property is set only when the event type is UFEventTypeFrame. The * object is owned by the library and is valid until the event is released. */ UFEventPropertyFrame, /** * Event time * * Value type: 64-bit unsigned int * * This property holds the time the event occurred in display server * timespace. The time is provided in milliseconds (ms). If the event, such as * device addition, occurred before the frame context was created, the value * will be 0. */ UFEventPropertyTime, } UFEventProperty; /** Event types */ typedef enum UFEventType { UFEventTypeDeviceAdded = 0, /**< A new device has been added */ UFEventTypeDeviceRemoved, /**< An existing device has been removed */ UFEventTypeFrame, /**< The state of one or more touches has changed */ } UFEventType; /** Touch frame properties */ typedef enum UFFrameProperty { /** * The device for the frame * * Value type: UFDevice */ UFFramePropertyDevice = 0, /** * The window server ID of the window for the frame * * Value type: UFWindowId */ UFFramePropertyWindowId, /** * Number of touches in the frame * * Value type: unsigned int * * Some devices can track more touches than they can report data for. Only * touches with X and Y position are provided in the frame. */ UFFramePropertyNumTouches, /** * Total number of active touches on the device * * Value type: unsigned int * * Some devices can track more touches than they can report data for. This * value includes the number of reported and unreported touches. */ UFFramePropertyActiveTouches, } UFFrameProperty; /** State of an individual touch */ typedef enum UFTouchState { UFTouchStateBegin = 0, /**< The touch began */ UFTouchStateUpdate, /**< A value or property of the touch changed */ UFTouchStateEnd, /**< The touch ended */ } UFTouchState; /** Touch properties */ typedef enum UFTouchProperty { /** * Window server ID of the touch * * Value type: UFTouchId */ UFTouchPropertyId = 0, /** * State of the touch * * Value type: UFTouchState */ UFTouchPropertyState, /** * Location along X axis of touch relative to event window * * Value type: float * * The window server may provide touch location in window coordinate space. * This property will be set where available. */ UFTouchPropertyWindowX, /** * Location along Y axis of touch relative to event window * * Value type: float * * The window server may provide touch location in window coordinate space. * This property will be set where available. */ UFTouchPropertyWindowY, /** * Time of last touch state change * * Value type: 64-bit unsigned int * * See UFEventPropertyTime for the semantics of the value. If the touch has * not changed during this frame, the value of this property will be less than * the value of the UFEventPropertyTime event property for this frame. */ UFTouchPropertyTime, /** * Start time of touch * * Value type: 64-bit unsigned int * * See UFEventPropertyTime for the semantics of the value. */ UFTouchPropertyStartTime, /** * Whether the touch is owned by the client * * Value type: int with boolean semantics * * Some window servers have the concept of touch ownership. This property * is only valid when the server supports touch ownership. */ UFTouchPropertyOwned, /** * Whether the touch has physically ended before the touch sequence has ended * * Value type: int with boolean semantics * * Some window servers have the concept of touch ownership. If a touch has * ended before the client receives ownership, this property will be set to * true. The property will also be set to true when the touch has ended before * the client has accepted or rejected ownership of the touch sequence. */ UFTouchPropertyPendingEnd, } UFTouchProperty; /** * Get the event file descriptor for the frame context * * @param [in] handle The frame context object * @return A file descriptor for the context * * When events are available for processing, the file descriptor will be * readable. Perform an 8-byte read from the file descriptor to clear the state. * Refer to the EVENTFD(2) man page for more details. */ FRAME_PUBLIC int frame_get_fd(UFHandle handle); /** * Get an event from the frame context * * @param [in] handle The context object * @param [out] event The retrieved event * @return UFStatusSuccess or UFStatusErrorNoEvent * * The reference count of the returned event is implicity incremented once. */ FRAME_PUBLIC UFStatus frame_get_event(UFHandle handle, UFEvent *event); /** * Get the value of a property of a device * * @param [in] device The device object (const) * @param [in] property The property to retrieve a value for * @param [out] value The value retrieved * @return UFStatusSuccess or UFStatusErrorUnknownProperty */ #ifndef HAS_C_GENERIC_SELECTIONS /* See frame_internal.h */ FRAME_PUBLIC UFStatus frame_device_get_property(UFDevice device, UFDeviceProperty property, void *value); #endif /** * Get a device touch axis by index * * @param [in] device The device object (const) * @param [in] index The index of the axis to get * @param [out] axis The axis retrieved * @return UFStatusSuccess or UFStatusErrorInvalidAxis * * The index value must be greater than or equal to 0 and less than the number * axes of the device. */ FRAME_PUBLIC UFStatus frame_device_get_axis_by_index(UFDevice device, unsigned int index, UFAxis *axis); /** * Get a device touch axis by axis type * * @param [in] device The device object (const) * @param [in] type The axis type * @param [out] axis The axis retrieved * @return UFStatusSuccess or UFStatusErrorInvalidAxis * * UFStatusErrorInvalidAxis is returned if the device does not have an axis of * the type requested. */ FRAME_PUBLIC UFStatus frame_device_get_axis_by_type(UFDevice device, UFAxisType type, UFAxis *axis); /** * Get the type of a touch device axis * * @param [in] axis The touch device axis (const) * @return The type of the axis */ FRAME_PUBLIC UFAxisType frame_axis_get_type(UFAxis axis); /** * Get the minimum value of a touch device axis * * @param [in] axis The touch device axis (const) * @return The minimum value of the axis */ FRAME_PUBLIC float frame_axis_get_minimum(UFAxis axis); /** * Get the maximum value of a touch device axis * * @param [in] axis The touch device axis (const) * @return The maximum value of the axis */ FRAME_PUBLIC float frame_axis_get_maximum(UFAxis axis); /** * Get the resolution of a touch device axis * * @param [in] axis The touch device axis (const) * @return The resolution of the axis */ FRAME_PUBLIC float frame_axis_get_resolution(UFAxis axis); /** * Increment the reference count of an event * * @param [in] event The event object */ FRAME_PUBLIC void frame_event_ref(UFEvent event); /** * Decrement the reference count of an event * * @param [in] event The event object * * When the reference count reaches zero, the event is freed. */ FRAME_PUBLIC void frame_event_unref(UFEvent event); /** * Get the value of a property of an event * * @param [in] event The event object (const) * @param [in] property The property to retrieve a value for * @param [out] value The value retrieved * @return UFStatusSuccess or UFStatusErrorUnknownProperty */ #ifndef HAS_C_GENERIC_SELECTIONS /* See frame_internal.h */ FRAME_PUBLIC UFStatus frame_event_get_property(UFEvent event, UFEventProperty property, void *value); #endif /** * Get the value of a property of a frame * * @param [in] frame The frame object (const) * @param [in] property The property to retrieve a value for * @param [out] value The value retrieved * @return UFStatusSuccess or UFStatusErrorUnknownProperty */ #ifndef HAS_C_GENERIC_SELECTIONS /* See frame_internal.h */ FRAME_PUBLIC UFStatus frame_frame_get_property(UFFrame frame, UFFrameProperty property, void *value); #endif /** * Get a touch of a frame by index * * @param [in] frame The frame object (const) * @param [in] index The index of the touch to get * @param [out] touch The touch retrieved * @return UFStatusSuccess or UFStatusErrorInvalidTouch * * The index value must be greater than or equal to 0 and less than the number * touches reported in the frame. */ FRAME_PUBLIC UFStatus frame_frame_get_touch_by_index(UFFrame frame, unsigned int index, UFTouch *touch); /** * Get a touch from a frame by the window server ID * * @param [in] frame The frame object (const) * @param [in] touch_id The window server ID of the touch * The value type of the touch ID is window server dependent. See * UFTouchPropertyId for more details. * @param [out] touch The touch object * @return UFStatusSuccess or UFStatusErrorInvalidTouch */ FRAME_PUBLIC UFStatus frame_frame_get_touch_by_id(UFFrame frame, UFTouchId touch_id, UFTouch* touch); /** * Get the previous value of a property of a touch * * @param [in] frame The current frame object (const) * @param [in] touch The current touch object (const) * @param [in] property The property to retrieve a value for * @param [out] value The value retrieved * @return UFStatusSuccess, UFStatusErrorUnknownProperty, or * UFStatusErrorInvalidTouch * * The previous value is the value of the property in the previous frame. * UFStatusErrorInvalidTouch is returned if the touch did not exist in the * previous frame. */ FRAME_PUBLIC UFStatus frame_frame_get_previous_touch_property(UFFrame frame, UFTouch touch, UFTouchProperty property, void *value); /** * Get the previous value of an axis of a touch * * @param [in] frame The current frame object (const) * @param [in] touch The current touch object (const) * @param [in] type The axis to retrieve a value for * @param [out] value The value retrieved * @return UFStatusSuccess, UFStatusErrorInvalidAxis, or * UFStatusErrorInvalidTouch * * The previous value is the value of the axis in the previous frame. * UFStatusErrorInvalidTouch is returned if the touch did not exist in the * previous frame. */ FRAME_PUBLIC UFStatus frame_frame_get_previous_touch_value(UFFrame frame, UFTouch touch, UFAxisType type, float* value); /** * Get the value of a property of a touch * * @param [in] touch The touch object (const) * @param [in] property The property to retrieve a value for * @param [out] value The value retrieved * @return UFStatusSuccess or UFStatusErrorUnknownProperty */ #ifndef HAS_C_GENERIC_SELECTIONS /* See frame_internal.h */ FRAME_PUBLIC UFStatus frame_touch_get_property(UFTouch touch, UFTouchProperty property, void *value); #endif /** * Get the value of an axis of a touch * * @param [in] touch The touch object (const) * @param [in] type The axis to retrieve a value for * @param [out] value The value retrieved * @return UFStatusSuccess or UFStatusErrorInvalidAxis */ FRAME_PUBLIC UFStatus frame_touch_get_value(UFTouch touch, UFAxisType type, float *value); /** * @defgroup v2-helpers Helper Functions * These helper functions may be used in place of the generic property getters. * They are limited to properties that are guaranteed to exist in all instances * of the objects. * @{ */ /** * Get the type of an event * * @param [in] event The event object (const) * @return The type of the event */ FRAME_PUBLIC UFEventType frame_event_get_type(UFEvent event); /** * Get the time of an event * * @param [in] event The event object (const) * @return The time of the event */ FRAME_PUBLIC uint64_t frame_event_get_time(UFEvent event); /** * Get the number of axes of a device * * @param [in] device The device object (const) * @return The number of axes */ FRAME_PUBLIC unsigned int frame_device_get_num_axes(UFDevice device); /** * Get The resolution of the window coordinates of the device in the X axis * * @param [in] device The device object (const) * @return The resolution in pixels per meter */ FRAME_PUBLIC float frame_device_get_window_resolution_x(UFDevice device); /** * Get The resolution of the window coordinates of the device in the Y axis * * @param [in] device The device object (const) * @return The resolution in pixels per meter */ FRAME_PUBLIC float frame_device_get_window_resolution_y(UFDevice device); /** * Get the number of touches in the frame * * @param [in] frame The frame object (const) * @return The number of touches */ FRAME_PUBLIC uint32_t frame_frame_get_num_touches(UFFrame frame); /** * Get the device of a frame * * @param [in] frame The frame context object (const) * return The device of the window context */ FRAME_PUBLIC UFDevice frame_frame_get_device(UFFrame frame); /** * Get the window ID of a frame * * @param [in] frame The frame context object (const) * @return The window server ID of the window of the frame */ FRAME_PUBLIC UFWindowId frame_frame_get_window_id(UFFrame frame); /** * Get the window server ID of a touch * * @param [in] touch The touch context object (const) * @return The window server ID of the touch */ FRAME_PUBLIC UFTouchId frame_touch_get_id(UFTouch touch); /** * Get the state of a touch * * @param [in] touch The touch object (const) * @return The state of the touch */ FRAME_PUBLIC UFTouchState frame_touch_get_state(UFTouch touch); /** * Get the X window coordinate of a touch * * @param [in] touch The touch object (const) * @return The X window coordinate of the touch */ FRAME_PUBLIC float frame_touch_get_window_x(UFTouch touch); /** * Get the Y window coordinate of a touch * * @param [in] touch The touch object (const) * @return The Y window coordinate of the touch */ FRAME_PUBLIC float frame_touch_get_window_y(UFTouch touch); /** * Get the X device coordinate of a touch * * @param [in] touch The touch object (const) * @return The X device coordinate of the touch */ FRAME_PUBLIC float frame_touch_get_device_x(UFTouch touch); /** * Get the Y device coordinate of a touch * * @param [in] touch The touch object (const) * @return The Y device coordinate of the touch */ FRAME_PUBLIC float frame_touch_get_device_y(UFTouch touch); /** * Get the time of a touch state change * * @param [in] touch The touch object (const) * @return The time of the touch state change */ FRAME_PUBLIC uint64_t frame_touch_get_time(UFTouch touch); /** * Get the start time of a touch * * @param [in] touch The touch object (const) * @return The start time of the touch */ FRAME_PUBLIC uint64_t frame_touch_get_start_time(UFTouch touch); /** * Accept ownership of a touch * * All touches received should be eventally accepted or rejected. * This decision can come even after they have already ended but * should be done as soon as possible. * * You should accept a touch when you're going to use it and * reject it if you're not interested in it. * * Not all window servers have this concept. Those that do use * this information to pass rejected touches forward to other * clients that might want it. * * @param [in] device The device object for the touch (const) * @param [in] window The window to accept the touch for * @param [in] touch_id The touch ID object for the touch * @return UFStatusSuccess, UFStatusErrorInvalidTouch * @see frame_reject_touch */ FRAME_PUBLIC UFStatus frame_accept_touch(UFDevice device, UFWindowId window, UFTouchId touch_id); /** * Reject ownership of a touch * * @param [in] device The device object for the touch (const) * @param [in] window The window to reject the touch for * @param [in] touch_id The touch ID object for the touch * @return UFStatusSuccess, UFStatusErrorInvalidTouch * @see frame_accept_touch */ FRAME_PUBLIC UFStatus frame_reject_touch(UFDevice device, UFWindowId window, UFTouchId touch_id); /** @} */ #include "oif/frame_internal.h" #ifdef __cplusplus } #endif #undef HAS_C_GENERIC_SELECTIONS #endif // FRAME_OIF_FRAME_H_ ./include/oif/frame_internal.h0000644000004100000410000001241212752376103016610 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2010-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #ifndef FRAME_OIF_FRAME_INTERNAL_H_ #define FRAME_OIF_FRAME_INTERNAL_H_ #ifdef HAS_C_GENERIC_SELECTIONS #include FRAME_PUBLIC UFStatus frame_device_get_property_string_(UFDevice device, UFDeviceProperty property, char **value); FRAME_PUBLIC UFStatus frame_device_get_property_int_(UFDevice device, UFDeviceProperty property, int *value); FRAME_PUBLIC UFStatus frame_device_get_property_unsigned_int_(UFDevice device, UFDeviceProperty property, unsigned int *value); #define frame_device_get_property(device, property, value) \ _Generic((value), \ char **: frame_device_get_property_string_, \ int *: frame_device_get_property_int_, \ unsigned int *: frame_device_get_property_unsigned_int_) ((device), \ (property), \ (value)) FRAME_PUBLIC UFStatus frame_event_get_property_type_(UFEvent event, UFEventProperty property, UFEventType *value); FRAME_PUBLIC UFStatus frame_event_get_property_device_(UFEvent event, UFEventProperty property, UFDevice *value); FRAME_PUBLIC UFStatus frame_event_get_property_frame_(UFEvent event, UFEventProperty property, UFFrame *value); FRAME_PUBLIC UFStatus frame_event_get_property_uint64_(UFEvent event, UFEventProperty property, uint64_t *value); #define frame_event_get_property(event, property, value) \ _Generic((value), \ UFEventType *: frame_event_get_property_type_, \ UFDevice *: frame_event_get_property_device_, \ UFFrame *: frame_event_get_property_frame_, \ uint64_t *: frame_event_get_property_uint64_) ((event), \ (property), (value)) FRAME_PUBLIC UFStatus frame_frame_get_property_device_(UFFrame frame, UFFrameProperty property, UFDevice *value); FRAME_PUBLIC UFStatus frame_frame_get_property_uint64_(UFFrame frame, UFFrameProperty property, uint64_t *value); FRAME_PUBLIC UFStatus frame_frame_get_property_unsigned_int_(UFFrame frame, UFFrameProperty property, unsigned int *value); #define frame_frame_get_property(frame, property, value) \ _Generic((value), \ UFDevice *: frame_frame_get_property_device_, \ uint64_t *: frame_frame_get_property_window_id_, \ unsigned int *: frame_frame_get_property_unsigned_int_) ( \ (frame), \ (property), \ (value)) FRAME_PUBLIC UFStatus frame_touch_get_property_uint64_(UFTouch touch, UFTouchProperty property, uint64_t *value); FRAME_PUBLIC UFStatus frame_touch_get_property_state_(UFTouch touch, UFTouchProperty property, UFTouchState *value); FRAME_PUBLIC UFStatus frame_touch_get_property_float_(UFTouch touch, UFTouchProperty property, float *value); FRAME_PUBLIC UFStatus frame_touch_get_property_int_(UFTouch touch, UFTouchProperty property, int *value); #define frame_touch_get_property(touch, property, value) \ _Generic((value), \ uint64_t *: frame_touch_get_property_uint64_, \ UFTouchState *: frame_touch_get_property_state_, \ float *: frame_touch_get_property_float_, \ int *: frame_touch_get_property_int_) ((touch), (property), \ (value)) #endif // HAS_C_GENERIC_SELECTIONS #endif // FRAME_OIF_FRAME_INTERNAL_H_ ./include/oif/frame_x11.h0000644000004100000410000000772312752376103015416 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2010-2013 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #ifndef FRAME_OIF_FRAME_X11_H_ #define FRAME_OIF_FRAME_X11_H_ #include "oif/frame.h" #include #ifdef __cplusplus extern "C" { #endif /** * @defgroup x11 X11 * @{ */ /** * Create a new frame context for an X11 window server * * @param [in] display The X11 server connection * @param [out] handle The object for the new frame instance * @return UFStatusSuccess, UFStatusErrorResources, or UFStatusErrorGeneric */ FRAME_PUBLIC UFStatus frame_x11_new(Display *display, UFHandle *handle); /** * Delete an X11 frame instance * * @param [in] handle The object for the frame instance */ FRAME_PUBLIC void frame_x11_delete(UFHandle handle); /** * Process an X11 input event into the frame instance * * @param [in] handle The frame context * @param [in] event The X11 generic input event cookie * @return UFStatusSuccess or UFStatusErrorGeneric * * The frame library can process XIDeviceEvent and * XIHierarchyEvent events. Processing these events requires additional event * data. This data is obtained by calling XGetEventData on the XEvent. See the * XGetEventData and XFreeEventData man pages for more details. * * This function will silently ignore any events other than those listed above. */ FRAME_PUBLIC UFStatus frame_x11_process_event(UFHandle handle, XGenericEventCookie *xcookie); /** * Accept ownership of a touch * * @deprecated Use frame_accept_touch instead. * @param [in] device The device object for the touch (const) * @param [in] window The window to accept the touch for * @param [in] touch_id The touch ID object for the touch * @return UFStatusSuccess, UFStatusErrorInvalidTouch */ FRAME_PUBLIC UFStatus frame_x11_accept_touch(UFDevice device, UFWindowId window, UFTouchId touch_id); /** * Reject ownership of a touch * * @deprecated Use frame_reject_touch instead. * @param [in] device The device object for the touch (const) * @param [in] window The window to reject the touch for * @param [in] touch_id The touch ID object for the touch * @return UFStatusSuccess, UFStatusErrorInvalidTouch */ FRAME_PUBLIC UFStatus frame_x11_reject_touch(UFDevice device, UFWindowId window, UFTouchId touch_id); /** * Get the X11 Window ID of a frame window * * @param [in] window_id The frame window ID object (const) * @return The X11 window ID */ FRAME_PUBLIC Window frame_x11_get_window_id(UFWindowId window_id); /** * Create a new frame window ID object for an X11 window ID * * @param [in] id The X11 ID of the window * @return The new frame window ID object */ FRAME_PUBLIC UFWindowId frame_x11_create_window_id(Window id); /** * Get the X11 touch ID of a frame touch * * @param [in] touch_id The frame touch ID object (const) * @return The X11 touch ID */ FRAME_PUBLIC unsigned int frame_x11_get_touch_id(UFTouchId touch_id); /** * Create a new frame touch ID object for an X11 touch ID * * @param [in] id The X11 ID of the touch * @return The new frame touch ID object */ FRAME_PUBLIC UFTouchId frame_x11_create_touch_id(unsigned int id); /** * @} */ #ifdef __cplusplus } #endif #endif // FRAME_OIF_FRAME_X11_H_ ./src/0000755000004100000410000000000012752376120012037 5ustar www-datawww-data./src/libframe.ver0000644000004100000410000000617612752376103014351 0ustar www-datawww-dataFRAME_2.2 { global: frame_get_fd; frame_get_event; frame_device_get_property; frame_device_get_property_string_; frame_device_get_property_int_; frame_device_get_property_unsigned_int_; frame_device_get_axis_by_index; frame_device_get_axis_by_type; frame_device_get_window_resolution_x; frame_device_get_window_resolution_y; frame_axis_get_type; frame_axis_get_minimum; frame_axis_get_maximum; frame_axis_get_resolution; frame_event_ref; frame_event_unref; frame_event_get_property; frame_event_get_property_type_; frame_event_get_property_device_; frame_event_get_property_frame_; frame_event_get_property_uint64_; frame_frame_get_property; frame_frame_get_property_device_; frame_frame_get_property_uint64_; frame_frame_get_property_unsigned_int_; frame_frame_get_touch_by_index; frame_frame_get_touch_by_id; frame_frame_get_previous_touch_property; frame_frame_get_previous_touch_value; frame_touch_get_property; frame_touch_get_property_uint64_; frame_touch_get_property_state_; frame_touch_get_property_float_; frame_touch_get_property_int_; frame_touch_get_value; frame_event_get_type; frame_event_get_time; frame_device_get_num_axes; frame_frame_get_num_touches; frame_frame_get_window_id; frame_frame_get_device; frame_touch_get_id; frame_touch_get_state; frame_touch_get_window_x; frame_touch_get_window_y; frame_touch_get_device_x; frame_touch_get_device_y; frame_touch_get_time; frame_touch_get_start_time; frame_x11_new; frame_x11_delete; frame_x11_process_event; frame_x11_accept_touch; frame_x11_reject_touch; frame_x11_get_window_id; frame_x11_create_window_id; frame_x11_get_touch_id; frame_x11_create_touch_id; local: *; }; FRAME_2.4 { global: frame_backend_device_new; frame_backend_device_get_device; frame_backend_device_delete; frame_backend_device_set_name; frame_backend_device_set_direct; frame_backend_device_set_independent; frame_backend_device_set_semi_mt; frame_backend_device_set_max_touches; frame_backend_device_set_window_resolution; frame_backend_device_add_axis; frame_backend_frame_new; frame_backend_frame_create_next; frame_backend_frame_get_frame; frame_backend_frame_borrow_touch_by_id; frame_backend_frame_set_device; frame_backend_frame_set_window_id; frame_backend_frame_set_active_touches; frame_backend_frame_give_touch; frame_backend_frame_delete; frame_backend_touch_new; frame_backend_touch_get_touch; frame_backend_touch_set_id; frame_backend_touch_set_ended; frame_backend_touch_set_window_pos; frame_backend_touch_set_time; frame_backend_touch_set_start_time; frame_backend_touch_set_owned; frame_backend_touch_set_pending_end; frame_backend_touch_set_value; frame_event_new; frame_event_set_type; frame_event_set_device; frame_event_set_frame; frame_event_set_time; } FRAME_2.2; FRAME_2.5 { global: frame_accept_touch; frame_reject_touch; } FRAME_2.4; ./src/value.cpp0000644000004100000410000001234312752376103013663 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #include "value.h" #include #include #include #include "device.h" #include "frame.h" namespace oif { namespace frame { Value::Value(bool value) : type_(kBool), bool_(value) { } Value::Value(int value) : type_(kInt), int_(value) { } Value::Value(unsigned int value) : type_(kUnsignedInt), unsigned_int_(value) { } Value::Value(float value) : type_(kFloat), float_(value) { } #ifdef HAVE_LONG_UNSIGNED_VALUE Value::Value(long unsigned int value) : type_(kLongUnsignedInt), long_unsigned_int_(value) { } #endif // HAVE_LONG_UNSIGNED_VALUE Value::Value(uint64_t value) : type_(kuint64_t), uint64_t_(value) { } Value::Value(const char* value) : type_(kString), string_(strdup(value)) { } Value::Value(const SharedUFDevice& device) : type_(kSharedDevice), device_(new SharedUFDevice(device)) { } Value::Value(const SharedUFFrame& frame) : type_(kSharedFrame), frame_(new SharedUFFrame(frame)) { } Value::Value(UFEventType value) : type_(kEventType), event_type_(value) { } Value::Value(UFTouchState value) : type_(kTouchState), touch_state_(value) { } Value::Value(const Value& value) : type_(value.type_), any_(value.any_) { switch (type_) { case kString: string_ = strdup(value.string_); break; case kSharedDevice: device_ = new SharedUFDevice(*value.device_); break; case kSharedFrame: frame_ = new SharedUFFrame(*value.frame_); break; default: break; } } void Value::GetValue(void* data) const { switch (type_) { case kBool: *reinterpret_cast(data) = bool_; break; case kInt: *reinterpret_cast(data) = int_; break; case kUnsignedInt: *reinterpret_cast(data) = unsigned_int_; break; case kFloat: *reinterpret_cast(data) = float_; break; #ifdef HAVE_LONG_UNSIGNED_VALUE case kLongUnsignedInt: *reinterpret_cast(data) = long_unsigned_int_; break; #endif // HAVE_LONG_UNSIGNED_VALUE case kuint64_t: *reinterpret_cast(data) = uint64_t_; break; case kString: *reinterpret_cast(data) = string_; break; case kSharedDevice: *reinterpret_cast< ::UFDevice*>(data) = device_->get(); break; case kSharedFrame: *reinterpret_cast< ::UFFrame*>(data) = frame_->get(); break; case kEventType: *reinterpret_cast(data) = event_type_; break; case kTouchState: *reinterpret_cast(data) = touch_state_; break; } } void Value::GetValue(char** value) const { if (type_ == kString) *value = string_; else throw std::runtime_error("Bad property value type"); } void Value::GetValue(int* value) const { if (type_ == kInt) *value = int_; else if (type_ == kBool) *value = bool_; else throw std::runtime_error("Bad property value type"); } void Value::GetValue(unsigned int* value) const { if (type_ == kUnsignedInt) *value = unsigned_int_; else throw std::runtime_error("Bad property value type"); } void Value::GetValue(UFEventType* value) const { if (type_ == kEventType) *value = event_type_; else throw std::runtime_error("Bad property value type"); } void Value::GetValue(::UFDevice* value) const { if (type_ == kSharedDevice) *value = device_->get(); else throw std::runtime_error("Bad property value type"); } void Value::GetValue(::UFFrame* value) const { if (type_ == kSharedFrame) *value = frame_->get(); else throw std::runtime_error("Bad property value type"); } void Value::GetValue(uint64_t* value) const { if (type_ == kuint64_t) *value = uint64_t_; else throw std::runtime_error("Bad property value type"); } void Value::GetValue(UFTouchState* value) const { if (type_ == kTouchState) *value = touch_state_; else throw std::runtime_error("Bad property value type"); } void Value::GetValue(float* value) const { if (type_ == kFloat) *value = float_; else throw std::runtime_error("Bad property value type"); } Value::~Value() { switch (type_) { case kString: free(const_cast(string_)); break; case kSharedDevice: delete device_; break; case kSharedFrame: delete frame_; break; default: break; } } } // namespace frame } // namespace oif ./src/Makefile.am0000644000004100000410000000246712752376103014105 0ustar www-datawww-dataversion_script = $(srcdir)/libframe.ver lib_LTLIBRARIES = libframe.la libframe_la_LDFLAGS = \ -version-info @LIB_VERSION@ \ -Wl,-z,defs -Wl,--as-needed \ -Wl,--version-script=$(version_script) libframe_la_LIBADD = \ -lm \ $(COVERAGE_LIBS) \ $(XINPUT_LIBS) \ $(CXX_LIBS) AM_CPPFLAGS = \ -I$(top_builddir)/include \ -I$(top_srcdir)/include/ \ -I$(top_srcdir)/src \ $(WARNING_CPPFLAGS) \ -DBUILDING_FRAME AM_CFLAGS = $(VISIBILITY_CFLAGS) $(COVERAGE_CFLAGS) AM_CXXFLAGS = \ $(CXX11_CXXFLAGS) \ $(VISIBILITY_CXXFLAGS) \ $(COVERAGE_CXXFLAGS) \ $(XINPUT_CFLAGS) libframeincludedir = $(includedir)/oif libframeinclude_HEADERS = \ $(top_builddir)/include/oif/frame.h \ $(top_srcdir)/include/oif/frame_backend.h \ $(top_srcdir)/include/oif/frame_internal.h if HAVE_XINPUT libframeinclude_HEADERS += \ $(top_srcdir)/include/oif/frame_x11.h endif libframe_la_SOURCES = \ axis.h \ axis.cpp \ device.h \ device.cpp \ event.h \ event.cpp \ frame.h \ frame.cpp \ handle.h \ handle.cpp \ property.h \ touch.h \ touch.cpp \ typedefs.h \ value.h \ value.cpp \ window.h \ window.cpp if HAVE_XINPUT libframe_la_SOURCES += \ x11/device_x11.h \ x11/device_x11.cpp \ x11/frame_x11.cpp \ x11/handle_x11.h \ x11/handle_x11.cpp \ x11/window_x11.h \ x11/window_x11.cpp endif EXTRA_DIST = $(version_script) ./src/value.h0000644000004100000410000000553612752376103013336 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #ifndef FRAME_VALUE_H_ #define FRAME_VALUE_H_ #include #include #include "oif/frame.h" #include "typedefs.h" #if __SIZEOF_LONG__ != __SIZEOF_LONG_LONG__ #define HAVE_LONG_UNSIGNED_VALUE #endif namespace oif { namespace frame { class Value { public: explicit Value(bool value); explicit Value(int value); explicit Value(unsigned int value); explicit Value(float value); #ifdef HAVE_LONG_UNSIGNED_VALUE explicit Value(long unsigned int value); #endif // HAVE_LONG_UNSIGNED_VALUE explicit Value(uint64_t value); explicit Value(const char* value); explicit Value(const SharedUFDevice& device); explicit Value(const SharedUFFrame& frame); explicit Value(UFEventType value); explicit Value(UFTouchState value); explicit Value(const Value& value); ~Value(); void GetValue(void* data) const; void GetValue(char** data) const; void GetValue(int* data) const; void GetValue(unsigned int* data) const; void GetValue(UFEventType* data) const; void GetValue(::UFDevice* data) const; void GetValue(::UFFrame* data) const; void GetValue(uint64_t* data) const; void GetValue(UFTouchState* data) const; void GetValue(float* data) const; Value& operator=(const Value&) = delete; private: const enum { kBool, kInt, kUnsignedInt, kFloat, #ifdef HAVE_LONG_UNSIGNED_VALUE kLongUnsignedInt, #endif // HAVE_LONG_UNSIGNED_VALUE kuint64_t, kString, kSharedDevice, kSharedFrame, kEventType, kTouchState, } type_; union { const int bool_; const int int_; const unsigned int unsigned_int_; const float float_; #ifdef HAVE_LONG_UNSIGNED_VALUE const long unsigned int long_unsigned_int_; #endif // HAVE_LONG_UNSIGNED_VALUE const uint64_t uint64_t_; char* string_; SharedUFDevice* device_; SharedUFFrame* frame_; UFEventType event_type_; UFTouchState touch_state_; uint64_t const any_; /* Used to set any value */ }; }; } // namespace frame } // namespace oif #endif // FRAME_VALUE_H_ ./src/touch.cpp0000644000004100000410000002234012752376103013667 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #include "touch.h" #include #include "frame.h" #include oif::frame::UFTouch* UFBackendTouch_::GetModifiableTouch() { if (shared_ptr.unique()) { return static_cast(shared_ptr.get()); } else { /* Make a hard-copy. We don't want other holders of that UFTouch (like frames from previous but still existing events) to get the changes about to be made through this UFBackendTouch. */ oif::frame::UFTouch *old_touch = static_cast(shared_ptr.get()); oif::frame::UFTouch *new_touch = new oif::frame::UFTouch(*old_touch); shared_ptr.reset(new_touch); return new_touch; } } namespace oif { namespace frame { UFTouch::UFTouch() : state_(UFTouchStateBegin) { const Value* value; value = new Value(state_); InsertProperty(UFTouchPropertyState, value); } UFTouch::UFTouch(UFTouchState state, UFTouchId id, float x, float y, uint64_t time) : id_(id), state_(state), values_() { const Value* value; value = new Value(state); InsertProperty(UFTouchPropertyState, value); value = new Value(id); InsertProperty(UFTouchPropertyId, value); value = new Value(x); InsertProperty(UFTouchPropertyWindowX, value); value = new Value(y); InsertProperty(UFTouchPropertyWindowY, value); value = new Value(time); InsertProperty(UFTouchPropertyTime, value); if (state == UFTouchStateBegin) { value = new Value(time); InsertProperty(UFTouchPropertyStartTime, value); } } UFTouch::UFTouch(const UFTouch& touch, UFTouchState new_state) : Property(touch), id_(touch.id_), state_(new_state), values_(touch.values_) { const Value* value = new Value(new_state); InsertProperty(UFTouchPropertyState, value); } void UFTouch::SetValue(UFAxisType type, float value) { values_[type] = value; } UFStatus UFTouch::GetValue(UFAxisType type, float* value) const { auto it = values_.find(type); if (it == values_.end()) return UFStatusErrorInvalidAxis; *value = it->second; return UFStatusSuccess; } } // namespace frame } // namespace oif extern "C" { FRAME_PUBLIC UFStatus frame_touch_get_property_uint64_(UFTouch touch, UFTouchProperty property, uint64_t *value) { const oif::frame::UFTouch* uftouch = static_cast(touch); return uftouch->GetProperty(property, value); } FRAME_PUBLIC UFStatus frame_touch_get_property_state_(UFTouch touch, UFTouchProperty property, UFTouchState *value) { const oif::frame::UFTouch* uftouch = static_cast(touch); return uftouch->GetProperty(property, value); } FRAME_PUBLIC UFStatus frame_touch_get_property_float_(UFTouch touch, UFTouchProperty property, float *value) { const oif::frame::UFTouch* uftouch = static_cast(touch); return uftouch->GetProperty(property, value); } FRAME_PUBLIC UFStatus frame_touch_get_property_int_(UFTouch touch, UFTouchProperty property, int *value) { const oif::frame::UFTouch* uftouch = static_cast(touch); return uftouch->GetProperty(property, value); } #undef frame_touch_get_property /* Override C11 generic selections macro */ FRAME_PUBLIC UFStatus frame_touch_get_property(UFTouch touch, UFTouchProperty property, void* value) { const oif::frame::UFTouch* uftouch = static_cast(touch); return uftouch->GetProperty(property, value); } UFStatus frame_touch_get_value(UFTouch touch, UFAxisType type, float* value) { const oif::frame::UFTouch* uftouch = static_cast(touch); return uftouch->GetValue(type, value); } UFTouchId frame_touch_get_id(UFTouch touch) { UFTouchId touch_id; const oif::frame::UFTouch* uftouch = static_cast(touch); UFStatus status = uftouch->GetProperty(UFTouchPropertyId, &touch_id); assert(status == UFStatusSuccess); return touch_id; } UFTouchState frame_touch_get_state(UFTouch touch) { UFTouchState state; const oif::frame::UFTouch* uftouch = static_cast(touch); UFStatus status = uftouch->GetProperty(UFTouchPropertyState, &state); assert(status == UFStatusSuccess); return state; } float frame_touch_get_window_x(UFTouch touch) { float x; const oif::frame::UFTouch* uftouch = static_cast(touch); UFStatus status = uftouch->GetProperty(UFTouchPropertyWindowX, &x); assert(status == UFStatusSuccess); return x; } float frame_touch_get_window_y(UFTouch touch) { float y; const oif::frame::UFTouch* uftouch = static_cast(touch); UFStatus status = uftouch->GetProperty(UFTouchPropertyWindowY, &y); assert(status == UFStatusSuccess); return y; } float frame_touch_get_device_x(UFTouch touch) { float x; const oif::frame::UFTouch* uftouch = static_cast(touch); UFStatus status = uftouch->GetValue(UFAxisTypeX, &x); assert(status == UFStatusSuccess); return x; } float frame_touch_get_device_y(UFTouch touch) { float y; const oif::frame::UFTouch* uftouch = static_cast(touch); UFStatus status = uftouch->GetValue(UFAxisTypeY, &y); assert(status == UFStatusSuccess); return y; } uint64_t frame_touch_get_time(UFTouch touch) { uint64_t time; const oif::frame::UFTouch* uftouch = static_cast(touch); UFStatus status = uftouch->GetProperty(UFTouchPropertyTime, &time); assert(status == UFStatusSuccess); return time; } uint64_t frame_touch_get_start_time(UFTouch touch) { uint64_t start_time; const oif::frame::UFTouch* uftouch = static_cast(touch); UFStatus status = uftouch->GetProperty(UFTouchPropertyStartTime, &start_time); assert(status == UFStatusSuccess); return start_time; } UFBackendTouch frame_backend_touch_new() { return new UFBackendTouch_(new oif::frame::UFTouch); } UFTouch frame_backend_touch_get_touch(UFBackendTouch touch) { return touch->shared_ptr.get(); } void frame_backend_touch_set_id(UFBackendTouch touch_backend, UFTouchId id) { oif::frame::UFTouch *touch = touch_backend->GetModifiableTouch(); touch->InsertProperty(UFTouchPropertyId, new oif::frame::Value(id)); touch->SetId(id); } void frame_backend_touch_set_ended(UFBackendTouch touch_backend) { oif::frame::UFTouch *touch = touch_backend->GetModifiableTouch(); touch->InsertProperty(UFTouchPropertyState, new oif::frame::Value(UFTouchStateEnd)); touch->SetState(UFTouchStateEnd); } void frame_backend_touch_set_window_pos(UFBackendTouch touch_backend, float x, float y) { oif::frame::UFTouch *touch = touch_backend->GetModifiableTouch(); touch->InsertProperty(UFTouchPropertyWindowX, new oif::frame::Value(x)); touch->InsertProperty(UFTouchPropertyWindowY, new oif::frame::Value(y)); } void frame_backend_touch_set_time(UFBackendTouch touch_backend, uint64_t time) { oif::frame::UFTouch *touch = touch_backend->GetModifiableTouch(); touch->InsertProperty(UFTouchPropertyTime, new oif::frame::Value(time)); } void frame_backend_touch_set_start_time(UFBackendTouch touch_backend, uint64_t start_time) { oif::frame::UFTouch *touch = touch_backend->GetModifiableTouch(); touch->InsertProperty(UFTouchPropertyStartTime, new oif::frame::Value(start_time)); } void frame_backend_touch_set_owned(UFBackendTouch touch_backend, int owned) { oif::frame::UFTouch *touch = touch_backend->GetModifiableTouch(); touch->InsertProperty(UFTouchPropertyOwned, new oif::frame::Value(owned)); } void frame_backend_touch_set_pending_end(UFBackendTouch touch_backend, int pending_end) { oif::frame::UFTouch *touch = touch_backend->GetModifiableTouch(); touch->InsertProperty(UFTouchPropertyPendingEnd, new oif::frame::Value(pending_end)); } void frame_backend_touch_set_value(UFBackendTouch touch_backend, UFAxisType type, float value) { oif::frame::UFTouch *touch = touch_backend->GetModifiableTouch(); touch->SetValue(type, value); } } // extern "C" ./src/frame.cpp0000644000004100000410000003126012752376103013640 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #include "frame.h" #include #include #include "device.h" #include "touch.h" #include namespace oif { namespace frame { UFFrame::UFFrame(const SharedUFFrame& prev) : prev_(prev), touches_array_(), touches_map_() { for (const SharedUFTouch& prev_touch : prev_->touches_array_) { if (prev_touch->state() == UFTouchStateBegin) { touches_map_[prev_touch->id()] = touches_array_.size(); SharedUFTouch touch(prev->CopyTouch(prev_touch->id(), UFTouchStateUpdate)); touches_array_.push_back(touch); } else if (prev_touch->state() == UFTouchStateUpdate) { touches_map_[prev_touch->id()] = touches_array_.size(); touches_array_.push_back(prev_touch); } } const Value* value; value = new Value(static_cast(touches_map_.size())); InsertProperty(UFFramePropertyNumTouches, value); value = new Value(static_cast(touches_map_.size())); InsertProperty(UFFramePropertyActiveTouches, value); } UFTouch* UFFrame::CopyTouch(UFTouchId touchid, UFTouchState new_state) const { auto map_it = touches_map_.find(touchid); if (map_it == touches_map_.end()) { fprintf(stderr, "Failed to copy non-existent touch\n"); return NULL; } return new UFTouch(*touches_array_[map_it->second].get(), new_state); } bool UFFrame::IsTouchOwned(UFTouchId touchid) { auto map_it = touches_map_.find(touchid); if (map_it == touches_map_.end()) return false; SharedUFTouch& touch = touches_array_[map_it->second]; int owned; UFStatus status = touch->GetProperty(UFTouchPropertyOwned, &owned); if (status != UFStatusSuccess) /* If the window server doesn't support touch ownership, then all touches * are implicitly owned. */ return true; return owned; } namespace { void CopyStartTime(const SharedUFTouch& src, const SharedUFTouch& dst) { uint64_t start_time = 0; UFStatus status = src->GetProperty(UFTouchPropertyStartTime, &start_time); assert(status == UFStatusSuccess); const Value* value = new Value(start_time); dst->InsertProperty(UFTouchPropertyStartTime, value); } } // namespace UFStatus UFFrame::GiveTouch(SharedUFTouch& touch) { auto map_it = touches_map_.find(touch->id()); if (map_it != touches_map_.end()) { /* A loan is being returned */ SharedUFTouch &our_touch = touches_array_[map_it->second]; /* we shouldn't be referencing to any UFTouch here. If we are, it's a programming error by the API user. */ if (our_touch.get() != NULL) { return UFStatusErrorTouchIdExists; } /* take back our UFtouch */ our_touch.swap(touch); } else { touches_map_[touch->id()] = touches_array_.size(); touches_array_.push_back(touch); touch.reset(); } return UFStatusSuccess; } void UFFrame::UpdateTouch(const SharedUFTouch& touch) { auto map_it = touches_map_.find(touch->id()); switch (touch->state()) { case UFTouchStateBegin: if (map_it != touches_map_.end()) { CopyStartTime(touches_array_[map_it->second], touch); touches_array_[map_it->second] = touch; } else { touches_map_[touch->id()] = touches_array_.size(); touches_array_.push_back(touch); } break; case UFTouchStateUpdate: { case UFTouchStateEnd: if (map_it == touches_map_.end()) { fprintf(stderr, "Warning: ignoring update for unknown touch %ju\n", touch->id()); break; } CopyStartTime(touches_array_[map_it->second], touch); touches_array_[map_it->second] = touch; break; } } } bool UFFrame::IsEnded() const { for (const SharedUFTouch& touch : touches_array_) if (touch->state() != UFTouchStateEnd) return false; return true; } UFStatus UFFrame::GetPreviousTouchProperty(const UFTouch* touch, UFTouchProperty property, void* value) const { if (!prev_) return UFStatusErrorInvalidTouch; auto it = prev_->touches_map_.find(touch->id()); if (it == prev_->touches_map_.end()) return UFStatusErrorInvalidTouch; return prev_->touches_array_[it->second]->GetProperty(property, value); } UFStatus UFFrame::GetPreviousTouchValue(const UFTouch* touch, UFAxisType type, float* value) const { if (!prev_) return UFStatusErrorInvalidTouch; auto it = prev_->touches_map_.find(touch->id()); if (it == prev_->touches_map_.end()) return UFStatusErrorInvalidTouch; return prev_->touches_array_[it->second]->GetValue(type, value); } UFStatus UFFrame::GetTouchByIndex(unsigned int index, ::UFTouch* touch) const { if (index >= touches_array_.size()) return UFStatusErrorInvalidTouch; *touch = touches_array_[index].get(); return UFStatusSuccess; } SharedUFTouch* UFFrame::GetSharedTouchById(UFTouchId touch_id) { auto it = touches_map_.find(touch_id); if (it == touches_map_.end()) return nullptr; else return &(touches_array_[it->second]); } UFStatus UFFrame::GetTouchById(UFTouchId touch_id, ::UFTouch* touch) const { auto it = touches_map_.find(touch_id); if (it == touches_map_.end()) return UFStatusErrorInvalidTouch; *touch = touches_array_[it->second].get(); return UFStatusSuccess; } void UFFrame::ReleasePreviousFrame() { prev_.reset(); } } // namespace frame } // namespace oif extern "C" { FRAME_PUBLIC UFStatus frame_frame_get_property_device_(UFFrame frame, UFFrameProperty property, UFDevice *value) { const oif::frame::UFFrame* ufframe = static_cast(frame); return ufframe->GetProperty(property, value); } FRAME_PUBLIC UFStatus frame_frame_get_property_uint64_(UFFrame frame, UFFrameProperty property, uint64_t *value) { const oif::frame::UFFrame* ufframe = static_cast(frame); return ufframe->GetProperty(property, value); } FRAME_PUBLIC UFStatus frame_frame_get_property_unsigned_int_(UFFrame frame, UFFrameProperty property, unsigned int *value) { const oif::frame::UFFrame* ufframe = static_cast(frame); if (property == UFFramePropertyNumTouches) { *value = ufframe->GetNumTouches(); return UFStatusSuccess; } else if (property == UFFramePropertyActiveTouches) { UFStatus status = ufframe->GetProperty(property, value); if (status != UFStatusSuccess) { *value = ufframe->GetNumTouches(); status = UFStatusSuccess; } return status; } else { return ufframe->GetProperty(property, value); } } #undef frame_frame_get_property /* Override C11 generic selections macro */ FRAME_PUBLIC UFStatus frame_frame_get_property(UFFrame frame, UFFrameProperty property, void *value) { const oif::frame::UFFrame* ufframe = static_cast(frame); if (property == UFFramePropertyNumTouches) { *reinterpret_cast(value) = ufframe->GetNumTouches(); return UFStatusSuccess; } else if (property == UFFramePropertyActiveTouches) { UFStatus status = ufframe->GetProperty(property, value); if (status != UFStatusSuccess) { *reinterpret_cast(value) = ufframe->GetNumTouches(); status = UFStatusSuccess; } return status; } else { return ufframe->GetProperty(property, value); } } UFStatus frame_frame_get_touch_by_index(UFFrame frame, unsigned int index, UFTouch *touch) { const oif::frame::UFFrame* ufframe = static_cast(frame); return ufframe->GetTouchByIndex(index, touch); } UFStatus frame_frame_get_touch_by_id(UFFrame frame, UFTouchId touch_id, UFTouch *touch) { const oif::frame::UFFrame* ufframe = static_cast(frame); return ufframe->GetTouchById(touch_id, touch); } UFStatus frame_frame_get_previous_touch_property(UFFrame frame, UFTouch touch, UFTouchProperty property, void *value) { const oif::frame::UFFrame* ufframe = static_cast(frame); return ufframe->GetPreviousTouchProperty( static_cast(touch), property, value); } UFStatus frame_frame_get_previous_touch_value(UFFrame frame, UFTouch touch, UFAxisType type, float *value) { const oif::frame::UFFrame* ufframe = static_cast(frame); return ufframe->GetPreviousTouchValue( static_cast(touch), type, value); } UFWindowId frame_frame_get_window_id(UFFrame frame) { UFWindowId window_id; const oif::frame::UFFrame* ufframe = static_cast(frame); UFStatus status = ufframe->GetProperty(UFFramePropertyWindowId, &window_id); assert(status == UFStatusSuccess); return window_id; } uint32_t frame_frame_get_num_touches(UFFrame frame) { const oif::frame::UFFrame* ufframe = static_cast(frame); return ufframe->GetNumTouches(); } UFDevice frame_frame_get_device(UFFrame frame) { UFDevice device; const oif::frame::UFFrame* ufframe = static_cast(frame); UFStatus status = ufframe->GetProperty(UFFramePropertyDevice, &device); assert(status == UFStatusSuccess); return device; } UFBackendFrame frame_backend_frame_new() { return new UFBackendFrame_(new oif::frame::UFFrame); } UFBackendFrame frame_backend_frame_create_next(UFBackendFrame frame) { return new UFBackendFrame_(new oif::frame::UFFrame(frame->shared_ptr)); } UFFrame frame_backend_frame_get_frame(UFBackendFrame frame) { return frame->shared_ptr.get(); } UFStatus frame_backend_frame_borrow_touch_by_id(UFBackendFrame frame, UFTouchId id, UFBackendTouch *touch) { oif::frame::UFFrame* ufframe = static_cast(frame->shared_ptr.get()); oif::frame::SharedUFTouch *shared_touch = ufframe->GetSharedTouchById(id); if (shared_touch) { *touch = new UFBackendTouch_(*shared_touch); return UFStatusSuccess; } else { return UFStatusErrorInvalidTouch; } } void frame_backend_frame_set_device(UFBackendFrame frame, UFBackendDevice device) { static_cast(frame->shared_ptr.get())-> InsertProperty(UFFramePropertyDevice, new oif::frame::Value(device->shared_ptr)); } void frame_backend_frame_set_window_id(UFBackendFrame frame, UFWindowId window_id) { static_cast(frame->shared_ptr.get())-> InsertProperty(UFFramePropertyWindowId, new oif::frame::Value(window_id)); } void frame_backend_frame_set_active_touches(UFBackendFrame frame, unsigned int active_touches) { static_cast(frame->shared_ptr.get())-> InsertProperty(UFFramePropertyActiveTouches, new oif::frame::Value(active_touches)); } UFStatus frame_backend_frame_give_touch(UFBackendFrame frame, UFBackendTouch *touch) { UFStatus status; /* the touch backend must be carrying a UFtouch */ assert((*touch)->shared_ptr); status = static_cast(frame->shared_ptr.get())-> GiveTouch((*touch)->shared_ptr); /* frame must have taken the touch */ assert(!(*touch)->shared_ptr); delete (*touch); *touch = nullptr; return status; } void frame_backend_frame_delete(UFBackendFrame frame) { delete frame; } } // extern "C" ./src/device.cpp0000644000004100000410000001726712752376120014017 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #include "device.h" #include "axis.h" #include namespace oif { namespace frame { UFStatus UFDevice::GetAxisByIndex(unsigned int index, ::UFAxis* axis) const { if (index >= axes_.size()) return UFStatusErrorInvalidAxis; auto it = axes_.cbegin(); std::advance(it, index); *axis = it->second.get(); return UFStatusSuccess; } UFStatus UFDevice::GetAxisByType(UFAxisType type, ::UFAxis* axis) const { auto it = axes_.find(type); if (it == axes_.end()) return UFStatusErrorInvalidAxis; *axis = it->second.get(); return UFStatusSuccess; } UFStatus UFDevice::AcceptTouch(UFWindowId window_id, UFTouchId touch_id) { (void)window_id; (void)touch_id; return UFStatusSuccess; } UFStatus UFDevice::RejectTouch(UFWindowId window_id, UFTouchId touch_id) { (void)window_id; (void)touch_id; return UFStatusSuccess; } } // namespace frame } // namespace oif extern "C" { FRAME_PUBLIC UFStatus frame_device_get_property_string_(UFDevice device, UFDeviceProperty property, char **value) { return static_cast(device)->GetProperty( property, value); } FRAME_PUBLIC UFStatus frame_device_get_property_int_(UFDevice device, UFDeviceProperty property, int *value) { return static_cast(device)->GetProperty( property, value); } FRAME_PUBLIC UFStatus frame_device_get_property_unsigned_int_(UFDevice device, UFDeviceProperty property, unsigned int *value) { if (property == UFDevicePropertyNumAxes) { *value = static_cast(device)->axes_.size(); return UFStatusSuccess; } else { return static_cast(device)->GetProperty( property, value); } } #undef frame_device_get_property /* Override C11 generic selections macro */ FRAME_PUBLIC UFStatus frame_device_get_property(UFDevice device, UFDeviceProperty property, void *value) { if (property == UFDevicePropertyNumAxes) { *reinterpret_cast(value) = static_cast(device)->axes_.size(); return UFStatusSuccess; } else { return static_cast(device)->GetProperty( property, value); } } UFStatus frame_device_get_axis_by_index(UFDevice device, unsigned int index, UFAxis* axis) { return static_cast(device)->GetAxisByIndex( index, axis); } UFStatus frame_device_get_axis_by_type(UFDevice device, UFAxisType type, UFAxis* axis) { return static_cast(device)->GetAxisByType( type, axis); } unsigned int frame_device_get_num_axes(UFDevice device) { unsigned int num_axes; UFStatus status = frame_device_get_property(device, UFDevicePropertyNumAxes, &num_axes); if (status == UFStatusSuccess) return num_axes; fprintf(stderr, "Error: failed to get device number of axes\n"); return 0; } float frame_device_get_window_resolution_x(UFDevice device) { float resolution; UFStatus status = frame_device_get_property(device, UFDevicePropertyWindowResolutionX, &resolution); if (status == UFStatusSuccess) return resolution; fprintf(stderr, "Error: failed to get device X resolution\n"); return 0; } float frame_device_get_window_resolution_y(UFDevice device) { float resolution; UFStatus status = frame_device_get_property(device, UFDevicePropertyWindowResolutionY, &resolution); if (status == UFStatusSuccess) return resolution; fprintf(stderr, "Error: failed to get device Y resolution\n"); return 0; } UFStatus frame_accept_touch(UFDevice device, UFWindowId window_id, UFTouchId touch_id) { return static_cast(device)-> AcceptTouch(window_id, touch_id); } UFStatus frame_reject_touch(UFDevice device, UFWindowId window_id, UFTouchId touch_id) { return static_cast(device)-> RejectTouch(window_id, touch_id); } UFBackendDevice frame_backend_device_new() { return new UFBackendDevice_(new oif::frame::UFDevice); } UFDevice frame_backend_device_get_device(UFBackendDevice device) { return device->shared_ptr.get(); } void frame_backend_device_delete(UFBackendDevice device) { delete device; } void frame_backend_device_set_name(UFBackendDevice device, const char *name) { static_cast(device->shared_ptr.get())-> InsertProperty(UFDevicePropertyName, new oif::frame::Value(name)); } void frame_backend_device_set_direct(UFBackendDevice device, int direct) { static_cast(device->shared_ptr.get())-> InsertProperty(UFDevicePropertyDirect, new oif::frame::Value(direct)); } void frame_backend_device_set_independent(UFBackendDevice device, int independent) { static_cast(device->shared_ptr.get())-> InsertProperty(UFDevicePropertyIndependent, new oif::frame::Value(independent)); } void frame_backend_device_set_semi_mt(UFBackendDevice device, int semi_mt) { static_cast(device->shared_ptr.get())-> InsertProperty(UFDevicePropertySemiMT, new oif::frame::Value(semi_mt)); } void frame_backend_device_set_max_touches(UFBackendDevice device, unsigned int max_touches) { static_cast(device->shared_ptr.get())-> InsertProperty(UFDevicePropertyMaxTouches, new oif::frame::Value(max_touches)); } void frame_backend_device_set_window_resolution(UFBackendDevice device, float x, float y) { static_cast(device->shared_ptr.get())-> InsertProperty(UFDevicePropertyWindowResolutionX, new oif::frame::Value(x)); static_cast(device->shared_ptr.get())-> InsertProperty(UFDevicePropertyWindowResolutionY, new oif::frame::Value(y)); } void frame_backend_device_add_axis(UFBackendDevice device, UFAxisType type, float min, float max, float resolution) { using oif::frame::UFAxis; UFAxis_* axis = new UFAxis(type, min, max, resolution); static_cast(device->shared_ptr.get())-> axes_[type] = std::unique_ptr(static_cast(axis)); } } // extern "C" ./src/axis.cpp0000644000004100000410000000311312752376103013506 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #include "axis.h" #include "value.h" namespace oif { namespace frame { UFAxis::UFAxis(UFAxisType type, float min, float max, float resolution) : type_(type), min_(min), max_(max), resolution_(resolution) { } } // namespace frame } // namespace oif extern "C" { UFAxisType frame_axis_get_type(UFAxis axis) { return static_cast(axis)->type(); } float frame_axis_get_minimum(UFAxis axis) { return static_cast(axis)->min(); } float frame_axis_get_maximum(UFAxis axis) { return static_cast(axis)->max(); } float frame_axis_get_resolution(UFAxis axis) { return static_cast(axis)->resolution(); } } // extern "C" ./src/window.h0000644000004100000410000000262212752376103013522 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #ifndef FRAME_WINDOW_H_ #define FRAME_WINDOW_H_ #include #include #include "oif/frame.h" #include "property.h" #include "typedefs.h" namespace oif{ namespace frame { class Window { public: Window(); virtual ~Window() {}; bool IsTouchOwned(UFTouchId touchid) const; void ReleaseFrames(); virtual bool IsContextEnded() const; Window(const Window&) = delete; Window& operator=(const Window&) = delete; protected: SharedUFFrame current_frame_; }; } // namespace frame } // namespace oif #endif // FRAME_WINDOW_H_ ./src/event.h0000644000004100000410000000270212752376103013333 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #ifndef FRAME_EVENT_H_ #define FRAME_EVENT_H_ #include #include "oif/frame.h" #include "property.h" struct UFEvent_ { virtual ~UFEvent_() {} }; namespace oif { namespace frame { class Value; class UFEvent : public UFEvent_, public Property { public: UFEvent(); UFEvent(UFEventType type, const Value* data, uint64_t time); ~UFEvent(); void Ref(); void Unref(); UFEvent(const UFEvent&) = delete; UFEvent& operator=(const UFEvent&) = delete; private: unsigned int ref_count_; }; } // namespace frame } // namespace oif #endif // FRAME_EVENT_H ./src/window.cpp0000644000004100000410000000245612752376103014062 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #include "window.h" #include #include "frame.h" namespace oif { namespace frame { Window::Window() : current_frame_(new UFFrame) { } bool Window::IsTouchOwned(UFTouchId touchid) const { return current_frame_->IsTouchOwned(touchid); } void Window::ReleaseFrames() { current_frame_ = SharedUFFrame(new UFFrame); } bool Window::IsContextEnded() const { return current_frame_->IsEnded(); } } // namespace frame } // namespace oif ./src/device.h0000644000004100000410000000355312752376103013456 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #ifndef FRAME_DEVICE_H_ #define FRAME_DEVICE_H_ #include #include #include "oif/frame.h" #include "axis.h" #include "typedefs.h" struct UFDevice_ { virtual ~UFDevice_() {}; }; struct UFBackendDevice_ { UFBackendDevice_(oif::frame::UFDevice* device) : shared_ptr(device) {} oif::frame::SharedUFDevice shared_ptr; }; namespace oif { namespace frame { class UFDevice : public UFDevice_, public Property { public: UFDevice() : axes_() {} UFStatus GetAxisByIndex(unsigned int index, ::UFAxis* axis) const; UFStatus GetAxisByType(UFAxisType type, ::UFAxis* axis) const; UFDevice(const UFDevice&) = delete; UFDevice& operator=(const UFDevice&) = delete; typedef std::unique_ptr UniqueUFAxis; std::map axes_; virtual UFStatus AcceptTouch(UFWindowId window_id, UFTouchId touch_id); virtual UFStatus RejectTouch(UFWindowId window_id, UFTouchId touch_id); }; } // namespace frame } // namespace oif #endif // FRAME_DEVICE_H_ ./src/typedefs.h0000644000004100000410000000240612752376103014036 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #ifndef FRAME_TYPEDEFS_H_ #define FRAME_TYPEDEFS_H_ namespace oif { namespace frame { class UFDevice; class UFFrame; class UFTouch; class Window; typedef std::shared_ptr SharedUFDevice; typedef std::shared_ptr SharedUFFrame; typedef std::shared_ptr SharedUFTouch; typedef std::shared_ptr SharedWindow; } // namespace frame } // namespace oif #endif // FRAME_TYPEDEFS_H_ ./src/handle.cpp0000644000004100000410000000452612752376103014006 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #include "handle.h" #include #include #include #include #include #include "event.h" namespace oif { namespace frame { UFHandle::UFHandle() : event_fd_(-1), event_queue_() { event_fd_ = eventfd(0, EFD_NONBLOCK); if (event_fd_ == -1) { fprintf(stderr, "Error: failed to create eventfd instance\n"); throw std::runtime_error("Failed to create eventfd instance"); } } void UFHandle::EnqueueEvent(UFEvent* event) { static const uint64_t num = 1; event_queue_.push(event); if (write(event_fd_, &num, sizeof(num)) != sizeof(num)) fprintf(stderr, "Warning: failed to update eventfd instance\n"); } UFStatus UFHandle::GetEvent(::UFEvent* event) { /* Clear event fd (see eventfd(2) man page) */ uint64_t buf; if (read(event_fd_, &buf, sizeof(buf)) != 8 && errno != EAGAIN) fprintf(stderr, "Warning: failed to read data from event fd\n"); if (event_queue_.empty()) return UFStatusErrorNoEvent; *event = event_queue_.front(); event_queue_.pop(); return UFStatusSuccess; } UFHandle::~UFHandle() { while (!event_queue_.empty()) { event_queue_.front()->Unref(); event_queue_.pop(); } } } // namespace frame } // namespace oif extern "C" { int frame_get_fd(UFHandle handle) { return static_cast(handle)->event_fd(); } UFStatus frame_get_event(UFHandle handle, UFEvent *event) { return static_cast(handle)->GetEvent(event); } } // extern "C" ./src/property.h0000644000004100000410000000373012752376103014100 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #ifndef FRAME_PROPERTY_H_ #define FRAME_PROPERTY_H_ #include #include "value.h" namespace oif { namespace frame { template class Property { public: Property() : properties_() {} virtual ~Property() {} explicit Property(const Property& property) : properties_() { for (const auto& pair : property.properties_) { T property = pair.first; Value* value = new Value(*pair.second); properties_[property] = std::move(UniqueValue(value)); } } void InsertProperty(T property, const Value* value) { properties_.erase(property); properties_[property] = std::move(UniqueValue(value)); } template UFStatus GetProperty(T property, D* data) const { auto it = properties_.find(property); if (it == properties_.end()) return UFStatusErrorUnknownProperty; it->second->GetValue(data); return UFStatusSuccess; } Property& operator=(const Property&) = delete; private: typedef std::unique_ptr UniqueValue; std::map properties_; }; } // namespace frame } // namespace oif #endif // FRAME_PROPERTY_H_ ./src/axis.h0000644000004100000410000000305112752376103013154 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #ifndef FRAME_AXIS_H_ #define FRAME_AXIS_H_ #include "oif/frame.h" #include "property.h" struct UFAxis_ { virtual ~UFAxis_() {} }; namespace oif { namespace frame { class UFAxis : public UFAxis_ { public: UFAxis(UFAxisType type, float min, float max, float resolution); UFAxisType type() const { return type_; } float min() const { return min_; } float max() const { return max_; } float resolution() const { return resolution_; } UFAxis(const UFAxis&) = delete; UFAxis& operator=(const UFAxis&) = delete; private: const UFAxisType type_; const float min_; const float max_; const float resolution_; }; } // namespace frame } // namespace oif #endif // FRAME_AXIS_H_ ./src/event.cpp0000644000004100000410000001166612752376103013677 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #include #include "event.h" #include "frame.h" #include "device.h" #include namespace oif { namespace frame { UFEvent::UFEvent() : ref_count_(1) { } UFEvent::UFEvent(UFEventType type, const Value* data, uint64_t time) : ref_count_(1) { const Value* value; value = new Value(type); InsertProperty(UFEventPropertyType, value); switch (type) { case UFEventTypeDeviceAdded: case UFEventTypeDeviceRemoved: InsertProperty(UFEventPropertyDevice, data); break; case UFEventTypeFrame: InsertProperty(UFEventPropertyFrame, data); break; } value = new Value(time); InsertProperty(UFEventPropertyTime, value); } void UFEvent::Ref() { ++ref_count_; } void UFEvent::Unref() { --ref_count_; if (ref_count_ == 0) delete this; } UFEvent::~UFEvent() { ::UFFrame frame; if (GetProperty(UFEventPropertyFrame, &frame) == UFStatusSuccess) static_cast(frame)->ReleasePreviousFrame(); } } // namespace frame } // namespace oif extern "C" { UFEvent frame_event_new() { return new oif::frame::UFEvent; } void frame_event_ref(UFEvent event) { static_cast(event)->Ref(); } void frame_event_unref(UFEvent event) { static_cast(event)->Unref(); } FRAME_PUBLIC UFStatus frame_event_get_property_type_(UFEvent event, UFEventProperty property, UFEventType *value) { return static_cast(event)->GetProperty( property, value); } FRAME_PUBLIC UFStatus frame_event_get_property_device_(UFEvent event, UFEventProperty property, UFDevice *value) { return static_cast(event)->GetProperty( property, value); } FRAME_PUBLIC UFStatus frame_event_get_property_frame_(UFEvent event, UFEventProperty property, UFFrame *value) { return static_cast(event)->GetProperty( property, value); } FRAME_PUBLIC UFStatus frame_event_get_property_uint64_(UFEvent event, UFEventProperty property, uint64_t *value) { return static_cast(event)->GetProperty( property, value); } #undef frame_event_get_property /* Override C11 generic selections macro */ FRAME_PUBLIC UFStatus frame_event_get_property(UFEvent event, UFEventProperty property, void *value) { return static_cast(event)->GetProperty( property, value); } UFEventType frame_event_get_type(UFEvent event) { UFEventType type; const oif::frame::UFEvent* ufevent = static_cast(event); UFStatus status = ufevent->GetProperty(UFEventPropertyType, &type); assert(status == UFStatusSuccess); return type; } uint64_t frame_event_get_time(UFEvent event) { uint64_t time; const oif::frame::UFEvent* ufevent = static_cast(event); UFStatus status = ufevent->GetProperty(UFEventPropertyTime, &time); assert(status == UFStatusSuccess); return time; } void frame_event_set_type(UFEvent event, UFEventType type) { static_cast(event)-> InsertProperty(UFEventPropertyType, new oif::frame::Value(type)); } void frame_event_set_device(UFEvent event, UFBackendDevice device) { static_cast(event)-> InsertProperty(UFEventPropertyDevice, new oif::frame::Value(device->shared_ptr)); } void frame_event_set_frame(UFEvent event, UFBackendFrame frame) { static_cast(event)-> InsertProperty(UFEventPropertyFrame, new oif::frame::Value(frame->shared_ptr)); } void frame_event_set_time(UFEvent event, uint64_t time) { static_cast(event)-> InsertProperty(UFEventPropertyTime, new oif::frame::Value(time)); } } // extern "C" ./src/touch.h0000644000004100000410000000415112752376103013334 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #ifndef FRAME_TOUCH_H_ #define FRAME_TOUCH_H_ #include #include #include #include "oif/frame.h" #include "property.h" #include "typedefs.h" struct UFTouch_ { virtual ~UFTouch_() {} }; struct UFBackendTouch_ { UFBackendTouch_(oif::frame::UFTouch* touch) : shared_ptr(touch) {} UFBackendTouch_(oif::frame::SharedUFTouch &shared_touch) { shared_ptr.swap(shared_touch); } oif::frame::UFTouch* GetModifiableTouch(); oif::frame::SharedUFTouch shared_ptr; }; namespace oif { namespace frame { class UFTouch : public UFTouch_, public Property { public: UFTouch(); UFTouch(UFTouchState state, UFTouchId id, float x, float y, uint64_t time); UFTouch(const UFTouch& touch, UFTouchState new_state); void SetId(UFTouchId id) { id_ = id; } UFTouchId id() const { return id_; } void SetState(UFTouchState state) { state_ = state; } UFTouchState state() const { return state_; } void SetValue(UFAxisType type, float value); UFStatus GetValue(UFAxisType type, float* value) const; UFTouch& operator=(const UFTouch&) = delete; private: UFTouchId id_; UFTouchState state_; std::map values_; }; } // namespace frame } // namespace oif #endif // FRAME_TOUCH_H_ ./src/handle.h0000644000004100000410000000277112752376103013453 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #ifndef FRAME_HANDLE_H_ #define FRAME_HANDLE_H_ #include #include "oif/frame.h" struct UFHandle_ { virtual ~UFHandle_() {} }; namespace oif { namespace frame { class UFEvent; class UFHandle : public UFHandle_ { public: UFHandle(); ~UFHandle(); int event_fd() const { return event_fd_; } UFStatus GetEvent(::UFEvent* event); void ReleaseEvent(UFEvent event); protected: void EnqueueEvent(UFEvent*); UFHandle(const UFHandle&) = delete; UFHandle& operator=(const UFHandle&) = delete; private: int event_fd_; std::queue event_queue_; }; } // namespace frame } // namespace oif #endif // FRAME_HANDLE_H_ ./src/frame.h0000644000004100000410000000472612752376103013314 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #ifndef FRAME_FRAME_H_ #define FRAME_FRAME_H_ #include #include #include #include "oif/frame.h" #include "property.h" #include "typedefs.h" struct UFFrame_ { virtual ~UFFrame_() {} }; struct UFBackendFrame_ { UFBackendFrame_(oif::frame::UFFrame* frame) : shared_ptr(frame) {} oif::frame::SharedUFFrame shared_ptr; }; namespace oif { namespace frame { class UFFrame : public UFFrame_, public Property { public: UFFrame() : prev_(), touches_array_(), touches_map_() {} UFFrame(const SharedUFFrame& prev); UFTouch* CopyTouch(UFTouchId touchid, UFTouchState new_state) const; bool IsTouchOwned(UFTouchId touchid); UFStatus GiveTouch(SharedUFTouch& touch); void UpdateTouch(const SharedUFTouch& touch); bool IsEnded() const; unsigned int GetNumTouches() const { return touches_array_.size(); } UFStatus GetPreviousTouchValue(const UFTouch* touch, UFAxisType type, float* value) const; UFStatus GetPreviousTouchProperty(const UFTouch* touch, UFTouchProperty property, void* value) const; UFStatus GetTouchByIndex(unsigned int index, ::UFTouch* touch) const; SharedUFTouch* GetSharedTouchById(UFTouchId touch_id); UFStatus GetTouchById(UFTouchId touch_id, ::UFTouch* touch) const; void ReleasePreviousFrame(); UFFrame(const UFFrame&) = delete; UFFrame& operator=(const UFFrame&) = delete; private: SharedUFFrame prev_; std::vector touches_array_; std::map touches_map_; }; } // namespace frame } // namespace oif #endif // FRAME_FRAME_H_ ./src/x11/0000755000004100000410000000000012752376103012451 5ustar www-datawww-data./src/x11/window_x11.cpp0000644000004100000410000001411112752376103015153 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #include "x11/window_x11.h" #include #include "oif/frame_x11.h" #include "frame.h" #include "touch.h" #include "value.h" #include "x11/device_x11.h" namespace oif { namespace frame { WindowX11::WindowX11(::Window window, const SharedUFDevice& device, Display* display) : window_(window), display_(display), device_(static_cast(device.get())), unaccepted_unrejected_touches_() { } namespace { void CopyOldValue(const UFFrame* frame, UFTouch* touch, UFAxisType type) { float value; UFStatus status; status = frame->GetPreviousTouchValue(touch, type, &value); if (status != UFStatusSuccess) { fprintf(stderr, "Warning: failed to get previous touch value\n"); return; } touch->SetValue(type, value); } } // namespace bool WindowX11::HandleDeviceEvent(const XIDeviceEvent* event, SharedUFFrame* frame) { UFTouchState state; switch (event->evtype) { case XI_TouchBegin: state = UFTouchStateBegin; break; case XI_TouchUpdate: state = UFTouchStateUpdate; break; case XI_TouchEnd: state = UFTouchStateEnd; break; default: return false; } *frame = SharedUFFrame(new UFFrame(current_frame_)); const Value* value = new Value(frame_x11_create_window_id(window_)); (*frame)->InsertProperty(UFFramePropertyWindowId, value); value = new Value(device_->shared_from_this()); (*frame)->InsertProperty(UFFramePropertyDevice, value); UFTouchId touch_id = frame_x11_create_touch_id(event->detail); std::shared_ptr touch(new UFTouch(state, touch_id, event->event_x, event->event_y, event->time)); if (event->evtype == XI_TouchBegin) { value = new Value(false); touch->InsertProperty(UFTouchPropertyOwned, value); } else { bool owned = current_frame_->IsTouchOwned(touch_id); value = new Value(owned); touch->InsertProperty(UFTouchPropertyOwned, value); } value = new Value(event->flags & XITouchPendingEnd); touch->InsertProperty(UFTouchPropertyPendingEnd, value); int i = 0; /* Current XI axis number */ int j = 0; /* Current XI valuator value offset in event */ int k = 0; /* Number of handled frame axes */ for (; i < event->valuators.mask_len * 8 && k < static_cast(device_->axis_map().size()); ++i) { const auto& axis = device_->axis_map().find(i); if (axis == device_->axis_map().cend()) { /* We don't care about this axis, but we may need to skip its value */ if (XIMaskIsSet(event->valuators.mask, i)) ++j; continue; } UFAxisType type = axis->second; if (XIMaskIsSet(event->valuators.mask, i)) touch->SetValue(type, event->valuators.values[j++]); else CopyOldValue(frame->get(), touch.get(), type); ++k; } for (; k < static_cast(device_->axis_map().size()); ++i) { const auto& axis = device_->axis_map().find(i); if (axis == device_->axis_map().cend()) continue; UFAxisType type = axis->second; CopyOldValue(frame->get(), touch.get(), type); ++k; } (*frame)->UpdateTouch(touch); current_frame_ = *frame; return true; } bool WindowX11::HandleOwnershipEvent(const XITouchOwnershipEvent* event, SharedUFFrame* frame) { *frame = SharedUFFrame(new UFFrame(current_frame_)); const Value* value = new Value(frame_x11_create_window_id(window_)); (*frame)->InsertProperty(UFFramePropertyWindowId, value); value = new Value(device_->shared_from_this()); (*frame)->InsertProperty(UFFramePropertyDevice, value); UFTouch* touch = (*frame)->CopyTouch(event->touchid, UFTouchStateUpdate); if (!touch) return false; value = new Value(static_cast(event->time)); touch->InsertProperty(UFTouchPropertyTime, value); value = new Value(true); touch->InsertProperty(UFTouchPropertyOwned, value); (*frame)->UpdateTouch(SharedUFTouch(touch)); current_frame_ = *frame; unaccepted_unrejected_touches_.insert(event->touchid); return true; } UFStatus WindowX11::AcceptTouch(UFTouchId touch_id) { if (XIAllowTouchEvents(display_, device_->master_id(), touch_id, window_, XIAcceptTouch)) return UFStatusErrorGeneric; /* Flush output buffer so touches are actually accepted ASAP. The server * can't perform pointer emulation while the currently emulated touch is * still potentially active for pointer emulation. */ XFlush(display_); unaccepted_unrejected_touches_.erase(touch_id); return UFStatusSuccess; } UFStatus WindowX11::RejectTouch(UFTouchId touch_id) { if (XIAllowTouchEvents(display_, device_->master_id(), touch_id, window_, XIRejectTouch)) return UFStatusErrorGeneric; /* Flush output buffer so touches are actually rejected ASAP. The server * can't perform pointer emulation while the currently emulated touch is * still potentially active for pointer emulation. */ XFlush(display_); unaccepted_unrejected_touches_.erase(touch_id); return UFStatusSuccess; } bool WindowX11::IsContextEnded() const { return unaccepted_unrejected_touches_.size() == 0 && current_frame_->IsEnded(); } } // namespace frame } // namespace oif ./src/x11/device_x11.h0000644000004100000410000000402612752376103014554 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #ifndef FRAME_DEVICE_X11_H_ #define FRAME_DEVICE_X11_H_ #include #include #include #include "oif/frame.h" #include "device.h" #include "typedefs.h" namespace oif { namespace frame { class UFDeviceX11 : public UFDevice, public std::enable_shared_from_this { public: UFDeviceX11(Display* display, const XIDeviceInfo& info); int master_id() const { return master_id_; } const std::map& axis_map() const { return axis_map_; } bool HandleDeviceEvent(const XIDeviceEvent* event, SharedUFFrame* frame); bool HandleOwnershipEvent(const XITouchOwnershipEvent* event, SharedUFFrame* frame); virtual UFStatus AcceptTouch(UFWindowId window_id, UFTouchId touch_id); virtual UFStatus RejectTouch(UFWindowId window_id, UFTouchId touch_id); void ReleaseFrames(); UFDeviceX11(const UFDeviceX11&) = delete; UFDeviceX11& operator=(const UFDeviceX11&) = delete; private: Display* display_; int master_id_; std::map axis_map_; std::map< ::Window, SharedWindow> windows_; }; } // namespace frame } // namespace oif #endif // FRAME_DEVICE_X11_H_ ./src/x11/window_x11.h0000644000004100000410000000362112752376103014624 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #ifndef FRAME_WINDOW_X11_H_ #define FRAME_WINDOW_X11_H_ #include #include #include #include #include #include "oif/frame.h" #include "typedefs.h" #include "window.h" namespace oif { namespace frame { class UFDeviceX11; class WindowX11 : public Window { public: WindowX11(::Window window, const SharedUFDevice& device, Display* display); virtual ~WindowX11() {}; bool HandleDeviceEvent(const XIDeviceEvent* event, SharedUFFrame* frame); bool HandleOwnershipEvent(const XITouchOwnershipEvent* event, SharedUFFrame* frame); UFStatus AcceptTouch(UFTouchId touch_id); UFStatus RejectTouch(UFTouchId touch_id); virtual bool IsContextEnded() const; WindowX11(const WindowX11&) = delete; WindowX11& operator=(const WindowX11&) = delete; private: ::Window window_; Display* display_; UFDeviceX11* device_; std::set unaccepted_unrejected_touches_; }; } // namespace frame } // namespace oif #endif // FRAME_WINDOW_X11_H_ ./src/x11/handle_x11.cpp0000644000004100000410000001276712752376103015116 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #include "x11/handle_x11.h" #include #include #include #include "oif/frame.h" #include "event.h" #include "value.h" #include "x11/device_x11.h" namespace oif { namespace frame { UFHandleX11::UFHandleX11(Display *display) : display_(display), xi2_opcode_(-1), devices_() { int event; int error; if (!XQueryExtension(display_, "XInputExtension", &xi2_opcode_, &event, &error)) { fprintf(stderr, "Error: failed to query XInput extension\n"); throw std::runtime_error("Failed to query XInput extension"); } XIDeviceInfo* devices; int num_devices; devices = XIQueryDevice(display_, XIAllDevices, &num_devices); for (int i = 0; i < num_devices; ++i) AddDevice(devices[i], 0); XIFreeDeviceInfo(devices); } void UFHandleX11::AddDevice(const XIDeviceInfo& info, uint64_t time) { if (info.use != XISlavePointer) return; /* If the device is not attached to a master pointer, ignore */ if (!info.attachment) return; bool is_touch = false; for (int i = 0; i < info.num_classes; i++) { if (info.classes[i]->type == XITouchClass) { is_touch = true; break; } } if (!is_touch) return; SharedUFDevice device(new UFDeviceX11(display_, info)); devices_[info.deviceid] = device; const Value* value = new Value(device); UFEvent* event = new UFEvent(UFEventTypeDeviceAdded, value, time); EnqueueEvent(event); } UFStatus UFHandleX11::ProcessEvent(XGenericEventCookie* xcookie) { if (xcookie->extension != xi2_opcode_) return UFStatusSuccess; switch (xcookie->evtype) { case XI_HierarchyChanged: { const XIHierarchyEvent* hierarchy_event = reinterpret_cast(xcookie->data); HandleHierarchyEvent(hierarchy_event); break; } case XI_TouchBegin: { case XI_TouchUpdate: case XI_TouchEnd: const XIDeviceEvent* device_event = reinterpret_cast(xcookie->data); HandleDeviceEvent(device_event); break; } case XI_TouchOwnership: { const XITouchOwnershipEvent* ownership_event = reinterpret_cast(xcookie->data); HandleOwnershipEvent(ownership_event); break; } } return UFStatusSuccess; } void UFHandleX11::HandleHierarchyEvent(const XIHierarchyEvent* event) { for (int i = 0; i < event->num_info; ++i) { if (event->info[i].flags == XISlaveAdded || event->info[i].flags == XISlaveAttached) { int num_devices; XIDeviceInfo* devices = XIQueryDevice(display_, event->info[i].deviceid, &num_devices); if (num_devices == 1) { AddDevice(devices[0], event->time); XIFreeDeviceInfo(devices); } } else if (event->info[i].flags == XISlaveRemoved || event->info[i].flags == XISlaveDetached) { if (devices_.find(event->info[i].deviceid) == devices_.end()) return; SharedUFDevice& device = devices_[event->info[i].deviceid]; const Value* value = new Value(device); UFEvent* frame_event = new UFEvent(UFEventTypeDeviceRemoved, value, event->time); EnqueueEvent(frame_event); UFDeviceX11* device_x11 = static_cast(device.get()); device_x11->ReleaseFrames(); devices_.erase(event->info[i].deviceid); } } } void UFHandleX11::HandleDeviceEvent(const XIDeviceEvent* event) { if (devices_.find(event->sourceid) == devices_.end()) return; UFDevice* device = devices_[event->sourceid].get(); UFDeviceX11* device_x11 = static_cast(device); SharedUFFrame frame; if (device_x11->HandleDeviceEvent(event, &frame)) { const Value* value = new Value(frame); UFEvent* frame_event = new UFEvent(UFEventTypeFrame, value, event->time); EnqueueEvent(frame_event); } } void UFHandleX11::HandleOwnershipEvent(const XITouchOwnershipEvent* event) { if (devices_.find(event->sourceid) == devices_.end()) return; UFDevice* device = devices_[event->sourceid].get(); UFDeviceX11* device_x11 = static_cast(device); SharedUFFrame frame; if (device_x11->HandleOwnershipEvent(event, &frame)) { const Value* value = new Value(frame); UFEvent* frame_event = new UFEvent(UFEventTypeFrame, value, event->time); EnqueueEvent(frame_event); } } UFHandleX11::~UFHandleX11() { for (auto& pair : devices_) { UFDeviceX11* device = static_cast(pair.second.get()); device->ReleaseFrames(); } devices_.clear(); } } // namespace frame } // namespace oif ./src/x11/device_x11.cpp0000644000004100000410000001651512752376103015115 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #include "x11/device_x11.h" #include #include #include #include #include "oif/frame_x11.h" #include "axis.h" #include "value.h" #include "x11/window_x11.h" namespace oif { namespace frame { namespace { UFAxisType UFAxisTypeForLabel(Display* display, Atom label) { if (label == XInternAtom(display, AXIS_LABEL_PROP_ABS_MT_TOUCH_MAJOR, True)) return UFAxisTypeTouchMajor; if (label == XInternAtom(display, AXIS_LABEL_PROP_ABS_MT_TOUCH_MINOR, True)) return UFAxisTypeTouchMinor; if (label == XInternAtom(display, AXIS_LABEL_PROP_ABS_MT_WIDTH_MAJOR, True)) return UFAxisTypeWidthMajor; if (label == XInternAtom(display, AXIS_LABEL_PROP_ABS_MT_WIDTH_MINOR, True)) return UFAxisTypeWidthMinor; if (label == XInternAtom(display, AXIS_LABEL_PROP_ABS_MT_ORIENTATION, True)) return UFAxisTypeOrientation; if (label == XInternAtom(display, AXIS_LABEL_PROP_ABS_MT_TOOL_TYPE, True)) return UFAxisTypeTool; if (label == XInternAtom(display, AXIS_LABEL_PROP_ABS_MT_BLOB_ID, True)) return UFAxisTypeBlobId; if (label == XInternAtom(display, AXIS_LABEL_PROP_ABS_MT_TRACKING_ID, True)) return UFAxisTypeTrackingId; if (label == XInternAtom(display, AXIS_LABEL_PROP_ABS_MT_PRESSURE, True)) return UFAxisTypePressure; throw std::domain_error("Not a multitouch axis"); } } // namespace UFDeviceX11::UFDeviceX11(Display* display, const XIDeviceInfo& info) : display_(display), master_id_(info.attachment), axis_map_(), windows_() { const Value* value; value = new Value(info.name); InsertProperty(UFDevicePropertyName, value); for (int i = 0; i < info.num_classes; ++i) { switch (info.classes[i]->type) { case XITouchClass: { XITouchClassInfo* touch_info = reinterpret_cast(info.classes[i]); value = new Value(touch_info->mode == XIDirectTouch); InsertProperty(UFDevicePropertyDirect, value); value = new Value(false); InsertProperty(UFDevicePropertyIndependent, value); value = new Value(false); InsertProperty(UFDevicePropertySemiMT, value); value = new Value(touch_info->num_touches); InsertProperty(UFDevicePropertyMaxTouches, value); break; } case XIValuatorClass: { XIValuatorClassInfo* valuator_info = reinterpret_cast(info.classes[i]); UFAxisType type; /* X and Y axes are always 0 and 1 in X11. Due to historical reasons, * the labels of these axes may not be consistent across input modules. * Hard code them here instead. */ if (valuator_info->number == 0) type = UFAxisTypeX; else if (valuator_info->number == 1) type = UFAxisTypeY; else { try { type = UFAxisTypeForLabel(display, valuator_info->label); } catch (std::domain_error &error) { break; } } UFAxis_* axis = new UFAxis(type, valuator_info->min, valuator_info->max, valuator_info->resolution); axes_[type] = std::move(UniqueUFAxis(static_cast(axis))); axis_map_[valuator_info->number] = type; break; } default: break; } } /* X11 doesn't provide us the real physical resolution of the display */ value = new Value(0.f); InsertProperty(UFDevicePropertyWindowResolutionX, value); value = new Value(0.f); InsertProperty(UFDevicePropertyWindowResolutionY, value); } bool UFDeviceX11::HandleDeviceEvent(const XIDeviceEvent* event, SharedUFFrame* frame) { WindowX11* window; if (windows_.find(event->event) != windows_.end()) { SharedWindow& shared_window = windows_[event->event]; window = static_cast(shared_window.get()); } else { window = new WindowX11(event->event, shared_from_this(), display_); windows_[event->event] = SharedWindow(window); } if (!window->HandleDeviceEvent(event, frame)) return false; if (window->IsContextEnded()) { window->ReleaseFrames(); windows_.erase(event->event); } return true; } bool UFDeviceX11::HandleOwnershipEvent(const XITouchOwnershipEvent* event, SharedUFFrame* frame) { /* We don't really know if the ownership event is for a particular window * when using the Ubuntu prototype multitouch X server. We just take the first * one for algorithmic completeness, and assume the frame client will work * around this issue. */ for (auto& pair : windows_) { WindowX11* window = static_cast(pair.second.get()); if (!window->IsTouchOwned(event->touchid)) return window->HandleOwnershipEvent(event, frame); } return false; } UFStatus UFDeviceX11::AcceptTouch(UFWindowId window_id, UFTouchId touch_id) { ::Window x11_window_id = frame_x11_get_window_id(window_id); auto it = windows_.find(x11_window_id); if (it != windows_.end()) { WindowX11* window = static_cast(it->second.get()); return window->AcceptTouch(touch_id); } return UFStatusErrorInvalidTouch; } UFStatus UFDeviceX11::RejectTouch(UFWindowId window_id, UFTouchId touch_id) { ::Window x11_window_id = frame_x11_get_window_id(window_id); auto it = windows_.find(x11_window_id); if (it != windows_.end()) { WindowX11* window = static_cast(it->second.get()); return window->RejectTouch(touch_id); } return UFStatusErrorInvalidTouch; } void UFDeviceX11::ReleaseFrames() { for (auto& pair : windows_) pair.second->ReleaseFrames(); windows_.clear(); } } // namespace frame } // namespace oif extern "C" { UFStatus frame_x11_accept_touch(UFDevice device, UFWindowId window_id, UFTouchId touch_id) { oif::frame::UFDeviceX11* device_x11 = static_cast(device); return device_x11->AcceptTouch(window_id, touch_id); } UFStatus frame_x11_reject_touch(UFDevice device, UFWindowId window_id, UFTouchId touch_id) { oif::frame::UFDeviceX11* device_x11 = static_cast(device); return device_x11->RejectTouch(window_id, touch_id); } } // extern "C" ./src/x11/handle_x11.h0000644000004100000410000000337612752376103014557 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-2012 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #ifndef FRAME_HANDLE_X11_H_ #define FRAME_HANDLE_X11_H_ #include #include #include #include #include #include "handle.h" #include "typedefs.h" namespace oif { namespace frame { class UFHandleX11 : public UFHandle { public: explicit UFHandleX11(Display *dsp); ~UFHandleX11(); UFStatus ProcessEvent(XGenericEventCookie* xcookie); UFHandleX11(const UFHandleX11&) = delete; UFHandleX11& operator=(const UFHandleX11&) = delete; private: void AddDevice(const XIDeviceInfo& info, uint64_t time); void HandleHierarchyEvent(const XIHierarchyEvent* event); void HandleDeviceEvent(const XIDeviceEvent* event); void HandleOwnershipEvent(const XITouchOwnershipEvent* event); Display *display_; int xi2_opcode_; std::map devices_; }; } // namespace frame } // namespace oif #endif // FRAME_HANDLE_X11_H_ ./src/x11/frame_x11.cpp0000644000004100000410000000423012752376103014737 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011-12 Canonical Ltd. * * This library is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3 * as published by the Free Software Foundation. * * This library is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranties of * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this library. If not, see . * ****************************************************************************/ #include #include #include "oif/frame.h" #include "oif/frame_x11.h" #include "x11/handle_x11.h" extern "C" { UFStatus frame_x11_new(Display* display, ::UFHandle* handle) { oif::frame::UFHandleX11** handle_x11 = reinterpret_cast(handle); try { *handle_x11 = new oif::frame::UFHandleX11(display); return UFStatusSuccess; } catch (const std::exception& exception) { *handle_x11 = NULL; return UFStatusErrorResources; } } UFStatus frame_x11_process_event(UFHandle handle, XGenericEventCookie* xcookie) { oif::frame::UFHandleX11* handle_x11 = static_cast(handle); return handle_x11->ProcessEvent(xcookie); } void frame_x11_delete(UFHandle handle) { oif::frame::UFHandleX11* handle_x11 = static_cast(handle); delete handle_x11; } Window frame_x11_get_window_id(UFWindowId window_id) { return static_cast(window_id); } UFWindowId frame_x11_create_window_id(Window id) { return static_cast(id); } unsigned int frame_x11_get_touch_id(UFTouchId touch_id) { return static_cast(touch_id); } UFTouchId frame_x11_create_touch_id(unsigned int id) { return static_cast(id); } } // extern "C" ./README0000644000004100000410000000023712752376103012133 0ustar www-datawww-dataframe - Touch Frame Library This tree handles the buildup and synchronization of a set of simultaneous touches. The library is input agnostic. Enjoy, Henrik ./Makefile.am0000644000004100000410000000462312752376103013312 0ustar www-datawww-dataSUBDIRS = doc src test # tools are all X11 based if HAVE_XINPUT SUBDIRS += tools endif ACLOCAL_AMFLAGS = -I m4 --install AM_MAKEFLAGS = --no-print-directory AM_DISTCHECK_CONFIGURE_FLAGS = --disable-integration-tests pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = frame.pc if HAVE_XINPUT pkgconfig_DATA += frame-x11.pc endif if HAVE_GCOV .PHONY: clean-gcda clean-gcda: @echo Removing old coverage results $(AM_V_at)-find -name '*.gcda' -print | xargs -r rm $(AM_V_at)-rm -f coverage-src.info coverage-test.info coverage.info .PHONY: coverage-html generate-coverage-html coverage-html-clean coverage-html: clean-gcda @echo Running test suite $(AM_V_at)-$(SUDO) $(MAKE) -C test $(AM_MAKEFLAGS) -k check $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) generate-coverage-html coverage-src.info: $(AM_V_GEN) $(LCOV_verbose) --directory $(top_builddir)/src --base-directory src --capture --output-file coverage-src.info --no-checksum --compat-libtool --ignore-errors source coverage-test.info: $(AM_V_GEN) $(LCOV_verbose) --directory $(top_builddir)/test --base-directory test --capture --output-file coverage-test.info --no-checksum --compat-libtool --ignore-errors source coverage.info: coverage-src.info coverage-test.info $(AM_V_GEN) $(LCOV_verbose) --add-tracefile coverage-src.info --add-tracefile coverage-test.info --output-file coverage.info generate-coverage-html: coverage.info @echo " GEN coveragereport" $(GENHTML_verbose) --prefix $(top_builddir) --output-directory coveragereport --title "Code Coverage" --legend --show-details --demangle-cpp coverage.info clean-coverage-html: clean-gcda @echo Removing coverage HTML report $(AM_V_at)-$(LCOV_verbose) --directory $(top_builddir) -z $(AM_V_at)-rm -rf coverage.info coveragereport .PHONY: coverage-xml generate-coverage-xml coverage-xml-clean coverage-xml: clean-gcda @echo Running test suite $(AM_V_at)-$(SUDO) $(MAKE) -C test $(AM_MAKEFLAGS) -k check $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) generate-coverage-xml generate-coverage-xml: @echo " GEN coverage.xml" $(AM_V_at)$(GCOVR_verbose) -x -r $(top_builddir) -o $(top_builddir)/coverage.xml --object-directory=$(abs_builddir)/.libs clean-coverage-xml: clean-gcda @echo Removing coverage XML report $(AM_V_at)-rm -rf $(top_builddir)/coverage.xml endif # HAVE_GCOV .PHONY: INSTALL INSTALL: $(INSTALL_CMD) doc-%: $(MAKE) -C doc $@ dist-hook: INSTALL EXTRA_DIST = COPYING.GPL3 ./tools/0000755000004100000410000000000012752376103012411 5ustar www-datawww-data./tools/Makefile.am0000644000004100000410000000125712752376103014452 0ustar www-datawww-dataAM_CPPFLAGS = \ -I$(top_builddir)/include \ -I$(top_srcdir)/include \ $(WARNING_CPPFLAGS) AM_CFLAGS = $(C11_CFLAGS) $(COVERAGE_CFLAGS) AM_CFLAGS += $(XINPUT_CFLAGS) commondir = common bin_PROGRAMS = frame-test-x11 frame_test_x11_SOURCES = frame-test-x11.c \ common/device.c \ common/device.h \ common/frame.c \ common/frame.h \ common/touch.c \ common/touch.h \ frame-test-x11.txt frame_test_x11_LDADD = \ $(XINPUT_LIBS) \ $(top_builddir)/src/libframe.la \ $(COVERAGE_LIBS) \ $(CXX_LIBS) local_manpages = frame-test-x11.1 if HAVE_DOCTOOLS dist_man_MANS = $(local_manpages) %.1: %.txt $(AM_V_GEN)$(ASCIIDOC) -L -f manpage $< CLEANFILES = $(dist_man_MANS) endif ./tools/frame-test-x11.c0000644000004100000410000001371212752376103015237 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2010-2011 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3 as published by * the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * ****************************************************************************/ #include #include #include #include #include #include #include #include #include "common/device.h" #include "common/frame.h" static void accept_touches(UFHandle handle, UFEvent event) { UFFrame frame; UFDevice device; UFWindowId window_id; unsigned int num_touches; UFStatus status; int i; status = frame_event_get_property(event, UFEventPropertyFrame, &frame); if (status != UFStatusSuccess) { fprintf(stderr, "Warning: failed to get frame from event\n"); return; } device = frame_frame_get_device(frame); num_touches = frame_frame_get_num_touches(frame); window_id = frame_frame_get_window_id(frame); for (i = 0; i < num_touches; ++i) { UFTouch touch; UFTouchId touch_id; status = frame_frame_get_touch_by_index(frame, i, &touch); if (status != UFStatusSuccess) { fprintf(stderr, "Warning: failed to get touch from frame by index\n"); continue; } if (frame_touch_get_state(touch) != UFTouchStateBegin) continue; touch_id = frame_touch_get_id(touch); if (frame_x11_accept_touch(device, window_id, touch_id) != UFStatusSuccess) fprintf(stderr, "Warning: failed to accept touch\n"); } } static void handle_frame_events(UFHandle handle) { UFEvent event; while (frame_get_event(handle, &event) == UFStatusSuccess) { switch (frame_event_get_type(event)) { case UFEventTypeDeviceAdded: print_device_added(handle, event); break; case UFEventTypeDeviceRemoved: print_device_removed(handle, event); break; case UFEventTypeFrame: print_frame(handle, event); accept_touches(handle, event); break; } frame_event_unref(event); } } static int quit = 0; static void sigint_handler(__attribute__((unused)) int signum) { quit = 1; } int main(int argc, const char* argv[]) { Display *display; Window root; Window win; XIEventMask mask; XIGrabModifiers mods = { XIAnyModifier, 0 }; UFStatus status; UFHandle frame_handle; int xi_major = 2; int xi_minor = 2; int frame_fd; int nfds; signal(SIGINT, sigint_handler); display = XOpenDisplay(NULL); if (!display) { fprintf(stderr, "Error: failed to open connection to X server\n"); return -1; } if (XIQueryVersion(display, &xi_major, &xi_minor) != Success) { fprintf(stderr, "Error: failed to query XInput version\n"); return -1; } if (xi_major < 2 || xi_minor < 2) { fprintf(stderr, "Error: XInput version of server is too old (%d.%d)\n", xi_major, xi_minor); return -1; } root = DefaultRootWindow(display); if (argc == 1) { win = XCreateSimpleWindow(display, root, 0, 0, 400, 400, 0, BlackPixel(display, 0), WhitePixel(display, 0)); } else if (argc == 2) { char *end; win = strtoul(argv[1], &end, 0); if (*end != '\0') { fprintf(stderr, "Invalid window ID\n"); return -1; } } else { fprintf(stderr, "Usage: %s [window ID]\n", argv[0]); return -1; } XMapWindow(display, win); XFlush(display); mask.deviceid = XIAllMasterDevices; mask.mask_len = XIMaskLen(XI_LASTEVENT); mask.mask = calloc(mask.mask_len, sizeof(char)); XISetMask(mask.mask, XI_TouchBegin); XISetMask(mask.mask, XI_TouchUpdate); XISetMask(mask.mask, XI_TouchEnd); XISetMask(mask.mask, XI_TouchOwnership); XISetMask(mask.mask, XI_HierarchyChanged); XIGrabTouchBegin(display, XIAllMasterDevices, win, 0, &mask, 1, &mods); free(mask.mask); status = frame_x11_new(display, &frame_handle); if (status != UFStatusSuccess) { fprintf(stderr, "Error: failed to create frame instance\n"); return -1; } frame_fd = frame_get_fd(frame_handle); nfds = ConnectionNumber(display) > frame_fd ? ConnectionNumber(display) + 1 : frame_fd + 1; while (!quit) { fd_set set; FD_ZERO(&set); XSync(display, 0); if (!XPending(display)) { int ret; FD_SET(ConnectionNumber(display), &set); FD_SET(frame_fd, &set); ret = select(nfds, &set, NULL, NULL, NULL); if (ret < 1) { if (quit) break; fprintf(stderr, "Warning: select returned with no fds\n"); continue; } } if (XPending(display) || FD_ISSET(ConnectionNumber(display), &set)) { while (XPending(display)) { XEvent event; XNextEvent(display, &event); if (event.type != GenericEvent) continue; XGenericEventCookie *xcookie = &event.xcookie; if (!XGetEventData(display, xcookie)) { fprintf(stderr, "Warning: failed to get X generic event data\n"); continue; } status = frame_x11_process_event(frame_handle, xcookie); if (status != UFStatusSuccess) fprintf(stderr, "Warning: failed to inject X event\n"); XFreeEventData(display, xcookie); } } if (FD_ISSET(frame_fd, &set)) handle_frame_events(frame_handle); } frame_x11_delete(frame_handle); XDestroyWindow(display, win); XCloseDisplay(display); return 0; } ./tools/frame-test-x11.txt0000644000004100000410000000042212752376103015626 0ustar www-datawww-dataFRAME-TEST-X11(1) ================= NAME ---- frame-test-x11 - Report touch frame events from X.org input devices SYNOPSIS -------- frame-test-x11 DESCRIPTION ----------- A test tool used to analyse the capabilities and act as a test driver for the frame library. ./tools/common/0000755000004100000410000000000012752376103013701 5ustar www-datawww-data./tools/common/frame.c0000644000004100000410000000431712752376103015144 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2010-2011 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * ****************************************************************************/ #include "common/frame.h" #include #include #include #include "common/touch.h" void print_frame(UFHandle handle, UFEvent event) { UFFrame frame; UFDevice device; UFStatus status; Window window; char *string = NULL; int num_touches = 0; int i; printf("Frame received:\n"); printf(" Time: %ju ms\n", frame_event_get_time(event)); status = frame_event_get_property(event, UFEventPropertyFrame, &frame); if (status != UFStatusSuccess) { fprintf(stderr, "Error: failed to get frame from frame event\n"); return; } window = frame_x11_get_window_id(frame_frame_get_window_id(frame)); printf(" Window: 0x%lx\n", window); device = frame_frame_get_device(frame); status = frame_device_get_property(device, UFDevicePropertyName, &string); if (status != UFStatusSuccess) fprintf(stderr, "Error: failed to get device name from device\n"); else printf(" Device: %s\n", string); num_touches = frame_frame_get_num_touches(frame); printf(" Number of touches: %d\n", num_touches); for (i = 0; i < num_touches; ++i) { UFTouch touch; printf(" Touch %d:\n", i); status = frame_frame_get_touch_by_index(frame, i, &touch); if (status != UFStatusSuccess) { fprintf(stderr, "Error: failed to get touch %d from frame\n", i); continue; } print_touch(touch, frame, device, window); } printf("\n"); } ./tools/common/touch.c0000644000004100000410000001533712752376103015200 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2010-2011 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * ****************************************************************************/ #include "common/touch.h" #include #include #include "common/device.h" void print_touch(UFTouch touch, UFFrame frame, UFDevice device, Window window) { UFStatus status; UFTouchState prev_state; int num_axes = 0; int prev_valid = 0; unsigned long long time; float floating; int owned; int pending_end; int j; printf(" ID: %u\n", frame_x11_get_touch_id(frame_touch_get_id(touch))); switch (frame_touch_get_state(touch)) { case UFTouchStateBegin: printf(" State: Begin"); prev_valid = 0; break; case UFTouchStateUpdate: printf(" State: Update"); prev_valid = 1; break; case UFTouchStateEnd: printf(" State: End"); prev_valid = 1; break; } if (prev_valid) { status = frame_frame_get_previous_touch_property(frame, touch, UFTouchPropertyState, &prev_state); if (status != UFStatusSuccess) fprintf(stderr, "\nError: failed to get previous touch state\n"); else { switch (prev_state) { case UFTouchStateBegin: printf(" (Prev: Begin)\n"); break; case UFTouchStateUpdate: printf(" (Prev: Update)\n"); break; case UFTouchStateEnd: printf(" (Prev: End)\n"); break; } } } else { printf("\n"); } printf(" Time: %ju", frame_touch_get_time(touch)); if (prev_valid) { status = frame_frame_get_previous_touch_property(frame, touch, UFTouchPropertyTime, &time); if (status != UFStatusSuccess) fprintf(stderr, "\nError: failed to get previous touch time\n"); else printf(" (Prev: %llu)\n", time); } else { printf("\n"); } printf(" Start Time: %ju", frame_touch_get_start_time(touch)); if (prev_valid) { status = frame_frame_get_previous_touch_property(frame, touch, UFTouchPropertyStartTime, &time); if (status != UFStatusSuccess) fprintf(stderr, "\nError: failed to get previous touch start time\n"); else printf(" (Prev: %llu)\n", time); } else { printf("\n"); } printf(" Window X: %f", frame_touch_get_window_x(touch)); if (prev_valid) { status = frame_frame_get_previous_touch_property(frame, touch, UFTouchPropertyWindowX, &floating); if (status != UFStatusSuccess) fprintf(stderr, "\nError: failed to get previous touch window X\n"); else printf(" (Prev: %f)\n", floating); } else { printf("\n"); } printf(" Window Y: %f", frame_touch_get_window_y(touch)); if (prev_valid) { status = frame_frame_get_previous_touch_property(frame, touch, UFTouchPropertyWindowY, &floating); if (status != UFStatusSuccess) fprintf(stderr, "\nError: failed to get previous touch window Y\n"); else printf(" (Prev: %f)\n", floating); } else { printf("\n"); } status = frame_touch_get_property(touch, UFTouchPropertyOwned, &owned); if (status != UFStatusSuccess) fprintf(stderr, "Error: failed to get touch ownership property\n"); else printf(" Owned: %s", owned ? "Yes" : "No"); if (prev_valid) { status = frame_frame_get_previous_touch_property(frame, touch, UFTouchPropertyOwned, &owned); if (status != UFStatusSuccess) fprintf(stderr, "\nError: failed to get previous touch ownership property\n"); else printf(" (Prev: %s)\n", owned ? "Yes" : "No"); } else { printf("\n"); } status = frame_touch_get_property(touch, UFTouchPropertyPendingEnd, &pending_end); if (status != UFStatusSuccess) fprintf(stderr, "Error: failed to get touch pending end property\n"); else printf(" Pending End: %s", pending_end ? "Yes" : "No"); if (prev_valid) { status = frame_frame_get_previous_touch_property(frame, touch, UFTouchPropertyPendingEnd, &pending_end); if (status != UFStatusSuccess) fprintf(stderr, "Error: failed to get previous touch pending end property\n"); else printf(" (Prev: %s)\n", pending_end ? "Yes" : "No"); } else { printf("\n"); } num_axes = frame_device_get_num_axes(device); for (j = 0; j < num_axes; ++j) { UFAxis axis; UFAxisType type; const char *name; float min; float max; float res; float value; float prev_value = 0; status = frame_device_get_axis_by_index(device, j, &axis); if (status != UFStatusSuccess) { fprintf(stderr, "Error: failed to get axis %d\n", j); continue; } get_axis_info(axis, &type, &name, &min, &max, &res); status = frame_touch_get_value(touch, type, &value); if (status != UFStatusSuccess) { fprintf(stderr, "Error: failed to get value for axis %d\n", j); continue; } if (prev_valid) { status = frame_frame_get_previous_touch_value(frame, touch, type, &prev_value); if (status != UFStatusSuccess) fprintf(stderr, "Error: failed to get previous value for axis %d\n", j); } printf("%s", (prev_valid && value != prev_value) ? " * " : " "); printf("Axis Value: %f (Axis: %s, Min: %f, Max: %f, Res: %f", value, name, min, max, res); if (prev_valid) printf(" Prev: %f", prev_value); printf(")\n"); } } ./tools/common/device.h0000644000004100000410000000210312752376103015305 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2010-2011 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * ****************************************************************************/ #include void get_axis_info(UFAxis axis, UFAxisType *type, const char **name, float *min, float *max, float *res); void print_device_added(UFHandle handle, UFEvent event); void print_device_removed(UFHandle handle, UFEvent event); ./tools/common/device.c0000644000004100000410000001202012752376103015277 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2010-2011 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * ****************************************************************************/ #include "common/device.h" #include void get_axis_info(UFAxis axis, UFAxisType *type, const char **name, float *min, float *max, float *res) { *type = frame_axis_get_type(axis); switch (*type) { case UFAxisTypeX: *name = "X"; break; case UFAxisTypeY: *name = "Y"; break; case UFAxisTypeTouchMajor: *name = "Touch major"; break; case UFAxisTypeTouchMinor: *name = "Touch minor"; break; case UFAxisTypeWidthMajor: *name = "Width major"; break; case UFAxisTypeWidthMinor: *name = "Width minor"; break; case UFAxisTypeOrientation: *name = "Orientation"; break; case UFAxisTypeTool: *name = "Tool"; break; case UFAxisTypeBlobId: *name = "Blob ID"; break; case UFAxisTypeTrackingId: *name = "Tracking ID"; break; case UFAxisTypePressure: *name = "Pressure"; break; case UFAxisTypeDistance: *name = "Distance"; break; default: *name = "Unknown"; break; } *min = frame_axis_get_minimum(axis); *max = frame_axis_get_maximum(axis); *res = frame_axis_get_resolution(axis); } void print_device_added(UFHandle handle, UFEvent event) { UFDevice device; char *string = NULL; UFStatus status; int num_axes = 0; int integer; int i; status = frame_event_get_property(event, UFEventPropertyDevice, &device); if (status != UFStatusSuccess) { fprintf(stderr, "Error: failed to get device from event\n"); return; } printf("Device added:\n"); printf(" Time: %ju ms\n", frame_event_get_time(event)); status = frame_device_get_property(device, UFDevicePropertyName, &string); if (status != UFStatusSuccess) fprintf(stderr, "Error: failed to get name from device\n"); else printf(" Name: %s\n", string); status = frame_device_get_property(device, UFDevicePropertyDirect, &integer); if (status != UFStatusSuccess) fprintf(stderr, "Error: failed to get direct property from device\n"); else printf(" Direct: %s\n", integer ? "yes" : "no"); status = frame_device_get_property(device, UFDevicePropertyIndependent, &integer); if (status != UFStatusSuccess) fprintf(stderr, "Error: failed to get independent property from device\n"); else printf(" Independent: %s\n", integer ? "yes" : "no"); status = frame_device_get_property(device, UFDevicePropertySemiMT, &integer); if (status != UFStatusSuccess) fprintf(stderr, "Error: failed to get semi-MT property from device\n"); else printf(" Semi-MT: %s\n", integer ? "yes" : "no"); status = frame_device_get_property(device, UFDevicePropertyMaxTouches, &integer); if (status != UFStatusSuccess) fprintf(stderr, "Error: failed to get max touches from device\n"); else printf(" Maximum touches: %d\n", integer); num_axes = frame_device_get_num_axes(device); printf(" Number of axes: %d\n", num_axes); for (i = 0; i < num_axes; ++i) { UFAxis axis; UFAxisType type; const char *name; float min; float max; float res; printf(" Axis %d:\n", i); status = frame_device_get_axis_by_index(device, i, &axis); if (status != UFStatusSuccess) { fprintf(stderr, "Error: failed to get axis %d from device\n", i); continue; } get_axis_info(axis, &type, &name, &min, &max, &res); printf(" Type: %s\n", name); printf(" Minimum: %f\n", min); printf(" Maximum: %f\n", max); printf(" Resolution: %f\n", res); } printf("\n"); } void print_device_removed(UFHandle handle, UFEvent event) { UFDevice device; char *string = NULL; UFStatus status; status = frame_event_get_property(event, UFEventPropertyDevice, &device); if (status != UFStatusSuccess) { fprintf(stderr, "Error: failed to get device from event\n"); return; } printf("Device removed:\n"); printf(" Time: %ju ms\n", frame_event_get_time(event)); status = frame_device_get_property(device, UFDevicePropertyName, &string); if (status != UFStatusSuccess) fprintf(stderr, "Error: failed to get name from device\n"); else printf(" Name: %s\n", string); } ./tools/common/touch.h0000644000004100000410000000166412752376103015203 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2010-2011 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * ****************************************************************************/ #include #include void print_touch(UFTouch touch, UFFrame frame, UFDevice device, Window window); ./tools/common/frame.h0000644000004100000410000000160312752376103015144 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2010-2011 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * ****************************************************************************/ #include void print_frame(UFHandle handle, UFEvent event); ./COPYING0000644000004100000410000001674312752376103012317 0ustar www-datawww-data GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. ./test/0000755000004100000410000000000012752376103012230 5ustar www-datawww-data./test/README0000644000004100000410000000053012752376103013106 0ustar www-datawww-dataDirectory structure =================== - integration Here goes all integration tests. Those tests take time to run and rely on or interact with other processes beyond the test program itself. - regular Here goes tests that are fast to run and don't rely on the run-time environment (such as other processes, files, etc). ./test/Makefile.am0000644000004100000410000000030412752376103014261 0ustar www-datawww-dataSUBDIRS = gtest if HAVE_XINPUT SUBDIRS += x11_mocks endif SUBDIRS += regular # integration tests are all X11 based if HAVE_XINPUT if ENABLE_INTEGRATION_TESTS SUBDIRS += integration endif endif ./test/gtest/0000755000004100000410000000000012752376103013356 5ustar www-datawww-data./test/gtest/Makefile-xorg-gtest.am0000644000004100000410000000477612752376103017531 0ustar www-datawww-data# Copyright (C) 2012 Canonical, Ltd. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice (including the next # paragraph) shall be included in all copies or substantial portions of the # Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # XORG_GTEST_BUILD_LIBS = \ libgtest.a \ libgtest_main.a \ libxorg-gtest.a \ libxorg-gtest_main.a # Here and below we compile without warnings (-w) because the projects using # xorg-gtest will not want to see warnings or fail to build due to warnings in # gtest or xorg-gtest. nodist_libgtest_a_SOURCES = $(GTEST_SOURCE)/src/gtest-all.cc libgtest_a_CPPFLAGS = --std=c++0x $(GTEST_CPPFLAGS) $(AM_CPPFLAGS) -w libgtest_a_CXXFLAGS = $(GTEST_CXXFLAGS) $(AM_CXXFLAGS) nodist_libgtest_main_a_SOURCES = $(GTEST_SOURCE)/src/gtest_main.cc libgtest_main_a_CPPFLAGS = --std=c++0x $(GTEST_CPPFLAGS) $(AM_CPPFLAGS) -w libgtest_main_a_CXXFLAGS = $(GTEST_CXXFLAGS) $(AM_CXXFLAGS) nodist_libxorg_gtest_a_SOURCES = $(XORG_GTEST_SOURCE)/src/xorg-gtest-all.cpp libxorg_gtest_a_CPPFLAGS = \ --std=c++0x \ $(XORG_GTEST_CPPFLAGS) \ $(GTEST_CPPFLAGS) \ $(AM_CPPFLAGS) \ -iquote$(XORG_GTEST_SOURCE) \ -w libxorg_gtest_a_CXXFLAGS = \ $(XORG_GTEST_CXXFLAGS) \ $(GTEST_CXXFLAGS) \ $(AM_CPPFLAGS) nodist_libxorg_gtest_main_a_SOURCES = \ $(XORG_GTEST_SOURCE)/src/xorg-gtest_main.cpp libxorg_gtest_main_a_CPPFLAGS = \ --std=c++0x \ $(XORG_GTEST_CPPFLAGS) \ $(GTEST_CPPFLAGS) \ $(AM_CPPFLAGS) \ -iquote$(XORG_GTEST_SOURCE) \ -w libxorg_gtest_main_a_CXXFLAGS = \ $(XORG_GTEST_CXXFLAGS) \ $(GTEST_CXXFLAGS) \ $(AM_CXXFLAGS) XORG_GTEST_LIBS = libxorg-gtest.a libgtest.a -lpthread $(X11_LIBS) XORG_GTEST_MAIN_LIBS = libxorg-gtest_main.a ./test/gtest/Makefile.am0000644000004100000410000000035512752376103015415 0ustar www-datawww-datainclude $(top_srcdir)/test/gtest/Makefile-xorg-gtest.am check_LIBRARIES = if HAVE_GTEST check_LIBRARIES += libgtest.a libgtest_main.a endif if ENABLE_INTEGRATION_TESTS check_LIBRARIES += libxorg-gtest.a libxorg-gtest_main.a endif ./test/integration/0000755000004100000410000000000012752376103014553 5ustar www-datawww-data./test/integration/Makefile.am0000644000004100000410000000226512752376103016614 0ustar www-datawww-datatest_targets = check-integration TESTS = $(test_targets) check_PROGRAMS = $(test_targets) x11dir = x11 check_integration_SOURCES = \ events.cpp \ events.h \ x11/device.cpp \ x11/dynamic_type_checking.cpp \ x11/fixture.cpp \ x11/fixture.h \ x11/ids.cpp \ x11/recording.cpp check_integration_CPPFLAGS = \ --std=c++0x \ -I$(top_srcdir) \ -I$(top_srcdir)/include \ -I../include \ -DTEST_ROOT_DIR=\"$(abs_top_srcdir)/test/integration/\"\ $(WARNING_CPPFLAGS) \ $(GTEST_CPPFLAGS) \ $(XORG_GTEST_CPPFLAGS) check_integration_CFLAGS = \ $(C11_CFLAGS) \ $(COVERAGE_CFLAGS) \ $(XORG_GTEST_CFLAGS) check_integration_CXXFLAGS = \ $(CXX11_CXXFLAGS) \ $(COVERAGE_CXXFLAGS) \ $(GTEST_CXXFLAGS) \ $(XORG_GTEST_CXXFLAGS) # check_integration_LDFLAGS = $(GTEST_LDFLAGS) # # Link against the (non-distributed) static lib to pick up the # internal symbols. # check_integration_LDADD = \ $(top_builddir)/src/.libs/libframe.a \ $(top_builddir)/test/gtest/libgtest.a \ $(top_builddir)/test/gtest/libxorg-gtest.a \ $(top_builddir)/test/gtest/libxorg-gtest_main.a \ $(GTEST_LIBS) \ $(XORG_GTEST_LIBS) \ $(XINPUT_LIBS) \ $(EVEMU_LIBS) \ $(COVERAGE_LIBS) \ $(CXX_LIBS) EXTRA_DIST = recordings ./test/integration/events.cpp0000644000004100000410000000531212752376103016564 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * ****************************************************************************/ #include "events.h" #include namespace oif { namespace frame { namespace testing { const Value NewValue(UFTouchState state) { Value value; value.state = state; return value; } const Value NewValue(float floating) { Value value; value.floating = floating; return value; } const Value NewValue(int boolean) { Value value; value.boolean = boolean; return value; } bool IsEqual(const oif::frame::testing::Touch& a, const oif::frame::testing::Touch& b) { /* We rely on the fact that values are stored in maps, so if the values are * equal they will also be stored in the same order. */ for (auto property_a = a.first.cbegin(), property_b = b.first.cbegin(); property_a != a.first.cend() && property_b != b.first.cend(); ++property_a, ++property_b) { if (property_a->first != property_b->first) return false; switch (property_a->first) { case UFTouchPropertyState: if (property_a->second.state != property_b->second.state) return false; break; case UFTouchPropertyWindowX: case UFTouchPropertyWindowY: if (property_a->second.floating != property_b->second.floating) return false; break; case UFTouchPropertyOwned: case UFTouchPropertyPendingEnd: if ((property_a->second.boolean && !property_b->second.boolean) || (!property_a->second.boolean && property_b->second.boolean)) return false; break; default: throw std::runtime_error("Unknown property to check for equality"); } } for (auto value_a = a.second.cbegin(), value_b = b.second.cbegin(); value_a != a.second.cend() && value_b != b.second.cend(); ++value_a, ++value_b) if (value_a->first != value_b->first || value_a->second != value_b->second) return false; return true; } } // namespace testing } // namespace frame } // namespace oif ./test/integration/events.h0000644000004100000410000000315712752376103016236 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * ****************************************************************************/ #ifndef FRAME_TEST_EVENTS_H_ #define FRAME_TEST_EVENTS_H_ #include #include #include "oif/frame.h" namespace oif { namespace frame { namespace testing { union Value { UFTouchState state; float floating; int boolean; }; typedef std::pair Property; typedef std::map Properties; typedef std::pair AxisValue; typedef std::map AxisValues; typedef std::pair Touch; typedef std::vector Touches; typedef std::vector Events; const Value NewValue(UFTouchState state); const Value NewValue(float floating); const Value NewValue(int boolean); bool IsEqual(const Touch& a, const Touch& b); } // namespace testing } // namespace frame } // namespace oif #endif // FRAME_TEST_EVENTS_H_ ./test/integration/recordings/0000755000004100000410000000000012752376103016712 5ustar www-datawww-data./test/integration/recordings/ntrig-dell-xt2.prop0000644000004100000410000000153012752376103022367 0ustar www-datawww-dataN: N-Trig-MultiTouch-Virtual-Device I: 0003 1b96 0001 0110 P: 00 00 00 00 00 00 00 00 B: 00 0b 00 00 00 00 00 00 00 B: 01 00 00 00 00 00 00 00 00 B: 01 00 00 00 00 00 00 00 00 B: 01 00 00 00 00 00 00 00 00 B: 01 00 00 00 00 00 00 00 00 B: 01 00 00 00 00 00 00 00 00 B: 01 00 04 00 00 00 00 00 00 B: 01 00 00 00 00 00 00 00 00 B: 01 00 00 00 00 00 00 00 00 B: 01 00 00 00 00 00 00 00 00 B: 01 00 00 00 00 00 00 00 00 B: 01 00 00 00 00 00 00 00 00 B: 01 00 00 00 00 00 00 00 00 B: 02 00 00 00 00 00 00 00 00 B: 03 03 00 00 00 00 01 73 00 B: 04 00 00 00 00 00 00 00 00 B: 05 00 00 00 00 00 00 00 00 B: 11 00 00 00 00 00 00 00 00 B: 12 00 00 00 00 00 00 00 00 B: 15 00 00 00 00 00 00 00 00 B: 15 00 00 00 00 00 00 00 00 A: 00 0 9600 75 0 A: 01 0 7200 78 0 A: 28 0 255 0 0 A: 30 0 9600 200 0 A: 31 0 7200 150 0 A: 34 0 1 0 0 A: 35 0 9600 75 0 A: 36 0 7200 78 0 ./test/integration/recordings/ntrig-dell-xt2.event0000644000004100000410000001173312752376103022536 0ustar www-datawww-dataE: 1299660667.063211 0003 0035 7411 E: 1299660667.063229 0003 0036 4677 E: 1299660667.063232 0003 0034 1 E: 1299660667.063236 0003 0030 462 E: 1299660667.063238 0003 0031 360 E: 1299660667.063242 0000 0002 0 E: 1299660667.063260 0003 0035 7361 E: 1299660667.063263 0003 0036 3291 E: 1299660667.063266 0003 0034 1 E: 1299660667.063269 0003 0030 462 E: 1299660667.063271 0003 0031 360 E: 1299660667.063275 0000 0002 0 E: 1299660667.063280 0003 0035 5912 E: 1299660667.063283 0003 0036 1483 E: 1299660667.063286 0003 0034 0 E: 1299660667.063289 0003 0030 540 E: 1299660667.063292 0003 0031 462 E: 1299660667.063295 0000 0002 0 E: 1299660667.063299 0001 014a 1 E: 1299660667.063302 0003 0000 7411 E: 1299660667.063306 0003 0001 4677 E: 1299660667.063310 0003 0028 1 E: 1299660667.063311 0000 0000 0 E: 1299660667.081029 0003 0035 7380 E: 1299660667.081039 0003 0036 4674 E: 1299660667.081043 0003 0034 1 E: 1299660667.081045 0003 0030 462 E: 1299660667.081048 0003 0031 360 E: 1299660667.081051 0000 0002 0 E: 1299660667.081064 0003 0035 7401 E: 1299660667.081067 0003 0036 3263 E: 1299660667.081070 0003 0034 0 E: 1299660667.081073 0003 0030 360 E: 1299660667.081076 0003 0031 308 E: 1299660667.081079 0000 0002 0 E: 1299660667.081082 0003 0035 5887 E: 1299660667.081085 0003 0036 1484 E: 1299660667.081088 0003 0034 0 E: 1299660667.081091 0003 0030 540 E: 1299660667.081094 0003 0031 308 E: 1299660667.081097 0000 0002 0 E: 1299660667.081106 0000 0000 0 E: 1299660667.097214 0003 0035 7379 E: 1299660667.097237 0003 0036 4678 E: 1299660667.097240 0003 0034 0 E: 1299660667.097243 0003 0030 360 E: 1299660667.097246 0003 0031 308 E: 1299660667.097249 0000 0002 0 E: 1299660667.097267 0003 0035 7371 E: 1299660667.097270 0003 0036 3262 E: 1299660667.097273 0003 0034 1 E: 1299660667.097276 0003 0030 462 E: 1299660667.097279 0003 0031 360 E: 1299660667.097282 0000 0002 0 E: 1299660667.097286 0003 0035 5901 E: 1299660667.097290 0003 0036 1488 E: 1299660667.097293 0003 0034 0 E: 1299660667.097296 0003 0030 540 E: 1299660667.097299 0003 0031 462 E: 1299660667.097302 0000 0002 0 E: 1299660667.097312 0000 0000 0 E: 1299660667.113209 0003 0035 7382 E: 1299660667.113228 0003 0036 4680 E: 1299660667.113231 0003 0034 0 E: 1299660667.113234 0003 0030 360 E: 1299660667.113237 0003 0031 308 E: 1299660667.113240 0000 0002 0 E: 1299660667.113256 0003 0035 7399 E: 1299660667.113259 0003 0036 3253 E: 1299660667.113262 0003 0034 0 E: 1299660667.113265 0003 0030 360 E: 1299660667.113268 0003 0031 308 E: 1299660667.113271 0000 0002 0 E: 1299660667.113275 0003 0035 5886 E: 1299660667.113277 0003 0036 1489 E: 1299660667.113280 0003 0034 1 E: 1299660667.113283 0003 0030 462 E: 1299660667.113286 0003 0031 360 E: 1299660667.113289 0000 0002 0 E: 1299660667.113293 0003 0035 6837 E: 1299660667.113296 0003 0036 2669 E: 1299660667.113298 0003 0034 1 E: 1299660667.113301 0003 0030 462 E: 1299660667.113304 0003 0031 360 E: 1299660667.113307 0000 0002 0 E: 1299660667.113316 0000 0000 0 E: 1299660667.129014 0003 0035 7375 E: 1299660667.129022 0003 0036 4685 E: 1299660667.129025 0003 0034 0 E: 1299660667.129028 0003 0030 360 E: 1299660667.129031 0003 0031 308 E: 1299660667.129034 0000 0002 0 E: 1299660667.129043 0003 0035 7396 E: 1299660667.129046 0003 0036 3254 E: 1299660667.129049 0003 0034 0 E: 1299660667.129052 0003 0030 360 E: 1299660667.129055 0003 0031 308 E: 1299660667.129058 0000 0002 0 E: 1299660667.129062 0003 0035 5892 E: 1299660667.129064 0003 0036 1503 E: 1299660667.129067 0003 0034 0 E: 1299660667.129070 0003 0030 540 E: 1299660667.129073 0003 0031 462 E: 1299660667.129076 0000 0002 0 E: 1299660667.129080 0003 0035 6829 E: 1299660667.129083 0003 0036 2671 E: 1299660667.129086 0003 0034 1 E: 1299660667.129089 0003 0030 462 E: 1299660667.129091 0003 0031 360 E: 1299660667.129094 0000 0002 0 E: 1299660667.129103 0000 0000 0 E: 1299660667.145205 0003 0035 7378 E: 1299660667.145221 0003 0036 4687 E: 1299660667.145224 0003 0034 0 E: 1299660667.145232 0003 0030 360 E: 1299660667.145235 0003 0031 308 E: 1299660667.145238 0000 0002 0 E: 1299660667.145254 0003 0035 7403 E: 1299660667.145257 0003 0036 3252 E: 1299660667.145260 0003 0034 0 E: 1299660667.145263 0003 0030 360 E: 1299660667.145266 0003 0031 308 E: 1299660667.145269 0000 0002 0 E: 1299660667.145272 0003 0035 5894 E: 1299660667.145275 0003 0036 1508 E: 1299660667.145278 0003 0034 0 E: 1299660667.145281 0003 0030 540 E: 1299660667.145284 0003 0031 462 E: 1299660667.145287 0000 0002 0 E: 1299660667.145290 0003 0035 6853 E: 1299660667.145293 0003 0036 2668 E: 1299660667.145296 0003 0034 0 E: 1299660667.145299 0003 0030 360 E: 1299660667.145302 0003 0031 154 E: 1299660667.145305 0000 0002 0 E: 1299660667.145314 0000 0000 0 E: 1299660667.169030 0003 0035 5897 E: 1299660667.169040 0003 0036 1513 E: 1299660667.169044 0003 0034 0 E: 1299660667.169047 0003 0030 540 E: 1299660667.169049 0003 0031 308 E: 1299660667.169053 0000 0002 0 E: 1299660667.169066 0003 0000 5897 E: 1299660667.169069 0003 0001 1513 E: 1299660667.169074 0000 0000 0 E: 1299660667.181005 0001 014a 0 E: 1299660667.181013 0000 0000 0 ./test/integration/x11/0000755000004100000410000000000012752376103015164 5ustar www-datawww-data./test/integration/x11/dynamic_type_checking.cpp0000644000004100000410000000657412752376103022224 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * ****************************************************************************/ /* This test checks for proper dynamic type checking in property getters. * frame_device_get_property() is used as the guinea pig. It is not exhaustive, * but should let us know if the machinery is working. * * This test is a big no-op if C generic selections are unavailable. */ #include #include "x11/fixture.h" using namespace oif::frame::x11::testing; class DynamicTypeTest : public Test { public: DynamicTypeTest() : pass_(false) {} protected: virtual void ProcessFrameEvents(); void CheckDevice(UFDevice device); bool pass_; }; void DynamicTypeTest::ProcessFrameEvents() { UFEvent event; UFStatus status; while ((status = frame_get_event(handle(), &event)) == UFStatusSuccess) { switch (frame_event_get_type(event)) { case UFEventTypeDeviceAdded: { UFDevice device; ASSERT_EQ(UFStatusSuccess, frame_event_get_property(event, UFEventPropertyDevice, &device)); ASSERT_NE(nullptr, device); CheckDevice(device); break; } default: FAIL() << "Received spurious frame event"; break; } frame_event_unref(event); } EXPECT_EQ(UFStatusErrorNoEvent, status); } void DynamicTypeTest::CheckDevice(UFDevice device) { char* string; int integer; unsigned int unsigned_integer; EXPECT_EQ(UFStatusErrorInvalidType, frame_device_get_property(device, UFDevicePropertyName, &integer)); EXPECT_EQ(UFStatusErrorInvalidType, frame_device_get_property(device, UFDevicePropertyName, &unsigned_integer)); EXPECT_EQ(UFStatusErrorInvalidType, frame_device_get_property(device, UFDevicePropertyDirect, &string)); EXPECT_EQ(UFStatusErrorInvalidType, frame_device_get_property(device, UFDevicePropertyDirect, &unsigned_integer)); EXPECT_EQ(UFStatusErrorInvalidType, frame_device_get_property(device, UFDevicePropertyNumAxes, &string)); EXPECT_EQ(UFStatusErrorInvalidType, frame_device_get_property(device, UFDevicePropertyNumAxes, &integer)); pass_ = true; } TEST_F(DynamicTypeTest, Device) { #ifdef __has_extension #if __has_extension(c_generic_selections) xorg::testing::evemu::Device device("recordings/ntrig-dell-xt2.prop"); PumpEvents(); ASSERT_TRUE(pass_) << "Failed to receive device add event for NTrig touchscreen"; #endif // __has_extension(c_generic_selections) #endif // __has_extension } ./test/integration/x11/device.cpp0000644000004100000410000001473712752376103017143 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * ****************************************************************************/ #include #include #include "x11/fixture.h" #include "oif/frame_x11.h" using namespace oif::frame::x11::testing; class FrameDeviceTest : public Test { public: FrameDeviceTest() : pass_(false), device_(NULL) {} FrameDeviceTest(const FrameDeviceTest&) = delete; FrameDeviceTest& operator=(const FrameDeviceTest&) = delete; protected: virtual void ProcessFrameEvents(); void CheckDevice(UFDevice device); bool pass_; UFDevice device_; }; void FrameDeviceTest::ProcessFrameEvents() { UFEvent event; UFStatus status; while ((status = frame_get_event(handle(), &event)) == UFStatusSuccess) { switch (frame_event_get_type(event)) { case UFEventTypeDeviceRemoved: case UFEventTypeDeviceAdded: { UFDevice device; ASSERT_EQ(UFStatusSuccess, frame_event_get_property(event, UFEventPropertyDevice, &device)); ASSERT_NE(nullptr, device); if (frame_event_get_type(event) == UFEventTypeDeviceAdded) CheckDevice(device); else if (device == device_) pass_ = true; break; } default: FAIL() << "Received spurious frame event"; break; } frame_event_unref(event); } EXPECT_EQ(UFStatusErrorNoEvent, status); } void FrameDeviceTest::CheckDevice(UFDevice device) { char* name; EXPECT_EQ(UFStatusSuccess, frame_device_get_property(device, UFDevicePropertyName, &name)); if (strcmp("N-Trig-MultiTouch-Virtual-Device", name)) { std::cout << "Skipping unknown device \"" << name << "\"\n"; return; } EXPECT_EQ(nullptr, device_) << "Saw NTrig touchscreen virtual device twice"; device_ = device; EXPECT_STREQ("N-Trig-MultiTouch-Virtual-Device", name); int direct; EXPECT_EQ(UFStatusSuccess, frame_device_get_property(device, UFDevicePropertyDirect, &direct)); EXPECT_TRUE(direct); int independent; EXPECT_EQ(UFStatusSuccess, frame_device_get_property(device, UFDevicePropertyIndependent, &independent)); EXPECT_FALSE(independent); int semi_mt; EXPECT_EQ(UFStatusSuccess, frame_device_get_property(device, UFDevicePropertySemiMT, &semi_mt)); EXPECT_FALSE(semi_mt); int max_touches; EXPECT_EQ(UFStatusSuccess, frame_device_get_property(device, UFDevicePropertyMaxTouches, &max_touches)); EXPECT_EQ(5, max_touches); int num_axes = frame_device_get_num_axes(device); EXPECT_EQ(5, num_axes); UFAxis axis; UFAxis by_type; EXPECT_EQ(UFStatusSuccess, frame_device_get_axis_by_index(device, 0, &axis)); EXPECT_EQ(UFAxisTypeX, frame_axis_get_type(axis)); EXPECT_FLOAT_EQ(0, frame_axis_get_minimum(axis)); EXPECT_FLOAT_EQ(9600, frame_axis_get_maximum(axis)); EXPECT_FLOAT_EQ(0, frame_axis_get_resolution(axis)); EXPECT_EQ(UFStatusSuccess, frame_device_get_axis_by_type(device, UFAxisTypeX, &by_type)); EXPECT_EQ(axis, by_type); EXPECT_EQ(UFStatusSuccess, frame_device_get_axis_by_index(device, 1, &axis)); EXPECT_EQ(UFAxisTypeY, frame_axis_get_type(axis)); EXPECT_FLOAT_EQ(0, frame_axis_get_minimum(axis)); EXPECT_FLOAT_EQ(7200, frame_axis_get_maximum(axis)); EXPECT_FLOAT_EQ(0, frame_axis_get_resolution(axis)); EXPECT_EQ(UFStatusSuccess, frame_device_get_axis_by_type(device, UFAxisTypeY, &by_type)); EXPECT_EQ(axis, by_type); EXPECT_EQ(UFStatusSuccess, frame_device_get_axis_by_index(device, 2, &axis)); EXPECT_EQ(UFAxisTypeTouchMajor, frame_axis_get_type(axis)); EXPECT_FLOAT_EQ(0, frame_axis_get_minimum(axis)); EXPECT_FLOAT_EQ(9600, frame_axis_get_maximum(axis)); EXPECT_FLOAT_EQ(0, frame_axis_get_resolution(axis)); EXPECT_EQ(UFStatusSuccess, frame_device_get_axis_by_type(device, UFAxisTypeTouchMajor, &by_type)); EXPECT_EQ(axis, by_type); EXPECT_EQ(UFStatusSuccess, frame_device_get_axis_by_index(device, 3, &axis)); EXPECT_EQ(UFAxisTypeTouchMinor, frame_axis_get_type(axis)); EXPECT_FLOAT_EQ(0, frame_axis_get_minimum(axis)); EXPECT_FLOAT_EQ(7200, frame_axis_get_maximum(axis)); EXPECT_FLOAT_EQ(0, frame_axis_get_resolution(axis)); EXPECT_EQ(UFStatusSuccess, frame_device_get_axis_by_type(device, UFAxisTypeTouchMinor, &by_type)); EXPECT_EQ(axis, by_type); EXPECT_EQ(UFStatusSuccess, frame_device_get_axis_by_index(device, 4, &axis)); EXPECT_EQ(UFAxisTypeOrientation, frame_axis_get_type(axis)); EXPECT_FLOAT_EQ(0, frame_axis_get_minimum(axis)); EXPECT_FLOAT_EQ(1, frame_axis_get_maximum(axis)); EXPECT_FLOAT_EQ(0, frame_axis_get_resolution(axis)); EXPECT_EQ(UFStatusSuccess, frame_device_get_axis_by_type(device, UFAxisTypeOrientation, &by_type)); EXPECT_EQ(axis, by_type); EXPECT_EQ(UFStatusErrorInvalidAxis, frame_device_get_axis_by_index(device, 5, &axis)); EXPECT_EQ(UFStatusErrorInvalidAxis, frame_device_get_axis_by_type(device, UFAxisTypeDistance, &axis)); } TEST_F(FrameDeviceTest, Device) { xorg::testing::evemu::Device* device; device = new xorg::testing::evemu::Device("recordings/ntrig-dell-xt2.prop"); std::unique_ptr unique_device(device); PumpEvents(); ASSERT_NE(nullptr, device_) << "Failed to receive device add event for NTrig " "touchscreen"; unique_device.reset(); PumpEvents(); EXPECT_TRUE(pass_) << "Failed to receive device remove event for NTrig " "touchscreen"; } ./test/integration/x11/fixture.cpp0000644000004100000410000000727212752376103017366 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * ****************************************************************************/ #include "x11/fixture.h" #include #include #include "oif/frame.h" #include "oif/frame_x11.h" void oif::frame::x11::testing::Test::SetUp() { ASSERT_NO_FATAL_FAILURE(xorg::testing::Test::SetUp()); int xi_major = 2; int xi_minor = 2; ASSERT_EQ(Success, XIQueryVersion(Display(), &xi_major, &xi_minor)); ASSERT_GE(xi_major, 2); ASSERT_GE(xi_minor, 2); Window root = DefaultRootWindow(Display()); XIEventMask mask; mask.mask_len = XIMaskLen(XI_LASTEVENT); mask.mask = reinterpret_cast(calloc(mask.mask_len, sizeof(char))); mask.deviceid = XIAllDevices; XISetMask(mask.mask, XI_HierarchyChanged); ASSERT_EQ(Success, XISelectEvents(Display(), root, &mask, 1)); XIClearMask(mask.mask, XI_HierarchyChanged); mask.deviceid = XIAllMasterDevices; XISetMask(mask.mask, XI_TouchBegin); XISetMask(mask.mask, XI_TouchUpdate); XISetMask(mask.mask, XI_TouchEnd); XISetMask(mask.mask, XI_TouchOwnership); XIGrabModifiers mods = { static_cast(XIAnyModifier), 0 }; ASSERT_EQ(Success, XIGrabTouchBegin(Display(), XIAllMasterDevices, root, 0, &mask, 1, &mods)); free(mask.mask); UFStatus status = frame_x11_new(Display(), &handle_); ASSERT_EQ(UFStatusSuccess, status); ASSERT_TRUE(handle_ != NULL); } void oif::frame::x11::testing::Test::PumpEvents(uint64_t timeout) { fd_set set; FD_ZERO(&set); int display_fd = ConnectionNumber(Display()); int frame_fd = frame_get_fd(handle_); int nfds = display_fd > frame_fd ? display_fd + 1: frame_fd + 1; XSync(Display(), 0); while (true) { if (!XPending(Display())) { FD_SET(display_fd, &set); FD_SET(frame_fd, &set); struct timeval timeval = { static_cast(timeout / 1000), static_cast(timeout % 1000) }; int ret; if (timeout) ret = select(nfds, &set, NULL, NULL, &timeval); else ret = select(nfds, &set, NULL, NULL, NULL); ASSERT_GE(ret, 0) << "Failed to select on FDs"; if (ret == 0) return; } if (XPending(Display()) || FD_ISSET(display_fd, &set)) { while (XPending(Display())) { XEvent event; XNextEvent(Display(), &event); if (event.type != GenericEvent) continue; XGenericEventCookie* xcookie = &event.xcookie; ASSERT_NE(0, XGetEventData(Display(), xcookie)) << "Failed to get X generic event data"; ASSERT_EQ(UFStatusSuccess, frame_x11_process_event(handle_, xcookie)) << "Failed to process X event"; XFreeEventData(Display(), xcookie); } } if (FD_ISSET(frame_fd, &set)) { ProcessFrameEvents(); } } } void oif::frame::x11::testing::Test::TearDown() { frame_x11_delete(handle_); xorg::testing::Test::TearDown(); } ./test/integration/x11/recording.cpp0000644000004100000410000006435012752376103017654 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * ****************************************************************************/ #include #include "events.h" #include "x11/fixture.h" #include "oif/frame_x11.h" using namespace oif::frame::x11::testing; class FrameRecordingTest : public Test { public: FrameRecordingTest() : device_(NULL), step_(0), touch_map_(), saved_event_(NULL), touch_start_times_(), touch_times_() {} FrameRecordingTest(const FrameRecordingTest&) = delete; FrameRecordingTest& operator=(const FrameRecordingTest&) = delete; protected: static const oif::frame::testing::Events events_; virtual void ProcessFrameEvents(); void CheckFrame(UFFrame frame, uint64_t event_time); void CheckTouch(UFFrame frame, unsigned int touch_index, uint64_t event_time); void CheckProperty(const oif::frame::testing::Property& property, UFTouch touch, UFFrame frame, int touch_index, bool check_prev); void CheckAxisValue(const oif::frame::testing::AxisValue& axis_value, UFTouch touch, UFFrame frame, int touch_index, bool check_prev); UFDevice device_; unsigned int step_; std::map touch_map_; UFEvent saved_event_; /* Holds a ref'd event to double check at the end */ std::map touch_start_times_; std::map touch_times_; }; void FrameRecordingTest::ProcessFrameEvents() { UFEvent event; UFStatus status; while ((status = frame_get_event(handle(), &event)) == UFStatusSuccess) { switch (frame_event_get_type(event)) { case UFEventTypeFrame: { UFFrame frame; ASSERT_EQ(UFStatusSuccess, frame_event_get_property(event, UFEventPropertyFrame, &frame)); if (step_ == 0) { frame_event_ref(event); saved_event_ = event; } CheckFrame(frame, frame_event_get_time(event)); break; } case UFEventTypeDeviceAdded: { UFDevice device; ASSERT_EQ(UFStatusSuccess, frame_event_get_property(event, UFEventPropertyDevice, &device)); const char* name; ASSERT_EQ(UFStatusSuccess, frame_device_get_property(device, UFDevicePropertyName, &name)); if (strcmp(name, "N-Trig-MultiTouch-Virtual-Device") == 0) { EXPECT_EQ(NULL, device_); device_ = device; } break; } default: break; } frame_event_unref(event); } EXPECT_EQ(UFStatusErrorNoEvent, status); } void FrameRecordingTest::CheckFrame(UFFrame frame, uint64_t event_time) { ASSERT_LT(step_, events_.size()) << "Received too many frame events"; /* Ensure we got a device addition event first */ EXPECT_NE(nullptr, device_); EXPECT_EQ(device_, frame_frame_get_device(frame)); UFWindowId window_id = frame_frame_get_window_id(frame); EXPECT_EQ(DefaultRootWindow(Display()), frame_x11_get_window_id(window_id)); /* The number of active touches should match the number of provided touches * for an N-Trig display */ unsigned int active_touches; EXPECT_EQ(UFStatusSuccess, frame_frame_get_property(frame, UFFramePropertyActiveTouches, &active_touches)); EXPECT_EQ(frame_frame_get_num_touches(frame), active_touches); /* Check that the number of touches matches the expected amount for this step */ ASSERT_EQ(events_[step_].size(), active_touches); /* Check each touch */ for (unsigned int touch_index = 0; touch_index < events_[step_].size(); ++touch_index) CheckTouch(frame, touch_index, event_time); /* Update touch map if a touch ended in the previous frame event. This allows * us to properly check the previous property and axis values. */ if (step_ > 0) { for (const auto& pair : touch_map_) { const oif::frame::testing::Touch* touch; const oif::frame::testing::Properties* properties; UFTouchState state; /* Check if the size of the touch map is at most the expected size for * this step. If so, a touch may have begun. */ if (events_[step_].size() >= touch_map_.size()) { touch = &events_[step_][pair.second]; properties = &touch->first; state = properties->find(UFTouchPropertyState)->second.state; /* If touch is new in current step, skip */ if (state == UFTouchStateBegin) continue; } touch = &events_[step_ - 1][pair.second]; properties = &touch->first; state = properties->find(UFTouchPropertyState)->second.state; if (state == UFTouchStateEnd) { /* If touch ended in previous step */ /* Recalculate slot values for touches that come after this touch */ for (auto& pair2 : touch_map_) if (pair2.second > pair.second) pair2.second--; /* Remove ended touch from touch map */ touch_map_.erase(pair.first); break; /* In the X11 implementation, only one touch ends at a time */ } } } /* Check for out of range touch indexes and IDs */ UFTouch touch; EXPECT_EQ(UFStatusErrorInvalidTouch, frame_frame_get_touch_by_index(frame, active_touches, &touch)); EXPECT_EQ(UFStatusErrorInvalidTouch, frame_frame_get_touch_by_id(frame, 83492, &touch)); /* All touches will end after step 18, accept or reject them */ if (step_ == 18) { ASSERT_EQ(4, touch_map_.size()); UFWindowId window_id = frame_x11_create_window_id(DefaultRootWindow(Display())); int i = 0; for (const auto& pair : touch_map_) { if (i++ % 2) frame_x11_reject_touch(device_, window_id, pair.first); else frame_x11_accept_touch(device_, window_id, pair.first); } } ++step_; } void FrameRecordingTest::CheckTouch( UFFrame frame, unsigned int touch_index, uint64_t event_time) { UFTouch touch; ASSERT_EQ(UFStatusSuccess, frame_frame_get_touch_by_index(frame, touch_index, &touch)); UFTouchId id = frame_touch_get_id(touch); const oif::frame::testing::Touch& expected = events_[step_][touch_index]; /* Check each property */ for (const auto& property : expected.first) CheckProperty(property, touch, frame, touch_index, false); /* Check each axis value */ for (const auto& axis_value : expected.second) CheckAxisValue(axis_value, touch, frame, touch_index, false); if (frame_touch_get_state(touch) == UFTouchStateBegin) { /* Update touch map for new touch */ touch_map_[id] = touch_index; /* Ensure that the touch times match the current event time */ EXPECT_EQ(event_time, frame_touch_get_start_time(touch)); EXPECT_EQ(event_time, frame_touch_get_time(touch)); /* Update touch times for this touch */ touch_start_times_[id] = frame_touch_get_start_time(touch); touch_times_[id] = frame_touch_get_time(touch); } else { /* Check that the touch start time is still correct */ EXPECT_EQ(touch_start_times_[id], frame_touch_get_start_time(touch)) << "Step " << step_ << ", Touch " << id; int slot = touch_map_[id]; const oif::frame::testing::Touch& prev_expected = events_[step_ - 1][slot]; if (oif::frame::testing::IsEqual(expected, prev_expected)) { EXPECT_EQ(touch_times_[id], frame_touch_get_time(touch)) << "Step " << step_ << ", Touch " << id; } else { EXPECT_EQ(event_time, frame_touch_get_time(touch)) << "Step " << step_ << ", Touch " << id; touch_times_[id] = frame_touch_get_time(touch); } /* Check each property's previous value */ for (const auto& property : prev_expected.first) CheckProperty(property, touch, frame, touch_index, true); /* Check each axis' previous value */ for (const auto& axis_value : prev_expected.second) CheckAxisValue(axis_value, touch, frame, touch_index, true); } UFTouch check_touch; EXPECT_EQ(UFStatusSuccess, frame_frame_get_touch_by_id(frame, id, &check_touch)); EXPECT_EQ(touch, check_touch); } void FrameRecordingTest::CheckProperty( const oif::frame::testing::Property& property, UFTouch touch, UFFrame frame, int touch_index, bool check_prev) { switch(property.first) { case UFTouchPropertyState: UFTouchState state; if (!check_prev) ASSERT_EQ(UFStatusSuccess, frame_touch_get_property(touch, property.first, &state)); else ASSERT_EQ(UFStatusSuccess, frame_frame_get_previous_touch_property(frame, touch, property.first, &state)); EXPECT_EQ(property.second.state, state) << "Step " << step_ << ", Touch " << touch_index << ", Property " << property.first << ", Prev " << check_prev; break; case UFTouchPropertyWindowX: case UFTouchPropertyWindowY: float floating; if (!check_prev) { if (property.first == UFTouchPropertyWindowX) floating = frame_touch_get_window_x(touch); else floating = frame_touch_get_window_y(touch); } else { ASSERT_EQ(UFStatusSuccess, frame_frame_get_previous_touch_property(frame, touch, property.first, &floating)); } EXPECT_FLOAT_EQ(property.second.floating, floating) << "Step " << step_ << ", Touch " << touch_index << ", Property " << property.first << ", Prev " << check_prev; break; case UFTouchPropertyOwned: case UFTouchPropertyPendingEnd: int boolean; if (!check_prev) ASSERT_EQ(UFStatusSuccess, frame_touch_get_property(touch, property.first, &boolean)); else ASSERT_EQ(UFStatusSuccess, frame_frame_get_previous_touch_property(frame, touch, property.first, &boolean)); if (property.second.boolean) EXPECT_TRUE(boolean) << "Step " << step_ << ", Touch " << touch_index << ", Property " << property.first << ", Prev " << check_prev; else EXPECT_FALSE(boolean) << "Step " << step_ << ", Touch " << touch_index << ", Property " << property.first << ", Prev " << check_prev; break; default: ADD_FAILURE() << "Unimplemented touch property check for " << property.first; break; } } void FrameRecordingTest::CheckAxisValue( const oif::frame::testing::AxisValue& axis_value, UFTouch touch, UFFrame frame, int touch_index, bool check_prev) { float floating; if (!check_prev) { switch (axis_value.first) { case UFAxisTypeX: floating = frame_touch_get_device_x(touch); break; case UFAxisTypeY: floating = frame_touch_get_device_y(touch); break; default: ASSERT_EQ(UFStatusSuccess, frame_touch_get_value(touch, axis_value.first, &floating)) << "Step " << step_ << ", Touch " << touch_index << ", Axis " << axis_value.first; break; } } else { ASSERT_EQ(UFStatusSuccess, frame_frame_get_previous_touch_value(frame, touch, axis_value.first, &floating)); } EXPECT_FLOAT_EQ(axis_value.second, floating) << "Step " << step_ << ", Touch " << touch_index << ", Axis " << axis_value.first << ", Prev " << check_prev; } TEST_F(FrameRecordingTest, Recording) { xorg::testing::evemu::Device device("recordings/ntrig-dell-xt2.prop"); /* Pump once to ensure the X server has initialized the device */ PumpEvents(); ASSERT_NE(nullptr, device_) << "X server failed to initialize touchscreen"; device.Play("recordings/ntrig-dell-xt2.event"); PumpEvents(); EXPECT_EQ(events_.size(), step_) << "Failed to receive all frame events for " "touchscreen"; ASSERT_NE(nullptr, saved_event_); UFFrame frame; ASSERT_EQ(UFStatusSuccess, frame_event_get_property(saved_event_, UFEventPropertyFrame, &frame)); step_ = 0; CheckFrame(frame, frame_event_get_time(saved_event_)); frame_event_unref(saved_event_); saved_event_ = NULL; } /* Construct the expected events */ namespace { using namespace oif::frame::testing; const Touch ConstructTouch(UFTouchState state, float window_x, float window_y, bool owned, bool pending_end, float x, float y, float touch_major, float touch_minor, float orientation) { Properties properties; AxisValues values; properties[UFTouchPropertyState] = NewValue(state); properties[UFTouchPropertyWindowX] = NewValue(window_x); properties[UFTouchPropertyWindowY] = NewValue(window_y); properties[UFTouchPropertyOwned] = NewValue(owned); properties[UFTouchPropertyPendingEnd] = NewValue(pending_end); values[UFAxisTypeX] = x; values[UFAxisTypeY] = y; values[UFAxisTypeTouchMajor] = touch_major; values[UFAxisTypeTouchMinor] = touch_minor; values[UFAxisTypeOrientation] = orientation; return Touch(properties, values); } const Events ConstructEvents() { Events events; Touches touches; touches.push_back(ConstructTouch(UFTouchStateBegin, 790.506653, 498.880005, false, false, 7411, 4677, 462, 360, 1)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateUpdate, 790.506653, 498.880005, true, false, 7411, 4677, 462, 360, 1)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateUpdate, 790.506653, 498.880005, true, false, 7411, 4677, 462, 360, 1)); touches.push_back(ConstructTouch(UFTouchStateBegin, 785.173340, 351.040009, false, false, 7361, 3291, 462, 360, 1)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateUpdate, 790.506653, 498.880005, true, false, 7411, 4677, 462, 360, 1)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 785.173340, 351.040009, true, false, 7361, 3291, 462, 360, 1)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateUpdate, 790.506653, 498.880005, true, false, 7411, 4677, 462, 360, 1)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 785.173340, 351.040009, true, false, 7361, 3291, 462, 360, 1)); touches.push_back(ConstructTouch(UFTouchStateBegin, 630.613342, 158.186661, false, false, 5912, 1483, 540, 462, 0)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateUpdate, 790.506653, 498.880005, true, false, 7411, 4677, 462, 360, 1)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 785.173340, 351.040009, true, false, 7361, 3291, 462, 360, 1)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 630.613342, 158.186661, true, false, 5912, 1483, 540, 462, 0)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateUpdate, 790.506653, 498.880005, true, false, 7411, 4677, 462, 360, 1)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 786.239990, 351.040009, true, false, 7371, 3291, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 630.613342, 158.186661, true, false, 5912, 1483, 540, 462, 0)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateUpdate, 790.506653, 498.880005, true, false, 7411, 4677, 462, 360, 1)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 786.239990, 351.040009, true, false, 7371, 3291, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 630.613342, 158.186661, true, false, 5912, 1483, 540, 385, 0)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateUpdate, 790.506653, 498.880005, true, false, 7411, 4677, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 786.239990, 351.040009, true, false, 7371, 3291, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 630.613342, 158.186661, true, false, 5912, 1483, 540, 385, 0)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateUpdate, 790.506653, 498.880005, true, false, 7411, 4677, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 786.239990, 351.040009, true, false, 7371, 3291, 436, 360, 1)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 630.613342, 158.186661, true, false, 5912, 1483, 540, 385, 0)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateUpdate, 790.506653, 498.880005, true, false, 7411, 4677, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 786.239990, 351.040009, true, false, 7371, 3291, 436, 360, 1)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 630.613342, 158.186661, true, false, 5912, 1483, 540, 404, 0)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateUpdate, 790.506653, 498.880005, true, false, 7411, 4677, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 786.239990, 351.040009, true, false, 7371, 3291, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 630.613342, 158.186661, true, false, 5912, 1483, 540, 404, 0)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateUpdate, 790.506653, 498.880005, true, false, 7411, 4677, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 786.239990, 351.040009, true, false, 7371, 3291, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 630.613342, 158.186661, true, false, 5912, 1483, 540, 404, 1)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateUpdate, 790.506653, 498.880005, true, false, 7411, 4677, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 786.239990, 351.040009, true, false, 7371, 3291, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 630.613342, 158.186661, true, false, 5912, 1483, 540, 404, 1)); touches.push_back(ConstructTouch(UFTouchStateBegin, 729.280029, 284.693329, false, false, 6837, 2669, 462, 360, 1)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateUpdate, 790.506653, 498.880005, true, false, 7411, 4677, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 786.239990, 351.040009, true, false, 7371, 3291, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 630.613342, 158.186661, true, false, 5912, 1483, 540, 404, 1)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 729.280029, 284.693329, true, false, 6837, 2669, 462, 360, 1)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateUpdate, 790.506653, 498.880005, true, false, 7411, 4677, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 786.239990, 351.040009, true, false, 7371, 3291, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 630.613342, 158.186661, true, false, 5912, 1483, 540, 404, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 729.280029, 284.693329, true, false, 6837, 2669, 462, 360, 1)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateUpdate, 790.506653, 498.880005, true, false, 7411, 4677, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 786.239990, 349.973328, true, false, 7371, 3281, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 630.613342, 158.186661, true, false, 5912, 1483, 540, 404, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 729.280029, 284.693329, true, false, 6837, 2669, 462, 360, 1)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateUpdate, 790.506653, 498.880005, true, false, 7411, 4677, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 786.239990, 349.973328, true, false, 7371, 3281, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 630.613342, 158.186661, true, false, 5912, 1483, 540, 404, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 729.280029, 284.693329, true, false, 6837, 2669, 436, 257, 0)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateUpdate, 790.506653, 498.880005, true, false, 7411, 4677, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 786.239990, 349.973328, true, false, 7371, 3281, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 630.613342, 158.186661, true, false, 5912, 1483, 540, 380, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 729.280029, 284.693329, true, false, 6837, 2669, 436, 257, 0)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateEnd, 790.506653, 498.880005, true, false, 7411, 4677, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 786.239990, 349.973328, true, false, 7371, 3281, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 630.613342, 158.186661, true, false, 5912, 1483, 540, 380, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 729.280029, 284.693329, true, false, 6837, 2669, 436, 257, 0)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateEnd, 786.239990, 349.973328, true, false, 7371, 3281, 436, 360, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 630.613342, 158.186661, true, false, 5912, 1483, 540, 380, 0)); touches.push_back(ConstructTouch(UFTouchStateUpdate, 729.280029, 284.693329, true, false, 6837, 2669, 436, 257, 0)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateUpdate, 630.613342, 158.186661, true, false, 5912, 1483, 540, 380, 0)); touches.push_back(ConstructTouch(UFTouchStateEnd, 729.280029, 284.693329, true, false, 6837, 2669, 436, 257, 0)); events.push_back(touches); touches.clear(); touches.push_back(ConstructTouch(UFTouchStateEnd, 630.613342, 158.186661, true, false, 5912, 1483, 540, 380, 0)); events.push_back(touches); return events; } } // namespace /* Now initialize the static test fixture member */ const oif::frame::testing::Events FrameRecordingTest::events_(ConstructEvents()); ./test/integration/x11/ids.cpp0000644000004100000410000000234312752376103016451 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * ****************************************************************************/ #include #include "oif/frame_x11.h" TEST(FrameTest, IDs) { Window x11_window_id = 0x892347; UFWindowId frame_window_id = frame_x11_create_window_id(x11_window_id); EXPECT_EQ(x11_window_id, frame_x11_get_window_id(frame_window_id)); unsigned int x11_touch_id = 394; UFTouchId frame_touch_id = frame_x11_create_touch_id(x11_touch_id); EXPECT_EQ(x11_touch_id, frame_x11_get_touch_id(frame_touch_id)); } ./test/integration/x11/fixture.h0000644000004100000410000000274512752376103017033 0ustar www-datawww-data/***************************************************************************** * * frame - Touch Frame Library * * Copyright (C) 2011 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3 as published * by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . * ****************************************************************************/ #ifndef FRAME_TEST_FIXTURE_H_ #define FRAME_TEST_FIXTURE_H_ #include #include "oif/frame.h" namespace oif { namespace frame { namespace x11 { namespace testing { class Test : public xorg::testing::Test { public: Test() : handle_(NULL) {} virtual void SetUp(); virtual void TearDown(); Test(const Test&) = delete; Test& operator=(const Test&) = delete; protected: void PumpEvents(uint64_t timeout = 1000); virtual void ProcessFrameEvents() {}; UFHandle handle() const { return handle_; } private: UFHandle handle_; }; } // namespace testing } // namespace x11 } // namespace frame } // namespace oif #endif // FRAME_TEST_FIXTURE_H_ ./test/x11_mocks/0000755000004100000410000000000012752376103014035 5ustar www-datawww-data./test/x11_mocks/x11_mocks.cpp0000644000004100000410000002256112752376103016354 0ustar www-datawww-data/* needed to break into 'Display' struct internals. */ #define XLIB_ILLEGAL_ACCESS #include #include "x11_mocks.h" #include #include #include #include int xmock_xi2_opcode = 42; int xmock_xi2_event_base = 40000; int xmock_xi2_error_base = 40000; int xmock_xsync_event_base = 50000; int xmock_xsync_error_base = 50000; Display *xmock_display = NULL; uint64_t xmock_server_time = 0; XIDeviceInfo *xmock_devices = NULL; int xmock_devices_count = 0; std::map > > xmock_touch_acceptance; /* id to be used for the next alarm that gets created */ XSyncAlarm _xmock_next_alarm = 1; struct EventQueueItem { XEvent event; struct EventQueueItem *next; } *xmock_event_queue = NULL; #define XMOCK_PRINT_FUNCTION _xmock_print_function(__func__) void _xmock_print_function(const char *function) { static int debug_enabled = -1; if (debug_enabled == -1) { if (getenv("XMOCK_DEBUG")) debug_enabled = 1; else debug_enabled = 0; } if (debug_enabled) printf("XMOCK: %s mock called.\n", function); } void xmock_add_to_event_queue(const XEvent *event) { struct EventQueueItem *new_item = reinterpret_cast(malloc(sizeof(struct EventQueueItem))); new_item->event = *event; new_item->next = NULL; if (!xmock_event_queue) { xmock_event_queue = new_item; } else { struct EventQueueItem *last_item = xmock_event_queue; while (last_item->next) { last_item = last_item->next; } last_item->next = new_item; } static const uint64_t num = 1; if (write(xmock_display->fd, &num, sizeof(num)) != sizeof(num)) { fprintf(stderr, "ERROR: failed to update eventfd instance,\n"); exit(1); } } int xmock_get_touch_acceptance(int device_id, unsigned int touch_id, Window window) { if (xmock_touch_acceptance.find(device_id) == xmock_touch_acceptance.end()) return -1; std::map > &touch_map = xmock_touch_acceptance[device_id]; if (touch_map.find(touch_id) == touch_map.end()) return -1; std::map &window_map = touch_map[touch_id]; if (window_map.find(window) == window_map.end()) return -1; return window_map[window]; } Display *XOpenDisplay(_Xconst char *display_name) { XMOCK_PRINT_FUNCTION; (void)display_name; Display *display = (Display*)calloc(1, sizeof(Display)); display->fd = eventfd(0, EFD_NONBLOCK); display->default_screen = 0; display->nscreens = 1; display->screens = (Screen*)calloc(1, sizeof(Screen)); display->screens[0].root = 1; xmock_display = display; return display; } int XCloseDisplay(Display *display) { XMOCK_PRINT_FUNCTION; close(display->fd); free(display->screens); free(display); xmock_display = NULL; return 0; } int XSync(Display *display, Bool discard) { (void)display; (void)discard; return 0; } int XFlush(Display *display) { (void)display; return 0; } Bool XQueryExtension(Display *display, const char *name, int *major_opcode_return, int *first_event_return, int *first_error_return) { XMOCK_PRINT_FUNCTION; (void)display; (void)name; /* assuming name == "XInputExtension" */ *major_opcode_return = xmock_xi2_opcode; *first_event_return = xmock_xi2_event_base; *first_error_return = xmock_xi2_error_base; return True; } int XPending(Display *display) { XMOCK_PRINT_FUNCTION; (void)display; int pending_events_count = 0; struct EventQueueItem *item = xmock_event_queue; while (item != NULL) { ++pending_events_count; item = item->next; } return pending_events_count; } int XNextEvent(Display *display, XEvent *event_return) { XMOCK_PRINT_FUNCTION; (void)display; if (xmock_event_queue) { uint64_t num = 1; ssize_t bytes_read = read(xmock_display->fd, &num, sizeof(num)); (void)bytes_read; *event_return = xmock_event_queue->event; struct EventQueueItem *removed_item = xmock_event_queue; xmock_event_queue = xmock_event_queue->next; free(removed_item); } else { /* not going to block... */ } return 0; } Bool XGetEventData(Display *display, XGenericEventCookie *cookie) { XMOCK_PRINT_FUNCTION; (void)display; (void)cookie; return True; } void XFreeEventData(Display *display, XGenericEventCookie *cookie) { XMOCK_PRINT_FUNCTION; (void)display; if (cookie->data && cookie->extension == xmock_xi2_opcode) { if (cookie->evtype == XI_TouchBegin || cookie->evtype == XI_TouchUpdate || cookie->evtype == XI_TouchEnd) { XIDeviceEvent *device_event = (XIDeviceEvent*) cookie->data; free(device_event->valuators.mask); free(device_event->valuators.values); } free(cookie->data); } } XIDeviceInfo* XIQueryDevice(Display * display, int deviceid, int * ndevices_return) { XMOCK_PRINT_FUNCTION; (void)display; (void)deviceid; /* assuming XIAllDevices */ XIDeviceInfo *devices; devices = reinterpret_cast(calloc(xmock_devices_count, sizeof(XIDeviceInfo))); for (int i = 0; i < xmock_devices_count; ++i) { devices[i] = xmock_devices[i]; } *ndevices_return = xmock_devices_count; return devices; } void XIFreeDeviceInfo(XIDeviceInfo *info) { XMOCK_PRINT_FUNCTION; free(info); } Status XIQueryVersion(Display *display, int *major_version_inout, int *minor_version_inout) { XMOCK_PRINT_FUNCTION; (void)display; *major_version_inout = 2; *minor_version_inout = 2; return Success; } Status XISelectEvents(Display *display, Window win, XIEventMask *masks, int num_masks) { XMOCK_PRINT_FUNCTION; (void)display; (void)win; (void)masks; (void)num_masks; return Success; } int XIGrabTouchBegin( Display* display, int deviceid, Window grab_window, int owner_events, XIEventMask *mask, int num_modifiers, XIGrabModifiers *modifiers_inout) { XMOCK_PRINT_FUNCTION; (void)display; (void)deviceid; (void)grab_window; (void)owner_events; (void)mask; for (int i = 0; i < num_modifiers; ++i) { modifiers_inout[i].status = XIGrabSuccess; } return 0; } Status XIUngrabTouchBegin( Display* display, int deviceid, Window grab_window, int num_modifiers, XIGrabModifiers *modifiers) { XMOCK_PRINT_FUNCTION; (void)display; (void)deviceid; (void)grab_window; (void)num_modifiers; (void)modifiers; return Success; } Status XIAllowTouchEvents( Display* display, int deviceid, unsigned int touchid, Window grab_window, int event_mode) { XMOCK_PRINT_FUNCTION; (void)display; xmock_touch_acceptance[deviceid][touchid][grab_window] = event_mode; return Success; } Status XSyncQueryExtension( Display* dpy, int* event_base_return, int* error_base_return) { XMOCK_PRINT_FUNCTION; (void)dpy; *event_base_return = xmock_xsync_event_base; *error_base_return = xmock_xsync_error_base; return True; } Status XSyncInitialize( Display* dpy, int* major_version_return, int* minor_version_return) { XMOCK_PRINT_FUNCTION; (void)dpy; *major_version_return = 1; *minor_version_return = 0; return True; } XSyncSystemCounter *XSyncListSystemCounters( Display* dpy, int* n_counters_return) { XMOCK_PRINT_FUNCTION; (void)dpy; *n_counters_return = 1; XSyncSystemCounter *sys_counter = reinterpret_cast(malloc(sizeof(XSyncSystemCounter))); sys_counter->name = const_cast("SERVERTIME"); // I know it's technically dangerous, but it's simple. sys_counter->counter = 1; sys_counter->resolution.hi = 1; sys_counter->resolution.lo = 0; return sys_counter; } void XSyncFreeSystemCounterList(XSyncSystemCounter* list) { XMOCK_PRINT_FUNCTION; free(list); } XSyncAlarm XSyncCreateAlarm( Display* dpy, unsigned long values_mask, XSyncAlarmAttributes* values) { XMOCK_PRINT_FUNCTION; (void)dpy; XSyncAlarmNotifyEvent alarm_notify; alarm_notify.type = xmock_xsync_event_base + XSyncAlarmNotify; alarm_notify.alarm = _xmock_next_alarm; alarm_notify.counter_value = values->trigger.wait_value; xmock_add_to_event_queue((XEvent*)&alarm_notify); XSyncValue time = values->trigger.wait_value; uint64_t timeout = (uint64_t)XSyncValueHigh32(time) << 32 | (uint64_t)XSyncValueLow32(time); xmock_server_time = timeout + 1; return _xmock_next_alarm++; } Status XSyncDestroyAlarm( Display* dpy, XSyncAlarm alarm) { XMOCK_PRINT_FUNCTION; (void)dpy; (void)alarm; return Success; } void XSyncIntsToValue( XSyncValue* pv, unsigned int l, int h) { XMOCK_PRINT_FUNCTION; pv->hi = h; pv->lo = l; } int XSyncValueHigh32(XSyncValue v) { XMOCK_PRINT_FUNCTION; return v.hi; } unsigned int XSyncValueLow32(XSyncValue v) { XMOCK_PRINT_FUNCTION; return v.lo; } Atom XInternAtom(Display* display, _Xconst char* atom_name, Bool only_if_exists) { XMOCK_PRINT_FUNCTION; /* This function doesn't end up getting called when frame is run from tests yet. It's here just to make the code compile. Add some minimal logic when needed. */ abort(); return 1; } ./test/x11_mocks/Makefile.am0000644000004100000410000000036712752376103016077 0ustar www-datawww-data# # @file testsuite/x11_mocks/Makefile.am # @brief automake recipe for the X11 mockups # check_LIBRARIES = libx11_mocks.a libx11_mocks_a_SOURCES = \ x11_mocks.h x11_mocks.cpp libx11_mocks_a_CPPFLAGS = \ --std=c++0x \ -Wno-unused-parameter ./test/x11_mocks/x11_mocks.h0000644000004100000410000000226312752376103016016 0ustar www-datawww-data#ifndef X11_MOCKS_H #define X11_MOCKS_H #include #include #include #include #include extern int xmock_xi2_opcode; extern int xmock_xi2_event_base; extern int xmock_xi2_error_base; extern int xmock_xsync_event_base; extern int xmock_xsync_error_base; extern Display *xmock_display; extern uint64_t xmock_server_time; /* to be filled by user. A copy of it will be returned by each XIQueryDevice call */ extern XIDeviceInfo *xmock_devices; extern int xmock_devices_count; /* Adds the given XEvent to the xmock event queue. The Diplay connection will signal that there are pending events */ extern void xmock_add_to_event_queue(const XEvent* event); /* Each call to: XIAllowTouchEvents(display, device_id, touch_id, window_id, touch_acceptance) Causes: xmock_touch_acceptance[device_id][touch_id][window_id] = touch_acceptance; */ extern std::map > > xmock_touch_acceptance; /* Returns -1 if XIAllowTouchEvents wasn't called with the given parameters. */ int xmock_get_touch_acceptance(int device_id, unsigned int touch_id, Window window); #endif ./test/regular/0000755000004100000410000000000012752376103013671 5ustar www-datawww-data./test/regular/accept-ended-touch.cpp0000644000004100000410000000336612752376103020041 0ustar www-datawww-data#include "frame-x11-fixture.h" #include "x11_mocks.h" class AcceptEndedTouch : public FrameX11Fixture { }; /* Regression test for https://bugs.launchpad.net/bugs/1025297 The bug is as follows: frame lib fails to forward the accept/reject command to xserver for an owned touch if it has already ended. Steps to reproduce the issue: 1 - touch 1 begins and gets ownership 2 - touch 1 ends 3 - touch 2 begins and gets ownership 4 - frame client accepts touch 1 Expected outcome: frame lib accepts the touch on the XInput backend. Outcome of the bug: Nothing happens. frame lib never accepts that touch. */ TEST_F(AcceptEndedTouch, Test) { UFStatus status; UFDevice device; xmock_server_time = 1234; CreateXMockTouchScreenDevice(); Display *display = XOpenDisplay(NULL); status = frame_x11_new(display, &frame_handle); ASSERT_EQ(UFStatusSuccess, status); FetchDeviceAddedEvent(&device); AssertNoMoreEvents(); SendTouchEvent(XI_TouchBegin, 1, 10.0f, 10.0f); SendTouchOwnershipEvent(1); xmock_server_time += 10; SendTouchEvent(XI_TouchEnd, 1, 10.0f, 20.0f); xmock_server_time += 3; SendTouchEvent(XI_TouchBegin, 2, 10.0f, 21.0f); SendTouchOwnershipEvent(2); UFWindowId frame_window_id = frame_x11_create_window_id(DefaultRootWindow(display)); status = frame_x11_accept_touch(device, frame_window_id, 1); ASSERT_EQ(UFStatusSuccess, status); ASSERT_EQ(XIAcceptTouch, xmock_get_touch_acceptance(xmock_devices[0].attachment /* device id */, 1 /* touch id */, DefaultRootWindow(display))); frame_x11_delete(frame_handle); frame_handle = nullptr; XCloseDisplay(display); DestroyXMockDevices(); } ./test/regular/frame-x11-fixture.h0000644000004100000410000000126712752376103017235 0ustar www-datawww-data#ifndef GTEST_FRAME_X11_FIXTURE_H #define GTEST_FRAME_X11_FIXTURE_H #include #include "oif/frame.h" #include "oif/frame_x11.h" class FrameX11Fixture : public ::testing::Test { protected: FrameX11Fixture(); virtual void SetUp(); virtual void TearDown(); void CreateXMockTouchScreenDevice(); void DestroyXMockDevices(); void SendTouchEvent(int event_type, int touch_id, float x, float y); void SendTouchOwnershipEvent(int touch_id); void FetchDeviceAddedEvent(UFDevice *device); void AssertNoMoreEvents(); UFHandle frame_handle; private: /* holds the serial number to be used on the next synthetic XEvent */ int _xevent_serial_number; }; #endif ./test/regular/Makefile.am0000644000004100000410000000324512752376103015731 0ustar www-datawww-datatest_targets = if HAVE_XINPUT test_targets += check-c-compile check-cxx-compile endif if HAVE_GTEST test_targets += check-regular endif TESTS = $(test_targets) check_PROGRAMS = $(test_targets) check-static-type-checking AM_CFLAGS = \ $(COVERAGE_CFLAGS) AM_CPPFLAGS = \ -I$(top_builddir)/include \ -I$(top_srcdir)/include \ -iquote$(srcdir) check_c_compile_SOURCES = check-c-compile.c check_c_compile_LDADD = \ $(top_builddir)/src/libframe.la \ $(COVERAGE_LIBS) check_cxx_compile_SOURCES = check-cxx-compile.cpp check_cxx_compile_LDADD = \ $(top_builddir)/src/libframe.la \ $(COVERAGE_LIBS) check-static-type-checking$(EXEEXT): @echo "Checking whether static type checking works..." $(AM_V_at)if $(CC) -I../../include -L../../.libs check-static-type-checking.c -o check_static_type_checking; then \ echo "FAIL: Static type checking source compiled without error"; \ exit -1; \ else \ echo "SUCCESS: Static type checking source failed to compile"; \ exit 0; \ fi ### check-regular check_regular_SOURCES = \ backend.cpp if HAVE_XINPUT check_regular_SOURCES += \ accept-ended-touch.cpp \ x11-accept-touch.cpp \ frame-x11-fixture.cpp \ frame-x11-fixture.h endif # # Link against the (non-distributed) static lib to pick up the # internal symbols. # check_regular_LDADD = \ $(top_builddir)/src/.libs/libframe.a \ $(top_builddir)/test/gtest/libgtest.a \ $(top_builddir)/test/gtest/libgtest_main.a \ $(COVERAGE_LIBS) \ $(GTEST_LIBS) if HAVE_XINPUT check_regular_LDADD += \ $(top_builddir)/test/x11_mocks/libx11_mocks.a endif check_regular_CPPFLAGS = \ --std=c++0x \ -I$(top_srcdir)/test/x11_mocks \ $(AM_CPPFLAGS) \ $(WARNING_CPPFLAGS) \ $(GTEST_CPPFLAGS) ./test/regular/x11-accept-touch.cpp0000644000004100000410000000417412752376103017371 0ustar www-datawww-data#include "frame-x11-fixture.h" #include "x11_mocks.h" class X11TouchAcceptance : public FrameX11Fixture { }; /* Calls frame_accept_touch and check if the corresponding X11 call is made */ TEST_F(X11TouchAcceptance, Accept) { UFStatus status; UFDevice device; xmock_server_time = 1234; CreateXMockTouchScreenDevice(); Display *display = XOpenDisplay(NULL); status = frame_x11_new(display, &frame_handle); ASSERT_EQ(UFStatusSuccess, status); FetchDeviceAddedEvent(&device); AssertNoMoreEvents(); SendTouchEvent(XI_TouchBegin, 1, 10.0f, 10.0f); SendTouchOwnershipEvent(1); UFWindowId frame_window_id = frame_x11_create_window_id(DefaultRootWindow(display)); status = frame_accept_touch(device, frame_window_id, 1); ASSERT_EQ(UFStatusSuccess, status); ASSERT_EQ(XIAcceptTouch, xmock_get_touch_acceptance(xmock_devices[0].attachment /* device id */, 1 /* touch id */, DefaultRootWindow(display))); frame_x11_delete(frame_handle); frame_handle = nullptr; XCloseDisplay(display); DestroyXMockDevices(); } /* Calls frame_reject_touch and check if the corresponding X11 call is made */ TEST_F(X11TouchAcceptance, Reject) { UFStatus status; UFDevice device; xmock_server_time = 1234; CreateXMockTouchScreenDevice(); Display *display = XOpenDisplay(NULL); status = frame_x11_new(display, &frame_handle); ASSERT_EQ(UFStatusSuccess, status); FetchDeviceAddedEvent(&device); AssertNoMoreEvents(); SendTouchEvent(XI_TouchBegin, 1, 10.0f, 10.0f); SendTouchOwnershipEvent(1); UFWindowId frame_window_id = frame_x11_create_window_id(DefaultRootWindow(display)); status = frame_reject_touch(device, frame_window_id, 1); ASSERT_EQ(UFStatusSuccess, status); ASSERT_EQ(XIRejectTouch, xmock_get_touch_acceptance(xmock_devices[0].attachment /* device id */, 1 /* touch id */, DefaultRootWindow(display))); frame_x11_delete(frame_handle); frame_handle = nullptr; XCloseDisplay(display); DestroyXMockDevices(); } ./test/regular/check-static-type-checking.c0000644000004100000410000000147312752376103021134 0ustar www-datawww-data/* Simple test to verify that an impossible type passed into a * frame_*_get_property() function does not compile. Due to the nature of * compile tests, we do not test all combinations of types and functions. This * test is merely to check that the improper type mechanism is working at all. */ #include #ifdef __has_extension #if __has_extension(c_generic_selections) #define HAS_C_GENERIC_SELECTIONS #endif // __has_extension(c_generic_selections) #endif // __has_extension int main() { #ifdef HAS_C_GENERIC_SELECTIONS UFStatus status; UFTouch touch; char test; /* No touch properties are of type 'char', this should fail to compile */ status = frame_touch_get_property(touch, UFTouchPropertyId, &test); #else #error PASS: C compiler does not support generic selections #endif return 0; } ./test/regular/backend.cpp0000644000004100000410000002512712752376103015773 0ustar www-datawww-data#include #include "oif/frame_backend.h" TEST(Backend, Touch) { UFStatus status; UFBackendTouch touch_backend = frame_backend_touch_new(); ASSERT_TRUE(touch_backend != nullptr); UFTouch touch = frame_backend_touch_get_touch(touch_backend); ASSERT_TRUE(touch != nullptr); ASSERT_EQ(UFTouchStateBegin, frame_touch_get_state(touch)); frame_backend_touch_set_id(touch_backend, 123); ASSERT_EQ(123, frame_touch_get_id(touch)); frame_backend_touch_set_ended(touch_backend); ASSERT_EQ(UFTouchStateEnd, frame_touch_get_state(touch)); frame_backend_touch_set_window_pos(touch_backend, 1.2f, 3.4f); ASSERT_EQ(1.2f, frame_touch_get_window_x(touch)); ASSERT_EQ(3.4f, frame_touch_get_window_y(touch)); frame_backend_touch_set_time(touch_backend, 852); ASSERT_EQ(852, frame_touch_get_time(touch)); frame_backend_touch_set_start_time(touch_backend, 555); ASSERT_EQ(555, frame_touch_get_start_time(touch)); frame_backend_touch_set_owned(touch_backend, 1); int owned = 0; status = frame_touch_get_property(touch, UFTouchPropertyOwned, &owned); ASSERT_EQ(UFStatusSuccess, status); ASSERT_EQ(1, owned); frame_backend_touch_set_pending_end(touch_backend, 1); int pending_end = 0; status = frame_touch_get_property(touch, UFTouchPropertyPendingEnd, &pending_end); ASSERT_EQ(UFStatusSuccess, status); ASSERT_EQ(1, pending_end); frame_backend_touch_set_value(touch_backend, UFAxisTypeTouchMajor, 987.6f); float touch_major = 0.0f; status = frame_touch_get_value(touch, UFAxisTypeTouchMajor, &touch_major); ASSERT_EQ(UFStatusSuccess, status); ASSERT_EQ(987.6f, touch_major); /* clean up */ UFBackendFrame frame = frame_backend_frame_new(); frame_backend_frame_give_touch(frame, &touch_backend); frame_backend_frame_delete(frame); } TEST(Backend, Device) { UFStatus status; UFBackendDevice device_backend = frame_backend_device_new(); ASSERT_NE(nullptr, device_backend); UFDevice device = frame_backend_device_get_device(device_backend); ASSERT_NE(nullptr, device); const char *name = nullptr; status = frame_device_get_property(device, UFDevicePropertyName, &name); ASSERT_EQ(UFStatusErrorUnknownProperty, status); frame_backend_device_set_name(device_backend, "Hello World"); status = frame_device_get_property(device, UFDevicePropertyName, &name); ASSERT_EQ(UFStatusSuccess, status); ASSERT_STREQ("Hello World", name); int direct = 0; status = frame_device_get_property(device, UFDevicePropertyDirect, &direct); ASSERT_EQ(UFStatusErrorUnknownProperty, status); frame_backend_device_set_direct(device_backend, 1); status = frame_device_get_property(device, UFDevicePropertyDirect, &direct); ASSERT_EQ(UFStatusSuccess, status); ASSERT_EQ(1, direct); int independent = 0; status = frame_device_get_property(device, UFDevicePropertyIndependent, &independent); ASSERT_EQ(UFStatusErrorUnknownProperty, status); frame_backend_device_set_independent(device_backend, 1); status = frame_device_get_property(device, UFDevicePropertyIndependent, &independent); ASSERT_EQ(UFStatusSuccess, status); ASSERT_EQ(1, independent); int semi_mt = 0; status = frame_device_get_property(device, UFDevicePropertySemiMT, &semi_mt); ASSERT_EQ(UFStatusErrorUnknownProperty, status); frame_backend_device_set_semi_mt(device_backend, 1); status = frame_device_get_property(device, UFDevicePropertySemiMT, &semi_mt); ASSERT_EQ(UFStatusSuccess, status); ASSERT_EQ(1, semi_mt); unsigned int max_touches = 0; status = frame_device_get_property(device, UFDevicePropertyMaxTouches, &max_touches); ASSERT_EQ(UFStatusErrorUnknownProperty, status); frame_backend_device_set_max_touches(device_backend, 5); status = frame_device_get_property(device, UFDevicePropertyMaxTouches, &max_touches); ASSERT_EQ(UFStatusSuccess, status); ASSERT_EQ(5, max_touches); frame_backend_device_set_window_resolution(device_backend, 1024.0f, 768.0f); ASSERT_EQ(1024.0f, frame_device_get_window_resolution_x(device)); ASSERT_EQ(768.0f, frame_device_get_window_resolution_y(device)); unsigned int num_axes = 0; status = frame_device_get_property(device, UFDevicePropertyNumAxes, &num_axes); ASSERT_EQ(UFStatusSuccess, status); ASSERT_EQ(0, num_axes); frame_backend_device_add_axis(device_backend, UFAxisTypePressure, 1.0f, 1000.0f, 3.5f); status = frame_device_get_property(device, UFDevicePropertyNumAxes, &num_axes); ASSERT_EQ(UFStatusSuccess, status); ASSERT_EQ(1, num_axes); UFAxis axis = nullptr; status = frame_device_get_axis_by_type(device, UFAxisTypePressure, &axis); ASSERT_EQ(UFStatusSuccess, status); ASSERT_NE(nullptr, axis); ASSERT_EQ(UFAxisTypePressure, frame_axis_get_type(axis)); ASSERT_EQ(1.0f, frame_axis_get_minimum(axis)); ASSERT_EQ(1000.0f, frame_axis_get_maximum(axis)); ASSERT_EQ(3.5f, frame_axis_get_resolution(axis)); frame_backend_device_delete(device_backend); } TEST(Backend, Frame) { UFStatus status; UFBackendFrame frame_backend = frame_backend_frame_new(); ASSERT_NE(nullptr, frame_backend); UFFrame frame = frame_backend_frame_get_frame(frame_backend); ASSERT_NE(nullptr, frame); UFBackendDevice device_backend = frame_backend_device_new(); UFDevice device = frame_backend_device_get_device(device_backend); frame_backend_frame_set_device(frame_backend, device_backend); ASSERT_EQ(device, frame_frame_get_device(frame)); frame_backend_frame_set_window_id(frame_backend, 123); ASSERT_EQ(123, frame_frame_get_window_id(frame)); unsigned int active_touches = 0; UFBackendTouch touch_backend = frame_backend_touch_new(); UFTouch touch = frame_backend_touch_get_touch(touch_backend); frame_backend_touch_set_id(touch_backend, 10); UFTouch touch_retrieved = nullptr; ASSERT_EQ(0, frame_frame_get_num_touches(frame)); status = frame_frame_get_property(frame, UFFramePropertyActiveTouches, &active_touches); ASSERT_EQ(UFStatusSuccess, status); ASSERT_EQ(0, active_touches); status = frame_backend_frame_give_touch(frame_backend, &touch_backend); ASSERT_EQ(UFStatusSuccess, status); ASSERT_EQ(nullptr, touch_backend); ASSERT_EQ(1, frame_frame_get_num_touches(frame)); status = frame_frame_get_property(frame, UFFramePropertyActiveTouches, &active_touches); ASSERT_EQ(UFStatusSuccess, status); ASSERT_EQ(1, active_touches); status = frame_frame_get_touch_by_id(frame, 10, &touch_retrieved); ASSERT_EQ(UFStatusSuccess, status); ASSERT_EQ(touch, touch_retrieved); frame_backend_frame_set_active_touches(frame_backend, 3); status = frame_frame_get_property(frame, UFFramePropertyActiveTouches, &active_touches); ASSERT_EQ(UFStatusSuccess, status); ASSERT_EQ(3, active_touches); frame_backend_frame_delete(frame_backend); frame_backend_device_delete(device_backend); } TEST(Backend, FrameBorrowInexistentTouch) { UFStatus status; UFBackendFrame frame_backend = frame_backend_frame_new(); UFBackendTouch touch_backend; status = frame_backend_frame_borrow_touch_by_id(frame_backend, 123, &touch_backend); ASSERT_EQ(UFStatusErrorInvalidTouch, status); /* clean up */ frame_backend_frame_delete(frame_backend); } TEST(Backend, FrameCreateNext) { UFStatus status; /* frame 1 */ UFBackendTouch touch_backend = frame_backend_touch_new(); frame_backend_touch_set_id(touch_backend, 1); UFTouch frame1_touch = frame_backend_touch_get_touch(touch_backend); UFBackendFrame frame1_backend = frame_backend_frame_new(); status = frame_backend_frame_give_touch(frame1_backend, &touch_backend); ASSERT_EQ(UFStatusSuccess, status); /* frame 2 */ UFBackendFrame frame2_backend = frame_backend_frame_create_next(frame1_backend); UFFrame frame2 = frame_backend_frame_get_frame(frame2_backend); UFTouch frame2_touch; status = frame_frame_get_touch_by_id(frame2, 1, &frame2_touch); ASSERT_EQ(UFStatusSuccess, status); /* frame 3 */ UFBackendFrame frame3_backend = frame_backend_frame_create_next(frame2_backend); UFFrame frame3 = frame_backend_frame_get_frame(frame3_backend); UFTouch frame3_touch; status = frame_frame_get_touch_by_id(frame3, 1, &frame3_touch); ASSERT_EQ(UFStatusSuccess, status); /* frame 4 */ UFBackendFrame frame4_backend = frame_backend_frame_create_next(frame3_backend); status = frame_backend_frame_borrow_touch_by_id(frame4_backend, 1, &touch_backend); ASSERT_EQ(UFStatusSuccess, status); frame_backend_touch_set_ended(touch_backend); status = frame_backend_frame_give_touch(frame4_backend, &touch_backend); ASSERT_EQ(UFStatusSuccess, status); UFFrame frame4 = frame_backend_frame_get_frame(frame4_backend); UFTouch frame4_touch; status = frame_frame_get_touch_by_id(frame4, 1, &frame4_touch); ASSERT_EQ(UFStatusSuccess, status); /* frame 5 */ UFBackendFrame frame5_backend = frame_backend_frame_create_next(frame4_backend); UFFrame frame5 = frame_backend_frame_get_frame(frame5_backend); /* Test the status of touch 1 throughout all frames */ ASSERT_EQ(UFTouchStateBegin, frame_touch_get_state(frame1_touch)); ASSERT_EQ(UFTouchStateUpdate, frame_touch_get_state(frame2_touch)); ASSERT_EQ(UFTouchStateUpdate, frame_touch_get_state(frame3_touch)); ASSERT_EQ(frame2_touch, frame3_touch); ASSERT_EQ(UFTouchStateEnd, frame_touch_get_state(frame4_touch)); ASSERT_EQ(0, frame_frame_get_num_touches(frame5)); /* clean up */ frame_backend_frame_delete(frame1_backend); frame_backend_frame_delete(frame2_backend); frame_backend_frame_delete(frame3_backend); frame_backend_frame_delete(frame4_backend); frame_backend_frame_delete(frame5_backend); } TEST(Backend, Event) { UFStatus status; UFEvent event = frame_event_new(); ASSERT_NE(nullptr, event); frame_event_set_type(event, UFEventTypeDeviceRemoved); ASSERT_EQ(UFEventTypeDeviceRemoved, frame_event_get_type(event)); UFBackendDevice device_backend = frame_backend_device_new(); UFDevice device = frame_backend_device_get_device(device_backend); UFDevice device_retrieved = nullptr; frame_event_set_device(event, device_backend); status = frame_event_get_property(event, UFEventPropertyDevice, &device_retrieved); ASSERT_EQ(UFStatusSuccess, status); ASSERT_EQ(device, device_retrieved); UFBackendFrame frame_backend = frame_backend_frame_new(); UFFrame frame = frame_backend_frame_get_frame(frame_backend); UFFrame frame_retrieved = nullptr; frame_event_set_frame(event, frame_backend); status = frame_event_get_property(event, UFEventPropertyFrame, &frame_retrieved); ASSERT_EQ(UFStatusSuccess, status); ASSERT_EQ(frame, frame_retrieved); frame_event_set_time(event, 1234); ASSERT_EQ(1234, frame_event_get_time(event)); frame_event_unref(event); frame_backend_device_delete(device_backend); frame_backend_frame_delete(frame_backend); } ./test/regular/check-cxx-compile.cpp0000644000004100000410000000032012752376103017673 0ustar www-datawww-data/* * Test compiling and linking with a C++ compiler. */ #include int main(int argc, char **argv) { UFWindowId id __attribute__((unused)) = frame_x11_create_window_id(0); return 0; } ./test/regular/frame-x11-fixture.cpp0000644000004100000410000001234112752376103017563 0ustar www-datawww-data#include "frame-x11-fixture.h" #include "x11_mocks.h" FrameX11Fixture::FrameX11Fixture() : frame_handle(nullptr), _xevent_serial_number(1) { } void FrameX11Fixture::SetUp() { xmock_touch_acceptance.clear(); } void FrameX11Fixture::TearDown() { ASSERT_EQ(nullptr, frame_handle); } void FrameX11Fixture::CreateXMockTouchScreenDevice() { xmock_devices_count = 1; xmock_devices = (XIDeviceInfo*) calloc(xmock_devices_count, sizeof(XIDeviceInfo)); XITouchClassInfo *touch_info = (XITouchClassInfo*) malloc(sizeof(XITouchClassInfo)); touch_info->type = XITouchClass; touch_info->sourceid = 0; touch_info->mode = XIDirectTouch; touch_info->num_touches = 5; XIValuatorClassInfo *x_axis_info = (XIValuatorClassInfo*) malloc(sizeof(XIValuatorClassInfo)); x_axis_info->type = XIValuatorClass; x_axis_info->sourceid = 0; x_axis_info->number = 0; /* identifies it as being the X axis */ x_axis_info->min = -500.0; x_axis_info->max = 500.0; x_axis_info->resolution = 3000; /* counts/meter */ XIValuatorClassInfo *y_axis_info = (XIValuatorClassInfo*) malloc(sizeof(XIValuatorClassInfo)); y_axis_info->type = XIValuatorClass; y_axis_info->sourceid = 0; y_axis_info->number = 1; /* identifies it as being the Y axis */ y_axis_info->min = -500.0; y_axis_info->max = 500.0; y_axis_info->resolution = 3000; XIAnyClassInfo **classes = (XIAnyClassInfo**) malloc(sizeof(XIAnyClassInfo*)*3); classes[0] = (XIAnyClassInfo*) touch_info; classes[1] = (XIAnyClassInfo*) x_axis_info; classes[2] = (XIAnyClassInfo*) y_axis_info; xmock_devices[0].deviceid = 0; xmock_devices[0].name = const_cast("Fake Touch Screen"); xmock_devices[0].use = XISlavePointer; xmock_devices[0].attachment = 1; xmock_devices[0].enabled = True; xmock_devices[0].num_classes = 3; xmock_devices[0].classes = classes; } void FrameX11Fixture::DestroyXMockDevices() { for (int i = 0; i < xmock_devices_count; ++i) { for (int j = 0; j < xmock_devices[i].num_classes; ++j) free(xmock_devices[i].classes[j]); free(xmock_devices[i].classes); } free(xmock_devices); } void FrameX11Fixture::SendTouchEvent( int event_type, int touch_id, float x, float y) { UFStatus status; XGenericEventCookie xcookie; XIDeviceEvent *device_event = 0; device_event = (XIDeviceEvent*)calloc(1, sizeof(XIDeviceEvent)); device_event->serial = _xevent_serial_number++; device_event->display = xmock_display; device_event->extension = xmock_xi2_opcode; device_event->evtype = event_type; device_event->time = xmock_server_time; device_event->deviceid = 0; device_event->sourceid = device_event->deviceid; device_event->detail = touch_id; device_event->root = DefaultRootWindow(xmock_display); device_event->event = DefaultRootWindow(xmock_display); device_event->child = 0; device_event->root_x = x; device_event->root_y = y; device_event->event_x = device_event->root_x; device_event->event_y = device_event->root_y; device_event->valuators.mask_len = 2; device_event->valuators.mask = (unsigned char*) malloc(2); XISetMask(device_event->valuators.mask, 0); XISetMask(device_event->valuators.mask, 1); device_event->valuators.values = (double*) malloc(sizeof(double)*2); device_event->valuators.values[0] = 0; /* just change the coordinate system */ device_event->valuators.values[1] = 0; xcookie.extension = xmock_xi2_opcode; xcookie.evtype = event_type; xcookie.data = device_event; status = frame_x11_process_event(frame_handle, &xcookie); ASSERT_EQ(UFStatusSuccess, status); free(device_event->valuators.mask); free(device_event->valuators.values); free(device_event); } void FrameX11Fixture::SendTouchOwnershipEvent(int touch_id) { UFStatus status; XGenericEventCookie xcookie; XITouchOwnershipEvent *ownership_event = 0; ownership_event = (XITouchOwnershipEvent*)calloc(1, sizeof(XITouchOwnershipEvent)); ownership_event->type = GenericEvent; ownership_event->serial = _xevent_serial_number++; ownership_event->display = xmock_display; ownership_event->extension = xmock_xi2_opcode; ownership_event->evtype = XI_TouchOwnership; ownership_event->time = xmock_server_time; ownership_event->deviceid = 0; ownership_event->sourceid = ownership_event->deviceid; ownership_event->touchid = touch_id; ownership_event->root = DefaultRootWindow(xmock_display); ownership_event->event = DefaultRootWindow(xmock_display); ownership_event->child = 0; xcookie.extension = xmock_xi2_opcode; xcookie.evtype = XI_TouchOwnership; xcookie.data = ownership_event; status = frame_x11_process_event(frame_handle, &xcookie); ASSERT_EQ(UFStatusSuccess, status); free(ownership_event); } void FrameX11Fixture::FetchDeviceAddedEvent(UFDevice *device) { UFEvent event; UFStatus status; status = frame_get_event(frame_handle, &event); ASSERT_EQ(UFStatusSuccess, status); ASSERT_EQ(UFEventTypeDeviceAdded, frame_event_get_type(event)); status = frame_event_get_property(event, UFEventPropertyDevice, device); ASSERT_EQ(UFStatusSuccess, status); frame_event_unref(event); } void FrameX11Fixture::AssertNoMoreEvents() { UFEvent event; UFStatus status; status = frame_get_event(frame_handle, &event); ASSERT_EQ(UFStatusErrorNoEvent, status); } ./test/regular/check-c-compile.c0000644000004100000410000000032412752376103016757 0ustar www-datawww-data/* * Test compiling and linking with a plain C compiler. */ #include int main(int argc, char **argv) { UFWindowId id __attribute__((unused)) = frame_x11_create_window_id(0); return 0; } ./m4/0000755000004100000410000000000012752376103011571 5ustar www-datawww-data./m4/gtest.m40000644000004100000410000000510312752376103013160 0ustar www-datawww-data# Copyright (C) 2012 Canonical, Ltd. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice (including the next # paragraph) shall be included in all copies or substantial portions of the # Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # Checks whether the gtest source is available on the system. Allows for # adjusting the include and source path. Sets have_gtest=yes if the source is # present. Sets GTEST_CPPFLAGS and GTEST_SOURCE to the preprocessor flags and # source location respectively. AC_DEFUN([CHECK_GTEST], [ AC_ARG_WITH([gtest-include-path], [AS_HELP_STRING([--with-gtest-include-path], [location of the Google test headers])], [GTEST_CPPFLAGS="-I$withval"]) AC_ARG_WITH([gtest-source-path], [AS_HELP_STRING([--with-gtest-source-path], [location of the Google test sources, defaults to /usr/src/gtest])], [GTEST_SOURCE="$withval"], [GTEST_SOURCE="/usr/src/gtest"]) GTEST_CPPFLAGS="$GTEST_CPPFLAGS -I$GTEST_SOURCE" AC_LANG_PUSH(C++) gtest_save_CPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS $GTEST_CPPFLAGS" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include "src/gtest-all.cc"]])], [have_gtest=yes], [have_gtest=no]) AS_IF([test "x$have_gtest" = xyes], [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include "src/gtest_main.cc"]])], [], [have_gtest=no])]) CPPFLAGS=$gtest_save_CPPFLAGS AC_LANG_POP(C++) AS_IF([test "x$have_gtest" = xyes], [GTEST_LIBS=-lpthread AC_SUBST(GTEST_CPPFLAGS) AC_SUBST(GTEST_SOURCE) AC_SUBST(GTEST_LIBS)]) ]) # CHECK_GTEST ./m4/xorg-gtest.m40000644000004100000410000000642312752376103014143 0ustar www-datawww-data# serial 3 # Copyright (C) 2012 Canonical, Ltd. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice (including the next # paragraph) shall be included in all copies or substantial portions of the # Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # CHECK_XORG_GTEST([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # Checks whether the xorg-gtest source is available on the system. Allows for # adjusting the include and source path. Sets have_xorg_gtest=yes if the source # is present. Sets XORG_GTEST_CPPFLAGS and XORG_GTEST_SOURCE to the preprocessor # flags and source location respectively. Sets XORG_GTEST_LIBS to all the # libraries needed to link against a built xorg-gtest library. # # Both default actions are no-ops. AC_DEFUN([CHECK_XORG_GTEST], [ AC_REQUIRE([CHECK_GTEST]) PKG_CHECK_EXISTS([xorg-gtest], [have_xorg_gtest=yes], [have_xorg_gtest=no]) XORG_GTEST_SOURCE=`$PKG_CONFIG --variable=sourcedir --print-errors xorg-gtest` XORG_GTEST_CPPFLAGS=`$PKG_CONFIG --variable=CPPflags --print-errors xorg-gtest` XORG_GTEST_CPPFLAGS="$GTEST_CPPFLAGS $XORG_GTEST_CPPFLAGS" XORG_GTEST_CPPFLAGS="$XORG_GTEST_CPPFLAGS -I$XORG_GTEST_SOURCE" PKG_CHECK_MODULES(X11, [x11], [have_x11=yes], [have_x11=no]) # Check if we should include support for evemu AC_ARG_WITH([evemu], [AS_HELP_STRING([--with-evemu], [support Linux input device recording playback (default: enabled if available)])], [], [with_evemu=check]) AS_IF([test "x$with_evemu" = xyes], [PKG_CHECK_MODULES(EVEMU, [evemu], [have_xorg_gtest_evemu=yes])], [test "x$with_evemu" = xcheck], [PKG_CHECK_MODULES(EVEMU, [evemu], [have_xorg_gtest_evemu=yes], [have_xorg_gtest_evemu=no])]) AS_IF([test "x$have_xorg_gtest_evemu" = xyes], [XORG_GTEST_CPPFLAGS="$XORG_GTEST_CPPFLAGS -DHAVE_EVEMU"]) AS_IF([test "x$have_gtest" != xyes -o "x$have_x11" != xyes], [have_xorg_gtest=no]) AS_IF([test "x$have_xorg_gtest" = xyes], [AC_SUBST(XORG_GTEST_SOURCE)] [AC_SUBST(XORG_GTEST_CPPFLAGS)] # Get BASE_CXXFLAGS and STRICT_CXXFLAGS [XORG_MACROS_VERSION(1.17)] [AC_LANG_PUSH([C++])] [XORG_STRICT_OPTION] [AC_LANG_POP] [$1], [$2]) ]) # CHECK_XORG_GTEST ./m4/xorg-macros.m40000644000004100000410000020634212752376103014303 0ustar www-datawww-datadnl xorg-macros.m4. Generated from xorg-macros.m4.in xorgversion.m4 by configure. dnl dnl Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved. dnl dnl Permission is hereby granted, free of charge, to any person obtaining a dnl copy of this software and associated documentation files (the "Software"), dnl to deal in the Software without restriction, including without limitation dnl the rights to use, copy, modify, merge, publish, distribute, sublicense, dnl and/or sell copies of the Software, and to permit persons to whom the dnl Software is furnished to do so, subject to the following conditions: dnl dnl The above copyright notice and this permission notice (including the next dnl paragraph) shall be included in all copies or substantial portions of the dnl Software. dnl dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER dnl DEALINGS IN THE SOFTWARE. # XORG_MACROS_VERSION(required-version) # ------------------------------------- # Minimum version: 1.1.0 # # If you're using a macro added in Version 1.1 or newer, include this in # your configure.ac with the minimum required version, such as: # XORG_MACROS_VERSION(1.1) # # To ensure that this macro is defined, also add: # m4_ifndef([XORG_MACROS_VERSION], # [m4_fatal([must install xorg-macros 1.1 or later before running autoconf/autogen])]) # # # See the "minimum version" comment for each macro you use to see what # version you require. m4_defun([XORG_MACROS_VERSION],[ m4_define([vers_have], [1.17]) m4_define([maj_have], m4_substr(vers_have, 0, m4_index(vers_have, [.]))) m4_define([maj_needed], m4_substr([$1], 0, m4_index([$1], [.]))) m4_if(m4_cmp(maj_have, maj_needed), 0,, [m4_fatal([xorg-macros major version ]maj_needed[ is required but ]vers_have[ found])]) m4_if(m4_version_compare(vers_have, [$1]), -1, [m4_fatal([xorg-macros version $1 or higher is required but ]vers_have[ found])]) m4_undefine([vers_have]) m4_undefine([maj_have]) m4_undefine([maj_needed]) ]) # XORG_MACROS_VERSION # XORG_PROG_RAWCPP() # ------------------ # Minimum version: 1.0.0 # # Find cpp program and necessary flags for use in pre-processing text files # such as man pages and config files AC_DEFUN([XORG_PROG_RAWCPP],[ AC_REQUIRE([AC_PROG_CPP]) AC_PATH_PROGS(RAWCPP, [cpp], [${CPP}], [$PATH:/bin:/usr/bin:/usr/lib:/usr/libexec:/usr/ccs/lib:/usr/ccs/lbin:/lib]) # Check for flag to avoid builtin definitions - assumes unix is predefined, # which is not the best choice for supporting other OS'es, but covers most # of the ones we need for now. AC_MSG_CHECKING([if $RAWCPP requires -undef]) AC_LANG_CONFTEST([AC_LANG_SOURCE([[Does cpp redefine unix ?]])]) if test `${RAWCPP} < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then AC_MSG_RESULT([no]) else if test `${RAWCPP} -undef < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then RAWCPPFLAGS=-undef AC_MSG_RESULT([yes]) # under Cygwin unix is still defined even with -undef elif test `${RAWCPP} -undef -ansi < conftest.$ac_ext | grep -c 'unix'` -eq 1 ; then RAWCPPFLAGS="-undef -ansi" AC_MSG_RESULT([yes, with -ansi]) else AC_MSG_ERROR([${RAWCPP} defines unix with or without -undef. I don't know what to do.]) fi fi rm -f conftest.$ac_ext AC_MSG_CHECKING([if $RAWCPP requires -traditional]) AC_LANG_CONFTEST([AC_LANG_SOURCE([[Does cpp preserve "whitespace"?]])]) if test `${RAWCPP} < conftest.$ac_ext | grep -c 'preserve \"'` -eq 1 ; then AC_MSG_RESULT([no]) else if test `${RAWCPP} -traditional < conftest.$ac_ext | grep -c 'preserve \"'` -eq 1 ; then RAWCPPFLAGS="${RAWCPPFLAGS} -traditional" AC_MSG_RESULT([yes]) else AC_MSG_ERROR([${RAWCPP} does not preserve whitespace with or without -traditional. I don't know what to do.]) fi fi rm -f conftest.$ac_ext AC_SUBST(RAWCPPFLAGS) ]) # XORG_PROG_RAWCPP # XORG_MANPAGE_SECTIONS() # ----------------------- # Minimum version: 1.0.0 # # Determine which sections man pages go in for the different man page types # on this OS - replaces *ManSuffix settings in old Imake *.cf per-os files. # Not sure if there's any better way than just hardcoding by OS name. # Override default settings by setting environment variables # Added MAN_SUBSTS in version 1.8 # Added AC_PROG_SED in version 1.8 AC_DEFUN([XORG_MANPAGE_SECTIONS],[ AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([AC_PROG_SED]) if test x$APP_MAN_SUFFIX = x ; then APP_MAN_SUFFIX=1 fi if test x$APP_MAN_DIR = x ; then APP_MAN_DIR='$(mandir)/man$(APP_MAN_SUFFIX)' fi if test x$LIB_MAN_SUFFIX = x ; then LIB_MAN_SUFFIX=3 fi if test x$LIB_MAN_DIR = x ; then LIB_MAN_DIR='$(mandir)/man$(LIB_MAN_SUFFIX)' fi if test x$FILE_MAN_SUFFIX = x ; then case $host_os in solaris*) FILE_MAN_SUFFIX=4 ;; *) FILE_MAN_SUFFIX=5 ;; esac fi if test x$FILE_MAN_DIR = x ; then FILE_MAN_DIR='$(mandir)/man$(FILE_MAN_SUFFIX)' fi if test x$MISC_MAN_SUFFIX = x ; then case $host_os in solaris*) MISC_MAN_SUFFIX=5 ;; *) MISC_MAN_SUFFIX=7 ;; esac fi if test x$MISC_MAN_DIR = x ; then MISC_MAN_DIR='$(mandir)/man$(MISC_MAN_SUFFIX)' fi if test x$DRIVER_MAN_SUFFIX = x ; then case $host_os in solaris*) DRIVER_MAN_SUFFIX=7 ;; *) DRIVER_MAN_SUFFIX=4 ;; esac fi if test x$DRIVER_MAN_DIR = x ; then DRIVER_MAN_DIR='$(mandir)/man$(DRIVER_MAN_SUFFIX)' fi if test x$ADMIN_MAN_SUFFIX = x ; then case $host_os in solaris*) ADMIN_MAN_SUFFIX=1m ;; *) ADMIN_MAN_SUFFIX=8 ;; esac fi if test x$ADMIN_MAN_DIR = x ; then ADMIN_MAN_DIR='$(mandir)/man$(ADMIN_MAN_SUFFIX)' fi AC_SUBST([APP_MAN_SUFFIX]) AC_SUBST([LIB_MAN_SUFFIX]) AC_SUBST([FILE_MAN_SUFFIX]) AC_SUBST([MISC_MAN_SUFFIX]) AC_SUBST([DRIVER_MAN_SUFFIX]) AC_SUBST([ADMIN_MAN_SUFFIX]) AC_SUBST([APP_MAN_DIR]) AC_SUBST([LIB_MAN_DIR]) AC_SUBST([FILE_MAN_DIR]) AC_SUBST([MISC_MAN_DIR]) AC_SUBST([DRIVER_MAN_DIR]) AC_SUBST([ADMIN_MAN_DIR]) XORG_MAN_PAGE="X Version 11" AC_SUBST([XORG_MAN_PAGE]) MAN_SUBSTS="\ -e 's|__vendorversion__|\"\$(PACKAGE_STRING)\" \"\$(XORG_MAN_PAGE)\"|' \ -e 's|__xorgversion__|\"\$(PACKAGE_STRING)\" \"\$(XORG_MAN_PAGE)\"|' \ -e 's|__xservername__|Xorg|g' \ -e 's|__xconfigfile__|xorg.conf|g' \ -e 's|__projectroot__|\$(prefix)|g' \ -e 's|__apploaddir__|\$(appdefaultdir)|g' \ -e 's|__appmansuffix__|\$(APP_MAN_SUFFIX)|g' \ -e 's|__drivermansuffix__|\$(DRIVER_MAN_SUFFIX)|g' \ -e 's|__adminmansuffix__|\$(ADMIN_MAN_SUFFIX)|g' \ -e 's|__libmansuffix__|\$(LIB_MAN_SUFFIX)|g' \ -e 's|__miscmansuffix__|\$(MISC_MAN_SUFFIX)|g' \ -e 's|__filemansuffix__|\$(FILE_MAN_SUFFIX)|g'" AC_SUBST([MAN_SUBSTS]) ]) # XORG_MANPAGE_SECTIONS # XORG_CHECK_SGML_DOCTOOLS([MIN-VERSION]) # ------------------------ # Minimum version: 1.7.0 # # Defines the variable XORG_SGML_PATH containing the location of X11/defs.ent # provided by xorg-sgml-doctools, if installed. AC_DEFUN([XORG_CHECK_SGML_DOCTOOLS],[ AC_MSG_CHECKING([for X.Org SGML entities m4_ifval([$1],[>= $1])]) XORG_SGML_PATH= PKG_CHECK_EXISTS([xorg-sgml-doctools m4_ifval([$1],[>= $1])], [XORG_SGML_PATH=`$PKG_CONFIG --variable=sgmlrootdir xorg-sgml-doctools`], [m4_ifval([$1],[:], [if test x"$cross_compiling" != x"yes" ; then AC_CHECK_FILE([$prefix/share/sgml/X11/defs.ent], [XORG_SGML_PATH=$prefix/share/sgml]) fi]) ]) # Define variables STYLESHEET_SRCDIR and XSL_STYLESHEET containing # the path and the name of the doc stylesheet if test "x$XORG_SGML_PATH" != "x" ; then AC_MSG_RESULT([$XORG_SGML_PATH]) STYLESHEET_SRCDIR=$XORG_SGML_PATH/X11 XSL_STYLESHEET=$STYLESHEET_SRCDIR/xorg.xsl else AC_MSG_RESULT([no]) fi AC_SUBST(XORG_SGML_PATH) AC_SUBST(STYLESHEET_SRCDIR) AC_SUBST(XSL_STYLESHEET) AM_CONDITIONAL([HAVE_STYLESHEETS], [test "x$XSL_STYLESHEET" != "x"]) ]) # XORG_CHECK_SGML_DOCTOOLS # XORG_CHECK_LINUXDOC # ------------------- # Minimum version: 1.0.0 # # Defines the variable MAKE_TEXT if the necessary tools and # files are found. $(MAKE_TEXT) blah.sgml will then produce blah.txt. # Whether or not the necessary tools and files are found can be checked # with the AM_CONDITIONAL "BUILD_LINUXDOC" AC_DEFUN([XORG_CHECK_LINUXDOC],[ AC_REQUIRE([XORG_CHECK_SGML_DOCTOOLS]) AC_REQUIRE([XORG_WITH_PS2PDF]) AC_PATH_PROG(LINUXDOC, linuxdoc) AC_MSG_CHECKING([whether to build documentation]) if test x$XORG_SGML_PATH != x && test x$LINUXDOC != x ; then BUILDDOC=yes else BUILDDOC=no fi AM_CONDITIONAL(BUILD_LINUXDOC, [test x$BUILDDOC = xyes]) AC_MSG_RESULT([$BUILDDOC]) AC_MSG_CHECKING([whether to build pdf documentation]) if test x$have_ps2pdf != xno && test x$BUILD_PDFDOC != xno; then BUILDPDFDOC=yes else BUILDPDFDOC=no fi AM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes]) AC_MSG_RESULT([$BUILDPDFDOC]) MAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH GROFF_NO_SGR=y $LINUXDOC -B txt -f" MAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC -B latex --papersize=letter --output=ps" MAKE_PDF="$PS2PDF" MAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $LINUXDOC -B html --split=0" AC_SUBST(MAKE_TEXT) AC_SUBST(MAKE_PS) AC_SUBST(MAKE_PDF) AC_SUBST(MAKE_HTML) ]) # XORG_CHECK_LINUXDOC # XORG_CHECK_DOCBOOK # ------------------- # Minimum version: 1.0.0 # # Checks for the ability to build output formats from SGML DocBook source. # For XXX in {TXT, PDF, PS, HTML}, the AM_CONDITIONAL "BUILD_XXXDOC" # indicates whether the necessary tools and files are found and, if set, # $(MAKE_XXX) blah.sgml will produce blah.xxx. AC_DEFUN([XORG_CHECK_DOCBOOK],[ AC_REQUIRE([XORG_CHECK_SGML_DOCTOOLS]) BUILDTXTDOC=no BUILDPDFDOC=no BUILDPSDOC=no BUILDHTMLDOC=no AC_PATH_PROG(DOCBOOKPS, docbook2ps) AC_PATH_PROG(DOCBOOKPDF, docbook2pdf) AC_PATH_PROG(DOCBOOKHTML, docbook2html) AC_PATH_PROG(DOCBOOKTXT, docbook2txt) AC_MSG_CHECKING([whether to build text documentation]) if test x$XORG_SGML_PATH != x && test x$DOCBOOKTXT != x && test x$BUILD_TXTDOC != xno; then BUILDTXTDOC=yes fi AM_CONDITIONAL(BUILD_TXTDOC, [test x$BUILDTXTDOC = xyes]) AC_MSG_RESULT([$BUILDTXTDOC]) AC_MSG_CHECKING([whether to build PDF documentation]) if test x$XORG_SGML_PATH != x && test x$DOCBOOKPDF != x && test x$BUILD_PDFDOC != xno; then BUILDPDFDOC=yes fi AM_CONDITIONAL(BUILD_PDFDOC, [test x$BUILDPDFDOC = xyes]) AC_MSG_RESULT([$BUILDPDFDOC]) AC_MSG_CHECKING([whether to build PostScript documentation]) if test x$XORG_SGML_PATH != x && test x$DOCBOOKPS != x && test x$BUILD_PSDOC != xno; then BUILDPSDOC=yes fi AM_CONDITIONAL(BUILD_PSDOC, [test x$BUILDPSDOC = xyes]) AC_MSG_RESULT([$BUILDPSDOC]) AC_MSG_CHECKING([whether to build HTML documentation]) if test x$XORG_SGML_PATH != x && test x$DOCBOOKHTML != x && test x$BUILD_HTMLDOC != xno; then BUILDHTMLDOC=yes fi AM_CONDITIONAL(BUILD_HTMLDOC, [test x$BUILDHTMLDOC = xyes]) AC_MSG_RESULT([$BUILDHTMLDOC]) MAKE_TEXT="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKTXT" MAKE_PS="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPS" MAKE_PDF="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKPDF" MAKE_HTML="SGML_SEARCH_PATH=$XORG_SGML_PATH $DOCBOOKHTML" AC_SUBST(MAKE_TEXT) AC_SUBST(MAKE_PS) AC_SUBST(MAKE_PDF) AC_SUBST(MAKE_HTML) ]) # XORG_CHECK_DOCBOOK # XORG_WITH_XMLTO([MIN-VERSION], [DEFAULT]) # ---------------- # Minimum version: 1.5.0 # Minimum version for optional DEFAULT argument: 1.11.0 # # Documentation tools are not always available on all platforms and sometimes # not at the appropriate level. This macro enables a module to test for the # presence of the tool and obtain it's path in separate variables. Coupled with # the --with-xmlto option, it allows maximum flexibilty in making decisions # as whether or not to use the xmlto package. When DEFAULT is not specified, # --with-xmlto assumes 'auto'. # # Interface to module: # HAVE_XMLTO: used in makefiles to conditionally generate documentation # XMLTO: returns the path of the xmlto program found # returns the path set by the user in the environment # --with-xmlto: 'yes' user instructs the module to use xmlto # 'no' user instructs the module not to use xmlto # # Added in version 1.10.0 # HAVE_XMLTO_TEXT: used in makefiles to conditionally generate text documentation # xmlto for text output requires either lynx, links, or w3m browsers # # If the user sets the value of XMLTO, AC_PATH_PROG skips testing the path. # AC_DEFUN([XORG_WITH_XMLTO],[ AC_ARG_VAR([XMLTO], [Path to xmlto command]) m4_define([_defopt], m4_default([$2], [auto])) AC_ARG_WITH(xmlto, AS_HELP_STRING([--with-xmlto], [Use xmlto to regenerate documentation (default: ]_defopt[)]), [use_xmlto=$withval], [use_xmlto=]_defopt) m4_undefine([_defopt]) if test "x$use_xmlto" = x"auto"; then AC_PATH_PROG([XMLTO], [xmlto]) if test "x$XMLTO" = "x"; then AC_MSG_WARN([xmlto not found - documentation targets will be skipped]) have_xmlto=no else have_xmlto=yes fi elif test "x$use_xmlto" = x"yes" ; then AC_PATH_PROG([XMLTO], [xmlto]) if test "x$XMLTO" = "x"; then AC_MSG_ERROR([--with-xmlto=yes specified but xmlto not found in PATH]) fi have_xmlto=yes elif test "x$use_xmlto" = x"no" ; then if test "x$XMLTO" != "x"; then AC_MSG_WARN([ignoring XMLTO environment variable since --with-xmlto=no was specified]) fi have_xmlto=no else AC_MSG_ERROR([--with-xmlto expects 'yes' or 'no']) fi # Test for a minimum version of xmlto, if provided. m4_ifval([$1], [if test "$have_xmlto" = yes; then # scrape the xmlto version AC_MSG_CHECKING([the xmlto version]) xmlto_version=`$XMLTO --version 2>/dev/null | cut -d' ' -f3` AC_MSG_RESULT([$xmlto_version]) AS_VERSION_COMPARE([$xmlto_version], [$1], [if test "x$use_xmlto" = xauto; then AC_MSG_WARN([xmlto version $xmlto_version found, but $1 needed]) have_xmlto=no else AC_MSG_ERROR([xmlto version $xmlto_version found, but $1 needed]) fi]) fi]) # Test for the ability of xmlto to generate a text target have_xmlto_text=no cat > conftest.xml << "EOF" EOF AS_IF([test "$have_xmlto" = yes], [AS_IF([$XMLTO --skip-validation txt conftest.xml >/dev/null 2>&1], [have_xmlto_text=yes], [AC_MSG_WARN([xmlto cannot generate text format, this format skipped])])]) rm -f conftest.xml AM_CONDITIONAL([HAVE_XMLTO_TEXT], [test $have_xmlto_text = yes]) AM_CONDITIONAL([HAVE_XMLTO], [test "$have_xmlto" = yes]) ]) # XORG_WITH_XMLTO # XORG_WITH_XSLTPROC([MIN-VERSION], [DEFAULT]) # -------------------------------------------- # Minimum version: 1.12.0 # Minimum version for optional DEFAULT argument: 1.12.0 # # XSLT (Extensible Stylesheet Language Transformations) is a declarative, # XML-based language used for the transformation of XML documents. # The xsltproc command line tool is for applying XSLT stylesheets to XML documents. # It is used under the cover by xmlto to generate html files from DocBook/XML. # The XSLT processor is often used as a standalone tool for transformations. # It should not be assumed that this tool is used only to work with documnetation. # When DEFAULT is not specified, --with-xsltproc assumes 'auto'. # # Interface to module: # HAVE_XSLTPROC: used in makefiles to conditionally generate documentation # XSLTPROC: returns the path of the xsltproc program found # returns the path set by the user in the environment # --with-xsltproc: 'yes' user instructs the module to use xsltproc # 'no' user instructs the module not to use xsltproc # have_xsltproc: returns yes if xsltproc found in PATH or no # # If the user sets the value of XSLTPROC, AC_PATH_PROG skips testing the path. # AC_DEFUN([XORG_WITH_XSLTPROC],[ AC_ARG_VAR([XSLTPROC], [Path to xsltproc command]) # Preserves the interface, should it be implemented later m4_ifval([$1], [m4_warn([syntax], [Checking for xsltproc MIN-VERSION is not implemented])]) m4_define([_defopt], m4_default([$2], [auto])) AC_ARG_WITH(xsltproc, AS_HELP_STRING([--with-xsltproc], [Use xsltproc for the transformation of XML documents (default: ]_defopt[)]), [use_xsltproc=$withval], [use_xsltproc=]_defopt) m4_undefine([_defopt]) if test "x$use_xsltproc" = x"auto"; then AC_PATH_PROG([XSLTPROC], [xsltproc]) if test "x$XSLTPROC" = "x"; then AC_MSG_WARN([xsltproc not found - cannot transform XML documents]) have_xsltproc=no else have_xsltproc=yes fi elif test "x$use_xsltproc" = x"yes" ; then AC_PATH_PROG([XSLTPROC], [xsltproc]) if test "x$XSLTPROC" = "x"; then AC_MSG_ERROR([--with-xsltproc=yes specified but xsltproc not found in PATH]) fi have_xsltproc=yes elif test "x$use_xsltproc" = x"no" ; then if test "x$XSLTPROC" != "x"; then AC_MSG_WARN([ignoring XSLTPROC environment variable since --with-xsltproc=no was specified]) fi have_xsltproc=no else AC_MSG_ERROR([--with-xsltproc expects 'yes' or 'no']) fi AM_CONDITIONAL([HAVE_XSLTPROC], [test "$have_xsltproc" = yes]) ]) # XORG_WITH_XSLTPROC # XORG_WITH_PERL([MIN-VERSION], [DEFAULT]) # ---------------------------------------- # Minimum version: 1.15.0 # # PERL (Practical Extraction and Report Language) is a language optimized for # scanning arbitrary text files, extracting information from those text files, # and printing reports based on that information. # # When DEFAULT is not specified, --with-perl assumes 'auto'. # # Interface to module: # HAVE_PERL: used in makefiles to conditionally scan text files # PERL: returns the path of the perl program found # returns the path set by the user in the environment # --with-perl: 'yes' user instructs the module to use perl # 'no' user instructs the module not to use perl # have_perl: returns yes if perl found in PATH or no # # If the user sets the value of PERL, AC_PATH_PROG skips testing the path. # AC_DEFUN([XORG_WITH_PERL],[ AC_ARG_VAR([PERL], [Path to perl command]) # Preserves the interface, should it be implemented later m4_ifval([$1], [m4_warn([syntax], [Checking for perl MIN-VERSION is not implemented])]) m4_define([_defopt], m4_default([$2], [auto])) AC_ARG_WITH(perl, AS_HELP_STRING([--with-perl], [Use perl for extracting information from files (default: ]_defopt[)]), [use_perl=$withval], [use_perl=]_defopt) m4_undefine([_defopt]) if test "x$use_perl" = x"auto"; then AC_PATH_PROG([PERL], [perl]) if test "x$PERL" = "x"; then AC_MSG_WARN([perl not found - cannot extract information and report]) have_perl=no else have_perl=yes fi elif test "x$use_perl" = x"yes" ; then AC_PATH_PROG([PERL], [perl]) if test "x$PERL" = "x"; then AC_MSG_ERROR([--with-perl=yes specified but perl not found in PATH]) fi have_perl=yes elif test "x$use_perl" = x"no" ; then if test "x$PERL" != "x"; then AC_MSG_WARN([ignoring PERL environment variable since --with-perl=no was specified]) fi have_perl=no else AC_MSG_ERROR([--with-perl expects 'yes' or 'no']) fi AM_CONDITIONAL([HAVE_PERL], [test "$have_perl" = yes]) ]) # XORG_WITH_PERL # XORG_WITH_ASCIIDOC([MIN-VERSION], [DEFAULT]) # ---------------- # Minimum version: 1.5.0 # Minimum version for optional DEFAULT argument: 1.11.0 # # Documentation tools are not always available on all platforms and sometimes # not at the appropriate level. This macro enables a module to test for the # presence of the tool and obtain it's path in separate variables. Coupled with # the --with-asciidoc option, it allows maximum flexibilty in making decisions # as whether or not to use the asciidoc package. When DEFAULT is not specified, # --with-asciidoc assumes 'auto'. # # Interface to module: # HAVE_ASCIIDOC: used in makefiles to conditionally generate documentation # ASCIIDOC: returns the path of the asciidoc program found # returns the path set by the user in the environment # --with-asciidoc: 'yes' user instructs the module to use asciidoc # 'no' user instructs the module not to use asciidoc # # If the user sets the value of ASCIIDOC, AC_PATH_PROG skips testing the path. # AC_DEFUN([XORG_WITH_ASCIIDOC],[ AC_ARG_VAR([ASCIIDOC], [Path to asciidoc command]) m4_define([_defopt], m4_default([$2], [auto])) AC_ARG_WITH(asciidoc, AS_HELP_STRING([--with-asciidoc], [Use asciidoc to regenerate documentation (default: ]_defopt[)]), [use_asciidoc=$withval], [use_asciidoc=]_defopt) m4_undefine([_defopt]) if test "x$use_asciidoc" = x"auto"; then AC_PATH_PROG([ASCIIDOC], [asciidoc]) if test "x$ASCIIDOC" = "x"; then AC_MSG_WARN([asciidoc not found - documentation targets will be skipped]) have_asciidoc=no else have_asciidoc=yes fi elif test "x$use_asciidoc" = x"yes" ; then AC_PATH_PROG([ASCIIDOC], [asciidoc]) if test "x$ASCIIDOC" = "x"; then AC_MSG_ERROR([--with-asciidoc=yes specified but asciidoc not found in PATH]) fi have_asciidoc=yes elif test "x$use_asciidoc" = x"no" ; then if test "x$ASCIIDOC" != "x"; then AC_MSG_WARN([ignoring ASCIIDOC environment variable since --with-asciidoc=no was specified]) fi have_asciidoc=no else AC_MSG_ERROR([--with-asciidoc expects 'yes' or 'no']) fi m4_ifval([$1], [if test "$have_asciidoc" = yes; then # scrape the asciidoc version AC_MSG_CHECKING([the asciidoc version]) asciidoc_version=`$ASCIIDOC --version 2>/dev/null | cut -d' ' -f2` AC_MSG_RESULT([$asciidoc_version]) AS_VERSION_COMPARE([$asciidoc_version], [$1], [if test "x$use_asciidoc" = xauto; then AC_MSG_WARN([asciidoc version $asciidoc_version found, but $1 needed]) have_asciidoc=no else AC_MSG_ERROR([asciidoc version $asciidoc_version found, but $1 needed]) fi]) fi]) AM_CONDITIONAL([HAVE_ASCIIDOC], [test "$have_asciidoc" = yes]) ]) # XORG_WITH_ASCIIDOC # XORG_WITH_DOXYGEN([MIN-VERSION], [DEFAULT]) # -------------------------------- # Minimum version: 1.5.0 # Minimum version for optional DEFAULT argument: 1.11.0 # # Documentation tools are not always available on all platforms and sometimes # not at the appropriate level. This macro enables a module to test for the # presence of the tool and obtain it's path in separate variables. Coupled with # the --with-doxygen option, it allows maximum flexibilty in making decisions # as whether or not to use the doxygen package. When DEFAULT is not specified, # --with-doxygen assumes 'auto'. # # Interface to module: # HAVE_DOXYGEN: used in makefiles to conditionally generate documentation # DOXYGEN: returns the path of the doxygen program found # returns the path set by the user in the environment # --with-doxygen: 'yes' user instructs the module to use doxygen # 'no' user instructs the module not to use doxygen # # If the user sets the value of DOXYGEN, AC_PATH_PROG skips testing the path. # AC_DEFUN([XORG_WITH_DOXYGEN],[ AC_ARG_VAR([DOXYGEN], [Path to doxygen command]) m4_define([_defopt], m4_default([$2], [auto])) AC_ARG_WITH(doxygen, AS_HELP_STRING([--with-doxygen], [Use doxygen to regenerate documentation (default: ]_defopt[)]), [use_doxygen=$withval], [use_doxygen=]_defopt) m4_undefine([_defopt]) if test "x$use_doxygen" = x"auto"; then AC_PATH_PROG([DOXYGEN], [doxygen]) if test "x$DOXYGEN" = "x"; then AC_MSG_WARN([doxygen not found - documentation targets will be skipped]) have_doxygen=no else have_doxygen=yes fi elif test "x$use_doxygen" = x"yes" ; then AC_PATH_PROG([DOXYGEN], [doxygen]) if test "x$DOXYGEN" = "x"; then AC_MSG_ERROR([--with-doxygen=yes specified but doxygen not found in PATH]) fi have_doxygen=yes elif test "x$use_doxygen" = x"no" ; then if test "x$DOXYGEN" != "x"; then AC_MSG_WARN([ignoring DOXYGEN environment variable since --with-doxygen=no was specified]) fi have_doxygen=no else AC_MSG_ERROR([--with-doxygen expects 'yes' or 'no']) fi m4_ifval([$1], [if test "$have_doxygen" = yes; then # scrape the doxygen version AC_MSG_CHECKING([the doxygen version]) doxygen_version=`$DOXYGEN --version 2>/dev/null` AC_MSG_RESULT([$doxygen_version]) AS_VERSION_COMPARE([$doxygen_version], [$1], [if test "x$use_doxygen" = xauto; then AC_MSG_WARN([doxygen version $doxygen_version found, but $1 needed]) have_doxygen=no else AC_MSG_ERROR([doxygen version $doxygen_version found, but $1 needed]) fi]) fi]) AM_CONDITIONAL([HAVE_DOXYGEN], [test "$have_doxygen" = yes]) ]) # XORG_WITH_DOXYGEN # XORG_WITH_GROFF([DEFAULT]) # ---------------- # Minimum version: 1.6.0 # Minimum version for optional DEFAULT argument: 1.11.0 # # Documentation tools are not always available on all platforms and sometimes # not at the appropriate level. This macro enables a module to test for the # presence of the tool and obtain it's path in separate variables. Coupled with # the --with-groff option, it allows maximum flexibilty in making decisions # as whether or not to use the groff package. When DEFAULT is not specified, # --with-groff assumes 'auto'. # # Interface to module: # HAVE_GROFF: used in makefiles to conditionally generate documentation # HAVE_GROFF_MM: the memorandum macros (-mm) package # HAVE_GROFF_MS: the -ms macros package # GROFF: returns the path of the groff program found # returns the path set by the user in the environment # --with-groff: 'yes' user instructs the module to use groff # 'no' user instructs the module not to use groff # # Added in version 1.9.0: # HAVE_GROFF_HTML: groff has dependencies to output HTML format: # pnmcut pnmcrop pnmtopng pnmtops from the netpbm package. # psselect from the psutils package. # the ghostcript package. Refer to the grohtml man pages # # If the user sets the value of GROFF, AC_PATH_PROG skips testing the path. # # OS and distros often splits groff in a basic and full package, the former # having the groff program and the later having devices, fonts and macros # Checking for the groff executable is not enough. # # If macros are missing, we cannot assume that groff is useless, so we don't # unset HAVE_GROFF or GROFF env variables. # HAVE_GROFF_?? can never be true while HAVE_GROFF is false. # AC_DEFUN([XORG_WITH_GROFF],[ AC_ARG_VAR([GROFF], [Path to groff command]) m4_define([_defopt], m4_default([$1], [auto])) AC_ARG_WITH(groff, AS_HELP_STRING([--with-groff], [Use groff to regenerate documentation (default: ]_defopt[)]), [use_groff=$withval], [use_groff=]_defopt) m4_undefine([_defopt]) if test "x$use_groff" = x"auto"; then AC_PATH_PROG([GROFF], [groff]) if test "x$GROFF" = "x"; then AC_MSG_WARN([groff not found - documentation targets will be skipped]) have_groff=no else have_groff=yes fi elif test "x$use_groff" = x"yes" ; then AC_PATH_PROG([GROFF], [groff]) if test "x$GROFF" = "x"; then AC_MSG_ERROR([--with-groff=yes specified but groff not found in PATH]) fi have_groff=yes elif test "x$use_groff" = x"no" ; then if test "x$GROFF" != "x"; then AC_MSG_WARN([ignoring GROFF environment variable since --with-groff=no was specified]) fi have_groff=no else AC_MSG_ERROR([--with-groff expects 'yes' or 'no']) fi # We have groff, test for the presence of the macro packages if test "x$have_groff" = x"yes"; then AC_MSG_CHECKING([for ${GROFF} -ms macros]) if ${GROFF} -ms -I. /dev/null >/dev/null 2>&1 ; then groff_ms_works=yes else groff_ms_works=no fi AC_MSG_RESULT([$groff_ms_works]) AC_MSG_CHECKING([for ${GROFF} -mm macros]) if ${GROFF} -mm -I. /dev/null >/dev/null 2>&1 ; then groff_mm_works=yes else groff_mm_works=no fi AC_MSG_RESULT([$groff_mm_works]) fi # We have groff, test for HTML dependencies, one command per package if test "x$have_groff" = x"yes"; then AC_PATH_PROGS(GS_PATH, [gs gswin32c]) AC_PATH_PROG(PNMTOPNG_PATH, [pnmtopng]) AC_PATH_PROG(PSSELECT_PATH, [psselect]) if test "x$GS_PATH" != "x" -a "x$PNMTOPNG_PATH" != "x" -a "x$PSSELECT_PATH" != "x"; then have_groff_html=yes else have_groff_html=no AC_MSG_WARN([grohtml dependencies not found - HTML Documentation skipped. Refer to grohtml man pages]) fi fi # Set Automake conditionals for Makefiles AM_CONDITIONAL([HAVE_GROFF], [test "$have_groff" = yes]) AM_CONDITIONAL([HAVE_GROFF_MS], [test "$groff_ms_works" = yes]) AM_CONDITIONAL([HAVE_GROFF_MM], [test "$groff_mm_works" = yes]) AM_CONDITIONAL([HAVE_GROFF_HTML], [test "$have_groff_html" = yes]) ]) # XORG_WITH_GROFF # XORG_WITH_FOP([MIN-VERSION], [DEFAULT]) # --------------------------------------- # Minimum version: 1.6.0 # Minimum version for optional DEFAULT argument: 1.11.0 # Minimum version for optional MIN-VERSION argument: 1.15.0 # # Documentation tools are not always available on all platforms and sometimes # not at the appropriate level. This macro enables a module to test for the # presence of the tool and obtain it's path in separate variables. Coupled with # the --with-fop option, it allows maximum flexibilty in making decisions # as whether or not to use the fop package. When DEFAULT is not specified, # --with-fop assumes 'auto'. # # Interface to module: # HAVE_FOP: used in makefiles to conditionally generate documentation # FOP: returns the path of the fop program found # returns the path set by the user in the environment # --with-fop: 'yes' user instructs the module to use fop # 'no' user instructs the module not to use fop # # If the user sets the value of FOP, AC_PATH_PROG skips testing the path. # AC_DEFUN([XORG_WITH_FOP],[ AC_ARG_VAR([FOP], [Path to fop command]) m4_define([_defopt], m4_default([$2], [auto])) AC_ARG_WITH(fop, AS_HELP_STRING([--with-fop], [Use fop to regenerate documentation (default: ]_defopt[)]), [use_fop=$withval], [use_fop=]_defopt) m4_undefine([_defopt]) if test "x$use_fop" = x"auto"; then AC_PATH_PROG([FOP], [fop]) if test "x$FOP" = "x"; then AC_MSG_WARN([fop not found - documentation targets will be skipped]) have_fop=no else have_fop=yes fi elif test "x$use_fop" = x"yes" ; then AC_PATH_PROG([FOP], [fop]) if test "x$FOP" = "x"; then AC_MSG_ERROR([--with-fop=yes specified but fop not found in PATH]) fi have_fop=yes elif test "x$use_fop" = x"no" ; then if test "x$FOP" != "x"; then AC_MSG_WARN([ignoring FOP environment variable since --with-fop=no was specified]) fi have_fop=no else AC_MSG_ERROR([--with-fop expects 'yes' or 'no']) fi # Test for a minimum version of fop, if provided. m4_ifval([$1], [if test "$have_fop" = yes; then # scrape the fop version AC_MSG_CHECKING([for fop minimum version]) fop_version=`$FOP -version 2>/dev/null | cut -d' ' -f3` AC_MSG_RESULT([$fop_version]) AS_VERSION_COMPARE([$fop_version], [$1], [if test "x$use_fop" = xauto; then AC_MSG_WARN([fop version $fop_version found, but $1 needed]) have_fop=no else AC_MSG_ERROR([fop version $fop_version found, but $1 needed]) fi]) fi]) AM_CONDITIONAL([HAVE_FOP], [test "$have_fop" = yes]) ]) # XORG_WITH_FOP # XORG_WITH_PS2PDF([DEFAULT]) # ---------------- # Minimum version: 1.6.0 # Minimum version for optional DEFAULT argument: 1.11.0 # # Documentation tools are not always available on all platforms and sometimes # not at the appropriate level. This macro enables a module to test for the # presence of the tool and obtain it's path in separate variables. Coupled with # the --with-ps2pdf option, it allows maximum flexibilty in making decisions # as whether or not to use the ps2pdf package. When DEFAULT is not specified, # --with-ps2pdf assumes 'auto'. # # Interface to module: # HAVE_PS2PDF: used in makefiles to conditionally generate documentation # PS2PDF: returns the path of the ps2pdf program found # returns the path set by the user in the environment # --with-ps2pdf: 'yes' user instructs the module to use ps2pdf # 'no' user instructs the module not to use ps2pdf # # If the user sets the value of PS2PDF, AC_PATH_PROG skips testing the path. # AC_DEFUN([XORG_WITH_PS2PDF],[ AC_ARG_VAR([PS2PDF], [Path to ps2pdf command]) m4_define([_defopt], m4_default([$1], [auto])) AC_ARG_WITH(ps2pdf, AS_HELP_STRING([--with-ps2pdf], [Use ps2pdf to regenerate documentation (default: ]_defopt[)]), [use_ps2pdf=$withval], [use_ps2pdf=]_defopt) m4_undefine([_defopt]) if test "x$use_ps2pdf" = x"auto"; then AC_PATH_PROG([PS2PDF], [ps2pdf]) if test "x$PS2PDF" = "x"; then AC_MSG_WARN([ps2pdf not found - documentation targets will be skipped]) have_ps2pdf=no else have_ps2pdf=yes fi elif test "x$use_ps2pdf" = x"yes" ; then AC_PATH_PROG([PS2PDF], [ps2pdf]) if test "x$PS2PDF" = "x"; then AC_MSG_ERROR([--with-ps2pdf=yes specified but ps2pdf not found in PATH]) fi have_ps2pdf=yes elif test "x$use_ps2pdf" = x"no" ; then if test "x$PS2PDF" != "x"; then AC_MSG_WARN([ignoring PS2PDF environment variable since --with-ps2pdf=no was specified]) fi have_ps2pdf=no else AC_MSG_ERROR([--with-ps2pdf expects 'yes' or 'no']) fi AM_CONDITIONAL([HAVE_PS2PDF], [test "$have_ps2pdf" = yes]) ]) # XORG_WITH_PS2PDF # XORG_ENABLE_DOCS (enable_docs=yes) # ---------------- # Minimum version: 1.6.0 # # Documentation tools are not always available on all platforms and sometimes # not at the appropriate level. This macro enables a builder to skip all # documentation targets except traditional man pages. # Combined with the specific tool checking macros XORG_WITH_*, it provides # maximum flexibilty in controlling documentation building. # Refer to: # XORG_WITH_XMLTO --with-xmlto # XORG_WITH_ASCIIDOC --with-asciidoc # XORG_WITH_DOXYGEN --with-doxygen # XORG_WITH_FOP --with-fop # XORG_WITH_GROFF --with-groff # XORG_WITH_PS2PDF --with-ps2pdf # # Interface to module: # ENABLE_DOCS: used in makefiles to conditionally generate documentation # --enable-docs: 'yes' user instructs the module to generate docs # 'no' user instructs the module not to generate docs # parm1: specify the default value, yes or no. # AC_DEFUN([XORG_ENABLE_DOCS],[ m4_define([docs_default], m4_default([$1], [yes])) AC_ARG_ENABLE(docs, AS_HELP_STRING([--enable-docs], [Enable building the documentation (default: ]docs_default[)]), [build_docs=$enableval], [build_docs=]docs_default) m4_undefine([docs_default]) AM_CONDITIONAL(ENABLE_DOCS, [test x$build_docs = xyes]) AC_MSG_CHECKING([whether to build documentation]) AC_MSG_RESULT([$build_docs]) ]) # XORG_ENABLE_DOCS # XORG_ENABLE_DEVEL_DOCS (enable_devel_docs=yes) # ---------------- # Minimum version: 1.6.0 # # This macro enables a builder to skip all developer documentation. # Combined with the specific tool checking macros XORG_WITH_*, it provides # maximum flexibilty in controlling documentation building. # Refer to: # XORG_WITH_XMLTO --with-xmlto # XORG_WITH_ASCIIDOC --with-asciidoc # XORG_WITH_DOXYGEN --with-doxygen # XORG_WITH_FOP --with-fop # XORG_WITH_GROFF --with-groff # XORG_WITH_PS2PDF --with-ps2pdf # # Interface to module: # ENABLE_DEVEL_DOCS: used in makefiles to conditionally generate developer docs # --enable-devel-docs: 'yes' user instructs the module to generate developer docs # 'no' user instructs the module not to generate developer docs # parm1: specify the default value, yes or no. # AC_DEFUN([XORG_ENABLE_DEVEL_DOCS],[ m4_define([devel_default], m4_default([$1], [yes])) AC_ARG_ENABLE(devel-docs, AS_HELP_STRING([--enable-devel-docs], [Enable building the developer documentation (default: ]devel_default[)]), [build_devel_docs=$enableval], [build_devel_docs=]devel_default) m4_undefine([devel_default]) AM_CONDITIONAL(ENABLE_DEVEL_DOCS, [test x$build_devel_docs = xyes]) AC_MSG_CHECKING([whether to build developer documentation]) AC_MSG_RESULT([$build_devel_docs]) ]) # XORG_ENABLE_DEVEL_DOCS # XORG_ENABLE_SPECS (enable_specs=yes) # ---------------- # Minimum version: 1.6.0 # # This macro enables a builder to skip all functional specification targets. # Combined with the specific tool checking macros XORG_WITH_*, it provides # maximum flexibilty in controlling documentation building. # Refer to: # XORG_WITH_XMLTO --with-xmlto # XORG_WITH_ASCIIDOC --with-asciidoc # XORG_WITH_DOXYGEN --with-doxygen # XORG_WITH_FOP --with-fop # XORG_WITH_GROFF --with-groff # XORG_WITH_PS2PDF --with-ps2pdf # # Interface to module: # ENABLE_SPECS: used in makefiles to conditionally generate specs # --enable-specs: 'yes' user instructs the module to generate specs # 'no' user instructs the module not to generate specs # parm1: specify the default value, yes or no. # AC_DEFUN([XORG_ENABLE_SPECS],[ m4_define([spec_default], m4_default([$1], [yes])) AC_ARG_ENABLE(specs, AS_HELP_STRING([--enable-specs], [Enable building the specs (default: ]spec_default[)]), [build_specs=$enableval], [build_specs=]spec_default) m4_undefine([spec_default]) AM_CONDITIONAL(ENABLE_SPECS, [test x$build_specs = xyes]) AC_MSG_CHECKING([whether to build functional specifications]) AC_MSG_RESULT([$build_specs]) ]) # XORG_ENABLE_SPECS # XORG_ENABLE_UNIT_TESTS (enable_unit_tests=auto) # ---------------------------------------------- # Minimum version: 1.13.0 # # This macro enables a builder to enable/disable unit testing # It makes no assumption about the test cases implementation # Test cases may or may not use Automake "Support for test suites" # They may or may not use the software utility library GLib # # When used in conjunction with XORG_WITH_GLIB, use both AM_CONDITIONAL # ENABLE_UNIT_TESTS and HAVE_GLIB. Not all unit tests may use glib. # The variable enable_unit_tests is used by other macros in this file. # # Interface to module: # ENABLE_UNIT_TESTS: used in makefiles to conditionally build tests # enable_unit_tests: used in configure.ac for additional configuration # --enable-unit-tests: 'yes' user instructs the module to build tests # 'no' user instructs the module not to build tests # parm1: specify the default value, yes or no. # AC_DEFUN([XORG_ENABLE_UNIT_TESTS],[ AC_BEFORE([$0], [XORG_WITH_GLIB]) AC_BEFORE([$0], [XORG_LD_WRAP]) AC_REQUIRE([XORG_MEMORY_CHECK_FLAGS]) m4_define([_defopt], m4_default([$1], [auto])) AC_ARG_ENABLE(unit-tests, AS_HELP_STRING([--enable-unit-tests], [Enable building unit test cases (default: ]_defopt[)]), [enable_unit_tests=$enableval], [enable_unit_tests=]_defopt) m4_undefine([_defopt]) AM_CONDITIONAL(ENABLE_UNIT_TESTS, [test "x$enable_unit_tests" != xno]) AC_MSG_CHECKING([whether to build unit test cases]) AC_MSG_RESULT([$enable_unit_tests]) ]) # XORG_ENABLE_UNIT_TESTS # XORG_ENABLE_INTEGRATION_TESTS (enable_unit_tests=auto) # ------------------------------------------------------ # Minimum version: 1.17.0 # # This macro enables a builder to enable/disable integration testing # It makes no assumption about the test cases' implementation # Test cases may or may not use Automake "Support for test suites" # # Please see XORG_ENABLE_UNIT_TESTS for unit test support. Unit test support # usually requires less dependencies and may be built and run under less # stringent environments than integration tests. # # Interface to module: # ENABLE_INTEGRATION_TESTS: used in makefiles to conditionally build tests # enable_integration_tests: used in configure.ac for additional configuration # --enable-integration-tests: 'yes' user instructs the module to build tests # 'no' user instructs the module not to build tests # parm1: specify the default value, yes or no. # AC_DEFUN([XORG_ENABLE_INTEGRATION_TESTS],[ AC_REQUIRE([XORG_MEMORY_CHECK_FLAGS]) m4_define([_defopt], m4_default([$1], [auto])) AC_ARG_ENABLE(integration-tests, AS_HELP_STRING([--enable-integration-tests], [Enable building integration test cases (default: ]_defopt[)]), [enable_integration_tests=$enableval], [enable_integration_tests=]_defopt) m4_undefine([_defopt]) AM_CONDITIONAL([ENABLE_INTEGRATION_TESTS], [test "x$enable_integration_tests" != xno]) AC_MSG_CHECKING([whether to build unit test cases]) AC_MSG_RESULT([$enable_integration_tests]) ]) # XORG_ENABLE_INTEGRATION_TESTS # XORG_WITH_GLIB([MIN-VERSION], [DEFAULT]) # ---------------------------------------- # Minimum version: 1.13.0 # # GLib is a library which provides advanced data structures and functions. # This macro enables a module to test for the presence of Glib. # # When used with ENABLE_UNIT_TESTS, it is assumed GLib is used for unit testing. # Otherwise the value of $enable_unit_tests is blank. # # Please see XORG_ENABLE_INTEGRATION_TESTS for integration test support. Unit # test support usually requires less dependencies and may be built and run under # less stringent environments than integration tests. # # Interface to module: # HAVE_GLIB: used in makefiles to conditionally build targets # with_glib: used in configure.ac to know if GLib has been found # --with-glib: 'yes' user instructs the module to use glib # 'no' user instructs the module not to use glib # AC_DEFUN([XORG_WITH_GLIB],[ AC_REQUIRE([PKG_PROG_PKG_CONFIG]) m4_define([_defopt], m4_default([$2], [auto])) AC_ARG_WITH(glib, AS_HELP_STRING([--with-glib], [Use GLib library for unit testing (default: ]_defopt[)]), [with_glib=$withval], [with_glib=]_defopt) m4_undefine([_defopt]) have_glib=no # Do not probe GLib if user explicitly disabled unit testing if test "x$enable_unit_tests" != x"no"; then # Do not probe GLib if user explicitly disabled it if test "x$with_glib" != x"no"; then m4_ifval( [$1], [PKG_CHECK_MODULES([GLIB], [glib-2.0 >= $1], [have_glib=yes], [have_glib=no])], [PKG_CHECK_MODULES([GLIB], [glib-2.0], [have_glib=yes], [have_glib=no])] ) fi fi # Not having GLib when unit testing has been explicitly requested is an error if test "x$enable_unit_tests" = x"yes"; then if test "x$have_glib" = x"no"; then AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found]) fi fi # Having unit testing disabled when GLib has been explicitly requested is an error if test "x$enable_unit_tests" = x"no"; then if test "x$with_glib" = x"yes"; then AC_MSG_ERROR([--enable-unit-tests=yes specified but glib-2.0 not found]) fi fi # Not having GLib when it has been explicitly requested is an error if test "x$with_glib" = x"yes"; then if test "x$have_glib" = x"no"; then AC_MSG_ERROR([--with-glib=yes specified but glib-2.0 not found]) fi fi AM_CONDITIONAL([HAVE_GLIB], [test "$have_glib" = yes]) ]) # XORG_WITH_GLIB # XORG_LD_WRAP([required|optional]) # --------------------------------- # Minimum version: 1.13.0 # # Check if linker supports -wrap, passed via compiler flags # # When used with ENABLE_UNIT_TESTS, it is assumed -wrap is used for unit testing. # Otherwise the value of $enable_unit_tests is blank. # # Argument added in 1.16.0 - default is "required", to match existing behavior # of returning an error if enable_unit_tests is yes, and ld -wrap is not # available, an argument of "optional" allows use when some unit tests require # ld -wrap and others do not. # AC_DEFUN([XORG_LD_WRAP],[ XORG_CHECK_LINKER_FLAGS([-Wl,-wrap,exit],[have_ld_wrap=yes],[have_ld_wrap=no], [AC_LANG_PROGRAM([#include void __wrap_exit(int status) { return; }], [exit(0);])]) # Not having ld wrap when unit testing has been explicitly requested is an error if test "x$enable_unit_tests" = x"yes" -a "x$1" != "xoptional"; then if test "x$have_ld_wrap" = x"no"; then AC_MSG_ERROR([--enable-unit-tests=yes specified but ld -wrap support is not available]) fi fi AM_CONDITIONAL([HAVE_LD_WRAP], [test "$have_ld_wrap" = yes]) # ]) # XORG_LD_WRAP # XORG_CHECK_LINKER_FLAGS # ----------------------- # SYNOPSIS # # XORG_CHECK_LINKER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE], [PROGRAM-SOURCE]) # # DESCRIPTION # # Check whether the given linker FLAGS work with the current language's # linker, or whether they give an error. # # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on # success/failure. # # PROGRAM-SOURCE is the program source to link with, if needed # # NOTE: Based on AX_CHECK_COMPILER_FLAGS. # # LICENSE # # Copyright (c) 2009 Mike Frysinger # Copyright (c) 2009 Steven G. Johnson # Copyright (c) 2009 Matteo Frigo # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see . # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well.# AC_DEFUN([XORG_CHECK_LINKER_FLAGS], [AC_MSG_CHECKING([whether the linker accepts $1]) dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname: AS_LITERAL_IF([$1], [AC_CACHE_VAL(AS_TR_SH(xorg_cv_linker_flags_[$1]), [ ax_save_FLAGS=$LDFLAGS LDFLAGS="$1" AC_LINK_IFELSE([m4_default([$4],[AC_LANG_PROGRAM()])], AS_TR_SH(xorg_cv_linker_flags_[$1])=yes, AS_TR_SH(xorg_cv_linker_flags_[$1])=no) LDFLAGS=$ax_save_FLAGS])], [ax_save_FLAGS=$LDFLAGS LDFLAGS="$1" AC_LINK_IFELSE([AC_LANG_PROGRAM()], eval AS_TR_SH(xorg_cv_linker_flags_[$1])=yes, eval AS_TR_SH(xorg_cv_linker_flags_[$1])=no) LDFLAGS=$ax_save_FLAGS]) eval xorg_check_linker_flags=$AS_TR_SH(xorg_cv_linker_flags_[$1]) AC_MSG_RESULT($xorg_check_linker_flags) if test "x$xorg_check_linker_flags" = xyes; then m4_default([$2], :) else m4_default([$3], :) fi ]) # XORG_CHECK_LINKER_FLAGS # XORG_MEMORY_CHECK_FLAGS # ----------------------- # Minimum version: 1.16.0 # # This macro attempts to find appropriate memory checking functionality # for various platforms which unit testing code may use to catch various # forms of memory allocation and access errors in testing. # # Interface to module: # XORG_MALLOC_DEBUG_ENV - environment variables to set to enable debugging # Usually added to TESTS_ENVIRONMENT in Makefile.am # # If the user sets the value of XORG_MALLOC_DEBUG_ENV, it is used verbatim. # AC_DEFUN([XORG_MEMORY_CHECK_FLAGS],[ AC_REQUIRE([AC_CANONICAL_HOST]) AC_ARG_VAR([XORG_MALLOC_DEBUG_ENV], [Environment variables to enable memory checking in tests]) # Check for different types of support on different platforms case $host_os in solaris*) AC_CHECK_LIB([umem], [umem_alloc], [malloc_debug_env='LD_PRELOAD=libumem.so UMEM_DEBUG=default']) ;; *-gnu*) # GNU libc - Value is used as a single byte bit pattern, # both directly and inverted, so should not be 0 or 255. malloc_debug_env='MALLOC_PERTURB_=15' ;; darwin*) malloc_debug_env='MallocPreScribble=1 MallocScribble=1 DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib' ;; *bsd*) malloc_debug_env='MallocPreScribble=1 MallocScribble=1' ;; esac # User supplied flags override default flags if test "x$XORG_MALLOC_DEBUG_ENV" != "x"; then malloc_debug_env="$XORG_MALLOC_DEBUG_ENV" fi AC_SUBST([XORG_MALLOC_DEBUG_ENV],[$malloc_debug_env]) ]) # XORG_WITH_LINT # XORG_CHECK_MALLOC_ZERO # ---------------------- # Minimum version: 1.0.0 # # Defines {MALLOC,XMALLOC,XTMALLOC}_ZERO_CFLAGS appropriately if # malloc(0) returns NULL. Packages should add one of these cflags to # their AM_CFLAGS (or other appropriate *_CFLAGS) to use them. AC_DEFUN([XORG_CHECK_MALLOC_ZERO],[ AC_ARG_ENABLE(malloc0returnsnull, AS_HELP_STRING([--enable-malloc0returnsnull], [malloc(0) returns NULL (default: auto)]), [MALLOC_ZERO_RETURNS_NULL=$enableval], [MALLOC_ZERO_RETURNS_NULL=auto]) AC_MSG_CHECKING([whether malloc(0) returns NULL]) if test "x$MALLOC_ZERO_RETURNS_NULL" = xauto; then AC_RUN_IFELSE([AC_LANG_PROGRAM([ #include ],[ char *m0, *r0, *c0, *p; m0 = malloc(0); p = malloc(10); r0 = realloc(p,0); c0 = calloc(0,10); exit((m0 == 0 || r0 == 0 || c0 == 0) ? 0 : 1); ])], [MALLOC_ZERO_RETURNS_NULL=yes], [MALLOC_ZERO_RETURNS_NULL=no], [MALLOC_ZERO_RETURNS_NULL=yes]) fi AC_MSG_RESULT([$MALLOC_ZERO_RETURNS_NULL]) if test "x$MALLOC_ZERO_RETURNS_NULL" = xyes; then MALLOC_ZERO_CFLAGS="-DMALLOC_0_RETURNS_NULL" XMALLOC_ZERO_CFLAGS=$MALLOC_ZERO_CFLAGS XTMALLOC_ZERO_CFLAGS="$MALLOC_ZERO_CFLAGS -DXTMALLOC_BC" else MALLOC_ZERO_CFLAGS="" XMALLOC_ZERO_CFLAGS="" XTMALLOC_ZERO_CFLAGS="" fi AC_SUBST([MALLOC_ZERO_CFLAGS]) AC_SUBST([XMALLOC_ZERO_CFLAGS]) AC_SUBST([XTMALLOC_ZERO_CFLAGS]) ]) # XORG_CHECK_MALLOC_ZERO # XORG_WITH_LINT() # ---------------- # Minimum version: 1.1.0 # # This macro enables the use of a tool that flags some suspicious and # non-portable constructs (likely to be bugs) in C language source code. # It will attempt to locate the tool and use appropriate options. # There are various lint type tools on different platforms. # # Interface to module: # LINT: returns the path to the tool found on the platform # or the value set to LINT on the configure cmd line # also an Automake conditional # LINT_FLAGS: an Automake variable with appropriate flags # # --with-lint: 'yes' user instructs the module to use lint # 'no' user instructs the module not to use lint (default) # # If the user sets the value of LINT, AC_PATH_PROG skips testing the path. # If the user sets the value of LINT_FLAGS, they are used verbatim. # AC_DEFUN([XORG_WITH_LINT],[ AC_ARG_VAR([LINT], [Path to a lint-style command]) AC_ARG_VAR([LINT_FLAGS], [Flags for the lint-style command]) AC_ARG_WITH(lint, [AS_HELP_STRING([--with-lint], [Use a lint-style source code checker (default: disabled)])], [use_lint=$withval], [use_lint=no]) # Obtain platform specific info like program name and options # The lint program on FreeBSD and NetBSD is different from the one on Solaris case $host_os in *linux* | *openbsd* | kfreebsd*-gnu | darwin* | cygwin*) lint_name=splint lint_options="-badflag" ;; *freebsd* | *netbsd*) lint_name=lint lint_options="-u -b" ;; *solaris*) lint_name=lint lint_options="-u -b -h -erroff=E_INDISTING_FROM_TRUNC2" ;; esac # Test for the presence of the program (either guessed by the code or spelled out by the user) if test "x$use_lint" = x"yes" ; then AC_PATH_PROG([LINT], [$lint_name]) if test "x$LINT" = "x"; then AC_MSG_ERROR([--with-lint=yes specified but lint-style tool not found in PATH]) fi elif test "x$use_lint" = x"no" ; then if test "x$LINT" != "x"; then AC_MSG_WARN([ignoring LINT environment variable since --with-lint=no was specified]) fi else AC_MSG_ERROR([--with-lint expects 'yes' or 'no'. Use LINT variable to specify path.]) fi # User supplied flags override default flags if test "x$LINT_FLAGS" != "x"; then lint_options=$LINT_FLAGS fi AC_SUBST([LINT_FLAGS],[$lint_options]) AM_CONDITIONAL(LINT, [test "x$LINT" != x]) ]) # XORG_WITH_LINT # XORG_LINT_LIBRARY(LIBNAME) # -------------------------- # Minimum version: 1.1.0 # # Sets up flags for building lint libraries for checking programs that call # functions in the library. # # Interface to module: # LINTLIB - Automake variable with the name of lint library file to make # MAKE_LINT_LIB - Automake conditional # # --enable-lint-library: - 'yes' user instructs the module to created a lint library # - 'no' user instructs the module not to create a lint library (default) AC_DEFUN([XORG_LINT_LIBRARY],[ AC_REQUIRE([XORG_WITH_LINT]) AC_ARG_ENABLE(lint-library, [AS_HELP_STRING([--enable-lint-library], [Create lint library (default: disabled)])], [make_lint_lib=$enableval], [make_lint_lib=no]) if test "x$make_lint_lib" = x"yes" ; then LINTLIB=llib-l$1.ln if test "x$LINT" = "x"; then AC_MSG_ERROR([Cannot make lint library without --with-lint]) fi elif test "x$make_lint_lib" != x"no" ; then AC_MSG_ERROR([--enable-lint-library expects 'yes' or 'no'.]) fi AC_SUBST(LINTLIB) AM_CONDITIONAL(MAKE_LINT_LIB, [test x$make_lint_lib != xno]) ]) # XORG_LINT_LIBRARY # XORG_COMPILER_BRAND # ------------------- # Minimum version: 1.14.0 # # Checks for various brands of compilers and sets flags as appropriate: # GNU gcc - relies on AC_PROG_CC (via AC_PROG_CC_C99) to set GCC to "yes" # GNU g++ - relies on AC_PROG_CXX to set GXX to "yes" # clang compiler - sets CLANGCC to "yes" # Intel compiler - sets INTELCC to "yes" # Sun/Oracle Solaris Studio cc - sets SUNCC to "yes" # AC_DEFUN([XORG_COMPILER_BRAND], [ AC_LANG_CASE( [C], [ AC_REQUIRE([AC_PROG_CC_C99]) ], [C++], [ AC_REQUIRE([AC_PROG_CXX]) ] ) AC_CHECK_DECL([__clang__], [CLANGCC="yes"], [CLANGCC="no"]) AC_CHECK_DECL([__INTEL_COMPILER], [INTELCC="yes"], [INTELCC="no"]) AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"]) ]) # XORG_COMPILER_BRAND # XORG_TESTSET_CFLAG(, , [, ...]) # --------------- # Minimum version: 1.16.0 # # Test if the compiler works when passed the given flag as a command line argument. # If it succeeds, the flag is appeneded to the given variable. If not, it tries the # next flag in the list until there are no more options. # # Note that this does not guarantee that the compiler supports the flag as some # compilers will simply ignore arguments that they do not understand, but we do # attempt to weed out false positives by using -Werror=unknown-warning-option and # -Werror=unused-command-line-argument # AC_DEFUN([XORG_TESTSET_CFLAG], [ m4_if([$#], 0, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])]) m4_if([$#], 1, [m4_fatal([XORG_TESTSET_CFLAG was given with an unsupported number of arguments])]) AC_LANG_COMPILER_REQUIRE AC_LANG_CASE( [C], [ AC_REQUIRE([AC_PROG_CC_C99]) define([PREFIX], [C]) define([CACHE_PREFIX], [cc]) define([COMPILER], [$CC]) ], [C++], [ define([PREFIX], [CXX]) define([CACHE_PREFIX], [cxx]) define([COMPILER], [$CXX]) ] ) [xorg_testset_save_]PREFIX[FLAGS]="$PREFIX[FLAGS]" if test "x$[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]" = "x" ; then PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option" AC_CACHE_CHECK([if ]COMPILER[ supports -Werror=unknown-warning-option], [xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option], AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])], [xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option=yes], [xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option=no])) [xorg_testset_]CACHE_PREFIX[_unknown_warning_option]=$[xorg_cv_]CACHE_PREFIX[_flag_unknown_warning_option] PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]" fi if test "x$[xorg_testset_]CACHE_PREFIX[_unused_command_line_argument]" = "x" ; then if test "x$[xorg_testset_]CACHE_PREFIX[_unknown_warning_option]" = "xyes" ; then PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option" fi PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument" AC_CACHE_CHECK([if ]COMPILER[ supports -Werror=unused-command-line-argument], [xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument], AC_COMPILE_IFELSE([AC_LANG_SOURCE([int i;])], [xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument=yes], [xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument=no])) [xorg_testset_]CACHE_PREFIX[_unused_command_line_argument]=$[xorg_cv_]CACHE_PREFIX[_flag_unused_command_line_argument] PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]" fi found="no" m4_foreach([flag], m4_cdr($@), [ if test $found = "no" ; then if test "x$xorg_testset_unknown_warning_option" = "xyes" ; then PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unknown-warning-option" fi if test "x$xorg_testset_unused_command_line_argument" = "xyes" ; then PREFIX[FLAGS]="$PREFIX[FLAGS] -Werror=unused-command-line-argument" fi PREFIX[FLAGS]="$PREFIX[FLAGS] ]flag[" dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname AC_MSG_CHECKING([if ]COMPILER[ supports]flag[]) cacheid=AS_TR_SH([xorg_cv_]CACHE_PREFIX[_flag_]flag[]) AC_CACHE_VAL($cacheid, [AC_LINK_IFELSE([AC_LANG_PROGRAM([int i;])], [eval $cacheid=yes], [eval $cacheid=no])]) PREFIX[FLAGS]="$[xorg_testset_save_]PREFIX[FLAGS]" eval supported=\$$cacheid AC_MSG_RESULT([$supported]) if test "$supported" = "yes" ; then $1="$$1 ]flag[" found="yes" fi fi ]) ]) # XORG_TESTSET_CFLAG # XORG_COMPILER_FLAGS # --------------- # Minimum version: 1.16.0 # # Defines BASE_CFLAGS or BASE_CXXFLAGS to contain a set of command line # arguments supported by the selected compiler which do NOT alter the generated # code. These arguments will cause the compiler to print various warnings # during compilation AND turn a conservative set of warnings into errors. # # The set of flags supported by BASE_CFLAGS and BASE_CXXFLAGS will grow in # future versions of util-macros as options are added to new compilers. # AC_DEFUN([XORG_COMPILER_FLAGS], [ AC_REQUIRE([XORG_COMPILER_BRAND]) AC_ARG_ENABLE(selective-werror, AS_HELP_STRING([--disable-selective-werror], [Turn off selective compiler errors. (default: enabled)]), [SELECTIVE_WERROR=$enableval], [SELECTIVE_WERROR=yes]) AC_LANG_CASE( [C], [ define([PREFIX], [C]) ], [C++], [ define([PREFIX], [CXX]) ] ) # -v is too short to test reliably with XORG_TESTSET_CFLAG if test "x$SUNCC" = "xyes"; then [BASE_]PREFIX[FLAGS]="-v" else [BASE_]PREFIX[FLAGS]="" fi # This chunk of warnings were those that existed in the legacy CWARNFLAGS XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wall]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-arith]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-declarations]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wformat=2], [-Wformat]) AC_LANG_CASE( [C], [ XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wstrict-prototypes]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-prototypes]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnested-externs]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wbad-function-cast]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wold-style-definition]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wdeclaration-after-statement]) ] ) # This chunk adds additional warnings that could catch undesired effects. XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wunused]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wuninitialized]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wshadow]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-qual]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-noreturn]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-format-attribute]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wredundant-decls]) # These are currently disabled because they are noisy. They will be enabled # in the future once the codebase is sufficiently modernized to silence # them. For now, I don't want them to drown out the other warnings. # XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wlogical-op]) # XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wparentheses]) # XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wcast-align]) # Turn some warnings into errors, so we don't accidently get successful builds # when there are problems that should be fixed. if test "x$SELECTIVE_WERROR" = "xyes" ; then XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=implicit], [-errwarn=E_NO_EXPLICIT_TYPE_GIVEN -errwarn=E_NO_IMPLICIT_DECL_ALLOWED]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=nonnull]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=init-self]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=main]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=missing-braces]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=sequence-point]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=return-type], [-errwarn=E_FUNC_HAS_NO_RETURN_STMT]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=trigraphs]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=array-bounds]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=write-strings]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=address]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=int-to-pointer-cast], [-errwarn=E_BAD_PTR_INT_COMBINATION]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Werror=pointer-to-int-cast]) # Also -errwarn=E_BAD_PTR_INT_COMBINATION else AC_MSG_WARN([You have chosen not to turn some select compiler warnings into errors. This should not be necessary. Please report why you needed to do so in a bug report at $PACKAGE_BUGREPORT]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wimplicit]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wnonnull]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Winit-self]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmain]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wmissing-braces]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wsequence-point]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wreturn-type]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wtrigraphs]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Warray-bounds]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wwrite-strings]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Waddress]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wint-to-pointer-cast]) XORG_TESTSET_CFLAG([[BASE_]PREFIX[FLAGS]], [-Wpointer-to-int-cast]) fi AC_SUBST([BASE_]PREFIX[FLAGS]) ]) # XORG_COMPILER_FLAGS # XORG_CWARNFLAGS # --------------- # Minimum version: 1.2.0 # Deprecated since: 1.16.0 (Use XORG_COMPILER_FLAGS instead) # # Defines CWARNFLAGS to enable C compiler warnings. # # This function is deprecated because it defines -fno-strict-aliasing # which alters the code generated by the compiler. If -fno-strict-aliasing # is needed, then it should be added explicitly in the module when # it is updated to use BASE_CFLAGS. # AC_DEFUN([XORG_CWARNFLAGS], [ AC_REQUIRE([XORG_COMPILER_FLAGS]) AC_REQUIRE([XORG_COMPILER_BRAND]) AC_LANG_CASE( [C], [ CWARNFLAGS="$BASE_CFLAGS" if test "x$GCC" = xyes ; then CWARNFLAGS="$CWARNFLAGS -fno-strict-aliasing" fi AC_SUBST(CWARNFLAGS) ] ) ]) # XORG_CWARNFLAGS # XORG_STRICT_OPTION # ----------------------- # Minimum version: 1.3.0 # # Add configure option to enable strict compilation flags, such as treating # warnings as fatal errors. # If --enable-strict-compilation is passed to configure, adds strict flags to # $BASE_CFLAGS or $BASE_CXXFLAGS and the deprecated $CWARNFLAGS. # # Starting in 1.14.0 also exports $STRICT_CFLAGS for use in other tests or # when strict compilation is unconditionally desired. AC_DEFUN([XORG_STRICT_OPTION], [ AC_REQUIRE([XORG_CWARNFLAGS]) AC_REQUIRE([XORG_COMPILER_FLAGS]) AC_ARG_ENABLE(strict-compilation, AS_HELP_STRING([--enable-strict-compilation], [Enable all warnings from compiler and make them errors (default: disabled)]), [STRICT_COMPILE=$enableval], [STRICT_COMPILE=no]) AC_LANG_CASE( [C], [ define([PREFIX], [C]) ], [C++], [ define([PREFIX], [CXX]) ] ) [STRICT_]PREFIX[FLAGS]="" XORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-pedantic]) XORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror], [-errwarn]) # Earlier versions of gcc (eg: 4.2) support -Werror=attributes, but do not # activate it with -Werror, so we add it here explicitly. XORG_TESTSET_CFLAG([[STRICT_]PREFIX[FLAGS]], [-Werror=attributes]) if test "x$STRICT_COMPILE" = "xyes"; then [BASE_]PREFIX[FLAGS]="$[BASE_]PREFIX[FLAGS] $[STRICT_]PREFIX[FLAGS]" AC_LANG_CASE([C], [CWARNFLAGS="$CWARNFLAGS $STRICT_CFLAGS"]) fi AC_SUBST([STRICT_]PREFIX[FLAGS]) AC_SUBST([BASE_]PREFIX[FLAGS]) AC_LANG_CASE([C], AC_SUBST([CWARNFLAGS])) ]) # XORG_STRICT_OPTION # XORG_DEFAULT_OPTIONS # -------------------- # Minimum version: 1.3.0 # # Defines default options for X.Org modules. # AC_DEFUN([XORG_DEFAULT_OPTIONS], [ AC_REQUIRE([AC_PROG_INSTALL]) XORG_COMPILER_FLAGS XORG_CWARNFLAGS XORG_STRICT_OPTION XORG_RELEASE_VERSION XORG_CHANGELOG XORG_INSTALL XORG_MANPAGE_SECTIONS m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])]) ]) # XORG_DEFAULT_OPTIONS # XORG_INSTALL() # ---------------- # Minimum version: 1.4.0 # # Defines the variable INSTALL_CMD as the command to copy # INSTALL from $prefix/share/util-macros. # AC_DEFUN([XORG_INSTALL], [ AC_REQUIRE([PKG_PROG_PKG_CONFIG]) macros_datadir=`$PKG_CONFIG --print-errors --variable=pkgdatadir xorg-macros` INSTALL_CMD="(cp -f "$macros_datadir/INSTALL" \$(top_srcdir)/.INSTALL.tmp && \ mv \$(top_srcdir)/.INSTALL.tmp \$(top_srcdir)/INSTALL) \ || (rm -f \$(top_srcdir)/.INSTALL.tmp; touch \$(top_srcdir)/INSTALL; \ echo 'util-macros \"pkgdatadir\" from xorg-macros.pc not found: installing possibly empty INSTALL.' >&2)" AC_SUBST([INSTALL_CMD]) ]) # XORG_INSTALL dnl Copyright 2005 Red Hat, Inc dnl dnl Permission to use, copy, modify, distribute, and sell this software and its dnl documentation for any purpose is hereby granted without fee, provided that dnl the above copyright notice appear in all copies and that both that dnl copyright notice and this permission notice appear in supporting dnl documentation. dnl dnl The above copyright notice and this permission notice shall be included dnl in all copies or substantial portions of the Software. dnl dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS dnl OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF dnl MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. dnl IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR dnl OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, dnl ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR dnl OTHER DEALINGS IN THE SOFTWARE. dnl dnl Except as contained in this notice, the name of the copyright holders shall dnl not be used in advertising or otherwise to promote the sale, use or dnl other dealings in this Software without prior written authorization dnl from the copyright holders. dnl # XORG_RELEASE_VERSION # -------------------- # Defines PACKAGE_VERSION_{MAJOR,MINOR,PATCHLEVEL} for modules to use. AC_DEFUN([XORG_RELEASE_VERSION],[ AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MAJOR], [`echo $PACKAGE_VERSION | cut -d . -f 1`], [Major version of this package]) PVM=`echo $PACKAGE_VERSION | cut -d . -f 2 | cut -d - -f 1` if test "x$PVM" = "x"; then PVM="0" fi AC_DEFINE_UNQUOTED([PACKAGE_VERSION_MINOR], [$PVM], [Minor version of this package]) PVP=`echo $PACKAGE_VERSION | cut -d . -f 3 | cut -d - -f 1` if test "x$PVP" = "x"; then PVP="0" fi AC_DEFINE_UNQUOTED([PACKAGE_VERSION_PATCHLEVEL], [$PVP], [Patch version of this package]) ]) # XORG_CHANGELOG() # ---------------- # Minimum version: 1.2.0 # # Defines the variable CHANGELOG_CMD as the command to generate # ChangeLog from git. # # AC_DEFUN([XORG_CHANGELOG], [ CHANGELOG_CMD="(GIT_DIR=\$(top_srcdir)/.git git log > \$(top_srcdir)/.changelog.tmp && \ mv \$(top_srcdir)/.changelog.tmp \$(top_srcdir)/ChangeLog) \ || (rm -f \$(top_srcdir)/.changelog.tmp; touch \$(top_srcdir)/ChangeLog; \ echo 'git directory not found: installing possibly empty changelog.' >&2)" AC_SUBST([CHANGELOG_CMD]) ]) # XORG_CHANGELOG ./m4/gcov.m40000644000004100000410000000624512752376103013000 0ustar www-datawww-data# Checks for existence of coverage tools: # * gcov # * lcov # * genhtml # * gcovr # # Sets ac_cv_check_gcov to yes if tooling is present # and reports the executables to the variables LCOV, GCOVR and GENHTML. AC_DEFUN([AC_TDD_GCOV], [ AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov], [enable coverage testing with gcov]), [use_gcov=$enableval], [use_gcov=no]) if test "x$use_gcov" = "xyes"; then # we need gcc: if test "$GCC" != "yes"; then AC_MSG_ERROR([GCC is required for --enable-gcov]) fi # Check if ccache is being used AC_CHECK_PROG(SHTOOL, shtool, shtool) case `$SHTOOL path $CC` in *ccache*[)] gcc_ccache=yes;; *[)] gcc_ccache=no;; esac if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.]) fi lcov_version_list="1.6 1.7 1.8 1.9" AC_CHECK_PROG(LCOV, lcov, lcov) AC_CHECK_PROG(GENHTML, genhtml, genhtml) AC_CHECK_PROG(GCOVR, gcovr, gcovr) if test "$LCOV"; then AC_CACHE_CHECK([for lcov version], glib_cv_lcov_version, [ glib_cv_lcov_version=invalid lcov_version=`$LCOV -v 2>/dev/null | $SED -e 's/^.* //'` for lcov_check_version in $lcov_version_list; do if test "$lcov_version" = "$lcov_check_version"; then glib_cv_lcov_version="$lcov_check_version (ok)" fi done ]) else lcov_msg="To enable code coverage reporting you must have one of the following lcov versions installed: $lcov_version_list" AC_MSG_ERROR([$lcov_msg]) fi case $glib_cv_lcov_version in ""|invalid[)] lcov_msg="You must have one of the following versions of lcov: $lcov_version_list (found: $lcov_version)." AC_MSG_ERROR([$lcov_msg]) LCOV="exit 0;" ;; esac if test -z "$GENHTML"; then AC_MSG_ERROR([Could not find genhtml from the lcov package]) fi if test -z "$GCOVR"; then AC_MSG_ERROR([Could not find gcovr; easy_install (or pip) gcovr]) fi ac_cv_check_gcov=yes # Remove all optimization flags from CFLAGS changequote({,}) CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'` CXXFLAGS=`echo "$CXXFLAGS" | $SED -e 's/-O[0-9]*//g'` changequote([,]) # Add the special gcc flags AC_SUBST(COVERAGE_CFLAGS, [-O0 -fprofile-arcs -ftest-coverage]) AC_SUBST(COVERAGE_CXXFLAGS, [-O0 -fprofile-arcs -ftest-coverage]) AC_SUBST(COVERAGE_LIBS, [-lgcov]) # Define verbose versions of the tools AC_SUBST(LCOV_verbose, '$(LCOV_verbose_$(V))') AC_SUBST(LCOV_verbose_, '$(LCOV_verbose_$(AM_DEFAULT_VERBOSITY))') AC_SUBST(LCOV_verbose_0, '@$(LCOV) --quiet') AC_SUBST(LCOV_verbose_1, '$(LCOV)') AC_SUBST(GENHTML_verbose, '$(GENHTML_verbose_$(V))') AC_SUBST(GENHTML_verbose_, '$(GENHTML_verbose_$(AM_DEFAULT_VERBOSITY))') AC_SUBST(GENHTML_verbose_0, '@LANG=C $(GENHTML) --quiet') AC_SUBST(GENHTML_verbose_1, 'LANG=C $(GENHTML)') AC_SUBST(GCOVR_verbose, '$(GCOVR_verbose_$())') AC_SUBST(GCOVR_verbose_, '$(GCOVR_verbose_$(AM_DEFAULT_VERBOSITY))') AC_SUBST(GCOVR_verbose_0, '@$(GCOVR)') AC_SUBST(GCOVR_verbose_1, '$(GCOVR) -v') fi ]) # AC_TDD_GCOV ./INSTALL0000644000004100000410000000103412752376103012300 0ustar www-datawww-dataframe - Touch Frame Library To build, you need to have the autoconf, libtool, and x11 developer packages installed. Then, do ./autogen.sh ./configure make To test the touch properties of an MT device at /dev/input/eventX, do sudo ./test/frame-test /dev/input/eventX You should be able to see touch events in the terminal. After five seconds of inactivity, the program exits. To install frame, do sudo make install By default, frame installs to /usr/local. To change, use the --prefix configure option. Enjoy, Henrik ./configure.ac0000644000004100000410000001064212752376103013542 0ustar www-datawww-data# Initialize Autoconf AC_PREREQ([2.60]) AC_INIT([Touch Frame Library], [2.5.0], [], [frame]) AC_CONFIG_SRCDIR([Makefile.am]) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_AUX_DIR([config-aux]) AC_CONFIG_MACRO_DIR([m4]) # Initialize Automake AM_INIT_AUTOMAKE([1.11 foreign dist-xz]) AM_SILENT_RULES([yes]) AM_MAINTAINER_MODE([enable]) LIB_VERSION=6:0:0 AC_SUBST([LIB_VERSION]) # Initialize libtool AC_PROG_LIBTOOL # Checks for programs. AC_PROG_CC AC_PROG_CXX AC_PROG_INSTALL # *** Enable/disable the X11 backend *** AC_ARG_ENABLE(x11, AC_HELP_STRING(--disable-x11, Do not build the X11 backend. (default: enable if available)), [], [enable_x11=auto]) # Check for X11 as an optional dependency AS_IF([test "x$enable_x11" = "xauto"], [ PKG_CHECK_MODULES(XINPUT, x11 xext xorg-server [xi >= 1.5.99.1] [inputproto >= 2.1.99.6], [have_xinput=yes], [have_xinput=no]) ]) AS_IF([test "x$enable_x11" = "xyes"], [ PKG_CHECK_MODULES(XINPUT, x11 xext xorg-server [xi >= 1.5.99.1] [inputproto >= 2.1.99.6], [have_xinput=yes], [ AC_MSG_ERROR([x11 and/or XInput libraries not found!]) have_xinput=no ]) ]) AS_IF([test "x$enable_x11" = "xno"], [have_xinput=no]) AS_IF([test "x$have_xinput" = "xyes"], [ FRAME_X11_BACKEND="FRAME_X11_BACKEND" AM_CONDITIONAL(HAVE_XINPUT, true) ], [ FRAME_X11_BACKEND="FRAME_NO_X11_BACKEND" AM_CONDITIONAL(HAVE_XINPUT, false) ]) AC_SUBST(FRAME_X11_BACKEND) AC_SUBST(HAVE_XINPUT) AC_CHECK_PROG([ASCIIDOC], [a2x], [a2x]) AM_CONDITIONAL([HAVE_DOCTOOLS], [test "x$ASCIIDOC" != "x"]) AS_IF([test "x$ASCIIDOC" = "x"], [AC_MSG_WARN([asciidoc not installed, man pages will not be created])]) # Check for Google C++ Testing Framework CHECK_GTEST() AM_CONDITIONAL([HAVE_GTEST], [test "x$have_gtest" = xyes]) # Check for TDD tools AC_ARG_ENABLE([integration-tests], [AS_HELP_STRING([--enable-integration-tests], [Enable building integration test cases (default: auto)])], [enable_integration_tests=$enableval], [enable_integration_tests=auto]) AS_IF([test "x$enable_integration_tests" != xno], [CHECK_XORG_GTEST( [AC_MSG_NOTICE([xorg-gtest is available, integration tests will be built])], [AC_MSG_WARN([xorg-gtest is not available, tests will not be built])])], [have_xorg_gtest=no]) AM_CONDITIONAL([ENABLE_INTEGRATION_TESTS], [test "x$have_xorg_gtest" = xyes]) AC_SUBST([GTEST_LDFLAGS]) AC_SUBST([GTEST_CXXFLAGS]) # Enable coverage reports using gcov AC_TDD_GCOV AM_CONDITIONAL([HAVE_GCOV], [test "x$ac_cv_check_gcov" = xyes]) AS_IF([test "x$ac_cv_check_gcov" = xyes], [AC_CHECK_PROG([SUDO], [sudo], [sudo]) AS_IF([test "x$ac_cv_prog_SUDO" = x], [AC_MSG_WARN([sudo is not installed, coverage reports may fail])])]) AC_CONFIG_FILES([Makefile doc/Makefile include/oif/frame.h src/Makefile test/Makefile test/gtest/Makefile test/integration/Makefile test/regular/Makefile test/x11_mocks/Makefile tools/Makefile frame.pc]) AS_IF([test "x$have_xinput" = "xyes"], [AC_CONFIG_FILES([frame-x11.pc])]) AC_LANG_PUSH(C++) AC_CHECK_DECL(__clang__, CXX_LIBS="-lstdc++") AC_SUBST(CXX_LIBS) AC_LANG_POP(C++) AC_SUBST(WARNING_CPPFLAGS, "-Wall -Werror") AC_SUBST(C11_CFLAGS, "-std=c1x") AC_SUBST(CXX11_CXXFLAGS, "-std=c++0x") AC_SUBST(VISIBILITY_CFLAGS, "-fvisibility=hidden") AC_SUBST(VISIBILITY_CXXFLAGS, "-fvisibility=hidden") AC_OUTPUT bold_green=$(tput bold)$(tput setf 2) bold_white=$(tput bold)$(tput setf 7) reset=$(tput sgr0) AC_MSG_NOTICE([]) AC_MSG_NOTICE([${bold_green}Open Input Framework - Frame library - $VERSION${reset}]) AC_MSG_NOTICE([]) AC_MSG_NOTICE([ Prefix : ${bold_white}${prefix}${reset}]) AC_MSG_NOTICE([ CXXFLAGS : ${bold_white}${CXXFLAGS}${reset}]) AC_MSG_NOTICE([ Build X11 backend : ${bold_white}${have_xinput}${reset}]) AC_MSG_NOTICE([ Build integration tests : ${bold_white}${have_xorg_gtest}${reset}]) AC_MSG_NOTICE([]) ./frame.pc.in0000644000004100000410000000031512752376103013273 0ustar www-datawww-dataprefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: frame Description: Touch Frame Library Version: @PACKAGE_VERSION@ Cflags: -I${includedir} Libs: -L${libdir} -lframe ./frame-x11.pc.in0000644000004100000410000000032112752376103013677 0ustar www-datawww-dataprefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ Name: frame-x11 Description: Touch Frame Library - X11 support Version: @PACKAGE_VERSION@ Requires: frame = @PACKAGE_VERSION@ ./COPYING.GPL30000644000004100000410000010451312752376103013014 0ustar www-datawww-data GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read .