~sircmpwn/scurvy

5418b3e46a1d59bb4d4c7859a38ca4ac0f39c059 — emersion 2 years ago 3ce0ba6 master
Switch to meson
13 files changed, 91 insertions(+), 863 deletions(-)

D CMake/FindA2X.cmake
D CMake/FindCairo.cmake
D CMake/FindLibvterm.cmake
D CMake/FindPango.cmake
D CMake/FindWayland.cmake
D CMake/FindXKBCommon.cmake
D CMake/Wayland.cmake
D CMakeLists.txt
A meson.build
A protocol/meson.build
M src/child.c
D src/wayland/CMakeLists.txt
D src/wayland/xdg-shell.xml
D CMake/FindA2X.cmake => CMake/FindA2X.cmake +0 -75
@@ 1,75 0,0 @@
#
# (c)2015 KiCad Developers
# (c)2015 Brian Sidebotham <brian.sidebotham@gmail.com>
#
# CMake module to find a2x (part of the asciidoc toolchain).
#
# Variables generated:
#
# A2X_FOUND     true when A2X_COMMAND is valid
# A2X_COMMAND   The command to run a2x (may be a list including an interpreter)
# A2X_VERSION   The a2x version that has been found
#

# Have a go at finding a a2x executable
find_program( A2X_PROGRAM a2x )

# Found something, attempt to try and use it...
if( A2X_PROGRAM )
    execute_process(
        COMMAND ${A2X_PROGRAM} --version
        OUTPUT_VARIABLE _OUT
        ERROR_VARIABLE _ERR
        RESULT_VARIABLE _RES
        OUTPUT_STRIP_TRAILING_WHITESPACE )

    # If it worked, set the A2X_COMMAND
    if( _RES MATCHES 0 )
        set( A2X_COMMAND "${A2X_PROGRAM}" )
    endif()
endif()

# If nothing could be found, test to see if we can just find the script file,
# that we'll then run with the python interpreter
if( NOT A2X_COMMAND )
    find_file( A2X_SCRIPT a2x.py )

    if( A2X_SCRIPT )
        # Find the python interpreter quietly
        if( NOT PYTHONINTERP_FOUND )
            find_package( PYTHONINTERP QUIET )
        endif()

        if( NOT PYTHONINTERP_FOUND )
            # Python's not available so can't find a2x...
            set( A2X_COMMAND "" )
        else()
            # Build the python based command
            set( A2X_COMMAND "${PYTHON_EXECUTABLE}" "${A2X_SCRIPT}" )

            execute_process(
                COMMAND ${A2X_COMMAND} --version
                OUTPUT_VARIABLE _OUT
                ERROR_VARIABLE _ERR
                RESULT_VARIABLE _RES
                OUTPUT_STRIP_TRAILING_WHITESPACE )

            # If it still can't be run, then give up
            if( NOT _RES MATCHES 0 )
                set( A2X_COMMAND "" )
            endif()
        endif()
    endif()
endif()

# If we've found a command that works, check the version
if( A2X_COMMAND )
    string(REGEX REPLACE ".*a2x[^0-9.]*\([0-9.]+\).*" "\\1" A2X_VERSION "${_OUT}")
endif()

# Generate the *_FOUND as necessary, etc.
include( FindPackageHandleStandardArgs )
find_package_handle_standard_args(
    A2X
    REQUIRED_VARS A2X_COMMAND
    VERSION_VAR A2X_VERSION )

D CMake/FindCairo.cmake => CMake/FindCairo.cmake +0 -42
@@ 1,42 0,0 @@
# - Try to find the cairo library
# Once done this will define
#
#  CAIRO_FOUND - system has cairo
#  CAIRO_INCLUDE_DIRS - the cairo include directory
#  CAIRO_LIBRARIES - Link these to use cairo
#
# Define CAIRO_MIN_VERSION for which version desired.
#

find_package(PkgConfig)

if(Cairo_FIND_REQUIRED)
	set(_pkgconfig_REQUIRED "REQUIRED")
else(Cairo_FIND_REQUIRED)
	set(_pkgconfig_REQUIRED "")
endif(Cairo_FIND_REQUIRED)

if(CAIRO_MIN_VERSION)
	pkg_check_modules(CAIRO ${_pkgconfig_REQUIRED} cairo>=${CAIRO_MIN_VERSION})
else(CAIRO_MIN_VERSION)
	pkg_check_modules(CAIRO ${_pkgconfig_REQUIRED} cairo)
endif(CAIRO_MIN_VERSION)

if(NOT CAIRO_FOUND AND NOT PKG_CONFIG_FOUND)
	find_path(CAIRO_INCLUDE_DIRS cairo.h)
	find_library(CAIRO_LIBRARIES cairo)
else(NOT CAIRO_FOUND AND NOT PKG_CONFIG_FOUND)
	# Make paths absolute https://stackoverflow.com/a/35476270
	# Important on FreeBSD because /usr/local/lib is not on /usr/bin/ld's default path
	set(CAIRO_LIBS_ABSOLUTE)
	foreach(lib ${CAIRO_LIBRARIES})
		set(var_name CAIRO_${lib}_ABS)
		find_library(${var_name} ${lib} ${CAIRO_LIBRARY_DIRS})
		list(APPEND CAIRO_LIBS_ABSOLUTE ${${var_name}})
	endforeach()
	set(CAIRO_LIBRARIES ${CAIRO_LIBS_ABSOLUTE})
endif(NOT CAIRO_FOUND AND NOT PKG_CONFIG_FOUND)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CAIRO DEFAULT_MSG CAIRO_LIBRARIES CAIRO_INCLUDE_DIRS)
mark_as_advanced(CAIRO_LIBRARIES CAIRO_INCLUDE_DIRS)

D CMake/FindLibvterm.cmake => CMake/FindLibvterm.cmake +0 -26
@@ 1,26 0,0 @@
# Try to find libvterm
# Once done this will define
#
#  LIBVTERM_FOUND - system has libvterm
#  LIBVTERM_LIBRARIES - Link these to use libvterm

if(LIBVTERM_LIBRARIES)
    set (LIBVTERM_FIND_QUIETLY TRUE)
endif()

FIND_PATH(LIBVTERM_INCLUDE_DIRS vterm.h)
FIND_LIBRARY(LIBVTERM_LIBRARIES NAMES vterm)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LIBVTERM DEFAULT_MSG LIBVTERM_LIBRARIES LIBVTERM_INCLUDE_DIRS)

if (LIBVTERM_FOUND)
    message (STATUS "Found components for libvterm")
    message (STATUS "LIBVTERM_LIBRARIES = ${LIBVTERM_LIBRARIES}")
else (LIBVTERM_FOUND)
    if (LIBVTERM_FIND_REQUIRED)
        message (FATAL_ERROR "Could not find libvterm!")
    endif (LIBVTERM_FIND_REQUIRED)
endif (LIBVTERM_FOUND)

MARK_AS_ADVANCED(LIBVTERM_LIBRARIES LIBVTERM_INCLUDE_DIRS)

D CMake/FindPango.cmake => CMake/FindPango.cmake +0 -42
@@ 1,42 0,0 @@
# - Try to find the pango library
# Once done this will define
#
#  PANGO_FOUND - system has pango
#  PANGO_INCLUDE_DIRS - the pango include directory
#  PANGO_LIBRARIES - Link these to use pango
#
# Define PANGO_MIN_VERSION for which version desired.
#

find_package(PkgConfig)

if(Pango_FIND_REQUIRED)
	set(_pkgconfig_REQUIRED "REQUIRED")
else(Pango_FIND_REQUIRED)
	set(_pkgconfig_REQUIRED "")
endif(Pango_FIND_REQUIRED)

if(PANGO_MIN_VERSION)
	pkg_check_modules(PANGO ${_pkgconfig_REQUIRED} "pango>=${PANGO_MIN_VERSION}" "pangocairo>=${PANGO_MIN_VERSION}")
else(PANGO_MIN_VERSION)
	pkg_check_modules(PANGO ${_pkgconfig_REQUIRED} pango pangocairo)
endif(PANGO_MIN_VERSION)

if(NOT PANGO_FOUND AND NOT PKG_CONFIG_FOUND)
	find_path(PANGO_INCLUDE_DIRS pango.h)
	find_library(PANGO_LIBRARIES pango pangocairo)
else(NOT PANGO_FOUND AND NOT PKG_CONFIG_FOUND)
	# Make paths absolute https://stackoverflow.com/a/35476270
	# Important on FreeBSD because /usr/local/lib is not on /usr/bin/ld's default path
	set(PANGO_LIBS_ABSOLUTE)
	foreach(lib ${PANGO_LIBRARIES})
		set(var_name PANGO_${lib}_ABS)
		find_library(${var_name} ${lib} ${PANGO_LIBRARY_DIRS})
		list(APPEND PANGO_LIBS_ABSOLUTE ${${var_name}})
	endforeach()
	set(PANGO_LIBRARIES ${PANGO_LIBS_ABSOLUTE})
endif(NOT PANGO_FOUND AND NOT PKG_CONFIG_FOUND)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(PANGO DEFAULT_MSG PANGO_LIBRARIES PANGO_INCLUDE_DIRS)
mark_as_advanced(PANGO_LIBRARIES PANGO_INCLUDE_DIRS)

D CMake/FindWayland.cmake => CMake/FindWayland.cmake +0 -67
@@ 1,67 0,0 @@
# Try to find Wayland on a Unix system
#
# This will define:
#
#   WAYLAND_FOUND       - True if Wayland is found
#   WAYLAND_LIBRARIES   - Link these to use Wayland
#   WAYLAND_INCLUDE_DIR - Include directory for Wayland
#   WAYLAND_DEFINITIONS - Compiler flags for using Wayland
#
# In addition the following more fine grained variables will be defined:
#
#   WAYLAND_CLIENT_FOUND  WAYLAND_CLIENT_INCLUDE_DIR  WAYLAND_CLIENT_LIBRARIES
#   WAYLAND_SERVER_FOUND  WAYLAND_SERVER_INCLUDE_DIR  WAYLAND_SERVER_LIBRARIES
#   WAYLAND_EGL_FOUND     WAYLAND_EGL_INCLUDE_DIR     WAYLAND_EGL_LIBRARIES
#   WAYLAND_CURSOR_FOUND  WAYLAND_CURSOR_INCLUDE_DIR  WAYLAND_CURSOR_LIBRARIES
#
# Copyright (c) 2013 Martin Gräßlin <mgraesslin@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

IF (NOT WIN32)
  IF (WAYLAND_INCLUDE_DIR AND WAYLAND_LIBRARIES)
    # In the cache already
    SET(WAYLAND_FIND_QUIETLY TRUE)
  ENDIF ()

  # Use pkg-config to get the directories and then use these values
  # in the FIND_PATH() and FIND_LIBRARY() calls
  FIND_PACKAGE(PkgConfig)
  PKG_CHECK_MODULES(PKG_WAYLAND QUIET wayland-client wayland-server wayland-egl wayland-cursor)

  SET(WAYLAND_DEFINITIONS ${PKG_WAYLAND_CFLAGS})

  FIND_PATH(WAYLAND_CLIENT_INCLUDE_DIR  NAMES wayland-client.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
  FIND_PATH(WAYLAND_SERVER_INCLUDE_DIR  NAMES wayland-server.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
  FIND_PATH(WAYLAND_EGL_INCLUDE_DIR     NAMES wayland-egl.h    HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
  FIND_PATH(WAYLAND_CURSOR_INCLUDE_DIR  NAMES wayland-cursor.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})

  FIND_LIBRARY(WAYLAND_CLIENT_LIBRARIES NAMES wayland-client   HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
  FIND_LIBRARY(WAYLAND_SERVER_LIBRARIES NAMES wayland-server   HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
  FIND_LIBRARY(WAYLAND_EGL_LIBRARIES    NAMES wayland-egl      HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
  FIND_LIBRARY(WAYLAND_CURSOR_LIBRARIES NAMES wayland-cursor   HINTS ${PKG_WAYLAND_LIBRARY_DIRS})

  set(WAYLAND_INCLUDE_DIR ${WAYLAND_CLIENT_INCLUDE_DIR} ${WAYLAND_SERVER_INCLUDE_DIR} ${WAYLAND_EGL_INCLUDE_DIR} ${WAYLAND_CURSOR_INCLUDE_DIR})

  set(WAYLAND_LIBRARIES ${WAYLAND_CLIENT_LIBRARIES} ${WAYLAND_SERVER_LIBRARIES} ${WAYLAND_EGL_LIBRARIES} ${WAYLAND_CURSOR_LIBRARIES})

  list(REMOVE_DUPLICATES WAYLAND_INCLUDE_DIR)

  include(FindPackageHandleStandardArgs)

  FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_CLIENT  DEFAULT_MSG  WAYLAND_CLIENT_LIBRARIES  WAYLAND_CLIENT_INCLUDE_DIR)
  FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_SERVER  DEFAULT_MSG  WAYLAND_SERVER_LIBRARIES  WAYLAND_SERVER_INCLUDE_DIR)
  FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_EGL     DEFAULT_MSG  WAYLAND_EGL_LIBRARIES     WAYLAND_EGL_INCLUDE_DIR)
  FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_CURSOR  DEFAULT_MSG  WAYLAND_CURSOR_LIBRARIES  WAYLAND_CURSOR_INCLUDE_DIR)
  FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND         DEFAULT_MSG  WAYLAND_LIBRARIES         WAYLAND_INCLUDE_DIR)

  MARK_AS_ADVANCED(
        WAYLAND_INCLUDE_DIR         WAYLAND_LIBRARIES
        WAYLAND_CLIENT_INCLUDE_DIR  WAYLAND_CLIENT_LIBRARIES
        WAYLAND_SERVER_INCLUDE_DIR  WAYLAND_SERVER_LIBRARIES
        WAYLAND_EGL_INCLUDE_DIR     WAYLAND_EGL_LIBRARIES
        WAYLAND_CURSOR_INCLUDE_DIR  WAYLAND_CURSOR_LIBRARIES
  )

ENDIF ()

D CMake/FindXKBCommon.cmake => CMake/FindXKBCommon.cmake +0 -19
@@ 1,19 0,0 @@
# - Find XKBCommon
# Once done, this will define
#
#   XKBCOMMON_FOUND - System has XKBCommon
#   XKBCOMMON_INCLUDE_DIRS - The XKBCommon include directories
#   XKBCOMMON_LIBRARIES - The libraries needed to use XKBCommon
#   XKBCOMMON_DEFINITIONS - Compiler switches required for using XKBCommon

find_package(PkgConfig)
pkg_check_modules(PC_XKBCOMMON QUIET xkbcommon)
find_path(XKBCOMMON_INCLUDE_DIRS NAMES xkbcommon/xkbcommon.h HINTS ${PC_XKBCOMMON_INCLUDE_DIRS})
find_library(XKBCOMMON_LIBRARIES NAMES xkbcommon HINTS ${PC_XKBCOMMON_LIBRARY_DIRS})

set(XKBCOMMON_DEFINITIONS ${PC_XKBCOMMON_CFLAGS_OTHER})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(XKBCOMMON DEFAULT_MSG XKBCOMMON_LIBRARIES XKBCOMMON_INCLUDE_DIRS)
mark_as_advanced(XKBCOMMON_LIBRARIES XKBCOMMON_INCLUDE_DIRS)


D CMake/Wayland.cmake => CMake/Wayland.cmake +0 -77
@@ 1,77 0,0 @@
#=============================================================================
# Copyright (C) 2012-2013 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
#   notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
#   notice, this list of conditions and the following disclaimer in the
#   documentation and/or other materials provided with the distribution.
#
# * Neither the name of Pier Luigi Fiorini nor the names of his
#   contributors may be used to endorse or promote products derived
#   from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================

find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)

# wayland_add_protocol_client(outfiles inputfile basename)
function(WAYLAND_ADD_PROTOCOL_CLIENT _sources _protocol _basename)
    if(NOT WAYLAND_SCANNER_EXECUTABLE)
        message(FATAL "The wayland-scanner executable has not been found on your system. You must install it.")
    endif()

    get_filename_component(_infile ${_protocol} ABSOLUTE)
    set(_client_header "${CMAKE_CURRENT_BINARY_DIR}/wayland-${_basename}-client-protocol.h")
    set(_code "${CMAKE_CURRENT_BINARY_DIR}/wayland-${_basename}-client-protocol.c")

    add_custom_command(OUTPUT "${_client_header}"
        COMMAND ${WAYLAND_SCANNER_EXECUTABLE} client-header < ${_infile} > ${_client_header}
        DEPENDS ${_infile} VERBATIM)

    add_custom_command(OUTPUT "${_code}"
        COMMAND ${WAYLAND_SCANNER_EXECUTABLE} code < ${_infile} > ${_code}
        DEPENDS ${_infile} VERBATIM)

    list(APPEND ${_sources} "${_client_header}" "${_code}")
    set(${_sources} ${${_sources}} PARENT_SCOPE)
endfunction()

# wayland_add_protocol_server(outfiles inputfile basename)
function(WAYLAND_ADD_PROTOCOL_SERVER _sources _protocol _basename)
    if(NOT WAYLAND_SCANNER_EXECUTABLE)
        message(FATAL "The wayland-scanner executable has not been found on your system. You must install it.")
    endif()

    get_filename_component(_infile ${_protocol} ABSOLUTE)
    set(_server_header "${CMAKE_CURRENT_BINARY_DIR}/wayland-${_basename}-server-protocol.h")
    set(_code "${CMAKE_CURRENT_BINARY_DIR}/wayland-${_basename}-server-protocol.c")

    add_custom_command(OUTPUT "${_server_header}"
        COMMAND ${WAYLAND_SCANNER_EXECUTABLE} server-header < ${_infile} > ${_server_header}
        DEPENDS ${_infile} VERBATIM)

    add_custom_command(OUTPUT "${_code}"
        COMMAND ${WAYLAND_SCANNER_EXECUTABLE} code < ${_infile} > ${_code}
        DEPENDS ${_infile} VERBATIM)

    list(APPEND ${_sources} "${_server_header}" "${_code}")
    set(${_sources} ${${_sources}} PARENT_SCOPE)
endfunction()

D CMakeLists.txt => CMakeLists.txt +0 -49
@@ 1,49 0,0 @@
cmake_minimum_required(VERSION 3.1.0)

project(scurvy C)

set(CMAKE_C_STANDARD 99)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
if (CMAKE_COMPILER_IS_GNUCC)
    if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 7.0)
        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wimplicit-fallthrough=0")
    endif()
endif()

list(INSERT CMAKE_MODULE_PATH 0
	${CMAKE_CURRENT_SOURCE_DIR}/CMake
)

find_package(Libvterm REQUIRED)
find_package(Cairo REQUIRED)
find_package(Pango REQUIRED)

add_subdirectory(src/wayland)
include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}/include
    ${PANGO_INCLUDE_DIRS}
    ${CAIRO_INCLUDE_DIRS}
)

add_executable(scurvy
    src/main.c
    src/ini.c
    src/colors.c
    src/config.c
    src/log.c
    src/pango.c
    src/child.c
    src/term.c
    src/utf8.c
)

target_link_libraries(scurvy
    scurvy-wayland
    ${LIBVTERM_LIBRARIES}
)

A meson.build => meson.build +55 -0
@@ 0,0 1,55 @@
project(
	'scurvy',
	'c',
	license: 'MIT',
	meson_version: '>=0.43.0',
	default_options: [
		'c_std=c11',
		'warning_level=2',
		'werror=true',
	],
)

add_project_arguments('-Wno-unused-parameter', language: 'c')

scurvy_inc = include_directories('include')

wayland_client = dependency('wayland-client')
wayland_protos = dependency('wayland-protocols')
wayland_cursor = dependency('wayland-cursor')
vterm = dependency('vterm')
cairo = dependency('cairo')
pango = dependency('pango')
pangocairo = dependency('pangocairo')
xkbcommon = dependency('xkbcommon')

subdir('protocol')

executable(
	'scurvy',
	files(
		'src/main.c',
		'src/wayland/buffers.c',
		'src/wayland/main.c',
		'src/wayland/registry.c',
		'src/wayland/window.c',
		'src/ini.c',
		'src/colors.c',
		'src/config.c',
		'src/log.c',
		'src/pango.c',
		'src/child.c',
		'src/term.c',
		'src/utf8.c',
	),
	include_directories: scurvy_inc,
	dependencies: [
		wayland_cursor,
		vterm,
		cairo,
		pango,
		pangocairo,
		xkbcommon,
		scurvy_protos,
	],
)

A protocol/meson.build => protocol/meson.build +36 -0
@@ 0,0 1,36 @@
wl_protocol_dir = wayland_protos.get_pkgconfig_variable('pkgdatadir')

wayland_scanner = find_program('wayland-scanner')

wayland_scanner_code = generator(
	wayland_scanner,
	output: '@BASENAME@-protocol.c',
	arguments: ['code', '@INPUT@', '@OUTPUT@'],
)

wayland_scanner_client = generator(
	wayland_scanner,
	output: '@BASENAME@-client-protocol.h',
	arguments: ['client-header', '@INPUT@', '@OUTPUT@'],
)

protocols = [
	[wl_protocol_dir, 'unstable/xdg-shell/xdg-shell-unstable-v6.xml'],
]

wl_protos_src = []
wl_protos_headers = []

foreach p : protocols
	xml = join_paths(p)
	wl_protos_src += wayland_scanner_code.process(xml)
	wl_protos_headers += wayland_scanner_client.process(xml)
endforeach

lib_wl_protos = static_library('wl_protos', wl_protos_src + wl_protos_headers,
	dependencies: [wayland_client]) # for the include directory

scurvy_protos = declare_dependency(
	link_with: lib_wl_protos,
	sources: wl_protos_headers,
)

M src/child.c => src/child.c +0 -2
@@ 6,8 6,6 @@
#include <fcntl.h>
#include <limits.h>
#include <string.h>
#include <libtsm.h>
#include <termbox.h>
#include <signal.h>
#include <stdbool.h>
#include <errno.h>

D src/wayland/CMakeLists.txt => src/wayland/CMakeLists.txt +0 -34
@@ 1,34 0,0 @@
include(Wayland)
find_package(Wayland REQUIRED)
find_package(XKBCommon REQUIRED)

WAYLAND_ADD_PROTOCOL_CLIENT(proto-client-xdg-shell
	xdg-shell.xml
	xdg-shell
)

include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}/../../include
    ${CMAKE_BINARY_DIR}/wayland/
	${XKBCOMMON_INCLUDE_DIRS}
	${WAYLAND_INCLUDE_DIR}
    ${PANGO_INCLUDE_DIRS}
)

add_library(scurvy-wayland STATIC
	${proto-client-xdg-shell}
    main.c
    registry.c
    window.c
    buffers.c
)

target_link_libraries(scurvy-wayland
	${PANGO_LIBRARIES}
	${XKBCOMMON_LIBRARIES}
	${EPOLLSHIM_LIBRARIES}
	${WAYLAND_CLIENT_LIBRARIES}
	${WAYLAND_CURSOR_LIBRARIES}
	${CAIRO_LIBRARIES}
	${PANGO_LIBRARIES}
)

D src/wayland/xdg-shell.xml => src/wayland/xdg-shell.xml +0 -430
@@ 1,430 0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="xdg_shell">

  <copyright>
    Copyright © 2008-2013 Kristian Høgsberg
    Copyright © 2013      Rafael Antognolli
    Copyright © 2013      Jasper St. Pierre
    Copyright © 2010-2013 Intel Corporation

    Permission to use, copy, modify, distribute, and sell this
    software and its documentation for any purpose is hereby granted
    without fee, provided that the above copyright notice appear in
    all copies and that both that copyright notice and this permission
    notice appear in supporting documentation, and that the name of
    the copyright holders not be used in advertising or publicity
    pertaining to distribution of the software without specific,
    written prior permission.  The copyright holders make no
    representations about the suitability of this software for any
    purpose.  It is provided "as is" without express or implied
    warranty.

    THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
    SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
    FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
    SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
    AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
    ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
    THIS SOFTWARE.
  </copyright>

  <interface name="xdg_shell" version="1">
    <description summary="create desktop-style surfaces">
      This interface is implemented by servers that provide
      desktop-style user interfaces.

      It allows clients to associate a xdg_surface with
      a basic surface.
    </description>

    <enum name="version">
      <description summary="latest protocol version">
	The 'current' member of this enum gives the version of the
	protocol.  Implementations can compare this to the version
	they implement using static_assert to ensure the protocol and
	implementation versions match.
      </description>
      <entry name="current" value="4" summary="Always the latest version"/>
    </enum>

    <enum name="error">
      <entry name="role" value="0" summary="given wl_surface has another role"/>
    </enum>

    <request name="use_unstable_version">
      <description summary="enable use of this unstable version">
	Negotiate the unstable version of the interface.  This
	mechanism is in place to ensure client and server agree on the
	unstable versions of the protocol that they speak or exit
	cleanly if they don't agree.  This request will go away once
	the xdg-shell protocol is stable.
      </description>
      <arg name="version" type="int"/>
    </request>

    <request name="get_xdg_surface">
      <description summary="create a shell surface from a surface">
	Create a shell surface for an existing surface.

	This request gives the surface the role of xdg_surface. If the
	surface already has another role, it raises a protocol error.

	Only one shell or popup surface can be associated with a given
	surface.
      </description>
      <arg name="id" type="new_id" interface="xdg_surface"/>
      <arg name="surface" type="object" interface="wl_surface"/>
    </request>

    <request name="get_xdg_popup">
      <description summary="create a shell surface from a surface">
	Create a popup surface for an existing surface.

	This request gives the surface the role of xdg_popup. If the
	surface already has another role, it raises a protocol error.

	Only one shell or popup surface can be associated with a given
	surface.
      </description>
      <arg name="id" type="new_id" interface="xdg_popup"/>
      <arg name="surface" type="object" interface="wl_surface"/>
      <arg name="parent" type="object" interface="wl_surface"/>
      <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat whose pointer is used"/>
      <arg name="serial" type="uint" summary="serial of the implicit grab on the pointer"/>
      <arg name="x" type="int"/>
      <arg name="y" type="int"/>
      <arg name="flags" type="uint"/>
    </request>

    <event name="ping">
      <description summary="check if the client is alive">
        The ping event asks the client if it's still alive. Pass the
        serial specified in the event back to the compositor by sending
        a "pong" request back with the specified serial.

        Compositors can use this to determine if the client is still
        alive. It's unspecified what will happen if the client doesn't
        respond to the ping request, or in what timeframe. Clients should
        try to respond in a reasonable amount of time.
      </description>
      <arg name="serial" type="uint" summary="pass this to the callback"/>
    </event>

    <request name="pong">
      <description summary="respond to a ping event">
	A client must respond to a ping event with a pong request or
	the client may be deemed unresponsive.
      </description>
      <arg name="serial" type="uint" summary="serial of the ping event"/>
    </request>
  </interface>

  <interface name="xdg_surface" version="1">

    <description summary="desktop-style metadata interface">
      An interface that may be implemented by a wl_surface, for
      implementations that provide a desktop-style user interface.

      It provides requests to treat surfaces like windows, allowing to set
      properties like maximized, fullscreen, minimized, and to move and resize
      them, and associate metadata like title and app id.

      On the server side the object is automatically destroyed when
      the related wl_surface is destroyed.  On client side,
      xdg_surface.destroy() must be called before destroying
      the wl_surface object.
    </description>

    <request name="destroy" type="destructor">
      <description summary="remove xdg_surface interface">
	The xdg_surface interface is removed from the wl_surface object
	that was turned into a xdg_surface with
	xdg_shell.get_xdg_surface request. The xdg_surface properties,
	like maximized and fullscreen, are lost. The wl_surface loses
	its role as a xdg_surface. The wl_surface is unmapped.
      </description>
    </request>

    <request name="set_parent">
      <description summary="surface is a child of another surface">
	Child surfaces are stacked above their parents, and will be
	unmapped if the parent is unmapped too. They should not appear
	on task bars and alt+tab.
      </description>
      <arg name="parent" type="object" interface="wl_surface" allow-null="true"/>
    </request>

    <request name="set_title">
      <description summary="set surface title">
	Set a short title for the surface.

	This string may be used to identify the surface in a task bar,
	window list, or other user interface elements provided by the
	compositor.

	The string must be encoded in UTF-8.
      </description>
      <arg name="title" type="string"/>
    </request>

    <request name="set_app_id">
      <description summary="set surface class">
	Set an id for the surface.

	The app id identifies the general class of applications to which
	the surface belongs.

	It should be the ID that appears in the new desktop entry
	specification, the interface name.
      </description>
      <arg name="app_id" type="string"/>
    </request>

    <request name="show_window_menu">
      <description summary="show the window menu">
        Clients implementing client-side decorations might want to show
        a context menu when right-clicking on the decorations, giving the
        user a menu that they can use to maximize or minimize the window.

        This request asks the compositor to pop up such a window menu at
        the given position, relative to the parent surface. There are
        no guarantees as to what the window menu contains.

        Your surface must have focus on the seat passed in to pop up the
        window menu.
      </description>

      <arg name="seat" type="object" interface="wl_seat" summary="the seat to pop the window up on"/>
      <arg name="serial" type="uint" summary="serial of the event to pop up the window for"/>
      <arg name="x" type="int" summary="the x position to pop up the window menu at"/>
      <arg name="y" type="int" summary="the y position to pop up the window menu at"/>
    </request>

    <request name="move">
      <description summary="start an interactive move">
	Start a pointer-driven move of the surface.

	This request must be used in response to a button press event.
	The server may ignore move requests depending on the state of
	the surface (e.g. fullscreen or maximized).
      </description>
      <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat whose pointer is used"/>
      <arg name="serial" type="uint" summary="serial of the implicit grab on the pointer"/>
    </request>

    <enum name="resize_edge">
      <description summary="edge values for resizing">
	These values are used to indicate which edge of a surface
	is being dragged in a resize operation. The server may
	use this information to adapt its behavior, e.g. choose
	an appropriate cursor image.
      </description>
      <entry name="none" value="0"/>
      <entry name="top" value="1"/>
      <entry name="bottom" value="2"/>
      <entry name="left" value="4"/>
      <entry name="top_left" value="5"/>
      <entry name="bottom_left" value="6"/>
      <entry name="right" value="8"/>
      <entry name="top_right" value="9"/>
      <entry name="bottom_right" value="10"/>
    </enum>

    <request name="resize">
      <description summary="start an interactive resize">
	Start a pointer-driven resizing of the surface.

	This request must be used in response to a button press event.
	The server may ignore resize requests depending on the state of
	the surface (e.g. fullscreen or maximized).
      </description>
      <arg name="seat" type="object" interface="wl_seat" summary="the wl_seat whose pointer is used"/>
      <arg name="serial" type="uint" summary="serial of the implicit grab on the pointer"/>
      <arg name="edges" type="uint" summary="which edge or corner is being dragged"/>
    </request>

    <enum name="state">
      <description summary="types of state on the surface">
        The different state values used on the surface. This is designed for
        state values like maximized, fullscreen. It is paired with the
        configure event to ensure that both the client and the compositor
        setting the state can be synchronized.

        States set in this way are double-buffered. They will get applied on
        the next commit.

        Desktop environments may extend this enum by taking up a range of
        values and documenting the range they chose in this description.
        They are not required to document the values for the range that they
        chose. Ideally, any good extensions from a desktop environment should
        make its way into standardization into this enum.

        The current reserved ranges are:

        0x0000 - 0x0FFF: xdg-shell core values, documented below.
        0x1000 - 0x1FFF: GNOME
      </description>
      <entry name="maximized" value="1">
        <description summary="the surface is maximized">
        The surface is maximized. The window geometry specified in the configure
        event must be obeyed by the client.
        </description>
      </entry>
      <entry name="fullscreen" value="2">
        <description summary="the surface is fullscreen">
        The surface is fullscreen. The window geometry specified in the configure
        event must be obeyed by the client.
        </description>
      </entry>
      <entry name="resizing" value="3">
        <description summary="the surface is being resized">
        The surface is being resized. The window geometry specified in the
        configure event is a maximum; the client cannot resize beyond it.
        Clients that have aspect ratio or cell sizing configuration can use
        a smaller size, however.
        </description>
      </entry>
      <entry name="activated" value="4">
        <description summary="the client window is active">
        Client window decorations should be painted as if the window is
        active. Do not assume this means that the window actually has
        keyboard or pointer focus.
        </description>
      </entry>
    </enum>

    <event name="configure">
      <description summary="suggest a surface change">
	The configure event asks the client to resize its surface.

	The width and height arguments specify a hint to the window
        about how its surface should be resized in window geometry
        coordinates. The states listed in the event specify how the
        width/height arguments should be interpreted.

        A client should arrange a new surface, and then send a
        ack_configure request with the serial sent in this configure
        event before attaching a new surface.

	If the client receives multiple configure events before it
        can respond to one, it is free to discard all but the last
        event it received.
      </description>

      <arg name="width" type="int"/>
      <arg name="height" type="int"/>
      <arg name="states" type="array"/>
      <arg name="serial" type="uint"/>
    </event>

    <request name="ack_configure">
      <description summary="ack a configure event">
        When a configure event is received, a client should then ack it
        using the ack_configure request to ensure that the compositor
        knows the client has seen the event.

        By this point, the state is confirmed, and the next attach should
        contain the buffer drawn for the configure event you are acking.
      </description>
      <arg name="serial" type="uint" summary="a serial to configure for"/>
    </request>

    <request name="set_window_geometry">
      <description summary="set the new window geometry">
        The window geometry of a window is its "visible bounds" from the
        user's perspective. Client-side decorations often have invisible
        portions like drop-shadows which should be ignored for the
        purposes of aligning, placing and constraining windows.

        The default value is the full bounds of the surface, including any
        subsurfaces. Once the window geometry of the surface is set once,
        it is not possible to unset it, and it will remain the same until
        set_window_geometry is called again, even if a new subsurface or
        buffer is attached.

        If responding to a configure event, the window geometry in here
        must respect the sizing negotiations specified by the states in
        the configure event.
      </description>
      <arg name="x" type="int"/>
      <arg name="y" type="int"/>
      <arg name="width" type="int"/>
      <arg name="height" type="int"/>
    </request>

    <request name="set_maximized" />
    <request name="unset_maximized" />

    <request name="set_fullscreen">
      <description summary="set the window as fullscreen on a monitor">
	Make the surface fullscreen.

        You can specify an output that you would prefer to be fullscreen.
	If this value is NULL, it's up to the compositor to choose which
        display will be used to map this surface.
      </description>
      <arg name="output" type="object" interface="wl_output" allow-null="true"/>
    </request>
    <request name="unset_fullscreen" />

    <request name="set_minimized" />

    <event name="close">
      <description summary="surface wants to be closed">
        The close event is sent by the compositor when the user
        wants the surface to be closed. This should be equivalent to
        the user clicking the close button in client-side decorations,
        if your application has any...

        This is only a request that the user intends to close your
        window. The client may choose to ignore this request, or show
        a dialog to ask the user to save their data...
      </description>
    </event>
  </interface>

  <interface name="xdg_popup" version="1">
    <description summary="desktop-style metadata interface">
      An interface that may be implemented by a wl_surface, for
      implementations that provide a desktop-style popups/menus. A popup
      surface is a transient surface with an added pointer grab.

      An existing implicit grab will be changed to owner-events mode,
      and the popup grab will continue after the implicit grab ends
      (i.e. releasing the mouse button does not cause the popup to be
      unmapped).

      The popup grab continues until the window is destroyed or a mouse
      button is pressed in any other clients window. A click in any of
      the clients surfaces is reported as normal, however, clicks in
      other clients surfaces will be discarded and trigger the callback.

      The x and y arguments specify the locations of the upper left
      corner of the surface relative to the upper left corner of the
      parent surface, in surface local coordinates.

      xdg_popup surfaces are always transient for another surface.
    </description>

    <request name="destroy" type="destructor">
      <description summary="remove xdg_surface interface">
	The xdg_surface interface is removed from the wl_surface object
	that was turned into a xdg_surface with
	xdg_shell.get_xdg_surface request. The xdg_surface properties,
	like maximized and fullscreen, are lost. The wl_surface loses
	its role as a xdg_surface. The wl_surface is unmapped.
      </description>
    </request>

    <event name="popup_done">
      <description summary="popup interaction is done">
	The popup_done event is sent out when a popup grab is broken,
	that is, when the users clicks a surface that doesn't belong
	to the client owning the popup surface.
      </description>
      <arg name="serial" type="uint" summary="serial of the implicit grab on the pointer"/>
    </event>

  </interface>
</protocol>